emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/crux b923d61 082/112: Support creating shells and terminal


From: ELPA Syncer
Subject: [nongnu] elpa/crux b923d61 082/112: Support creating shells and terminal buffers
Date: Wed, 11 Aug 2021 09:57:58 -0400 (EDT)

branch: elpa/crux
commit b923d618133d8e6ff82554662f3c94f1e7a13b13
Author: Mathew Robinson <mathew@chasinglogic.io>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>

    Support creating shells and terminal buffers
---
 crux.el | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/crux.el b/crux.el
index 7a74702..3a498dc 100644
--- a/crux.el
+++ b/crux.el
@@ -99,7 +99,8 @@
   :type 'list
   :group 'crux)
 
-(defcustom crux-shell-func
+
+(defcustom crux-term-func
   #'crux-ansi-term
   "The function used to start the term buffer if it's not already running.
 
@@ -108,6 +109,15 @@ expected name of the shell buffer."
   :type 'symbol
   :group 'crux)
 
+(defcustom crux-shell-func
+  #'crux-eshell
+  "The function used to start the term buffer if it's not already running.
+
+It will be called with a two arguments: the shell to start and the
+expected name of the shell buffer."
+  :type 'symbol
+  :group 'crux)
+
 (defun crux-ansi-term (buffer-name)
   "Use ansi-term for `crux-visit-term-buffer'"
   (ansi-term crux-shell buffer-name))
@@ -149,6 +159,10 @@ With a prefix ARG always prompt for command to use."
   "The default buffer name used by `crux-visit-term-buffer'.
 This variable can be set via .dir-locals.el to provide multi-term support.")
 
+(defvar crux-shell-buffer-name "shell"
+  "The default buffer name used by `crux-visit-shell-buffer'.
+This variable can be set via .dir-locals.el to provide multi-term support.")
+
 (defun crux-start-or-switch-to (function buffer-name)
   "Invoke FUNCTION if there is no buffer with BUFFER-NAME.
 Otherwise switch to the buffer named BUFFER-NAME.  Don't clobber
@@ -166,15 +180,28 @@ the current buffer."
 If the process in that buffer died, ask to restart."
   (interactive)
   (crux-start-or-switch-to (lambda ()
-                             (apply crux-shell-func (list 
crux-term-buffer-name)))
+                             (apply crux-term-func (list 
crux-term-buffer-name)))
                            (format "*%s*" crux-term-buffer-name))
   (when (and (null (get-buffer-process (current-buffer)))
-             (not (eq major-mode 'eshell-mode)) ; eshell doesn't have a process
              (y-or-n-p "The process has died.  Do you want to restart it? "))
     (kill-buffer-and-window)
     (crux-visit-term-buffer)))
 
 ;;;###autoload
+(defun crux-visit-shell-buffer ()
+  "Create or visit a shell buffer.
+If the process in that buffer died, ask to restart."
+  (interactive)
+  (crux-start-or-switch-to (lambda ()
+                             (apply crux-shell-func (list 
crux-shell-buffer-name)))
+                           (format "*%s*" crux-shell-buffer-name))
+  (when (and (null (get-buffer-process (current-buffer)))
+             (not (eq major-mode 'eshell)) ; eshell has no process
+             (y-or-n-p "The process has died.  Do you want to restart it? "))
+    (kill-buffer-and-window)
+    (crux-visit-shell-buffer)))
+
+;;;###autoload
 (defun crux-indent-rigidly-and-copy-to-clipboard (begin end arg)
   "Indent region between BEGIN and END by ARG columns and copy to clipboard."
   (interactive "r\nP")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]