From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#46119: 28.0.50; this-error-recenter Date: Mon, 01 Feb 2021 20:17:31 +0100 Message-ID: <874kivlhro.fsf@gmail.com> References: <8735yn1jjn.fsf@gmail.com> <87czxqbwp4.fsf@mail.linkov.net> <87im7eqxij.fsf@gmail.com> <87mtwqqose.fsf@mail.linkov.net> <87y2g9bgjc.fsf@mail.linkov.net> <87o8h5f6b9.fsf@gmail.com> <87sg6gbx4z.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21455"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 46119@debbugs.gnu.org, uyennhi.qm@gmail.com To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 01 20:19:17 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l6ejF-0005Tb-6d for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Feb 2021 20:19:17 +0100 Original-Received: from localhost ([::1]:37692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6ejE-00042y-6Q for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Feb 2021 14:19:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6ei2-0003CU-PJ for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2021 14:18:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l6ei2-00051b-82 for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2021 14:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l6ei2-0000Po-2d for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2021 14:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Feb 2021 19:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46119 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 46119-submit@debbugs.gnu.org id=B46119.16122070681575 (code B ref 46119); Mon, 01 Feb 2021 19:18:02 +0000 Original-Received: (at 46119) by debbugs.gnu.org; 1 Feb 2021 19:17:48 +0000 Original-Received: from localhost ([127.0.0.1]:33251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6ehn-0000PL-Tf for submit@debbugs.gnu.org; Mon, 01 Feb 2021 14:17:48 -0500 Original-Received: from mail-wr1-f53.google.com ([209.85.221.53]:46857) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l6ehe-0000P1-W2 for 46119@debbugs.gnu.org; Mon, 01 Feb 2021 14:17:45 -0500 Original-Received: by mail-wr1-f53.google.com with SMTP id q7so17837222wre.13 for <46119@debbugs.gnu.org>; Mon, 01 Feb 2021 11:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=wWFdbJEW4EceV8sMaTy6SzQZYlK0XHP9sdAe+o224e4=; b=C11Ir0it5MMKhoNCoySy55EPrjh9jQBA0cPODcMViPAHaHDWx575I1QhTQPgMtpMsf FRxnK61W/1AhtZ/CcR4Jz9VsT2VHFE0Waa0GyTGNufHYw7UdL19HgUXPsUWetk7uDgNu 1GX5lZTTuOhIkRntQx1frof7Z9Kk7D6DFeLsZfiIc/Rt2cB+DY8U+RzV0MLhirU4QQDQ iZ9coD180aQ+IPitdUnL+fGqa0XF7E7hw33T1PVDCQHJcejekh13GtCZPl76yb2JmWmb 9drbEIA7RCk0HtLcvH9eop2YFfgtRBGaasbdW897A/m+2UEERaZperAfAoo7LWXrsMJj PjNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=wWFdbJEW4EceV8sMaTy6SzQZYlK0XHP9sdAe+o224e4=; b=YD2oUsGUKqunpfp2o7p2HbvdA05raUcV3hnv0nlhA73Nf4fesIGFpJsAqsGLxgz/E0 Tp6CGeH3BA/xv6eG39JDYRURPmOssBqxOSCORX5DXJftHqW4ekdGYFYTvqYtVUu+VNQc KB+i5W8O5OhoSZIq5lXFd3zeBPUW1wkrJwJFDBmmFsE6L9EAiRQQDHQHlXwx/nIRCuGk MTjJKDwl8VbHXyvEXBPYhhY1p8RZ+hbM+fpFMbBp/u1s/kkJDsCuANjNwbHkY9tW5cq5 zrSmsrWSJVITpRHDlMC6mhuekpoEa3eP/6qv56m5A/ABiDQCPWQSV13SAoULMYeaJXJA dU6w== X-Gm-Message-State: AOAM531tINK2WLsxam7dzjgvuJbBZOuX1Zl6GYa5HWSGfJGVTb/mMWZW IPnFVEMmaXO3ypdpw6iqd7c= X-Google-Smtp-Source: ABdhPJychBH5fBkUXwkLRQ7iZ1GmqPw0kj3XRQD5xh8lbVmvkW1S5LPImAbzZeEXB+aItgQpYVVl+Q== X-Received: by 2002:a5d:414f:: with SMTP id c15mr19938393wrq.42.1612207053125; Mon, 01 Feb 2021 11:17:33 -0800 (PST) Original-Received: from localhost.example.com ([31.7.242.222]) by smtp.gmail.com with ESMTPSA id r15sm28154618wrj.61.2021.02.01.11.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 11:17:32 -0800 (PST) In-Reply-To: <87sg6gbx4z.fsf@mail.linkov.net> (Juri Linkov's message of "Sun, 31 Jan 2021 23:43:24 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:199104 Archived-At: Juri Linkov writes: >> Do you agree with adding two separated commands? > > Maybe two commands is fine. Then the users can decide what command > better suites user's needs. I am posting now the approach using two new commands: --8<-----------------------------cut here---------------start------------->8--- commit 16ea65701456ce7071f56d337f518d49a03e723f Author: Tino Calancha Date: Mon Feb 1 20:07:22 2021 +0100 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 M-C-l. * 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 `this-error-recenter' to l. * lisp/replace.el (occur-mode-map): Same. * etc/NEWS (Changes in Specialized Modes and Packages in Emacs 28.1): Announce the changes. diff --git a/etc/NEWS b/etc/NEWS index e038076e96..dbe53b3f29 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -85,6 +85,8 @@ useful on systems such as FreeBSD which ships only with "etc/termcap". * Changes in Emacs 28.1 +** The new command 'recenter-other-window' is bound to 'M-C-l'. + ** The new NonGNU ELPA archive is enabled by default alongside GNU ELPA ** Minibuffer scrolling is now conservative by default. @@ -454,9 +456,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..31a2ac3c88 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))) + + ;;; diff --git a/lisp/window.el b/lisp/window.el index 0a37d16273..c75ed90ef5 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9771,6 +9771,19 @@ recenter-top-bottom (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 [?\M-\C-l] 'recenter-other-window) + (defun move-to-window-line-top-bottom (&optional arg) "Position point relative to window. --8<-----------------------------cut here---------------end--------------->8---