emacs-devel
[Top][All Lists]
Advanced

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

Re: Generalizing find-definition


From: Helmut Eller
Subject: Re: Generalizing find-definition
Date: Fri, 19 Dec 2014 09:49:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

On Fri, Dec 19 2014, Dmitry Gutov wrote:

> I've pushed the patch with some updates to
> http://git.savannah.gnu.org/cgit/emacs.git/log/?h=scratch/xref, please
> everyone take a look.

xref-goto-xref should be rewritten as:

(defun xref-goto-xref ()
  "Jump to the xref at point and close the xref buffer."
  (interactive)
  (let ((loc (xref--location-at-point)))
    (quit-window)
    (xref--pop-to-location loc)))

as the old version could quit the wrong window.

I would also add this to make the next-error command work:

(defun xref--next-error-function (n reset?)
  (when reset?
    (goto-char (point-min)))
  (let ((backward (< n 0))
        (n (abs n))
        (loc nil))
    (dotimes (_ n)
      (setq loc (xref--search-property 'xref-location backward)))
    (cond (loc
           (xref--display-position (point) t 0)
           (xref--pop-to-location loc))
          (t
           (error "No %s xref" (if backward "previous" "next"))))))

(define-derived-mode xref--xref-buffer-mode fundamental-mode "XREF"
  "Mode for displaying cross refenences."
  (setq buffer-read-only t)
  (setq next-error-function #'xref--next-error-function)
  (setq next-error-last-buffer (current-buffer)))

Helmut



reply via email to

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