]> git.eshelyaron.com Git - emacs.git/commitdiff
Use etags-goto-tag-location in etags xref backend
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 20 Jan 2015 02:28:50 +0000 (04:28 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 20 Jan 2015 02:32:25 +0000 (04:32 +0200)
* progmodes/etags.el (xref-etags-location): New class.
(xref-make-etags-location): New function.
(etags--xref-find-definitions): Use it.
(xref-location-marker): New method implementation.

* lisp/progmodes/xref.el: Mention that xref-location is an EIEIO class.

lisp/ChangeLog
lisp/progmodes/etags.el
lisp/progmodes/xref.el

index b1a3a73864cd68338e92c4c02a943a18ab69ddd6..3f7182d50dcda210bf6e6116cffcf187c503ccac 100644 (file)
@@ -1,3 +1,12 @@
+2015-01-20  Dmitry Gutov  <dgutov@yandex.ru>
+
+       * progmodes/etags.el (xref-etags-location): New class.
+       (xref-make-etags-location): New function.
+       (etags--xref-find-definitions): Use it.
+       (xref-location-marker): New method implementation.
+
+       * progmodes/xref.el: Mention that xref-location is an EIEIO class.
+
 2015-01-19  Dmitry Gutov  <dgutov@yandex.ru>
 
        * ido.el: Update Customization instructions.
index 47b305fb08132b50f503726d470f67bc5771592b..dc3380d02f6c87065145d2f1fd4104129696ea09 100644 (file)
@@ -2100,17 +2100,35 @@ for \\[find-tag] (which see)."
                       (< (hash-table-count marks) etags--xref-limit))
             (when (funcall order-fun pattern)
               (beginning-of-line)
-              (cl-destructuring-bind (hint line &rest pos) (etags-snarf-tag)
+              (pcase-let* ((tag-info (etags-snarf-tag))
+                           (`(,hint ,line . _) tag-info))
                 (unless (eq hint t) ; hint==t if we are in a filename line
                   (let* ((file (file-of-tag))
                          (mark-key (cons file line)))
                     (unless (gethash mark-key marks)
-                      (let ((loc (xref-make-file-location
-                                  (expand-file-name file) line 0)))
+                      (let ((loc (xref-make-etags-location
+                                  tag-info (expand-file-name file))))
                         (push (xref-make hint loc) xrefs)
                         (puthash mark-key t marks)))))))))))
     (nreverse xrefs)))
 
+(defclass xref-etags-location (xref-location)
+  ((tag-info :type list   :initarg :tag-info)
+   (file     :type string :initarg :file
+             :reader xref-location-group))
+  :documentation "Location of an etags tag.")
+
+(defun xref-make-etags-location (tag-info file)
+  (make-instance 'xref-etags-location :tag-info tag-info
+                 :file (expand-file-name file)))
+
+(defmethod xref-location-marker ((l xref-etags-location))
+  (with-slots (tag-info file) l
+    (let ((buffer (find-file-noselect file)))
+      (with-current-buffer buffer
+        (etags-goto-tag-location tag-info)
+        (point-marker)))))
+
 \f
 (provide 'etags)
 
index 12123c8f2e22b490f47d2a8677a144cd02d759f5..536096f612fc175caa7d276ab303c9158724f716 100644 (file)
@@ -34,7 +34,9 @@
 ;;
 ;; One would usually call `make-xref' and `xref-make-file-location',
 ;; `xref-make-buffer-location' or `xref-make-bogus-location' to create
-;; them.
+;; them.  More generally, a location must be an instance of an EIEIO
+;; class inheriting from `xref-location' and implementing
+;; `xref-location-group' and `xref-location-marker'.
 ;;
 ;; Each identifier must be represented as a string.  Implementers can
 ;; use string properties to store additional information about the