diff options
-rw-r--r-- | emacs/.emacs.d/init/ycp-prog.el | 1 | ||||
-rw-r--r-- | emacs/.emacs.d/lisp/my/my-prog.el | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/emacs/.emacs.d/init/ycp-prog.el b/emacs/.emacs.d/init/ycp-prog.el index 9ab868b..4e2daf5 100644 --- a/emacs/.emacs.d/init/ycp-prog.el +++ b/emacs/.emacs.d/init/ycp-prog.el @@ -82,6 +82,7 @@ '(shell-mode . my-shell-with-directory)) (my-keybind shell-mode-map "<f2>" #'my-restart-shell) (add-hook 'shell-mode-hook 'my-shell-disable-company-if-remote) + (my-keybind global-map "<f10>" #'my-switch-or-create-shell-buffer) ) (my-package eshell diff --git a/emacs/.emacs.d/lisp/my/my-prog.el b/emacs/.emacs.d/lisp/my/my-prog.el index 6b7c705..210d7ef 100644 --- a/emacs/.emacs.d/lisp/my/my-prog.el +++ b/emacs/.emacs.d/lisp/my/my-prog.el @@ -138,5 +138,22 @@ some of the references to the identifiers." (toggle-debug-on-error)) ) +(require 'my-buffer) + +(defun my-switch-or-create-shell-buffer (arg) + "Switch to or create a shell buffer. + +If there's no buffer with shell mode, or with a prefix-arg, +create a shell buffer using `my-shell-with-directory'" + (interactive "P") + (if (or arg + (not (seq-filter + (lambda (buffer) + (with-current-buffer buffer + (derived-mode-p 'shell-mode))) + (buffer-list)))) + (call-interactively 'my-shell-with-directory) + (my-buffer-quick-major-mode 'shell-mode))) + (provide 'my-prog) ;;; my-prog.el ends here |