emacs-devel
[Top][All Lists]
Advanced

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

[PATCH 3/3] lisp/progmodes/etags.el improve match by string trimming


From: Konstantin Kharlamov
Subject: [PATCH 3/3] lisp/progmodes/etags.el improve match by string trimming
Date: Sat, 16 Mar 2019 04:53:14 +0300

Not only this improves general usability, but also works around existing
bug in anjuta-tagsĀ¹

1: https://gitlab.gnome.org/GNOME/anjuta/issues/8
---
 lisp/progmodes/etags.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 62637414ef8..e8b67cf10f4 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -1363,9 +1363,10 @@ etags-goto-tag-location
       ;; since just going around the loop once probably
       ;; costs about as much as searching 2000 chars.
       (setq offset 1000
-           pat (concat (if (eq selective-display t)
-                           "\\(^\\|\^m\\)" "^")
-                       (regexp-quote (car tag-info))))
+            ;; Improve the match by trimming the pattern. It's
+            ;; impossible anyway that 2 tags would only differ by
+            ;; trailing whitespace.
+           pat (string-trim (regexp-quote (car tag-info))))
       ;; The character position in the tags table is 0-origin and counts CRs.
       ;; Convert it to a 1-origin Emacs character position.
       (when startpos
@@ -1386,8 +1387,7 @@ etags-goto-tag-location
          (setq startpos (point-min)))
 
       (goto-char startpos)
-      (or (looking-at pat) ; Is tag at the specified location?
-          (while (progn
+      (or (while (progn
                    (goto-char (- startpos offset))
                    (and (not (bobp))
                         (not (re-search-forward pat (+ startpos offset) t))))
-- 
2.21.0




reply via email to

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