bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#31027: 27.0.50; xref, tags-location-ring equivalent


From: Charles A. Roelli
Subject: bug#31027: 27.0.50; xref, tags-location-ring equivalent
Date: Thu, 05 Apr 2018 20:56:22 +0200

> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Thu, 5 Apr 2018 01:14:14 +0300
>
> >> What's simpler about that? You'd need some new commands to use it as
> >> well, right?
> > 
> > Is the idea to use a ring of next-error capable buffers?
> > So that the next-error command in the current buffer
> > will return a list of all potentially next-error capable buffers
> > and allow the user to select the required one.
> 
> Umm, I don't think the request is anything so ambitious.
> 
> Charles has been asking for a ring to store the navigation locations 
> visited by xref only.

Exactly, this feature request is only about xref.  Nevertheless, the
idea of a "ring of next-error capable buffers" does sound like it
could be useful in its own right -- if anybody wants to open up a bug
for that, feel free.

Anyway, I suggest we follow the etags implementation of
"tags-location-ring".  This is all there is to it, in simplified
terms:

(defun find-tag-noselect ...
  ...
  (if (eq '- PREFIX-ARG)
        ;; Pop back to a previous location.
        (if (ring-empty-p tags-location-ring)
            (user-error "No previous tag locations")
          (let ((marker (ring-remove tags-location-ring 0)))
            (prog1
                ;; Move to the saved location.
                (set-buffer (or (marker-buffer marker)
                                (error "The marked buffer has been deleted")))
              (goto-char (marker-position marker))
              ;; Kill that marker so it doesn't slow down editing.
              (set-marker marker nil nil))))
    ;; Else, we jump to wherever we wanted to go, and record and add a
    ;; marker to tags-location-ring.
    (let ((marker (make-marker)))
      (with-current-buffer
          (find-tag-in-order ...)
        (set-marker marker (point))
        (run-hooks 'local-find-tag-hook)
        (ring-insert tags-location-ring marker)
        (current-buffer))))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]