From 2ec436b2b5c7dc417cef80d9d9208c1379db009e Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sun, 2 Feb 2020 12:14:34 +0000 Subject: Support KBDs for term-switcher package To facilitate transitioning from using `terminator` to using `vterm`, I'm defining some KBDs that I hope will help me habituate my usage of `vterm`. --- emacs/.emacs.d/wpc/keybindings.el | 4 ++ emacs/.emacs.d/wpc/window-manager.el | 94 +----------------------------------- 2 files changed, 6 insertions(+), 92 deletions(-) diff --git a/emacs/.emacs.d/wpc/keybindings.el b/emacs/.emacs.d/wpc/keybindings.el index 755311483dd1..967baf8c5192 100644 --- a/emacs/.emacs.d/wpc/keybindings.el +++ b/emacs/.emacs.d/wpc/keybindings.el @@ -15,6 +15,8 @@ (require 'chrome) (require 'scrot) (require 'ivy-clipmenu) +(require 'term-switcher) +(require 'general) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Configuration @@ -42,5 +44,7 @@ ;; super. Remove this once I fix my Ergodox. (keybinding/exwm "C-S-s-s" #'scrot/select) +(general-define-key (kbd/raw 'x11 "t") #'ts/switch-to-terminal) + (provide 'keybindings) ;;; keybindings.el ends here diff --git a/emacs/.emacs.d/wpc/window-manager.el b/emacs/.emacs.d/wpc/window-manager.el index b6caa8adfd8f..ad9af199ab9c 100644 --- a/emacs/.emacs.d/wpc/window-manager.el +++ b/emacs/.emacs.d/wpc/window-manager.el @@ -26,6 +26,7 @@ (require 'display) (require 'dotfiles) (require 'org-helpers) +(require 'vterm) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Library @@ -205,12 +206,6 @@ (:key "" :fn exwm/ivy-switch) (:key "C-M-\\" :fn ivy-pass) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;; REPLs - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - - (:key ,(kbd/raw 'x11 "r") :fn exwm/ivy-find-or-create-repl) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Workspaces ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -315,12 +310,6 @@ (help-mode)) (buffer/show b))) -;; TODO: I'm having difficulties with the Nix-built terminator. The one at -;; /usr/bin/terminator (i.e. built w/o Nix) works just fine. Using this, -;; however, cheapens my Nix setup. -(defconst exwm/preferred-terminal "terminator" - "My preferred terminal.") - ;; TODO: How do I handle this dependency? (defconst exwm/preferred-browser "google-chrome" "My preferred web browser.") @@ -332,83 +321,6 @@ :buffer-name (string/format "*%s*<%s>" exwm/preferred-browser url) :process-name url)) -;; TODO: Consider storing local state of all processes started with this command -;; for some nice ways to cycle through existing terminals, etc. -(defun exwm/terminal-open (cmd) - "Call CMD using `exwm/preferred-terminal'." - (exwm/open (string/format - "%s --command '%s'" - exwm/preferred-terminal - cmd) - :buffer-name (string/format "*%s*<%s>" exwm/preferred-terminal cmd) - :process-name cmd)) - -;; TODO: Create a KBD that calls the `C-x b' I call often. -;; TODO: Consider auto-generating KBDs for spawning these using the first -;; character in their name. Also assert that none of the generated keybindings -;; will clash with one another. -(defconst exwm/repls - '(("python" . (lambda () (exwm/terminal-open "python3"))) - ("zsh" . (lambda () (exwm/terminal-open "zsh"))) - ("fish" . (lambda () (exwm/terminal-open "fish"))) - ("nix" . (lambda () (exwm/terminal-open "nix repl"))) - ("racket" . racket-repl) - ;; NOTE: `ielm' as-is is a find-or-create operation. - ("elisp" . ielm)) - "Mapping of REPL labels to the commands needed to initialize those REPLs.") - -;; NOTE: Some of these commands split the window already. Some of these -;; commands find-or-create already. -;; -;; Find-or-create: -;; +---+---+ -;; | Y | N | -;; +---+---+ -;; python | | x | -;; zsh | | x | -;; racket | x | | -;; elisp | x | | -;; +---+---+ -;; -;; Split: -;; +---+---+ -;; | Y | N | -;; +---+---+ -;; python | | x | -;; zsh | | x | -;; racket | x | | -;; elisp | | x | -;; +---+---+ - -;; - Split: -;; - racket -(defun exwm/ivy-find-or-create-repl () - "Select a type of REPL using `ivy' and then find-or-create it." - (interactive) - (ivy-helpers/kv "REPLs: " - exwm/repls - (lambda (_ v) - (funcall v)))) - -;; KBDs to quickly open X11 applications. -(general-define-key - ;; TODO: Eventually switch this to a find-or-create operation. In general, I - ;; shouldn't need multiple instances of `python3` REPLs. - ;; TODO: Consider coupling these KBDs with the `exwm/ivy-find-or-create-repl' - ;; functionality defined above. - (kbd/raw 'x11 "n") (lambda () - (interactive) - (exwm/terminal-open "nix repl")) - (kbd/raw 'x11 "p") (lambda () - (interactive) - (exwm/terminal-open "python3")) - (kbd/raw 'x11 "t") (lambda () - (interactive) - (exwm/open exwm/preferred-terminal)) - (kbd/raw 'x11 "c") (lambda () - (interactive) - (exwm/open exwm/preferred-browser))) - ;; TODO: Support searching all "launchable" applications like OSX's Spotlight. ;; TODO: Model this as key-value pairs. (defconst window-manager/applications @@ -596,9 +508,7 @@ Currently using super- as the prefix for switching workspaces." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (progn (exwm/switch "Terminal") - ;; TODO: Why does "gnome-terminal" work but not "terminator"? - ;; (call-process-shell-command "gnome-terminal") - ) + (vterm)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Todos ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -- cgit 1.4.1