all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#46119: 28.0.50; this-error-recenter
@ 2021-01-26 21:21 Tino Calancha
  2021-01-27  9:19 ` Juri Linkov
  2021-01-28  6:38 ` Richard Stallman
  0 siblings, 2 replies; 21+ messages in thread
From: Tino Calancha @ 2021-01-26 21:21 UTC (permalink / raw)
  To: 46119; +Cc: uyennhi.qm

X-Debbugs-Cc: Juri Linkov <juri@jurta.org>,uyennhi.qm@gmail.com
Severity: wishlist
Tags: patch

As a regular greper with a tiny screen I tend to use this command quite often.

Tentatively, I have named it `this-error-recenter'; if you find a
better name for it, please let me know.

--8<-----------------------------cut here---------------start------------->8---
commit 8cf1b91190013154a82a731a067cdf7d18288379
Author: Tino Calancha <ccalancha@suse.com>
Date:   Tue Jan 26 21:57:50 2021 +0100

    Add command to recenter errors from Occur/Grep buffers
    
    It allows to scroll up/down the current displayed occurrence/error
    without abandon the Occur/Grep buffer.
    
    * lisp/simple.el (this-error-recenter): 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 the new command to l.
    * lisp/replace.el (occur-mode-map):
    Bind the new command to l.
    * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1):
    Announce it.

diff --git a/etc/NEWS b/etc/NEWS
index e038076e96..a51a6b4f63 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -454,9 +454,15 @@ 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 'this-error-recenter', bound to 'l', recenters the
+current displayed occurrence from a Occur buffer and the current
+displayed error in a compilation buffer.
+
 ** EIEIO
 
 +++
diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 94e4f3c6fa..1031f835f8 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -2073,6 +2073,10 @@ compilation-minor-mode-map
     (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" 'this-error-recenter)
+
     (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 1a8435fde3..d6ee8bb423 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -275,8 +275,6 @@ grep-mode-map
     (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 db5b340631..bd3a96a26e 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1135,6 +1135,7 @@ occur-mode-map
     (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" 'this-error-recenter)
     (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 c878fdab92..6da1dec003 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -496,6 +496,16 @@ next-error-message-highlight
         (overlay-put ol 'window (get-buffer-window))
         (setf next-error--message-highlight-overlay ol)))))
 
+(defun this-error-recenter (&optional arg)
+  "Recenter the current displayed error in the `next-error' buffer."
+  (interactive "P")
+  (if (not (or (eq major-mode 'occur-mode)
+               (derived-mode-p 'compilation-mode)))
+      (user-error "This command is for *Occur* or *Grep* buffers")
+    (funcall next-error-function 0 nil)
+    (recenter-top-bottom arg)
+    (pop-to-buffer next-error-last-buffer)))
+
 \f
 ;;;
 

--8<-----------------------------cut here---------------end--------------->8---

In GNU Emacs 28.0.50 (build 9, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2021-01-26 built on localhost.example.com
Repository revision: 8cf1b91190013154a82a731a067cdf7d18288379
Repository branch: this-error-recenter
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: openSUSE Tumbleweed

Configured using:
 'configure --with-x-toolkit=lucid'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG
LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB






^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-02-07 15:56 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-26 21:21 bug#46119: 28.0.50; this-error-recenter Tino Calancha
2021-01-27  9:19 ` Juri Linkov
2021-01-30 15:01   ` Tino Calancha
2021-01-30 18:40     ` Juri Linkov
2021-01-30 20:41       ` Tino Calancha
2021-01-31  9:29         ` Juri Linkov
2021-01-31 15:56           ` Tino Calancha
2021-01-31 21:43             ` Juri Linkov
2021-02-01 17:19               ` Juri Linkov
2021-02-01 18:45                 ` Tino Calancha
2021-02-02 17:04                   ` Juri Linkov
2021-02-02 21:10                     ` Tino Calancha
2021-02-01 19:17               ` Tino Calancha
2021-02-02 17:05                 ` Juri Linkov
2021-02-02 21:16                   ` Tino Calancha
2021-02-03  8:58                     ` Juri Linkov
2021-02-03 13:03                       ` Tino Calancha
2021-02-03 17:39                         ` Juri Linkov
2021-02-07 15:56                           ` Tino Calancha
2021-01-28  6:38 ` Richard Stallman
2021-01-30 14:50   ` Tino Calancha

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.