diff options
| author | Dmitry Gutov | 2015-01-20 04:28:50 +0200 |
|---|---|---|
| committer | Dmitry Gutov | 2015-01-20 04:32:25 +0200 |
| commit | 05fb53a16c00bd4067ddd6d6a18c6744b91bd1f2 (patch) | |
| tree | 0108806bc4c698f595d4a20fed15ef57afbbeb72 | |
| parent | 347e01447194e511daaeee8835bcb86d2505e642 (diff) | |
| download | emacs-05fb53a16c00bd4067ddd6d6a18c6744b91bd1f2.tar.gz emacs-05fb53a16c00bd4067ddd6d6a18c6744b91bd1f2.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/progmodes/etags.el | 24 | ||||
| -rw-r--r-- | lisp/progmodes/xref.el | 4 |
3 files changed, 33 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b1a3a73864c..3f7182d50dc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-01-20 Dmitry Gutov <dgutov@yandex.ru> | ||
| 2 | |||
| 3 | * progmodes/etags.el (xref-etags-location): New class. | ||
| 4 | (xref-make-etags-location): New function. | ||
| 5 | (etags--xref-find-definitions): Use it. | ||
| 6 | (xref-location-marker): New method implementation. | ||
| 7 | |||
| 8 | * progmodes/xref.el: Mention that xref-location is an EIEIO class. | ||
| 9 | |||
| 1 | 2015-01-19 Dmitry Gutov <dgutov@yandex.ru> | 10 | 2015-01-19 Dmitry Gutov <dgutov@yandex.ru> |
| 2 | 11 | ||
| 3 | * ido.el: Update Customization instructions. | 12 | * ido.el: Update Customization instructions. |
diff --git a/lisp/progmodes/etags.el b/lisp/progmodes/etags.el index 47b305fb081..dc3380d02f6 100644 --- a/lisp/progmodes/etags.el +++ b/lisp/progmodes/etags.el | |||
| @@ -2100,17 +2100,35 @@ for \\[find-tag] (which see)." | |||
| 2100 | (< (hash-table-count marks) etags--xref-limit)) | 2100 | (< (hash-table-count marks) etags--xref-limit)) |
| 2101 | (when (funcall order-fun pattern) | 2101 | (when (funcall order-fun pattern) |
| 2102 | (beginning-of-line) | 2102 | (beginning-of-line) |
| 2103 | (cl-destructuring-bind (hint line &rest pos) (etags-snarf-tag) | 2103 | (pcase-let* ((tag-info (etags-snarf-tag)) |
| 2104 | (`(,hint ,line . _) tag-info)) | ||
| 2104 | (unless (eq hint t) ; hint==t if we are in a filename line | 2105 | (unless (eq hint t) ; hint==t if we are in a filename line |
| 2105 | (let* ((file (file-of-tag)) | 2106 | (let* ((file (file-of-tag)) |
| 2106 | (mark-key (cons file line))) | 2107 | (mark-key (cons file line))) |
| 2107 | (unless (gethash mark-key marks) | 2108 | (unless (gethash mark-key marks) |
| 2108 | (let ((loc (xref-make-file-location | 2109 | (let ((loc (xref-make-etags-location |
| 2109 | (expand-file-name file) line 0))) | 2110 | tag-info (expand-file-name file)))) |
| 2110 | (push (xref-make hint loc) xrefs) | 2111 | (push (xref-make hint loc) xrefs) |
| 2111 | (puthash mark-key t marks))))))))))) | 2112 | (puthash mark-key t marks))))))))))) |
| 2112 | (nreverse xrefs))) | 2113 | (nreverse xrefs))) |
| 2113 | 2114 | ||
| 2115 | (defclass xref-etags-location (xref-location) | ||
| 2116 | ((tag-info :type list :initarg :tag-info) | ||
| 2117 | (file :type string :initarg :file | ||
| 2118 | :reader xref-location-group)) | ||
| 2119 | :documentation "Location of an etags tag.") | ||
| 2120 | |||
| 2121 | (defun xref-make-etags-location (tag-info file) | ||
| 2122 | (make-instance 'xref-etags-location :tag-info tag-info | ||
| 2123 | :file (expand-file-name file))) | ||
| 2124 | |||
| 2125 | (defmethod xref-location-marker ((l xref-etags-location)) | ||
| 2126 | (with-slots (tag-info file) l | ||
| 2127 | (let ((buffer (find-file-noselect file))) | ||
| 2128 | (with-current-buffer buffer | ||
| 2129 | (etags-goto-tag-location tag-info) | ||
| 2130 | (point-marker))))) | ||
| 2131 | |||
| 2114 | 2132 | ||
| 2115 | (provide 'etags) | 2133 | (provide 'etags) |
| 2116 | 2134 | ||
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 12123c8f2e2..536096f612f 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el | |||
| @@ -34,7 +34,9 @@ | |||
| 34 | ;; | 34 | ;; |
| 35 | ;; One would usually call `make-xref' and `xref-make-file-location', | 35 | ;; One would usually call `make-xref' and `xref-make-file-location', |
| 36 | ;; `xref-make-buffer-location' or `xref-make-bogus-location' to create | 36 | ;; `xref-make-buffer-location' or `xref-make-bogus-location' to create |
| 37 | ;; them. | 37 | ;; them. More generally, a location must be an instance of an EIEIO |
| 38 | ;; class inheriting from `xref-location' and implementing | ||
| 39 | ;; `xref-location-group' and `xref-location-marker'. | ||
| 38 | ;; | 40 | ;; |
| 39 | ;; Each identifier must be represented as a string. Implementers can | 41 | ;; Each identifier must be represented as a string. Implementers can |
| 40 | ;; use string properties to store additional information about the | 42 | ;; use string properties to store additional information about the |