org-fixup.el 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. (with-temp-buffer
  28. (insert "\
  29. ;;; org-version.el --- autogenerated file, do not edit
  30. ;;
  31. ;;; Code:
  32. ;;;\#\#\#autoload
  33. \(defun org-release ()
  34. \"The release version of org-mode.
  35. Inserted by installing org-mode or when a release is made.\"
  36. (let ((org-release \"" org-release "\"))
  37. org-release))
  38. ;;;\#\#\#autoload
  39. \(defun org-git-version ()
  40. \"The Git version of org-mode.
  41. Inserted by installing org-mode or when a release is made.\"
  42. (let ((org-git-version \"" org-git-version "\"))
  43. org-git-version))
  44. ;;;\#\#\#autoload
  45. \(defconst org-odt-data-dir \"" odt-dir "\"
  46. \"The location of ODT styles.\")
  47. \f\n;; Local Variables:\n;; version-control: never
  48. ;; no-byte-compile: t
  49. ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n")
  50. (toggle-read-only 0)
  51. (write-file "org-version.el")))
  52. (defun org-make-org-install (absfile)
  53. (with-temp-buffer
  54. (set-visited-file-name absfile)
  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. (toggle-read-only 0)
  63. (write-file absfile)))
  64. (defun org-make-autoloads ()
  65. (let* ((origin default-directory)
  66. (dirlisp (org-find-library-dir "org"))
  67. (dirorg (concat dirlisp "../" ))
  68. (dirodt (if (boundp 'org-odt-data-dir)
  69. org-odt-data-dir
  70. (concat dirorg "etc/"))))
  71. (unwind-protect
  72. (progn
  73. (cd dirlisp)
  74. (org-fixup)
  75. (org-make-org-version (org-release) (org-git-version) dirodt)
  76. (org-make-org-install (concat dirlisp "org-install.el")))
  77. (cd origin))))
  78. (defun org-make-autoloads-compile (&rest force)
  79. (let* ((origin default-directory)
  80. (dirlisp (org-find-library-dir "org")))
  81. (unwind-protect
  82. (progn
  83. (cd dirlisp)
  84. (org-make-autoloads)
  85. (byte-recompile-directory dirlisp 0 force))
  86. (cd origin))))
  87. (defmacro org-fixup ()
  88. (let* ((origin default-directory)
  89. (dirlisp (org-find-library-dir "org"))
  90. (dirorg (concat dirlisp "../" ))
  91. (dirgit (concat dirorg ".git/" ))
  92. (org-version "N/A-fixup")
  93. (org-git-version "N/A-fixup !!check installation!!"))
  94. (if (load (concat dirlisp "org-version.el") 'noerror 'nomessage 'nosuffix)
  95. (setq org-version (org-release)
  96. org-git-version (org-git-version))
  97. (when (and (file-exists-p dirgit)
  98. (executable-find "git"))
  99. (unwind-protect
  100. (progn
  101. (cd dirorg)
  102. (let ((git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -1))
  103. (git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -1))
  104. (gitd (string-match "\\S-" (shell-command-to-string "git status -uno --porcelain"))))
  105. (setq org-git-version (concat git6 (when gitd ".dirty")))
  106. (if (string-match "^release_" git0)
  107. (setq org-version (substring git0 8))
  108. (setq org-version git0))))
  109. (cd origin))))
  110. `(progn
  111. (defun org-release () ,org-version)
  112. (defun org-git-version () ,org-git-version)
  113. "org-fixup.el: redefined org version.")))
  114. (provide 'org-fixup)
  115. ;; Local Variables:
  116. ;; no-byte-compile: t
  117. ;; coding: utf-8
  118. ;; End:
  119. ;;; org-fixup.el ends here