Can multi-buffers have their own etags marks stack?
Question
It seems that etags use a global marks stack.
When i open two buffers that use the same TAGS, I performs find-tags
operations in one buffer(A), then performs find-tags
operation in the other buffer(B). I switch back to the previous buffer(A) and perform pop-tag-mark
operation. It will jump back to the mark that is the previous mark of buffer B!
Is there any way to solve this problem?
Solution
First of all, this is completely by design. If you're jumping within a file, imenu
is more suitable.
Now let's try to modify the design:
(defun my-pop-tag-mark (arg)
"call `pop-tag-mark' without argument.
Pop to the next mark in the current buffer wit C-u prefix."
(interactive "P")
(when (consp arg)
(let ((buf (current-buffer))
index)
(loop for marker in (ring-elements find-tag-marker-ring)
for i from 0 below (ring-length find-tag-marker-ring)
do (when (eq (setq temp (marker-buffer marker))
(current-buffer))
(setq index i)
(return)))
(if index
(ring-insert find-tag-marker-ring (ring-remove find-tag-marker-ring index))
(error "no marker found in current buffer."))))
(pop-tag-mark))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow