aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-17 17:40:02 +1000
committerYuchen Pei <id@ypei.org>2023-06-17 17:40:02 +1000
commit2445425165e761e0f2c1aa78372259a6fe302a22 (patch)
tree66f77f95f83056a0de95e4a4159219a3f3cac964 /emacs/.emacs.d/lisp/my
parent093ffa5fbf7143f4668bb0a3dc9659a5cc836e12 (diff)
Adding a function to switch or create a shell buffer
Diffstat (limited to 'emacs/.emacs.d/lisp/my')
-rw-r--r--emacs/.emacs.d/lisp/my/my-prog.el17
1 files changed, 17 insertions, 0 deletions
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