From f9744d23e5bdc90ebdfaf78db55966e436876b28 Mon Sep 17 00:00:00 2001 From: Thierry Volpiatto Date: Thu, 27 Jun 2019 19:20:50 +0200 Subject: [PATCH] Add a new regexp variable to control boring winner buffers * doc/emacs/windows.texi (Window Convenience): Mention it. * lisp/winner.el (winner-boring-buffers-regexp): New variable. * lisp/winner.el (winner-set): Use it (bug#11151). --- doc/emacs/windows.texi | 4 +++- etc/NEWS | 4 ++++ lisp/winner.el | 34 ++++++++++++++++++++-------------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/doc/emacs/windows.texi b/doc/emacs/windows.texi index 4b39e8bfe10..4aeb467dff8 100644 --- a/doc/emacs/windows.texi +++ b/doc/emacs/windows.texi @@ -538,6 +538,7 @@ Reference Manual}), and cannot exceed the size of the containing frame. @vindex winner-dont-bind-my-keys @vindex winner-ring-size @vindex winner-boring-buffers +@vindex winner-boring-buffers-regexp @cindex Winner mode @cindex mode, Winner @cindex undoing window configuration changes @@ -556,7 +557,8 @@ non-@code{nil} value. By default, Winner mode stores a maximum of 200 window configurations per frame, but you can change that by modifying the variable @code{winner-ring-size}. If there are some buffers whose windows you wouldn't want Winner mode to restore, add their names to -the list variable @code{winner-boring-buffers}. +the list variable @code{winner-boring-buffers} or to the regexp +@code{winner-boring-buffers-regexp}. Follow mode (@kbd{M-x follow-mode}) synchronizes several windows on the same buffer so that they always display adjacent sections of that diff --git a/etc/NEWS b/etc/NEWS index 6b38b81d4ab..988ee8bb41e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -475,6 +475,10 @@ current and the previous or the next line, as before. * Changes in Specialized Modes and Packages in Emacs 27.1 ++++ +** winner +*** A new variable, `winner-boring-buffers-regexp', has been added. + ** table ** `table-generate-source' and friends now support outputting wiki and mediawiki format tables. diff --git a/lisp/winner.el b/lisp/winner.el index 92dd9c0f122..ec3b296489c 100644 --- a/lisp/winner.el +++ b/lisp/winner.el @@ -57,21 +57,22 @@ (defcustom winner-dont-bind-my-keys nil "Non-nil means do not bind keys in Winner mode." - :type 'boolean - :group 'winner) + :type 'boolean) (defcustom winner-ring-size 200 "Maximum number of stored window configurations per frame." - :type 'integer - :group 'winner) + :type 'integer) (defcustom winner-boring-buffers '("*Completions*") "List of buffer names whose windows `winner-undo' will not restore. You may want to include buffer names such as *Help*, *Apropos*, *Buffer List*, *info* and *Compile-Log*." - :type '(repeat string) - :group 'winner) + :type '(repeat string)) +(defcustom winner-boring-buffers-regexp nil + "`winner-undo' will not restore windows with buffers matching this regexp." + :type 'string + :version "27.1") ;;;; Saving old configurations (internal variables and subroutines) @@ -273,8 +274,9 @@ You may want to include buffer names such as *Help*, *Apropos*, ;; Make sure point does not end up in the minibuffer and delete ;; windows displaying dead or boring buffers -;; (c.f. `winner-boring-buffers'). Return nil if all the windows -;; should be deleted. Preserve correct points and marks. +;; (c.f. `winner-boring-buffers') and `winner-boring-buffers-regexp'. +;; Return nil if all the windows should be deleted. Preserve correct +;; points and marks. (defun winner-set (conf) ;; For the format of `conf', see `winner-conf'. (let* ((buffers nil) @@ -302,8 +304,12 @@ You may want to include buffer names such as *Help*, *Apropos*, (not (= marker pos))) (setq pos marker)) (setf (window-point win) pos))) - (not (member (buffer-name (window-buffer win)) - winner-boring-buffers))) + (not (or (member (buffer-name (window-buffer win)) + winner-boring-buffers) + (and winner-boring-buffers-regexp + (string-match + winner-boring-buffers-regexp + (buffer-name (window-buffer win))))))) (push win xwins))) ; delete this window ;; Restore marks @@ -320,10 +326,10 @@ You may want to include buffer names such as *Help*, *Apropos*, ;; Return t if this is still a possible configuration. (or (null xwins) (progn - (mapc 'delete-window (cdr xwins)) ; delete all but one - (unless (one-window-p t) - (delete-window (car xwins)) - t)))))) + (mapc 'delete-window (cdr xwins)) ; delete all but one + (unless (one-window-p t) + (delete-window (car xwins)) + t)))))) -- 2.39.2