[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 05fb53a: Use etags-goto-tag-location in etags xref
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 05fb53a: Use etags-goto-tag-location in etags xref backend |
Date: |
Tue, 20 Jan 2015 02:32:41 +0000 |
branch: master
commit 05fb53a16c00bd4067ddd6d6a18c6744b91bd1f2
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Use etags-goto-tag-location in etags xref backend
* 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 | 9 +++++++++
lisp/progmodes/etags.el | 24 +++++++++++++++++++++---
lisp/progmodes/xref.el | 4 +++-
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b1a3a73..3f7182d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-20 Dmitry Gutov <address@hidden>
+
+ * 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 <address@hidden>
* ido.el: Update Customization instructions.
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el
index 47b305f..dc3380d 100644
--- a/lisp/progmodes/etags.el
+++ b/lisp/progmodes/etags.el
@@ -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)))))
+
(provide 'etags)
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 12123c8..536096f 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 05fb53a: Use etags-goto-tag-location in etags xref backend,
Dmitry Gutov <=