1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

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).
This commit is contained in:
Thierry Volpiatto 2019-06-27 19:20:50 +02:00 committed by Lars Ingebrigtsen
parent e51f328465
commit f9744d23e5
3 changed files with 27 additions and 15 deletions

View File

@ -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

View File

@ -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.

View File

@ -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))))))