[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 9380a7e: Add command to recenter errors from Occur/Grep buffers
From: |
Tino Calancha |
Subject: |
master 9380a7e: Add command to recenter errors from Occur/Grep buffers |
Date: |
Sun, 7 Feb 2021 10:52:37 -0500 (EST) |
branch: master
commit 9380a7ed906e667df4fc5b9d9c8e487fafa7c654
Author: Tino Calancha <ccalancha@suse.com>
Commit: Tino Calancha <ccalancha@suse.com>
Add command to recenter errors from Occur/Grep buffers
To scroll up/down the current displayed occurrence/error
without abandon the Occur/Grep buffer.
Add also a command 'recenter-other-window' to recenter
the other window from any kind of buffer.
* lisp/window.el (recenter-other-window): New command.
Bind recenter-other-window to S-M-C-l (Bug#46119).
* lisp/simple.el (recenter-current-error): New command.
* lisp/progmodes/grep.el (grep-mode-map):
Delete bidings for n and p.
* lisp/progmodes/compile.el (compilation-minor-mode-map):
Move here the n and p bindings.
Bind `recenter-current-error' to l.
* lisp/replace.el (occur-mode-map):
Same.
* doc/emacs/windows.texi (Other Window):
* doc/emacs/display.texi (Recentering):
Document recenter-other-window.
* etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1):
Announce the changes.
---
doc/emacs/display.texi | 4 ++++
doc/emacs/windows.texi | 8 +++++++-
etc/NEWS | 13 +++++++++++--
lisp/progmodes/compile.el | 4 ++++
lisp/progmodes/grep.el | 2 --
lisp/replace.el | 1 +
lisp/simple.el | 10 ++++++++++
lisp/window.el | 13 +++++++++++++
8 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/doc/emacs/display.texi b/doc/emacs/display.texi
index 2781328..58d08b4 100644
--- a/doc/emacs/display.texi
+++ b/doc/emacs/display.texi
@@ -173,6 +173,10 @@ line; on subsequent consecutive invocations, make the
current line the
top line, the bottom line, and so on in cyclic order. Possibly
redisplay the screen too (@code{recenter-top-bottom}).
+@item C-M-S-l
+Scroll the other window; this is equivalent to @kbd{C-l} acting on the
+other window.
+
@item M-x recenter
Scroll the selected window so the current line is the center-most text
line. Possibly redisplay the screen too.
diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi
index e851f1b..c66deb7 100644
--- a/doc/emacs/windows.texi
+++ b/doc/emacs/windows.texi
@@ -161,6 +161,8 @@ Select another window (@code{other-window}).
Scroll the next window upward (@code{scroll-other-window}).
@item C-M-S-v
Scroll the next window downward (@code{scroll-other-window-down}).
+@item C-M-S-l
+Recenter the next window (@code{recenter-other-window}).
@item mouse-1
@kbd{mouse-1}, in the text area of a window, selects the window and
moves point to the position clicked. Clicking in the mode line
@@ -194,6 +196,8 @@ rebind a command.)
@findex scroll-other-window
@kindex C-M-S-v
@findex scroll-other-window-down
+@kindex C-M-S-l
+@findex recenter-other-window
The usual scrolling commands (@pxref{Display}) apply to the selected
window only, but there are also commands to scroll the next window.
@kbd{C-M-v} (@code{scroll-other-window}) scrolls the window that
@@ -203,7 +207,9 @@ take positive and negative arguments. (In the minibuffer,
@kbd{C-M-v}
scrolls the help window associated with the minibuffer, if any, rather
than the next window in the standard cyclic order; @pxref{Minibuffer
Edit}.) @kbd{C-M-S-v} (@code{scroll-other-window-down}) scrolls the
-next window downward in a similar way.
+next window downward in a similar way. Likewise, @kbd{C-M-S-l}
+(@code{recenter-other-window}) behaves like @kbd{C-l}
+(@code{recenter-top-bottom}) in the next window.
@vindex mouse-autoselect-window
If you set @code{mouse-autoselect-window} to a non-@code{nil} value,
diff --git a/etc/NEWS b/etc/NEWS
index 0faed3e..f65e3cf 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -85,7 +85,11 @@ useful on systems such as FreeBSD which ships only with
"etc/termcap".
* Changes in Emacs 28.1
-** The new NonGNU ELPA archive is enabled by default alongside GNU ELPA.
++++
+** New command 'recenter-other-window', bound to 'S-M-C-l'.
+Like 'recenter-top-bottom' acting in the other window.
+
+** The new NonGNU ELPA archive is enabled by default alongside GNU ELPA
** Minibuffer scrolling is now conservative by default.
This is controlled by the new variable 'scroll-minibuffer-conservatively'.
@@ -469,9 +473,14 @@ applied when the option 'tab-line-tab-face-functions' is
so-configured. That option may also be used to customize tab-line
faces in other ways.
-** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and
+** Occur mode
+
+*** New bindings in occur-mode, 'next-error-no-select' bound to 'n' and
'previous-error-no-select' bound to 'p'.
+*** The new command 'recenter-current-error', bound to 'l' in Occur or
+compilation buffers, recenters the current displayed occurrence/error.
+
** EIEIO
+++
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 614ed7d..48b5ee9 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -2069,6 +2069,10 @@ Returns the compilation buffer created."
(define-key map "\M-p" 'compilation-previous-error)
(define-key map "\M-{" 'compilation-previous-file)
(define-key map "\M-}" 'compilation-next-file)
+ (define-key map "n" 'next-error-no-select)
+ (define-key map "p" 'previous-error-no-select)
+ (define-key map "l" 'recenter-current-error)
+
(define-key map "g" 'recompile) ; revert
;; Set up the menu-bar
(define-key map [menu-bar compilation]
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index 1a8435f..d6ee8bb 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -275,8 +275,6 @@ See `compilation-error-screen-columns'."
(define-key map "\C-c\C-f" 'next-error-follow-minor-mode)
(define-key map "\r" 'compile-goto-error) ;; ?
- (define-key map "n" 'next-error-no-select)
- (define-key map "p" 'previous-error-no-select)
(define-key map "{" 'compilation-previous-file)
(define-key map "}" 'compilation-next-file)
(define-key map "\t" 'compilation-next-error)
diff --git a/lisp/replace.el b/lisp/replace.el
index d320542..eb7a439 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1161,6 +1161,7 @@ a previously found match."
(define-key map "\C-o" 'occur-mode-display-occurrence)
(define-key map "n" 'next-error-no-select)
(define-key map "p" 'previous-error-no-select)
+ (define-key map "l" 'recenter-current-error)
(define-key map "\M-n" 'occur-next)
(define-key map "\M-p" 'occur-prev)
(define-key map "r" 'occur-rename-buffer)
diff --git a/lisp/simple.el b/lisp/simple.el
index 73e3fb9..60c1316 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -492,6 +492,16 @@ buffer causes automatic display of the corresponding
source code location."
(overlay-put ol 'window (get-buffer-window))
(setf next-error--message-highlight-overlay ol)))))
+(defun recenter-current-error (&optional arg)
+ "Recenter the current displayed error in the `next-error' buffer."
+ (interactive "P")
+ (save-selected-window
+ (let ((next-error-highlight next-error-highlight-no-select)
+ (display-buffer-overriding-action
+ '(nil (inhibit-same-window . t))))
+ (next-error 0)
+ (set-buffer (window-buffer))
+ (recenter-top-bottom arg))))
;;;
diff --git a/lisp/window.el b/lisp/window.el
index 92ed6ee..2d0a73b 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9768,6 +9768,19 @@ With plain \\[universal-argument], move current line to
window center."
(define-key global-map [?\C-l] 'recenter-top-bottom)
+(defun recenter-other-window (&optional arg)
+ "Call `recenter-top-bottom' in the other window.
+
+A prefix argument is handled like `recenter':
+ With numeric prefix ARG, move current line to window-line ARG.
+ With plain `C-u', move current line to window center."
+ (interactive "P")
+ (with-selected-window (other-window-for-scrolling)
+ (recenter-top-bottom arg)
+ (pulse-momentary-highlight-one-line (point))))
+
+(define-key global-map [?\S-\M-\C-l] 'recenter-other-window)
+
(defun move-to-window-line-top-bottom (&optional arg)
"Position point relative to window.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 9380a7e: Add command to recenter errors from Occur/Grep buffers,
Tino Calancha <=