about summary refs log tree commit diff
path: root/users/tazjin/emacs/config
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-02-23T14·53+0300
committerclbot <clbot@tvl.fyi>2022-02-23T14·58+0000
commitaacd03db7e9694d70f670453de3f4ee5e694d8cb (patch)
tree23f8f82b1151458fb355598775df7616d2c78fd4 /users/tazjin/emacs/config
parentbfbc5948f3da5d8617d41a46f5515ee0e461f12d (diff)
feat(tazjin/emacs): Add #'exwm-jump-to-buffer r/3865
This allows me to jump to a workspace that is already displayed on
some buffer.

This also interfaces correctly with my back-and-forth jump
functionality, setting the variables to allow quick jumping back to
the previous buffer via the numerical index of the destination or - of
course - via s-b.

Change-Id: I25db7535089bcb17b3d61d53030b9154cfeac023
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5323
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'users/tazjin/emacs/config')
-rw-r--r--users/tazjin/emacs/config/desktop.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/users/tazjin/emacs/config/desktop.el b/users/tazjin/emacs/config/desktop.el
index 094880a00870..2b50c4203933 100644
--- a/users/tazjin/emacs/config/desktop.el
+++ b/users/tazjin/emacs/config/desktop.el
@@ -219,6 +219,21 @@ in-progress."
 
 (exwm-input-set-key (kbd "s-f") #'switch-to-next-workspace)
 
+;; Provide a binding for jumping to a buffer on a workspace.
+(defun exwm-jump-to-buffer ()
+  "Jump to a workspace on which the target buffer is displayed."
+  (interactive)
+  (let ((exwm-layout-show-all-buffers nil)
+        (initial exwm-workspace-current-index))
+    (call-interactively #'exwm-workspace-switch-to-buffer)
+    ;; After jumping, update the back-and-forth list like on a direct
+    ;; index jump.
+    (when (not (eq initial exwm-workspace-current-index))
+      (setq *exwm-workspace-from-to*
+            (cons initial exwm-workspace-current-index)))))
+
+(exwm-input-set-key (kbd "C-c j") #'exwm-jump-to-buffer)
+
 ;; Launch applications / any command with completion (dmenu style!)
 (exwm-input-set-key (kbd "s-d") #'counsel-linux-app)
 (exwm-input-set-key (kbd "s-x") #'run-external-command)