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

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

bug#44611: Prefix arg for xref-goto-xref


From: Juri Linkov
Subject: bug#44611: Prefix arg for xref-goto-xref
Date: Mon, 01 Feb 2021 19:16:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

> I think C-u RET is probably fine, especially if we add a change like you
> described to compile-goto-error as well. But if anyone wanted to propose
> some other alternative, they're welcome to.

I want to propose another alternative: to implement C-u RET
not only for compilation-mode, but also for e.g. occur-mode,
maybe current-prefix-arg could be handled in 'next-error-found'
by adding to the end:

  (when (and current-prefix-arg from-buffer (not (eq from-buffer to-buffer)))
    (let ((window (get-buffer-window from-buffer)))
      (with-selected-window window
        (quit-restore-window window))))

But this means that it should take into account possible values
of the prefix arg of the command 'next-error':

  A prefix ARG specifies how many error messages to move;
  negative means move back to previous error messages.
  Just C-u as a prefix means reparse the error message buffer
  and start at the first error.

So since 'C-u M-g n' is already taken, an alternative is 'C-0 M-g n'.
If 'C-0' makes no sense for 'C-0 M-g n', it could be used to close the window.
Or maybe 'C-0 M-g n' still makes sense, e.g. to redisplay the current location?

BTW, here are the commands that work like TAB in grep-mode.
I propose to install this patch, so at least users could bind them
in own init files:

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 18fdd963fb..750a090b84 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -607,16 +607,26 @@ xref-show-location-at-point
     (when xref
       (xref--show-location (xref-item-location xref)))))
 
+(defun xref-next-line-no-display ()
+  "Move to the next xref but don't display its source."
+  (interactive)
+  (xref--search-property 'xref-item))
+
 (defun xref-next-line ()
   "Move to the next xref and display its source in the appropriate window."
   (interactive)
-  (xref--search-property 'xref-item)
+  (xref-next-line-no-display)
   (xref-show-location-at-point))
 
+(defun xref-prev-line-no-display ()
+  "Move to the previous xref but don't display its source."
+  (interactive)
+  (xref--search-property 'xref-item t))
+
 (defun xref-prev-line ()
   "Move to the previous xref and display its source in the appropriate window."
   (interactive)
-  (xref--search-property 'xref-item t)
+  (xref-prev-line-no-display)
   (xref-show-location-at-point))
 
 (defun xref-next-group ()

reply via email to

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