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

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

[elpa] externals/compat 1430aaa 09/99: Add highlighting for compatibilit


From: ELPA Syncer
Subject: [elpa] externals/compat 1430aaa 09/99: Add highlighting for compatibility code
Date: Sun, 17 Oct 2021 05:57:48 -0400 (EDT)

branch: externals/compat
commit 1430aaae3f28b17edb7b28832d9fe5328bb12bec
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Add highlighting for compatibility code
    
    The face for compatibility code is font-lock-preprocessor-face, as
    this isn't used elsewhere in emacs-lisp-mode.
---
 compat-macs.el | 10 ++++++++++
 compat.el      |  3 +++
 2 files changed, 13 insertions(+)

diff --git a/compat-macs.el b/compat-macs.el
index 39a04ee..46ffa0c 100644
--- a/compat-macs.el
+++ b/compat-macs.el
@@ -57,6 +57,9 @@ attributes are handled, all others are ignored:
 - :force :: Non-nil means the compatibility code is installed no
   matter what.
 
+- :no-highlight :: Do not highlight this definition as
+  compatibility function.
+
 - :version :: Manual specification of the version the compatee
   code was defined in (string).
 
@@ -92,6 +95,13 @@ attributes are handled, all others are ignored:
                                 (version<= emacs-version max-version)))
                        `(unless ,(funcall check-fn realname)))
                       ('(compat--ignore)))
+                   ,(unless (plist-get attr :no-highlight)
+                      `(font-lock-add-keywords
+                        'emacs-lisp-mode
+                        `((,(concat "\\_<\\("
+                                    (regexp-quote (symbol-name name))
+                                    "\\)\\_>")
+                           1 font-lock-preprocessor-face))))
                    ,(funcall install-fn realname)))))
     (if (and feature (not compat--disable-defer))
         `(eval-after-load ',feature (lambda () ,body))
diff --git a/compat.el b/compat.el
index c9b9103..804ae50 100644
--- a/compat.el
+++ b/compat.el
@@ -47,6 +47,9 @@
 ;; older versions of Emacs (e.g. subr-x).
 (compat-advise require (feature &optional filename noerror)
   "Avoid throwing an error if library has compatibility code."
+  ;; As the compatibility advise around `require` is more a hack than
+  ;; of of actual value, the highlighting is supressed.
+  :no-highlight t
   :force t
   (condition-case err
       (funcall oldfun feature filename noerror)



reply via email to

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