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

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

[nongnu] elpa/git-commit 363e5acffe 5/8: magit-thingatpt--git-revision:


From: ELPA Syncer
Subject: [nongnu] elpa/git-commit 363e5acffe 5/8: magit-thingatpt--git-revision: Trim parentheses and punctuation
Date: Tue, 5 Sep 2023 21:59:36 -0400 (EDT)

branch: elpa/git-commit
commit 363e5acffed27b945a0a2a6e4faf6eaf705c3ec8
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    magit-thingatpt--git-revision: Trim parentheses and punctuation
    
    Because we want to match in arbitrary buffers and the format of refs
    is actually pretty permissive, we tend to overmatch, and then have to
    cleanup the intermediate result.
---
 lisp/magit-git.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/magit-git.el b/lisp/magit-git.el
index 2c9679df65..3e5987e0b7 100644
--- a/lisp/magit-git.el
+++ b/lisp/magit-git.el
@@ -2563,7 +2563,15 @@ and this option only controls what face is used.")
                            (lambda ()
                              (re-search-forward (format "\\=[^%s]*" c) nil 
t))))
                   (bounds-of-thing-at-point 'git-revision))))
-             (string (buffer-substring-no-properties (car bounds) (cdr 
bounds))))
+             (string (buffer-substring-no-properties (car bounds) (cdr 
bounds)))
+             ;; References are allowed to contain most parentheses and
+             ;; most punctuation, but if those characters appear at the
+             ;; edges of a possible reference in arbitrary text, then
+             ;; they are much more likely to be intended as just that:
+             ;; punctuation and delimiters.
+             (string (thread-first string
+                       (string-trim-left  "[(</]")
+                       (string-trim-right "[])>/.,;!]"))))
     (and (or (and (>= (length string) 7)
                   (string-match-p "[a-z]" string)
                   (magit-commit-p string))



reply via email to

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