feat(tazjin/emacs): i3-style jumping back&forth for tab-bar-mode

Change-Id: I19cab91646241edc38a58bf5546c9dd8161abeb0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10130
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2023-11-26 21:38:07 +03:00 committed by clbot
parent 79c38dbf2a
commit 5730742bdf

View file

@ -119,8 +119,22 @@
;; Tab-management shortcuts ;; Tab-management shortcuts
(defun tab-bar-select-or-return ()
"This function behaves like `tab-bar-select-tab', except it calls
`tab-recent' if asked to jump to the current tab. This simulates
the back&forth behaviour of i3."
(interactive)
(let* ((key (event-basic-type last-command-event))
(tab (if (and (characterp key) (>= key ?1) (<= key ?9))
(- key ?0)
0))
(current (1+ (tab-bar--current-tab-index))))
(if (eq tab current)
(tab-recent)
(tab-bar-select-tab tab))))
(dotimes (i 8) (dotimes (i 8)
(exwm-input-set-key (kbd (format "s-%d" (+ 1 i))) #'tab-bar-select-tab)) (exwm-input-set-key (kbd (format "s-%d" (+ 1 i))) #'tab-bar-select-or-return))
(exwm-input-set-key (kbd "s-9") #'tab-last) (exwm-input-set-key (kbd "s-9") #'tab-last)
(exwm-input-set-key (kbd "s-f") #'tab-next) (exwm-input-set-key (kbd "s-f") #'tab-next)