[layout] consittent buffer list (#15520)
* [spacemacs-defaults] make split double windows consistent * [layout] new macro spacemacs||with-persp-buffer-list to use instead of `with-persp-buffer-list`. The new repsects the order of original buffer-list * [default] improve split-triple|grid windows functions buffer-list will return the list int the the most recent accessed order. Of which the first one is always the current buffer. So we don't need to do extra work in removing it.
This commit is contained in:
parent
7834b2b7e1
commit
35bfa8601a
|
@ -993,14 +993,13 @@ as a means to remove windows, regardless of the value in
|
|||
(delete-other-windows))
|
||||
(funcall spacemacs-window-split-delete-function))
|
||||
(if (spacemacs--window-split-splittable-windows)
|
||||
(let* ((previous-files (seq-filter #'buffer-file-name
|
||||
(delq (current-buffer) (buffer-list))))
|
||||
(let* ((previous-files (buffer-list))
|
||||
(second (split-window-below))
|
||||
(third (split-window-right))
|
||||
(fourth (split-window second nil 'right)))
|
||||
(set-window-buffer third (or (car previous-files) "*scratch*"))
|
||||
(set-window-buffer second (or (cadr previous-files) "*scratch*"))
|
||||
(set-window-buffer fourth (or (caddr previous-files) "*scratch*"))
|
||||
(set-window-buffer third (or (nth 1 previous-files) "*scratch*"))
|
||||
(set-window-buffer second (or (nth 2 previous-files) "*scratch*"))
|
||||
(set-window-buffer fourth (or (nth 3 previous-files) "*scratch*"))
|
||||
(balance-windows))
|
||||
(message "There are no main windows available to split!")))
|
||||
|
||||
|
@ -1019,12 +1018,11 @@ as a means to remove windows, regardless of the value in
|
|||
(delete-other-windows))
|
||||
(funcall spacemacs-window-split-delete-function))
|
||||
(if (spacemacs--window-split-splittable-windows)
|
||||
(let* ((previous-files (seq-filter #'buffer-file-name
|
||||
(delq (current-buffer) (buffer-list))))
|
||||
(let* ((previous-files (buffer-list))
|
||||
(second (split-window-right))
|
||||
(third (split-window second nil 'right)))
|
||||
(set-window-buffer second (or (car previous-files) "*scratch*"))
|
||||
(set-window-buffer third (or (cadr previous-files) "*scratch*"))
|
||||
(set-window-buffer second (or (nth 1 previous-files) "*scratch*"))
|
||||
(set-window-buffer third (or (nth 2 previous-files) "*scratch*"))
|
||||
(balance-windows))
|
||||
(message "There are no main windows available to split!")))
|
||||
|
||||
|
@ -1034,6 +1032,9 @@ as a means to remove windows, regardless of the value in
|
|||
Uses the funcion defined in `spacemacs-window-split-delete-function'
|
||||
as a means to remove windows.
|
||||
|
||||
Left side window is the current buffer. Right side one is the
|
||||
most recently selected buffer other than current buffer.
|
||||
|
||||
When called with a prefix argument, it uses `delete-other-windows'
|
||||
as a means to remove windows, regardless of the value in
|
||||
`spacemacs-window-split-delete-function'."
|
||||
|
@ -1043,10 +1044,8 @@ as a means to remove windows, regardless of the value in
|
|||
(delete-other-windows))
|
||||
(funcall spacemacs-window-split-delete-function))
|
||||
(if (spacemacs--window-split-splittable-windows)
|
||||
(let* ((previous-files (seq-filter #'buffer-file-name
|
||||
(delq (current-buffer) (buffer-list)))))
|
||||
(set-window-buffer (split-window-right)
|
||||
(or (car previous-files) "*scratch*"))
|
||||
(let* ((right-side-buffer (other-buffer (current-buffer) t)))
|
||||
(set-window-buffer (split-window-right) right-side-buffer)
|
||||
(balance-windows))
|
||||
(message "There are no main windows available to split!")))
|
||||
|
||||
|
|
|
@ -111,9 +111,21 @@ Cancels autosave on exiting perspectives mode."
|
|||
(let ((ivy-ignore-buffers (remove #'spacemacs//layout-not-contains-buffer-p ivy-ignore-buffers)))
|
||||
(ivy-switch-buffer)))
|
||||
|
||||
(defmacro spacemacs||with-persp-buffer-list (&rest body)
|
||||
"This one is a brute force version of `with-persp-buffer-list'.
|
||||
It maitains the order of the original `buffer-list'"
|
||||
`(cl-letf* ((org-buffer-list
|
||||
(symbol-function 'buffer-list))
|
||||
((symbol-function 'buffer-list)
|
||||
#'(lambda (&optional frame)
|
||||
(seq-filter
|
||||
#'persp-contain-buffer-p
|
||||
(funcall org-buffer-list frame)))))
|
||||
,@body))
|
||||
|
||||
(defun spacemacs-layouts//advice-with-persp-buffer-list (orig-fun &rest args)
|
||||
"Advice to provide persp buffer list."
|
||||
(with-persp-buffer-list () (apply orig-fun args)))
|
||||
(spacemacs||with-persp-buffer-list () (apply orig-fun args)))
|
||||
|
||||
|
||||
;; Persp transient-state
|
||||
|
|
Loading…
Reference in a new issue