]> git.eshelyaron.com Git - emacs.git/commitdiff
tags-completion-at-point-function: Don't trust the find-tag function
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 23 May 2015 16:05:21 +0000 (12:05 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 23 May 2015 16:05:21 +0000 (12:05 -0400)
* lisp/progmodes/etags.el (tags-completion-at-point-function):
Don't trust the find-tag function.

lisp/progmodes/etags.el

index 7a87377503d9662e3709a1af3de0ca51e88bda06..60ea456d57c64b5a81e9855705f9018dea4cf540 100644 (file)
@@ -805,15 +805,16 @@ If no tags table is loaded, do nothing and return nil."
                                    case-fold-search))
          (pattern (funcall (or find-tag-default-function
                                (get major-mode 'find-tag-default-function)
-                               'find-tag-default)))
+                               #'find-tag-default)))
          beg)
       (when pattern
        (save-excursion
           (forward-char (1- (length pattern)))
-          (search-backward pattern)
-          (setq beg (point))
-          (forward-char (length pattern))
-          (list beg (point) (tags-lazy-completion-table) :exclusive 'no))))))
+          ;; The find-tag function might be overly optimistic.
+          (when (search-backward pattern nil t)
+            (setq beg (point))
+            (forward-char (length pattern))
+            (list beg (point) (tags-lazy-completion-table) :exclusive 'no)))))))
 \f
 (defun find-tag-tag (string)
   "Read a tag name, with defaulting and completion."