about summary refs log tree commit diff
path: root/users
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2023-11-26T18·38+0300
committerclbot <clbot@tvl.fyi>2023-11-26T22·16+0000
commit5730742bdf996f0a780579068b33459a6e3139ef (patch)
treea0501565d8792f50447914b9017dd334f3b646f7 /users
parent79c38dbf2abf8d2a067d1f878b5c353baa1ed9b7 (diff)
feat(tazjin/emacs): i3-style jumping back&forth for tab-bar-mode r/7072
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
Diffstat (limited to 'users')
-rw-r--r--users/tazjin/emacs/config/desktop.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/users/tazjin/emacs/config/desktop.el b/users/tazjin/emacs/config/desktop.el
index 2a1f0a8d4815..2688588d20e5 100644
--- a/users/tazjin/emacs/config/desktop.el
+++ b/users/tazjin/emacs/config/desktop.el
@@ -119,8 +119,22 @@
 
 ;; 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)
-  (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-f") #'tab-next)