mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-04 19:10:37 -08:00
* lisp/bs.el: Adapt to modern display-buffer-alist window setup
* lisp/bs.el (bs--window-config-coming-from): Delete. (bs-default-action-list): New user customizable option. (bs--restore-window-config): Delete. (bs-kill, bs-select, bs-select-other-window) (bs-select-other-frame): Use `quit-window' instead. (bs--show-with-configuration): Use `pop-to-buffer' to display the "*buffer-selection*" buffer.
This commit is contained in:
parent
f803203088
commit
80df980e41
1 changed files with 26 additions and 32 deletions
58
lisp/bs.el
58
lisp/bs.el
|
|
@ -420,9 +420,6 @@ naming a sort behavior. Default is \"by nothing\" which means no sorting."
|
|||
Non-nil means to show all buffers. Otherwise show buffers
|
||||
defined by current configuration `bs-current-configuration'.")
|
||||
|
||||
(defvar bs--window-config-coming-from nil
|
||||
"Window configuration before starting Buffer Selection Menu.")
|
||||
|
||||
(defvar bs--intern-show-never "^ \\|\\*buffer-selection\\*"
|
||||
"Regular expression specifying which buffers never to show.
|
||||
A buffer whose name matches this regular expression will never be
|
||||
|
|
@ -491,7 +488,23 @@ Used internally, only.")
|
|||
"<mouse-2>" #'bs-mouse-select
|
||||
"<mouse-3>" #'bs-mouse-select-other-frame)
|
||||
|
||||
;; ----------------------------------------------------------------------
|
||||
(defcustom bs-default-action-list '((display-buffer-reuse-window
|
||||
display-buffer-below-selected)
|
||||
(window-height . bs-max-window-height))
|
||||
"Default action list for showing the '*bs-selection*' buffer.
|
||||
|
||||
This list will be passed to `pop-to-buffer' as its ACTION argument.
|
||||
It should be a cons cell (FUNCTIONS . ALIST), where FUNCTIONS is
|
||||
an action function or a list of action functions and ALIST is an
|
||||
action alist. Each such action function should accept two
|
||||
arguments: a buffer to display and an alist of the same form as
|
||||
ALIST. See `display-buffer' for details."
|
||||
:type display-buffer--action-custom-type
|
||||
:risky t
|
||||
:version "30.1"
|
||||
:group 'bs)
|
||||
|
||||
; ----------------------------------------------------------------------
|
||||
;; Functions
|
||||
;; ----------------------------------------------------------------------
|
||||
|
||||
|
|
@ -668,20 +681,11 @@ apply it.
|
|||
(add-hook 'kill-buffer-hook 'bs--remove-hooks nil t)
|
||||
(add-hook 'change-major-mode-hook 'bs--remove-hooks nil t))
|
||||
|
||||
(defun bs--restore-window-config ()
|
||||
"Restore window configuration on the current frame."
|
||||
(when bs--window-config-coming-from
|
||||
(let ((frame (selected-frame)))
|
||||
(unwind-protect
|
||||
(set-window-configuration bs--window-config-coming-from)
|
||||
(select-frame frame)))
|
||||
(setq bs--window-config-coming-from nil)))
|
||||
|
||||
(defun bs-kill ()
|
||||
"Let buffer disappear and reset window configuration."
|
||||
(interactive)
|
||||
(bury-buffer (current-buffer))
|
||||
(bs--restore-window-config))
|
||||
(quit-window))
|
||||
|
||||
(defun bs-abort ()
|
||||
"Ding and leave Buffer Selection Menu without a selection."
|
||||
|
|
@ -742,7 +746,7 @@ Leave Buffer Selection Menu."
|
|||
(interactive)
|
||||
(let ((buffer (bs--current-buffer)))
|
||||
(bury-buffer (current-buffer))
|
||||
(bs--restore-window-config)
|
||||
(quit-window)
|
||||
(switch-to-buffer buffer)
|
||||
(when bs--marked-buffers
|
||||
;; Some marked buffers for selection
|
||||
|
|
@ -765,7 +769,7 @@ Leave Buffer Selection Menu."
|
|||
(interactive)
|
||||
(let ((buffer (bs--current-buffer)))
|
||||
(bury-buffer (current-buffer))
|
||||
(bs--restore-window-config)
|
||||
(quit-window)
|
||||
(switch-to-buffer-other-window buffer)))
|
||||
|
||||
(defun bs-tmp-select-other-window ()
|
||||
|
|
@ -781,7 +785,7 @@ Leave Buffer Selection Menu."
|
|||
(interactive)
|
||||
(let ((buffer (bs--current-buffer)))
|
||||
(bury-buffer (current-buffer))
|
||||
(bs--restore-window-config)
|
||||
(quit-window)
|
||||
(switch-to-buffer-other-frame buffer)))
|
||||
|
||||
(defun bs-mouse-select-other-frame (event)
|
||||
|
|
@ -1438,21 +1442,11 @@ for buffer selection."
|
|||
;; Only when not in buffer *buffer-selection*
|
||||
;; we have to set the buffer we started the command
|
||||
(setq bs--buffer-coming-from (current-buffer)))
|
||||
(let ((liste (bs-buffer-list))
|
||||
(active-window (get-window-with-predicate
|
||||
(lambda (w)
|
||||
(string= (buffer-name (window-buffer w))
|
||||
"*buffer-selection*"))
|
||||
nil (selected-frame))))
|
||||
(if active-window
|
||||
(select-window active-window)
|
||||
(bs--restore-window-config)
|
||||
(setq bs--window-config-coming-from (current-window-configuration))
|
||||
(when (> (window-height) 7)
|
||||
;; Errors would mess with the window configuration (bug#10882).
|
||||
(ignore-errors (select-window (split-window-below)))))
|
||||
(bs-show-in-buffer liste)
|
||||
(bs-message-without-log "%s" (bs--current-config-message)))))
|
||||
(let ((window-combination-limit 'window-size))
|
||||
(pop-to-buffer (get-buffer-create "*buffer-selection*")
|
||||
bs-default-action-list))
|
||||
(bs-show-in-buffer (bs-buffer-list))
|
||||
(bs-message-without-log "%s" (bs--current-config-message))))
|
||||
|
||||
(defun bs--configuration-name-for-prefix-arg (prefix)
|
||||
"Convert prefix argument PREFIX to a name of a buffer configuration.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue