emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex 400609e 18/78: New TeX--if-macro-fboundp compati


From: Tassilo Horn
Subject: [elpa] externals/auctex 400609e 18/78: New TeX--if-macro-fboundp compatibility macro
Date: Mon, 19 Oct 2015 09:10:44 +0000

branch: externals/auctex
commit 400609e380524a6b307983e2b6084271ff310c12
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    New TeX--if-macro-fboundp compatibility macro
    
    * tex.el (TeX--if-macro-fboundp): New portability macro.
    (VirTeX-common-initialization): Use it.
---
 ChangeLog |    5 +++++
 tex.el    |   22 +++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5057a0a..dde5951 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-01  Tassilo Horn  <address@hidden>
+
+       * tex.el (TeX--if-macro-fboundp): New portability macro.
+       (VirTeX-common-initialization): Use it.
+
 2015-08-31  Mos� Giordano  <address@hidden>
 
        * tex-buf.el (TeX-previous-error): Delete point in error message.
diff --git a/tex.el b/tex.el
index 0868d10..3e43bb4 100644
--- a/tex.el
+++ b/tex.el
@@ -583,6 +583,26 @@ the name of the file being processed, with an optional 
extension."
 
 ;;; Portability.
 
+(defmacro TeX--if-macro-fboundp (name then &rest else)
+  "Execute THEN if macro NAME is bound and ELSE otherwise.
+Essentially,
+
+  (TeX--if-macro-fboundp name then else...)
+
+is equivalent to
+
+  (if (fboundp 'name) then else...)
+
+but takes care of byte-compilation issues where the byte-code for
+the latter could signal an error if it has been compiled with
+emacs 24.1 and is then later run by emacs 24.5."
+  (declare (indent 2) (debug (symbolp form)))
+  (if (fboundp name)            ;If macro exists at compile-time, just use it.
+      then
+    `(if (fboundp ',name)       ;Else, check if it exists at run-time.
+        (eval ',then)          ;If it does, then run the then code.
+       ,@else)))                ;Otherwise, run the else code.
+
 (require 'easymenu)
 
 (eval-and-compile
@@ -3458,7 +3478,7 @@ The algorithm is as follows:
   (when (and (boundp 'tex--prettify-symbols-alist)
             (boundp 'prettify-symbols-compose-predicate))
     (set (make-local-variable 'prettify-symbols-alist) 
tex--prettify-symbols-alist)
-    (if (fboundp 'add-function)
+    (TeX--if-macro-fboundp add-function
        (add-function :override (local 'prettify-symbols-compose-predicate)
                      #'tex--prettify-symbols-compose-p)
       (set (make-local-variable 'prettify-symbols-compose-predicate)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]