emacs-diffs
[Top][All Lists]
Advanced

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

master 9e8d8e1 2/2: Make (find-face-definition 'default) work more relia


From: Lars Ingebrigtsen
Subject: master 9e8d8e1 2/2: Make (find-face-definition 'default) work more reliably
Date: Fri, 25 Jun 2021 11:16:36 -0400 (EDT)

branch: master
commit 9e8d8e1a037b0f8d4f06dfd384c27a894f442de7
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make (find-face-definition 'default) work more reliably
    
    * lisp/emacs-lisp/find-func.el (find-function--defface): New
    function (bug#30230).
    (find-function-regexp-alist): Use it to skip past definitions
    inside comments and strings.
---
 lisp/emacs-lisp/find-func.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index 58876a4..7bc3e6b 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -123,10 +123,18 @@ should insert the feature name."
   :group 'xref
   :version "25.1")
 
+(defun find-function--defface (symbol)
+  (catch 'found
+    (while (re-search-forward (format find-face-regexp symbol) nil t)
+      (unless (ppss-comment-or-string-start
+               (save-excursion (syntax-ppss (match-beginning 0))))
+        ;; We're not in a comment or a string.
+        (throw 'found t)))))
+
 (defvar find-function-regexp-alist
   '((nil . find-function-regexp)
     (defvar . find-variable-regexp)
-    (defface . find-face-regexp)
+    (defface . find-function--defface)
     (feature . find-feature-regexp)
     (defalias . find-alias-regexp))
   "Alist mapping definition types into regexp variables.



reply via email to

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