org-fixup.el 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ;;; org-fixup.el - to make life easier for folks without GNU make
  2. ;;
  3. ;; Author: Achim Gratz
  4. ;; Keywords: outlines, hypermedia, calendar, wp
  5. ;; Homepage: http://orgmode.org
  6. ;;
  7. ;; This file is not yet part of GNU Emacs.
  8. ;;
  9. ;; GNU Emacs is free software; you can redistribute it and/or modify
  10. ;; it under the terms of the GNU General Public License as published by
  11. ;; the Free Software Foundation; either version 3, or (at your option)
  12. ;; any later version.
  13. ;; GNU Emacs is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;; GNU General Public License for more details.
  17. ;; You should have received a copy of the GNU General Public License
  18. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  19. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  20. ;; Boston, MA 02110-1301, USA.
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;;
  23. ;;; Commentary:
  24. (require 'org-compat)
  25. (require 'autoload)
  26. (defun org-make-org-version (org-release org-git-version odt-dir)
  27. (find-file "org-version.el")
  28. (erase-buffer)
  29. (insert "\
  30. ;;; org-version.el --- autogenerated file, do not edit
  31. ;;
  32. ;;; Code:
  33. ;;;\#\#\#autoload
  34. \(defun org-release ()
  35. \"The release version of org-mode.
  36. Inserted by installing org-mode or when a release is made.\"
  37. (let ((org-release \"" org-release "\"))
  38. org-release))
  39. ;;;\#\#\#autoload
  40. \(defun org-git-version ()
  41. \"The Git version of org-mode.
  42. Inserted by installing org-mode or when a release is made.\"
  43. (let ((org-git-version \"" org-git-version "\"))
  44. org-git-version))
  45. ;;;\#\#\#autoload
  46. \(defconst org-odt-data-dir \"" odt-dir "\"
  47. \"The location of ODT styles.\")
  48. \f\n;; Local Variables:\n;; version-control: never
  49. ;; no-byte-compile: t
  50. ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n")
  51. (save-buffer))
  52. (defun org-make-org-install (absfile)
  53. (find-file absfile)
  54. (erase-buffer)
  55. (insert ";;; org-install.el --- autogenerated file, do not edit\n;;\n;;; Code:\n")
  56. (let ((files (directory-files (file-name-directory absfile) 'full "^[^.#~]*\\.el$")))
  57. (mapc (lambda (f) (generate-file-autoloads f)) files))
  58. (insert "\f\n(provide 'org-install)\n")
  59. (insert "\f\n;; Local Variables:\n;; version-control: never\n")
  60. (insert ";; no-byte-compile: t\n;; no-update-autoloads: t\n")
  61. (insert ";; coding: utf-8\n;; End:\n;;; org-install.el ends here\n")
  62. (save-buffer))
  63. (defmacro org-fixup ()
  64. (let* ((origin default-directory)
  65. (dirlisp (org-find-library-dir "org"))
  66. (dirorg (concat dirlisp "../" ))
  67. (dirgit (concat dirorg ".git/" ))
  68. (org-version "N/A-fixup")
  69. (org-git-version "N/A-fixup !!check installation!!"))
  70. (if (load (concat dirlisp "org-version.el") 'noerror 'nomessage 'nosuffix)
  71. (setq org-version (org-release)
  72. org-git-version (org-git-version))
  73. (when (and (file-exists-p dirgit)
  74. (executable-find "git"))
  75. (unwind-protect
  76. (progn
  77. (cd dirorg)
  78. (let (( git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -1))
  79. ( git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -1))
  80. ( gitd (string-match "\\S-" (shell-command-to-string "git status -uno --porcelain"))))
  81. (setq org-git-version (concat git6 (when gitd ".dirty")))
  82. (if (string-match "^release_" git0)
  83. (setq org-version (substring git0 8))
  84. (setq org-version git0)))
  85. (cd origin)))))
  86. `(progn
  87. (defun org-release () ,org-version)
  88. (defun org-git-version () ,org-git-version)
  89. "org-fixup.el: redefined org version.")))
  90. (provide 'org-fixup)
  91. ;; Local Variables:
  92. ;; no-byte-compile: t
  93. ;; coding: utf-8
  94. ;; End:
  95. ;;; org-fixup.el ends here