emacs-diffs
[Top][All Lists]
Advanced

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

master a2e56a8d65: Send region to the subshell specified by the current


From: Lars Ingebrigtsen
Subject: master a2e56a8d65: Send region to the subshell specified by the current file interpreter
Date: Wed, 6 Jul 2022 07:46:28 -0400 (EDT)

branch: master
commit a2e56a8d659d31466c248a38a954a1b165087781
Author: Davide Masserut <dm@mssdvd.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Send region to the subshell specified by the current file interpreter
    
    * sh-script.el (sh-execute-region): Send region to the subshell
    specified by the current file interpreter (bug#56406).
---
 lisp/progmodes/sh-script.el | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el
index 75758fd39a..c3e93c397a 100644
--- a/lisp/progmodes/sh-script.el
+++ b/lisp/progmodes/sh-script.el
@@ -2410,6 +2410,8 @@ Lines containing only comments are considered empty."
 The working directory is that of the buffer, and only environment variables
 are already set which is why you can mark a header within the script.
 
+The executed subshell is `sh-shell-file'.
+
 With a positive prefix ARG, instead of sending region, define header from
 beginning of buffer to point.  With a negative prefix ARG, instead of sending
 region, clear header."
@@ -2417,17 +2419,18 @@ region, clear header."
   (if flag
       (setq sh-header-marker (if (> (prefix-numeric-value flag) 0)
                                 (point-marker)))
-    (if sh-header-marker
-       (save-excursion
-         (let (buffer-undo-list)
-           (goto-char sh-header-marker)
-           (append-to-buffer (current-buffer) start end)
-           (shell-command-on-region (point-min)
-                                    (setq end (+ sh-header-marker
-                                                 (- end start)))
-                                    sh-shell-file)
-           (delete-region sh-header-marker end)))
-      (shell-command-on-region start end (concat sh-shell-file " -")))))
+    (let ((shell-file-name sh-shell-file))
+      (if sh-header-marker
+         (save-excursion
+           (let (buffer-undo-list)
+             (goto-char sh-header-marker)
+             (append-to-buffer (current-buffer) start end)
+             (shell-command-on-region (point-min)
+                                      (setq end (+ sh-header-marker
+                                                   (- end start)))
+                                      sh-shell-file)
+             (delete-region sh-header-marker end)))
+        (shell-command-on-region start end (concat sh-shell-file " -"))))))
 
 
 (defun sh-remember-variable (var)



reply via email to

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