Ver Fonte

Clean-up for build system support and a fix for org-version.

* UTILITIES/org-fixup.el: Clean up and add doc strings.
* UTILITIES/org-fixup.el (org-make-autoloads): Add optional arguments
  and implementation for comopiling and force compiling.
* UTILITIES/org-fixup.el (org-make-autoloads-compile,
  org-make-autoloads-compile-force): Convenience definitions with
  pre-selected arguments, avoids complicated quoted on invocation from
  command line.
* UTILITIES/org-fixup.el (org-fixup): Add "-git" to git version when
  run from a bare Git worktree.  Give message instead of returning
  string inside quoted progn for easier tracing.
* lisp/org.el: Fix a subtle error resulting in version functions
  sometimes not being defined and byte-compiling failing.  Always
  compile in fallback definitions into org.elc -- org-fixup either
  provides re-definitions at compile-time or checks org-version.el and
  then the git work tree when run uncompiled.  So the fallback
  definitions will only come into effect when org-fixup is not
  available.
Achim Gratz há 12 anos atrás
pai
commit
6762c7ea60
2 ficheiros alterados com 51 adições e 25 exclusões
  1. 42 19
      UTILITIES/org-fixup.el
  2. 9 6
      lisp/org.el

+ 42 - 19
UTILITIES/org-fixup.el

@@ -1,7 +1,7 @@
-;;; org-fixup.el - to make life easier for folks without GNU make
+;;; org-fixup.el --- make life easier for folks without GNU make
 ;;
 ;; Author: Achim Gratz
-;; Keywords: outlines, hypermedia, calendar, wp
+;; Keywords: orgmode
 ;; Homepage: http://orgmode.org
 ;;
 ;; This file is not part of GNU Emacs.
@@ -24,10 +24,16 @@
 ;;
 ;;; Commentary:
 
-(load "autoload" nil 'nomessage)
-(load "org-compat.el" nil 'nomessage 'nosuffix)
+(require 'autoload)
+(require 'org-compat "org-compat.el")
 
 (defun org-make-org-version (org-release org-git-version odt-dir)
+  "Make the file org-version.el in the current directory.
+This function is internally used by the build system and should
+be used by foreign build systems or installers to produce this
+file in the installation directory of org-mode.  Org will not
+work correctly if this file is not present (except directly from
+the Git work tree)."
   (with-temp-buffer
     (insert "\
 ;;; org-version.el --- autogenerated file, do not edit
@@ -55,6 +61,11 @@
     (write-file "org-version.el")))
 
 (defun org-make-org-install ()
+  "Make the file org-install.el in the current directory.
+This function is internally used by the build system and should
+be used by foreign build systems or installers to produce this
+file in the installation directory of org-mode.  Org will not
+work correctly if this file is not up-to-date."
   (with-temp-buffer
     (set-visited-file-name "org-install.el")
     (insert ";;; org-install.el --- autogenerated file, do not edit\n;;\n;;; Code:\n")
@@ -67,7 +78,12 @@
     (toggle-read-only 0)
     (save-buffer)))
 
-(defun org-make-autoloads ()
+(defun org-make-autoloads (&optional compile force)
+  "Make the files org-install and org-version.el in the install directory.
+Finds the install directory by looking for library \"org\".
+Optionally byte-compile lisp files in the install directory or
+force re-compilation.  This function is provided for easier
+manual install when the build system can't be used."
   (let* ((origin default-directory)
 	 (dirlisp (org-find-library-dir "org"))
 	 (dirorg (concat dirlisp "../" ))
@@ -79,20 +95,24 @@
 	  (cd dirlisp)
 	  (org-fixup)
 	  (org-make-org-version (org-release) (org-git-version) dirodt)
-	  (org-make-org-install))
+	  (org-make-org-install)
+	  (when compile (byte-recompile-directory dirlisp 0 force)))
       (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))))
+(defun org-make-autoloads-compile ()
+  "Call org-make-autoloads with compile argument.
+Convenience function for easier invocation from command line."
+  (org-make-autoloads 'compile nil))
+
+(defun org-make-autoloads-compile-force ()
+  "Call org-make-autoloads with compile force arguments.
+Convenience function for easier invocation from command line."
+  (org-make-autoloads 'compile 'force))
+
+;; Internal functions
 
 (defun org-make-local-mk ()
+  "Internal function for the build system."
   (let ((default "default.mk")
 	(local   "local.mk"))
     (unwind-protect
@@ -123,6 +143,7 @@ oldorg:	# do what the old Makfile did by default
       nil)))
 
 (defun org-make-letterformat (a4name lettername)
+  "Internal function for the build system."
   (unwind-protect
       (with-temp-buffer
 	(insert-file-contents a4name)
@@ -133,6 +154,8 @@ oldorg:	# do what the old Makfile did by default
 	(write-file lettername))
     nil))
 
+;; redefine version functions
+
 (defmacro org-fixup ()
   (let* ((origin default-directory)
 	 (dirlisp (org-find-library-dir "org"))
@@ -156,15 +179,15 @@ oldorg:	# do what the old Makfile did by default
 		      (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")))
+		  (setq org-git-version (concat git6 (when gitd ".dirty") "-git"))
 		  (if (string-match "^release_" git0)
 		      (setq org-version (substring git0 8))
 		    (setq org-version git0))))
-	  (cd origin)))))
+	    (cd origin)))))
+    (message "org-fixup.el: redefined org version.")
     `(progn
        (defun org-release () ,org-version)
-       (defun org-git-version () ,org-git-version)
-       "org-fixup.el: redefined org version.")))
+       (defun org-git-version () ,org-git-version))))
 
 (provide 'org-fixup)
 

+ 9 - 6
lisp/org.el

@@ -209,12 +209,15 @@ identifier."
   :group 'org-id)
 
 ;;; Version
-(eval-when-compile
-  (defun org-release () "N/A")
-  (defun org-git-version () "N/A !!check installation!!")
-  (and (load (concat (org-find-library-dir "org") "../UTILITIES/org-fixup.el")
-	    'noerror 'nomessage 'nosuffix)
-       (org-no-warnings (org-fixup))))
+;; fallback definitions if everything goes wrong
+(defun org-release () "N/A")
+(defun org-git-version () "N/A !!check installation!!")
+;; re-define them with something sensible if possible
+(when (eval-when-compile
+	(require 'org-fixup
+		 (concat (org-find-library-dir "org") "../UTILITIES/org-fixup.el")
+		 'noerror))
+  (org-fixup))
 ;;;###autoload
 (defun org-version (&optional here full message)
   "Show the org-mode version in the echo area.