]> code.delx.au - gnu-emacs/commitdiff
Use find-tag-default for xref-backend-identifier-at-point
authorDmitry Gutov <dgutov@yandex.ru>
Thu, 26 Nov 2015 02:38:17 +0000 (04:38 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Thu, 26 Nov 2015 02:38:31 +0000 (04:38 +0200)
* lisp/progmodes/etags.el (find-tag-tag)
(tags-completion-at-point-function): Extract common code as
find-tag--default.
(xref-backend-identifier-at-point): Define in terms of the new
function.

lisp/progmodes/etags.el

index 6a77b1b2456d43a0c17f9ef4a12088eb7346d40d..2c066df90bc38e7188599c26bbefbeb4f8804e1a 100644 (file)
@@ -799,9 +799,7 @@ If no tags table is loaded, do nothing and return nil."
     (let ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
                                      tags-case-fold-search
                                    case-fold-search))
-         (pattern (funcall (or find-tag-default-function
-                               (get major-mode 'find-tag-default-function)
-                               #'find-tag-default)))
+         (pattern (find-tag--default))
          beg)
       (when pattern
        (save-excursion
@@ -818,9 +816,7 @@ If no tags table is loaded, do nothing and return nil."
   (let* ((completion-ignore-case (if (memq tags-case-fold-search '(t nil))
                                     tags-case-fold-search
                                   case-fold-search))
-        (default (funcall (or find-tag-default-function
-                              (get major-mode 'find-tag-default-function)
-                              'find-tag-default)))
+        (default (find-tag--default))
         (spec (completing-read (if default
                                    (format "%s (default %s): "
                                            (substring string 0 (string-match "[ :]+\\'" string))
@@ -832,6 +828,11 @@ If no tags table is loaded, do nothing and return nil."
        (or default (user-error "There is no default tag"))
       spec)))
 
+(defun find-tag--default ()
+  (funcall (or find-tag-default-function
+               (get major-mode 'find-tag-default-function)
+               'find-tag-default)))
+
 (defvar last-tag nil
   "Last tag found by \\[find-tag].")
 
@@ -2084,6 +2085,9 @@ for \\[find-tag] (which see)."
                                                 tag-implicit-name-match-p)
   "Tag order used in `xref-backend-definitions' to look for definitions.")
 
+(cl-defmethod xref-backend-identifier-at-point ((_backend (eql etags)))
+  (find-tag--default))
+
 (cl-defmethod xref-backend-identifier-completion-table ((_backend (eql etags)))
   (tags-lazy-completion-table))