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

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

[elpa] externals/detached 886e037bdc 1/2: Bug fix: Make advice preserve


From: ELPA Syncer
Subject: [elpa] externals/detached 886e037bdc 1/2: Bug fix: Make advice preserve called-interactively
Date: Fri, 27 May 2022 06:57:30 -0400 (EDT)

branch: externals/detached
commit 886e037bdcb8c8352fadeea5d5882afb75df7667
Author: Niklas Eklund <niklas.eklund@posteo.net>
Commit: Niklas Eklund <niklas.eklund@posteo.net>

    Bug fix: Make advice preserve called-interactively
    
    This patch addresses a subtle bug that was present in
    detached-shell-override-history.
    
    The issue was that apply was used to call the original function in the
    advice. This however lead to orig-fun, which is shell, not detect that
    it was called interactively.
    
    The called-interactively-p is used in shell, and the docstring of the
    function says:
    
    "This function is very brittle, it may fail to return the intended result 
when
    the code is debugged, advised, or instrumented in some form."
    
    Which explains why it failed. The issue became noticeable on remote
    hosts where shell would not ask the user for a "Remote shell path "
    since it didn't think it was called interactively.
---
 detached-shell.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/detached-shell.el b/detached-shell.el
index 9fef96ef9a..f00583bd71 100644
--- a/detached-shell.el
+++ b/detached-shell.el
@@ -131,7 +131,10 @@ cluttering the comint-history with dtach commands."
 This function also makes sure that the HISTFILE is disabled for local shells."
   (cl-letf (((getenv "HISTFILE") ""))
     (advice-add 'comint-read-input-ring :around 
#'detached-shell--comint-read-input-ring-advice)
-    (apply orig-fun args)))
+    (apply (if (called-interactively-p 'any)
+               #'funcall-interactively #'funcall)
+           orig-fun
+           args)))
 
 ;;;###autoload
 (defun detached-shell-save-history-on-kill ()



reply via email to

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