Open jluttine opened 8 years ago
is it possible to change the order of layouts?
Everything is possible if you really want it.)
For now there is no such functionality in the persp-mode.el
.
You can just redefine the persp-names-current-frame-fast-ordered
function to return a list of perspective names in the order you want. For example you can store names in a vector or list, and add functions to persp-created-functions
and persp-before-kill-functions
lists to put/remove names from your ordered vector/list(however there is no hooks for persp-rename, but you can use advices).
Another way is to alter and reorder the persp-minor-mode-menu
because the persp-names-current-frame-fast-ordered
function return names from it.
Hey! Don't know if you still need it, here is an example of how it could be achieved:
(with-eval-after-load "persp-mode"
(defvar persp-names-sorted (when (bound-and-true-p *persp-hash*)
(persp-names))
"Ordered list of perspective names.")
(add-hook 'persp-before-switch-functions
#'(lambda (new-persp-name w-or-f)
(let ((cur-persp-name (safe-persp-name (get-current-persp))))
(when (member cur-persp-name persp-names-sorted)
(setq persp-names-sorted
(cons cur-persp-name
(delete cur-persp-name persp-names-sorted)))))))
(add-hook 'persp-renamed-functions
#'(lambda (persp old-name new-name)
(setq persp-names-sorted
(cons new-name (delete old-name persp-names-sorted)))))
(add-hook 'persp-before-kill-functions
#'(lambda (persp)
(setq persp-names-sorted
(delete (safe-persp-name persp) persp-names-sorted))))
(add-hook 'persp-created-functions
#'(lambda (persp phash)
(when (and (eq phash *persp-hash*)
(not (member (safe-persp-name persp) persp-names-sorted)))
(setq persp-names-sorted
(cons (safe-persp-name persp) persp-names-sorted)))))
(defsubst* persp-names-sorted (&optional (phash *persp-hash*)) (append persp-names-sorted nil))
(defun persp-names-current-frame-fast-ordered () (append persp-names-sorted nil)))
You can sort persp-names-sorted
as you like. In this example it's just puts the previous perspective on the top of list.
Ok, thanks a lot. Would really love to see some re-ordering capability built-in though. For instance, N
to move current perspective one step forward and P
to move current perspective one step backward. Anyway, thanks!
Thanks for persp-mode.el, it's great! I was wondering, is it possible to change the order of layouts? I have four layouts open but I'd like to change their order.