diff options
author | William Carroll <wpcarro@gmail.com> | 2017-06-06T14·35-0400 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2017-06-06T14·35-0400 |
commit | 981f86bf7d8368b2925ac62bb97742ad9d6b9be0 (patch) | |
tree | 04e32ee2198d2238198268158a3f1eead57cda66 | |
parent | d688393344d254339144623863a8e430c56decf3 (diff) |
Removes unnecessary kbds; enhances config
-rw-r--r-- | configs/.emacs | 10 | ||||
-rw-r--r-- | emacs/wc-helper-functions.lisp | 43 |
2 files changed, 39 insertions, 14 deletions
diff --git a/configs/.emacs b/configs/.emacs index 045a98f27518..d1e055c59ef7 100644 --- a/configs/.emacs +++ b/configs/.emacs @@ -244,8 +244,6 @@ ("C-l" . evil-window-right) ("C-k" . evil-window-up) ("C-j" . evil-window-down) - ("C-c" . term-interrupt-subjob) - :map evil-normal-state-map ("<return>" . nil) @@ -322,18 +320,14 @@ "d" 'dired-jump "D" 'projectile-dired "q" 'kill-this-buffer - "h" 'evil-window-left + "h" 'help "i" 'helm-semantic-or-imenu - "l" 'evil-window-right - "k" 'evil-window-up - "j" 'evil-window-down "b" 'helm-mini "T" 'alchemist-mix-test-at-point "B" 'alchemist-mix-test-this-buffer "L" 'alchemist-mix-rerun-last-test "g" 'magit-status - "z" 'wc/projectile-shell-pop - )) + "z" 'wc/projectile-shell-pop)) ;; Evil Match-it diff --git a/emacs/wc-helper-functions.lisp b/emacs/wc-helper-functions.lisp index 272b80809dd8..7b0704d679ea 100644 --- a/emacs/wc-helper-functions.lisp +++ b/emacs/wc-helper-functions.lisp @@ -1,12 +1,32 @@ (defun wc/projectile-shell-pop () "Opens `ansi-term' at the project root according to Projectile." (interactive) - (let ((default-directory (projectile-project-root))) - (if (get-buffer "*ansi-term*") - (switch-to-buffer "*ansi-term*") - (ansi-term "/bin/zsh")) - (term-send-string (terminal) (format "cd '%s'\n" default-directory)) - (get-buffer-process "*ansi-term*"))) + (let* ((project-name (projectile-project-root)) + (default-directory project-name) + (buffer-name (format "ansi-term <%s>" project-name))) + (if (get-buffer buffer-name) + (switch-to-buffer buffer-name) + (ansi-term "/bin/zsh" buffer-name)))) + + +(defun wc/ansi-term-project-p (input) + (string-match-p "*ansi-term <[^>]+>*" input)) + + +(defun wc/list-project-terminals () + "Returns a list of ansi-term buffers with associated projects." + (interactive) + (let ((buffer-names (mapcar 'buffer-name (buffer-list)))) + (remove-if-not #'wc/ansi-term-project-p buffer-names))) + + +(defun wc/open-terminals () + "Lists active terminal buffers." + (interactive) + (helm :sources (helm-build-in-buffer-source "test1" + :data (wc/list-project-terminals) + :action 'switch-to-buffer) + :buffer "*helm projectile terminals*")) (defun wc/shell-history () @@ -71,6 +91,14 @@ (lookup-key (current-global-map) binding))) +(defun wc/focus-term-at-bottom () + "Moves term to the bottom of the page on insert mode." + (interactive) + (end-of-buffer) + (evil-insert-state) + (term-send-raw-string "\b")) + + (defun wc/bootstrap-ansi-term () "Custom `ansi-term' configuration." (interactive) @@ -81,6 +109,9 @@ (local-set-key (kbd "C-k") 'evil-window-up) (local-set-key (kbd "C-j") 'evil-window-down) (wc/expose-global-binding-in-term (kbd "M-x")) + (evil-define-key 'normal term-raw-map + (kbd "C-c") 'term-interrupt-subjob + (kbd "i") 'wc/focus-term-at-bottom) (define-key term-raw-map (kbd "C-r") 'wc/helm-shell-history) (define-key term-raw-map (kbd "M-:") 'eval-expression) (define-key term-raw-map (kbd "M-j") 'wc/helm-autojump) |