[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master b0902d9: * lisp/simple.el (next-error-quit-window): New function
From: |
Juri Linkov |
Subject: |
master b0902d9: * lisp/simple.el (next-error-quit-window): New function (bug#44611). |
Date: |
Thu, 18 Mar 2021 13:56:59 -0400 (EDT) |
branch: master
commit b0902d926dd837ad06c9c6bbde35a5411a351779
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>
* lisp/simple.el (next-error-quit-window): New function (bug#44611).
(next-error-found-function): Add it as a choice.
---
etc/NEWS | 6 ++++++
lisp/simple.el | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/etc/NEWS b/etc/NEWS
index d5cfed4..7b76782 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1934,6 +1934,12 @@ highlight the current error message in the 'next-error'
buffer.
This user option can be also customized to keep highlighting on all
visited errors, so you can have an overview what errors were already visited.
+---
+*** New choice 'next-error-quit-window' for 'next-error-found-function'.
+When 'next-error-found-function' is customized to 'next-error-quit-window',
+then typing the numeric prefix argument 0 before the command 'next-error'
+will quit the source window after visiting the next occurrence.
+
+++
*** New user option 'tab-first-completion'.
If 'tab-always-indent' is 'complete', this new user option can be used to
diff --git a/lisp/simple.el b/lisp/simple.el
index 37aa650..eeef40f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -377,11 +377,22 @@ To control which errors are matched, customize the
variable
(not (eq prev next-error-last-buffer)))
(message "Current locus from %s" next-error-last-buffer)))))
+(defun next-error-quit-window (from-buffer to-buffer)
+ "Quit window of FROM-BUFFER when the prefix arg is 0.
+Intended to be used in `next-error-found-function'."
+ (when (and (eq current-prefix-arg 0) from-buffer
+ (not (eq from-buffer to-buffer)))
+ (let ((window (get-buffer-window from-buffer)))
+ (when (window-live-p window)
+ (quit-restore-window window)))))
+
(defcustom next-error-found-function #'ignore
"Function called when a next locus is found and displayed.
Function is called with two arguments: a FROM-BUFFER buffer
from which next-error navigated, and a target buffer TO-BUFFER."
:type '(choice (const :tag "No default" ignore)
+ (const :tag "Quit previous window with M-0"
+ next-error-quit-window)
(function :tag "Other function"))
:group 'next-error
:version "27.1")
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master b0902d9: * lisp/simple.el (next-error-quit-window): New function (bug#44611).,
Juri Linkov <=