瀏覽代碼

further cleanup for org version

* UTILITIES/org-fixup.el (org-make-org-version): Provide feature
  'org-version.
* lisp/org-compat.el (org-check-version): New macro.  Check if
  org-version.el exists and provide autoloads to that. Otherwise check
  if org-fixup.el exists and use it to provide definitions.  Finally
  if nothing worked, complain about a botched installation and provide
  fallback definitions.
* lisp/org.el: Use org-check-version.

This should finally provide the correct behaviour in all supported
use-cases as well as a few corner scenarios that were reported on the
mailing list and allow to always build on Git, ELPA and Emacs Bzr
correctly.  The file org-version.el must be added to the Emacs sources
and should be re-generated each time orgmode Git is synced to Emacs
Bzr (it would be best to automate this).

Note that the internal functions (org-release) and (org-git-release)
are not autoloaded when org-version is not present and become only
available when org.el is loaded.  This should pose no problem since
they are only used by (org-version), which is autoloaded from org.el.
Achim Gratz 12 年之前
父節點
當前提交
6fbc226ca5
共有 3 個文件被更改,包括 19 次插入9 次删除
  1. 1 0
      UTILITIES/org-fixup.el
  2. 17 0
      lisp/org-compat.el
  3. 1 9
      lisp/org.el

+ 1 - 0
UTILITIES/org-fixup.el

@@ -54,6 +54,7 @@ the Git work tree)."
 ;;;\#\#\#autoload
 ;;;\#\#\#autoload
 \(defconst org-odt-data-dir \"" odt-dir "\"
 \(defconst org-odt-data-dir \"" odt-dir "\"
   \"The location of ODT styles.\")
   \"The location of ODT styles.\")
+\f\n\(provide 'org-version\)
 \f\n;; Local Variables:\n;; version-control: never
 \f\n;; Local Variables:\n;; version-control: never
 ;; no-byte-compile: t
 ;; no-byte-compile: t
 ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n")
 ;; coding: utf-8\n;; End:\n;;; org-version.el ends here\n")

+ 17 - 0
lisp/org-compat.el

@@ -443,6 +443,23 @@ With two arguments, return floor and remainder of their quotient."
       'condition-case-unless-debug
       'condition-case-unless-debug
     'condition-case-no-debug))
     'condition-case-no-debug))
 
 
+(defmacro org-check-version ()
+  "Try very hard to provide sensible version strings."
+  (let* ((org-dir        (org-find-library-dir "org"))
+	 (org-version.el (concat org-dir "org-version.el"))
+	 (org-fixup.el   (concat org-dir "../UTILITIES/org-fixup.el")))
+    (if (require 'org-version org-version.el 'noerror)
+	'(progn
+	   (autoload 'org-release     "org-version.el")
+	   (autoload 'org-git-version "org-version.el"))
+      (if (require 'org-fixup org-fixup.el 'noerror)
+	  '(org-fixup)
+	;; provide fallback definitions and complain
+	(warn "Could not define org version correctly.  Check installation!")
+	'(progn
+	   (defun org-release () "N/A")
+	   (defun org-git-version () "N/A !!check installation!!"))))))
+
 (provide 'org-compat)
 (provide 'org-compat)
 
 
 ;;; org-compat.el ends here
 ;;; org-compat.el ends here

+ 1 - 9
lisp/org.el

@@ -209,15 +209,7 @@ identifier."
   :group 'org-id)
   :group 'org-id)
 
 
 ;;; Version
 ;;; Version
-;; 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))
+(org-check-version)
 ;;;###autoload
 ;;;###autoload
 (defun org-version (&optional here full message)
 (defun org-version (&optional here full message)
   "Show the org-mode version in the echo area.
   "Show the org-mode version in the echo area.