From 7a6bcf54b0263a5afeafddf1a0121e2c8ac7d42a Mon Sep 17 00:00:00 2001 From: Achim Gratz Date: Sat, 19 May 2012 19:54:00 +0200 Subject: [PATCH] make functions in org-fixup.el more robust, add full build functionality * UTILITIES/org-fixup.el(org-make-org-version): Use temporary buffer. * UTILITIES/org-fixup.el(org-make-org-install): Use temporary buffer. * UTILITIES/org-fixup.el(org-make-autoloads): New function, generates autoload files using (org-make-org-version) and (org-make-org-install). Uses (org-fixup) to determine version strings. * UTILITIES/org-fixup.el(org-make-autoloads-compile): New function, generates autoload files using (org-make-autoloads) and byte-compiles files in lisp. Optional argument forces re-compilation of all files. * UTILITIES/org-fixup.el(org-fixup): Clean up whitespace and correct the unwind form. --- UTILITIES/org-fixup.el | 64 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/UTILITIES/org-fixup.el b/UTILITIES/org-fixup.el index bf70a80..9f56f16 100644 --- a/UTILITIES/org-fixup.el +++ b/UTILITIES/org-fixup.el @@ -28,9 +28,8 @@ (require 'autoload) (defun org-make-org-version (org-release org-git-version odt-dir) - (find-file "org-version.el") - (erase-buffer) - (insert "\ + (with-temp-buffer + (insert "\ ;;; org-version.el --- autogenerated file, do not edit ;; ;;; Code: @@ -52,19 +51,46 @@ (defun org-make-org-version (org-release org-git-version odt-dir) \f\n;; Local Variables:\n;; version-control: never ;; no-byte-compile: t ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n") - (save-buffer)) + (toggle-read-only 0) + (write-file "org-version.el"))) (defun org-make-org-install (absfile) - (find-file absfile) - (erase-buffer) - (insert ";;; org-install.el --- autogenerated file, do not edit\n;;\n;;; Code:\n") - (let ((files (directory-files (file-name-directory absfile) 'full "^[^.#~]*\\.el$"))) - (mapc (lambda (f) (generate-file-autoloads f)) files)) - (insert "\f\n(provide 'org-install)\n") - (insert "\f\n;; Local Variables:\n;; version-control: never\n") - (insert ";; no-byte-compile: t\n;; no-update-autoloads: t\n") - (insert ";; coding: utf-8\n;; End:\n;;; org-install.el ends here\n") - (save-buffer)) + (with-temp-buffer + (set-visited-file-name absfile) + (insert ";;; org-install.el --- autogenerated file, do not edit\n;;\n;;; Code:\n") + (let ((files (directory-files (file-name-directory absfile) 'full "^[^.#~]*\\.el$"))) + (mapc (lambda (f) (generate-file-autoloads f)) files)) + (insert "\f\n(provide 'org-install)\n") + (insert "\f\n;; Local Variables:\n;; version-control: never\n") + (insert ";; no-byte-compile: t\n;; no-update-autoloads: t\n") + (insert ";; coding: utf-8\n;; End:\n;;; org-install.el ends here\n") + (toggle-read-only 0) + (write-file absfile))) + +(defun org-make-autoloads () + (let* ((origin default-directory) + (dirlisp (org-find-library-dir "org")) + (dirorg (concat dirlisp "../" )) + (dirodt (if (boundp 'org-odt-data-dir) + org-odt-data-dir + (concat dirorg "etc/")))) + (unwind-protect + (progn + (cd dirlisp) + (org-fixup) + (org-make-org-version (org-release) (org-git-version) dirodt) + (org-make-org-install (concat dirlisp "org-install.el"))) + (cd origin)))) + +(defun org-make-autoloads-compile (&rest force) + (let* ((origin default-directory) + (dirlisp (org-find-library-dir "org"))) + (unwind-protect + (progn + (cd dirlisp) + (org-make-autoloads) + (byte-recompile-directory dirlisp 0 force)) + (cd origin)))) (defmacro org-fixup () (let* ((origin default-directory) @@ -81,14 +107,14 @@ (defmacro org-fixup () (unwind-protect (progn (cd dirorg) - (let (( git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -1)) - ( git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -1)) - ( gitd (string-match "\\S-" (shell-command-to-string "git status -uno --porcelain")))) + (let ((git6 (substring (shell-command-to-string "git describe --abbrev=6 HEAD") 0 -1)) + (git0 (substring (shell-command-to-string "git describe --abbrev=0 HEAD") 0 -1)) + (gitd (string-match "\\S-" (shell-command-to-string "git status -uno --porcelain")))) (setq org-git-version (concat git6 (when gitd ".dirty"))) (if (string-match "^release_" git0) (setq org-version (substring git0 8)) - (setq org-version git0))) - (cd origin))))) + (setq org-version git0)))) + (cd origin)))) `(progn (defun org-release () ,org-version) (defun org-git-version () ,org-git-version) -- 1.7.9.2