diff options
Diffstat (limited to 'emacs/.config')
-rw-r--r-- | emacs/.config/emacs-kj/init.el | 6 | ||||
-rw-r--r-- | emacs/.config/emacs-kj/lisp/kj-bindings.el | 1 | ||||
-rw-r--r-- | emacs/.config/emacs-kj/lisp/kj-defaults.el | 14 | ||||
-rw-r--r-- | emacs/.config/emacs-kj/lisp/kj-eshell.el | 37 |
4 files changed, 51 insertions, 7 deletions
diff --git a/emacs/.config/emacs-kj/init.el b/emacs/.config/emacs-kj/init.el index 7cb8547..37741a8 100644 --- a/emacs/.config/emacs-kj/init.el +++ b/emacs/.config/emacs-kj/init.el @@ -683,12 +683,6 @@ ;; (unbind-key "M-r" paredit-mode-map) ;; (unbind-key "M-s" paredit-mode-map)))) -(defun kj/kill-word-or-region (arg) - (interactive "p") - (if (region-active-p) - (kill-region (region-beginning) (region-end)) - (backward-kill-word (or arg 1)))) - (define-key isearch-mode-map (kbd "C-RET") #'isearch-exit-other-end) ;; Why does C-RET not always work? diff --git a/emacs/.config/emacs-kj/lisp/kj-bindings.el b/emacs/.config/emacs-kj/lisp/kj-bindings.el index d421943..a9979cc 100644 --- a/emacs/.config/emacs-kj/lisp/kj-bindings.el +++ b/emacs/.config/emacs-kj/lisp/kj-bindings.el @@ -5,6 +5,7 @@ (("C-w" . kj/kill-word-or-region) ("C-c s" . kj/shell-here) ("C-c t" . eshell) + ("C-c ." . kj/eshell-here) ("C-c c" . org-capture) ("M-o" . other-window) ("C-c a m" . notmuch) diff --git a/emacs/.config/emacs-kj/lisp/kj-defaults.el b/emacs/.config/emacs-kj/lisp/kj-defaults.el index f4fd4ce..a5ced96 100644 --- a/emacs/.config/emacs-kj/lisp/kj-defaults.el +++ b/emacs/.config/emacs-kj/lisp/kj-defaults.el @@ -32,4 +32,18 @@ (setq kill-whole-line t) +(defun kj/kill-word-or-region (arg) + (interactive "p") + (if (region-active-p) + (kill-region (region-beginning) (region-end)) + (backward-kill-word (or arg 1)))) +(global-set-key (kbd "C-w") 'kj/kill-word-or-region) + +(defun kj/open-line (n) + (interactive "*p") + (beginning-of-line) + (open-line n) + (indent-according-to-mode)) +(global-set-key (kbd "C-o") 'kj/open-line) + (provide 'kj-defaults) diff --git a/emacs/.config/emacs-kj/lisp/kj-eshell.el b/emacs/.config/emacs-kj/lisp/kj-eshell.el index aa8a4d8..d52299c 100644 --- a/emacs/.config/emacs-kj/lisp/kj-eshell.el +++ b/emacs/.config/emacs-kj/lisp/kj-eshell.el @@ -19,7 +19,9 @@ (defun kj/eshell-on-load () (dolist (command '("htop" "tmux" "vim" "nvim")) (add-to-list 'eshell-visual-commands - command))) + command)) + + (define-key eshell-mode-map (kbd "C-d") 'eshell-life-is-too-much)) (add-to-list 'eshell-complex-commands "ssh") @@ -44,4 +46,37 @@ (eshell-parse-command "*ssh" (eshell-stringify-list (flatten-tree args)))))) +(defvar kj/eshell-here-directory) + +(defun kj/eshell-buffer-name () + (let ((base (concat "*eshell:" default-directory))) + (cond + ((not (get-buffer base)) base) + (t (cl-loop for n from 2 + for name = (format "%s<%d>" base n) + until (not (get-buffer name)) + finally return name))))) + +(defun kj/eshell-update-buffer-name () + (interactive) + (rename-buffer (kj/eshell-buffer-name))) +(add-hook 'eshell-directory-change-hook 'kj/eshell-update-buffer-name) + +(defun kj/new-eshell-here () + (let ((default-directory kj/eshell-here-directory)) + (eshell t))) + +(defun kj/eshell-here () + (interactive) + (unless (eq last-command 'kj/eshell-here) + (setq kj/eshell-here-directory + (if (derived-mode-p 'eshell-mode) + (with-current-buffer (other-buffer (current-buffer) t) + default-directory) + default-directory))) + (if (derived-mode-p 'eshell-mode) + (kj/new-eshell-here) + (eshell)) + (kj/eshell-update-buffer-name)) + (provide 'kj-eshell) |