From b9d2ac94f213f276c17dc1ca5bb51906273f2f3d Mon Sep 17 00:00:00 2001 From: Joseph Corneli Date: Sun, 23 Nov 2025 16:01:36 +0000 Subject: [PATCH 1/2] add chatgpt-shell-before-command-functions --- chatgpt-shell.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/chatgpt-shell.el b/chatgpt-shell.el index 6612f7c..dfc1f43 100644 --- a/chatgpt-shell.el +++ b/chatgpt-shell.el @@ -165,6 +165,21 @@ Note: in all cases responses are written to the shell to keep context." (const :tag "Shell" shell)) :group 'chatgpt) +(defcustom chatgpt-shell-before-command-functions nil + "Abnormal hook (i.e. with parameters) invoked before each command. + +This is useful if you'd like to automatically handle or suggest things +post execution. + +For example: + +\(add-hook `chatgpt-shell-before-command-functions' + (lambda (command output success) + (message \"Command: %s\" command) + (message \"Output: %s\" output)))" + :type 'hook + :group 'shell-maker) + (defcustom chatgpt-shell-after-command-functions nil "Abnormal hook (i.e. with parameters) invoked after each command. @@ -780,6 +795,7 @@ See `shell-maker-welcome-message' as an example." (unless (and (boundp 'shell-maker-version) (version<= "0.79.1" shell-maker-version)) (error "Please update 'shell-maker' to v0.79.1 or newer")) + (run-hook-with-args 'chatgpt-shell-before-command-functions command) (funcall handler :model model :command (if chatgpt-shell-include-local-file-link-content From a9aa8179746d63bdd4ceb0382dc28d50e76b085d Mon Sep 17 00:00:00 2001 From: Joseph Corneli Date: Sun, 23 Nov 2025 16:05:21 +0000 Subject: [PATCH 2/2] adjust docs to match reality --- chatgpt-shell.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/chatgpt-shell.el b/chatgpt-shell.el index dfc1f43..9847529 100644 --- a/chatgpt-shell.el +++ b/chatgpt-shell.el @@ -169,14 +169,13 @@ Note: in all cases responses are written to the shell to keep context." "Abnormal hook (i.e. with parameters) invoked before each command. This is useful if you'd like to automatically handle or suggest things -post execution. +prior to execution. For example: \(add-hook `chatgpt-shell-before-command-functions' - (lambda (command output success) - (message \"Command: %s\" command) - (message \"Output: %s\" output)))" + (lambda (command) + (message \"Command: %s\" command)))" :type 'hook :group 'shell-maker)