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

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

[elpa] externals/shell-command+ a08896f4f4: Use shell-command+ in shell-


From: ELPA Syncer
Subject: [elpa] externals/shell-command+ a08896f4f4: Use shell-command+ in shell-command+-cmd-sudo
Date: Sat, 1 Jan 2022 09:57:50 -0500 (EST)

branch: externals/shell-command+
commit a08896f4f4d961fcb848857b6fe3f5cec2d3d8e5
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    Use shell-command+ in shell-command+-cmd-sudo
---
 shell-command+.el | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/shell-command+.el b/shell-command+.el
index ea30ea49e0..0f9d7f7e73 100644
--- a/shell-command+.el
+++ b/shell-command+.el
@@ -238,10 +238,13 @@ If EXPAND is non-nil, expand wildcards."
                                      (cadr files)
                                      flags)))))
 
+(defvar shell-command+--command-regexp)
 (defun shell-command+-cmd-sudo (command)
-  "Use TRAMP to execute COMMAND."
+  "Use TRAMP's \"sudo\" method to execute COMMAND."
   (let ((default-directory (concat "/sudo::" default-directory)))
-    (shell-command command)))
+    (unless (string-match shell-command+--command-regexp command)
+      (error "Couldn't parse command"))
+    (shell-command+ (replace-match "" nil nil command 4))))
 
 (defun shell-command+-cmd-cd (command)
   "Convert COMMAND into a `cd' call."
@@ -326,7 +329,7 @@ proper upwards directory pointers.  This means that '....' 
becomes
             (error (match-string-no-properties 3 command))))))
 
 ;;;###autoload
-(defun shell-command+ (command beg end)
+(defun shell-command+ (command &optional beg end)
   "Intelligently execute string COMMAND in inferior shell.
 
 If COMMAND is prefixed with an absolute or relative path, the
@@ -355,9 +358,9 @@ between BEG and END.  Otherwise the whole buffer is 
processed."
                       (if (bound-and-true-p shell-command-prompt-show-cwd)
                           (format shell-command+-prompt
                                   (abbreviate-file-name default-directory))
-                        shell-command+-prompt))
-                     (if (use-region-p) (region-beginning) (point-min))
-                     (if (use-region-p) (region-end) (point-max))))
+                        shell-command+-prompt))))
+  (unless beg (setq beg (if (use-region-p) (region-beginning) (point-min))))
+  (unless end (setq end (if (use-region-p) (region-end) (point-max))))
   (pcase-let* ((`(,path ,mode ,command ,rest) (shell-command+-parse command))
                (default-directory (shell-command+-expand-path (or path "."))))
     ;; Make sure the previous output buffer was killed, to prevent



reply via email to

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