+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.
(< (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)
;;
;; 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