org-fixup.el 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 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. (load "autoload" nil 'nomessage)
  25. (load "org-compat.el" nil 'nomessage 'nosuffix)
  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 ()
  53. (with-temp-buffer
  54. (set-visited-file-name "org-install.el")
  55. (insert ";;; org-install.el --- autogenerated file, do not edit\n;;\n;;; Code:\n")
  56. (let ((files (directory-files default-directory nil "^\\(org\\|ob\\)\\(-.*\\)?\\.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. (save-buffer)))
  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))
  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. (defun org-make-local-mk ()
  88. (let ((default "default.mk")
  89. (local "local.mk"))
  90. (unwind-protect
  91. (with-temp-buffer
  92. (insert-file-contents default)
  93. (goto-char (point-min))
  94. (when (search-forward "-8<-" nil t)
  95. (forward-line 1)
  96. (delete-region (point-min) (point)))
  97. (when (search-forward "->8-" nil t)
  98. (forward-line 0)
  99. (delete-region (point) (point-max)))
  100. (goto-char (point-min))
  101. (insert "
  102. # Remove \"oldorg:\" to switch to \"all\" as the default target.
  103. # Change \"oldorg:\" to an existing target to make that target the default,
  104. # or define your own target here to become the default target.
  105. oldorg: # do what the old Makfile did by default
  106. ##----------------------------------------------------------------------
  107. ")
  108. (goto-char (point-max))
  109. (insert "\
  110. # See default.mk for further configuration options.
  111. ")
  112. (toggle-read-only 0)
  113. (write-file local))
  114. nil)))
  115. (defun org-make-letterformat (a4name lettername)
  116. (unwind-protect
  117. (with-temp-buffer
  118. (insert-file-contents a4name)
  119. (goto-char (point-min))
  120. (while (search-forward "\\pdflayout=(0l)" nil t)
  121. (replace-match "\\pdflayout=(1l)" nil t))
  122. (toggle-read-only 0)
  123. (write-file lettername))
  124. nil))
  125. (defmacro org-fixup ()
  126. (let* ((origin default-directory)
  127. (dirlisp (org-find-library-dir "org"))
  128. (dirorg (concat dirlisp "../" ))
  129. (dirgit (concat dirorg ".git/" ))
  130. (org-version "N/A-fixup")
  131. (org-git-version "N/A-fixup !!check installation!!"))
  132. (if (load (concat dirlisp "org-version.el") 'noerror 'nomessage 'nosuffix)
  133. (setq org-version (org-release)
  134. org-git-version (org-git-version))
  135. (when (and (file-exists-p dirgit)
  136. (executable-find "git"))
  137. (unwind-protect
  138. (progn
  139. (cd dirorg)
  140. (let ((git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -1))
  141. (git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -1))
  142. (gitd (string-match "\\S-" (shell-command-to-string "git status -uno --porcelain"))))
  143. (setq org-git-version (concat git6 (when gitd ".dirty")))
  144. (if (string-match "^release_" git0)
  145. (setq org-version (substring git0 8))
  146. (setq org-version git0))))
  147. (cd origin))))
  148. `(progn
  149. (defun org-release () ,org-version)
  150. (defun org-git-version () ,org-git-version)
  151. "org-fixup.el: redefined org version.")))
  152. (provide 'org-fixup)
  153. ;; Local Variables:
  154. ;; no-byte-compile: t
  155. ;; coding: utf-8
  156. ;; End:
  157. ;;; org-fixup.el ends here