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

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

[elpa] externals/marginalia 785297d 075/241: Indicate advised functions


From: Stefan Monnier
Subject: [elpa] externals/marginalia 785297d 075/241: Indicate advised functions with an asterisk
Date: Fri, 28 May 2021 20:49:00 -0400 (EDT)

branch: externals/marginalia
commit 785297d9f98d4d23a1bf9f047e6aeca889e3f9ea
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Indicate advised functions with an asterisk
    
    Part of the work on issue #19.
    
    Should we apply a face to the asterisk?
---
 marginalia.el | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 2020a3d..b6d795d 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -291,6 +291,16 @@ This hash table is needed to speed up 
`marginalia-annotate-command-binding'.")
    (marginalia-annotate-command-binding cand)
    (marginalia-annotate-symbol cand)))
 
+(defconst marginalia--advice-regexp
+  (rx bos
+      (1+ (seq (? "This function has ")
+               (or ":before" ":after" ":around" ":override"
+                   ":before-while" ":before-until" ":after-while"
+                   ":after-until" ":filter-args" ":filter-return")
+               " advice: " (0+ nonl) "\n"))
+      "\n")
+  "Regexp to match lines about advice in function documentation strings.")
+
 (defun marginalia-annotate-symbol (cand)
   "Annotate symbol CAND with its documentation string."
   (when-let ((sym (intern-soft cand)))
@@ -298,16 +308,11 @@ This hash table is needed to speed up 
`marginalia-annotate-command-binding'.")
      (cond
       ((fboundp sym)
        (when-let ((doc (ignore-errors (documentation sym))))
-         (replace-regexp-in-string
-          (rx bos
-              (1+ (seq (? "This function has ")
-                       (or ":before" ":after" ":around" ":override"     
-                           ":before-while" ":before-until" ":after-while"  
-                           ":after-until" ":filter-args" ":filter-return")
-                       " advice: " (0+ nonl) "\n"))
-              "\n")
-          ""
-          doc)))
+         (if (string-match-p marginalia--advice-regexp doc)
+             (concat "*"
+                     (replace-regexp-in-string
+                      marginalia--advice-regexp "" doc))
+           (concat " " doc))))
       ((facep sym) (documentation-property sym 'face-documentation))
       (t (documentation-property sym 'variable-documentation))))))
 



reply via email to

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