mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
'window-state-normalize-buffer-name' option for `uniquify' buffers
If 'window-state-normalize-buffer-name' is non-nil, 'window-state-get' will normalize stored buffer names, making them easier to restore for users that use 'uniquify' buffer naming. * doc/lispref/windows.texi (Window Configurations): Document 'window-state-normalize-buffer-name'. * lisp/window.el (window-state-normalize-buffer-name): New defvar. (window--state-normalize-buffer-name): New function. (window--state-get-1): Call 'window--state-normalize-buffer-name' rather than 'buffer-name'. * etc/NEWS: Announce 'window-state-normalize-buffer-name'. (Bug#76980)
This commit is contained in:
parent
1aebb02611
commit
4266514dc8
3 changed files with 33 additions and 3 deletions
|
|
@ -7000,6 +7000,11 @@ state will be written to disk and read back in another session.
|
||||||
Together, the argument @var{writable} and the variable
|
Together, the argument @var{writable} and the variable
|
||||||
@code{window-persistent-parameters} specify which window parameters are
|
@code{window-persistent-parameters} specify which window parameters are
|
||||||
saved by this function. @xref{Window Parameters}.
|
saved by this function. @xref{Window Parameters}.
|
||||||
|
|
||||||
|
Bind @code{window-state-normalize-buffer-name} to non-@code{nil} to
|
||||||
|
normalize buffer names under @file{uniquify} management by removing its
|
||||||
|
prefixes and suffixes. This helps restore window buffers across Emacs
|
||||||
|
sessions. @xref{Uniquify,,, emacs, The GNU Emacs Manual}.
|
||||||
@end defun
|
@end defun
|
||||||
|
|
||||||
The value returned by @code{window-state-get} can be used in the same
|
The value returned by @code{window-state-get} can be used in the same
|
||||||
|
|
|
||||||
6
etc/NEWS
6
etc/NEWS
|
|
@ -292,6 +292,12 @@ return value windows whose buffers share their text with BUFFER-OR-NAME.
|
||||||
With such an entry, 'display-buffer-reuse-window' may also choose a
|
With such an entry, 'display-buffer-reuse-window' may also choose a
|
||||||
window whose buffer shares text with the buffer to display.
|
window whose buffer shares text with the buffer to display.
|
||||||
|
|
||||||
|
+++
|
||||||
|
*** New variable 'window-state-normalize-buffer-name'.
|
||||||
|
When bound to non-nil, 'window-state-get' will normalize 'uniquify'
|
||||||
|
managed buffer names by removing 'uniquify' prefixes and suffixes. This
|
||||||
|
helps restore window buffers across Emacs sessions.
|
||||||
|
|
||||||
** Frames
|
** Frames
|
||||||
|
|
||||||
+++
|
+++
|
||||||
|
|
|
||||||
|
|
@ -6300,6 +6300,22 @@ specific buffers."
|
||||||
))
|
))
|
||||||
|
|
||||||
;;; Window states, how to get them and how to put them in a window.
|
;;; Window states, how to get them and how to put them in a window.
|
||||||
|
|
||||||
|
(defvar window-state-normalize-buffer-name nil
|
||||||
|
"Non-nil means accommodate buffer names under `uniquify' management.
|
||||||
|
`uniquify' prefixes and suffixes will be removed.")
|
||||||
|
|
||||||
|
(defun window--state-normalize-buffer-name (buffer)
|
||||||
|
"Normalize BUFFER name, accommodating `uniquify'.
|
||||||
|
If BUFFER is under `uniquify' management, return its `buffer-name' with
|
||||||
|
its prefixes and suffixes removed; otherwise return BUFFER
|
||||||
|
`buffer-name'."
|
||||||
|
(or (and window-state-normalize-buffer-name
|
||||||
|
(fboundp 'uniquify-buffer-base-name)
|
||||||
|
(with-current-buffer buffer
|
||||||
|
(uniquify-buffer-base-name)))
|
||||||
|
(buffer-name buffer)))
|
||||||
|
|
||||||
(defun window--state-get-1 (window &optional writable)
|
(defun window--state-get-1 (window &optional writable)
|
||||||
"Helper function for `window-state-get'."
|
"Helper function for `window-state-get'."
|
||||||
(let* ((type
|
(let* ((type
|
||||||
|
|
@ -6352,7 +6368,8 @@ specific buffers."
|
||||||
(let ((point (window-point window))
|
(let ((point (window-point window))
|
||||||
(start (window-start window)))
|
(start (window-start window)))
|
||||||
`((buffer
|
`((buffer
|
||||||
,(if writable (buffer-name buffer) buffer)
|
,(if writable (window--state-normalize-buffer-name
|
||||||
|
buffer) buffer)
|
||||||
(selected . ,selected)
|
(selected . ,selected)
|
||||||
(hscroll . ,(window-hscroll window))
|
(hscroll . ,(window-hscroll window))
|
||||||
(fringes . ,(window-fringes window))
|
(fringes . ,(window-fringes window))
|
||||||
|
|
@ -6374,13 +6391,15 @@ specific buffers."
|
||||||
,@(when next-buffers
|
,@(when next-buffers
|
||||||
`((next-buffers
|
`((next-buffers
|
||||||
. ,(if writable
|
. ,(if writable
|
||||||
(mapcar #'buffer-name next-buffers)
|
(mapcar #'window--state-normalize-buffer-name
|
||||||
|
next-buffers)
|
||||||
next-buffers))))
|
next-buffers))))
|
||||||
,@(when prev-buffers
|
,@(when prev-buffers
|
||||||
`((prev-buffers
|
`((prev-buffers
|
||||||
. ,(if writable
|
. ,(if writable
|
||||||
(mapcar (lambda (entry)
|
(mapcar (lambda (entry)
|
||||||
(list (buffer-name (nth 0 entry))
|
(list (window--state-normalize-buffer-name
|
||||||
|
(nth 0 entry))
|
||||||
(marker-position (nth 1 entry))
|
(marker-position (nth 1 entry))
|
||||||
(marker-position (nth 2 entry))))
|
(marker-position (nth 2 entry))))
|
||||||
prev-buffers)
|
prev-buffers)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue