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

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

[nongnu] elpa/bash-completion c99083233f 241/313: Fix shell-type detecti


From: ELPA Syncer
Subject: [nongnu] elpa/bash-completion c99083233f 241/313: Fix shell-type detection logic for remote processes.
Date: Sat, 3 Dec 2022 10:59:34 -0500 (EST)

branch: elpa/bash-completion
commit c99083233fd8e9d39eec3314f6d00450e029af86
Author: Stephane Zermatten <szermatt@gmx.net>
Commit: Stephane Zermatten <szermatt@gmx.net>

    Fix shell-type detection logic for remote processes.
    
    (bash-completion--current-shell) reproduces the logic used by
    shell-mode when figuring out what type of shell it's starting to
    tell bash from other shells.
---
 bash-completion.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/bash-completion.el b/bash-completion.el
index 02f591bbce..0f862949a8 100644
--- a/bash-completion.el
+++ b/bash-completion.el
@@ -153,6 +153,7 @@
 
 (require 'comint)
 (require 'cl-lib)
+(require 'shell)
 
 ;;; ---------- Customization
 (defgroup bash-completion nil
@@ -1172,6 +1173,19 @@ is set to t."
                   (bash-completion-kill process)
                 (error nil)))))))))
 
+(defun bash-completion--current-shell ()
+  "Figure out what the shell associated with the current buffer is."
+  (let ((prog (or
+               (if (derived-mode-p 'shell-mode)
+                   (or explicit-shell-file-name
+                       (getenv "ESHELL")
+                       shell-file-name))
+               (let ((process (get-buffer-process (current-buffer))))
+                 (when process
+                   (car (process-command process)))))))
+    (when prog
+      (file-name-nondirectory prog))))
+
 (defun bash-completion--get-same-process ()
   "Return the BASH process associated with the current buffer.
 
@@ -1181,8 +1195,8 @@ Completion will fallback to creating a separate process
 completion in these cases."
   (when (derived-mode-p 'comint-mode)
     (let* ((process (get-buffer-process (current-buffer)))
-           (command (when process (file-name-nondirectory (car 
(process-command process))))))
-      (when (and command (bash-completion-starts-with command "bash"))
+           (shell (if process (bash-completion--current-shell))))
+      (when (and shell (bash-completion-starts-with shell "bash"))
         (unless (process-get process 'setup-done)
           (bash-completion--setup-bash-common process))
         process))))



reply via email to

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