Make switching forward and backward work like Vim.
This commit is contained in:
50
eyebrowse.el
50
eyebrowse.el
@ -246,35 +246,41 @@ last window config."
|
|||||||
|
|
||||||
;; --- public functions ------------------------------------------------------
|
;; --- public functions ------------------------------------------------------
|
||||||
|
|
||||||
(defun eyebrowse-next-window-config ()
|
(defun eyebrowse-next-window-config (count)
|
||||||
"Switch to the next available window config.
|
"Switch to the next available window config.
|
||||||
If `eyebrowse-wrap-around-p' is t, this will switch from the last
|
If `eyebrowse-wrap-around-p' is t, this will switch from the last
|
||||||
to the first one."
|
to the first one. When used with a numerical argument, switch to
|
||||||
(interactive)
|
window config COUNT."
|
||||||
|
(interactive "P")
|
||||||
(let* ((match (assq eyebrowse-current-slot eyebrowse-window-configs))
|
(let* ((match (assq eyebrowse-current-slot eyebrowse-window-configs))
|
||||||
(index (-elem-index match eyebrowse-window-configs)))
|
(index (-elem-index match eyebrowse-window-configs)))
|
||||||
(when index
|
(if count
|
||||||
(if (< (1+ index) (length eyebrowse-window-configs))
|
(eyebrowse-switch-to-window-config count)
|
||||||
(eyebrowse-switch-to-window-config
|
(when index
|
||||||
(car (nth (1+ index) eyebrowse-window-configs)))
|
(if (< (1+ index) (length eyebrowse-window-configs))
|
||||||
(when eyebrowse-wrap-around-p
|
(eyebrowse-switch-to-window-config
|
||||||
(eyebrowse-switch-to-window-config
|
(car (nth (1+ index) eyebrowse-window-configs)))
|
||||||
(caar eyebrowse-window-configs)))))))
|
(when eyebrowse-wrap-around-p
|
||||||
|
(eyebrowse-switch-to-window-config
|
||||||
|
(caar eyebrowse-window-configs))))))))
|
||||||
|
|
||||||
(defun eyebrowse-prev-window-config ()
|
(defun eyebrowse-prev-window-config (count)
|
||||||
"Switch to the previous available window config.
|
"Switch to the previous available window config.
|
||||||
If `eyebrowse-wrap-around-p' is t, this will switch from the
|
If `eyebrowse-wrap-around-p' is t, this will switch from the
|
||||||
first to the last one."
|
first to the last one. When used with a numerical argument,
|
||||||
(interactive)
|
switch COUNT window configs backwards and always wrap around."
|
||||||
|
(interactive "P")
|
||||||
(let* ((match (assq eyebrowse-current-slot eyebrowse-window-configs))
|
(let* ((match (assq eyebrowse-current-slot eyebrowse-window-configs))
|
||||||
(index (-elem-index match eyebrowse-window-configs)))
|
(index (-elem-index match eyebrowse-window-configs)))
|
||||||
(when index
|
(if count
|
||||||
(if (> index 0)
|
(eyebrowse-prev-window-config (when (> count 1) (eyebrowse-prev-window-config (1- count))))
|
||||||
(eyebrowse-switch-to-window-config
|
(when index
|
||||||
(car (nth (1- index) eyebrowse-window-configs)))
|
(if (> index 0)
|
||||||
(when eyebrowse-wrap-around-p
|
(eyebrowse-switch-to-window-config
|
||||||
(eyebrowse-switch-to-window-config
|
(car (nth (1- index) eyebrowse-window-configs)))
|
||||||
(caar (last eyebrowse-window-configs))))))))
|
(when eyebrowse-wrap-around-p
|
||||||
|
(eyebrowse-switch-to-window-config
|
||||||
|
(caar (last eyebrowse-window-configs)))))))))
|
||||||
|
|
||||||
(defun eyebrowse-last-window-config ()
|
(defun eyebrowse-last-window-config ()
|
||||||
"Switch to the last window config."
|
"Switch to the last window config."
|
||||||
@ -289,8 +295,8 @@ another appropriate window config."
|
|||||||
(when (> (length eyebrowse-window-configs) 1)
|
(when (> (length eyebrowse-window-configs) 1)
|
||||||
(if (equal (assq eyebrowse-current-slot eyebrowse-window-configs)
|
(if (equal (assq eyebrowse-current-slot eyebrowse-window-configs)
|
||||||
(car (last eyebrowse-window-configs)))
|
(car (last eyebrowse-window-configs)))
|
||||||
(eyebrowse-prev-window-config)
|
(eyebrowse-prev-window-config nil)
|
||||||
(eyebrowse-next-window-config))
|
(eyebrowse-next-window-config nil))
|
||||||
(eyebrowse-delete-window-config eyebrowse-last-slot)))
|
(eyebrowse-delete-window-config eyebrowse-last-slot)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|||||||
Reference in New Issue
Block a user