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

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

[nongnu] elpa/eat b4d07cb474 2/9: Add shell commands run in Eat to Emacs


From: ELPA Syncer
Subject: [nongnu] elpa/eat b4d07cb474 2/9: Add shell commands run in Eat to Emacs history
Date: Tue, 6 Dec 2022 13:58:45 -0500 (EST)

branch: elpa/eat
commit b4d07cb4740d8e3cf36e523d7d8fae70361a144e
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>

    Add shell commands run in Eat to Emacs history
    
    * eat.el (eat-enable-shell-command-history): New user option.
    * eat.el (eat--set-cmd): New function.
    * eat.el (eat-exec, eat--eshell-setup-proc-and-term): Call
    'eat--set-cmd' when the shell reports the command being run.
---
 eat.el | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/eat.el b/eat.el
index 249ee93e1d..2c2908b80a 100644
--- a/eat.el
+++ b/eat.el
@@ -151,6 +151,16 @@ to setup your shell."
   :group 'eat-ui
   :group 'eat-eshell)
 
+(defcustom eat-enable-shell-command-history t
+  "Non-nil means add shell commands to Emacs history.
+
+When non-nil, any command you run in your shell will also appear in
+the history of commands like `eat', `shell-command' and
+`async-shell-command'."
+  :type 'boolean
+  :group 'eat-ui
+  :group 'eat-eshell)
+
 (defconst eat--cursor-type-value-type
   (let ((cur-type
          '(choice
@@ -4159,6 +4169,12 @@ If HOST isn't the host Emacs is running on, don't do 
anything."
              (string= host (system-name)))
     (ignore-errors
       (cd-absolute cwd))))
+
+(defun eat--set-cmd (_ cmd)
+  "Add CMD to `shell-command-history'."
+  (when eat-enable-shell-command-history
+    (add-to-history 'shell-command-history cmd)))
+
 
 ;;;;; Input.
 
@@ -4799,7 +4815,8 @@ same Eat buffer.  The hook `eat-exec-hook' is run after 
each exec."
             (eat-term-manipulate-selection-function eat--terminal)
             #'eat--manipulate-kill-ring
             (eat-term-ring-bell-function eat--terminal) #'eat--bell
-            (eat-term-set-cwd-function eat--terminal) #'eat--set-cwd)
+            (eat-term-set-cwd-function eat--terminal) #'eat--set-cwd
+            (eat-term-set-cmd-function eat--terminal) #'eat--set-cmd)
       ;; Crank up a new process.
       (let* ((size (eat-term-size eat--terminal))
              (process-environment
@@ -5064,7 +5081,8 @@ PROGRAM can be a shell command."
           (eat-term-manipulate-selection-function eat--terminal)
           #'eat--manipulate-kill-ring
           (eat-term-ring-bell-function eat--terminal) #'eat--bell
-          (eat-term-set-cwd-function eat--terminal) #'eat--set-cwd)
+          (eat-term-set-cwd-function eat--terminal) #'eat--set-cwd
+          (eat-term-set-cmd-function eat--terminal) #'eat--set-cmd)
     (when-let* ((window (get-buffer-window nil t)))
       (with-selected-window window
         (eat-term-resize eat--terminal (window-max-chars-per-line)



reply via email to

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