From: Helmut Eller Date: Thu, 30 Apr 2015 00:41:34 +0000 (+0300) Subject: Set next-error-* in xref--xref-buffer-mode X-Git-Tag: emacs-25.0.90~2249 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fa175b449597256dc4cb0411ce1978aa2016c170;p=emacs.git Set next-error-* in xref--xref-buffer-mode * xref.el (xref--xref-buffer-mode): Set `next-error-function' and `next-error-last-buffer'. (xref--next-error-function): New function. (http://lists.gnu.org/archive/html/emacs-devel/2015-04/msg01311.html) --- diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 9f1068668b1..fc27c268845 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -444,7 +444,22 @@ Used for temporary buffers.") (define-derived-mode xref--xref-buffer-mode special-mode "XREF" "Mode for displaying cross-references." - (setq buffer-read-only t)) + (setq buffer-read-only t) + (setq next-error-function #'xref--next-error-function) + (setq next-error-last-buffer (current-buffer))) + +(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--pop-to-location loc)) + (t + (error "No %s xref" (if backward "previous" "next")))))) (defun xref-quit (&optional kill) "Bury temporarily displayed buffers, then quit the current window.