Skip to content

Commit

Permalink
"Generic" backends to return a list of markers for either etags or gt…
Browse files Browse the repository at this point in the history
…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
markhepburn committed Sep 14, 2009
1 parent acfeffb commit 80da4b7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tags-view.el
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ etc."
(t (rec (file-name-directory (directory-file-name dir))))))) (t (rec (file-name-directory (directory-file-name dir)))))))
(catch 'exit (rec working-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 () (defun tv-view-history ()
"The main entry point; pops open a buffer with the list of "The main entry point; pops open a buffer with the list of
locations on the tag stack that can then optionally be operated locations on the tag stack that can then optionally be operated
Expand All @@ -112,7 +130,7 @@ etc). The following options will be available:
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(erase-buffer)) (erase-buffer))
(tags-history-mode) (tags-history-mode)
(let ((tag-items (copy-list (ring-elements tags-location-ring)))) (let ((tag-items (tv-get-tags-marker-list)))
(tv-insert-items tag-items)) (tv-insert-items tag-items))
(setq buffer-read-only t) (setq buffer-read-only t)
(goto-char 0))) (goto-char 0)))
Expand Down

0 comments on commit 80da4b7

Please sign in to comment.