Skip to content
Browse files

"Generic" backends to return a list of markers for either etags or gt…

…ags (admittedly, the gtags backend hasn't been tested yet!). Two issues, apart from hackishness: I think it should use something like memq indexing rather than symbol interning, and secondly the gtags backend will pollute the visited buffers with markers that weren't there before, which I hadn't thought about. Might be better to rewrite things in terms of buffer/position rather than markers.
  • Loading branch information...
1 parent acfeffb commit 80da4b7ab620b1da3e5fa25149ffee960aecdcef @markhepburn committed
Showing with 19 additions and 1 deletion.
  1. +19 −1 tags-view.el
20 tags-view.el
@@ -98,6 +98,24 @@ etc."
(t (rec (file-name-directory (directory-file-name dir)))))))
(catch 'exit (rec working-dir)))))
+(defun tv-get-tags-marker-list ()
+ (let* ((backend (tv-determine-backend))
+ (backend-fn (intern (concat "tv-get-tags-marker-list-for-"
+ (symbol-name backend)))))
+ (if (or (eq backend 'none) (not (fboundp backend-fn)))
+ (error "Can't find a usable backend")
+ (funcall backend-fn))))
+(defun tv-get-tags-marker-list-for-etags ()
+ (copy-list (ring-elements tags-location-ring)))
+(defun tv-get-tags-marker-list-for-gtags ()
+ (let ((points-and-buffers (mapcar 'cons gtags-point-stack gtags-buffer-stack))
+ (gtags-markers nil))
+ (dolist (pb points-and-buffers gtags-markers)
+ (with-current-buffer (cdr pb)
+ (save-excursion
+ (goto-char (car pb))
+ (setq gtags-markers (cons (point-marker) gtags-markers)))))))
(defun tv-view-history ()
"The main entry point; pops open a buffer with the list of
locations on the tag stack that can then optionally be operated
@@ -112,7 +130,7 @@ etc). The following options will be available:
(let ((inhibit-read-only t))
- (let ((tag-items (copy-list (ring-elements tags-location-ring))))
+ (let ((tag-items (tv-get-tags-marker-list)))
(tv-insert-items tag-items))
(setq buffer-read-only t)
(goto-char 0)))

0 comments on commit 80da4b7

Please sign in to comment.
Something went wrong with that request. Please try again.