bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for


From: Chunyang Xu
Subject: bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
Date: Thu, 09 Feb 2017 23:10:45 +0800

Hi,

When using 'C-u M-!' ('shell-command') I feel confident if the
minibuffer prompt becomes

  Shell command and insert output:

since it explains the purpose of the prefix argument. The same thing
goes for 'M-&' ('async-shell-command') and 'M-|'
('shell-command-on-region'). I have attached a patch which implements
this idea.

>From e395aa9e601bb8071b53704b7aa27b8b28ac22b1 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <address@hidden>
Date: Thu, 9 Feb 2017 22:47:40 +0800
Subject: [PATCH] Indicate prefix arg in minibuffer prompt for shell-command

* lisp/simple.el (async-shell-command, shell-command)
(shell-command-on-region): Show purpose of prefix argument in
the minibuffer prompt.

Copyright-paperwork-exempt: yes
---
 lisp/simple.el | 42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 441713a18b..9720a8935c 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3311,13 +3311,17 @@ async-shell-command
 shell (with its need to quote arguments)."
   (interactive
    (list
-    (read-shell-command "Async shell command: " nil nil
-                       (let ((filename
-                              (cond
-                               (buffer-file-name)
-                               ((eq major-mode 'dired-mode)
-                                (dired-get-filename nil t)))))
-                         (and filename (file-relative-name filename))))
+    (read-shell-command (format "Async shell command%s: "
+                                (if current-prefix-arg
+                                    " and insert output"
+                                  ""))
+                        nil nil
+                        (let ((filename
+                               (cond
+                                (buffer-file-name)
+                                ((eq major-mode 'dired-mode)
+                                 (dired-get-filename nil t)))))
+                          (and filename (file-relative-name filename))))
     current-prefix-arg
     shell-command-default-error-buffer))
   (unless (string-match "&[ \t]*\\'" command)
@@ -3382,13 +3386,17 @@ shell-command
 
   (interactive
    (list
-    (read-shell-command "Shell command: " nil nil
-                       (let ((filename
-                              (cond
-                               (buffer-file-name)
-                               ((eq major-mode 'dired-mode)
-                                (dired-get-filename nil t)))))
-                         (and filename (file-relative-name filename))))
+    (read-shell-command (format "Shell command%s: "
+                                (if current-prefix-arg
+                                    " and insert output"
+                                  ""))
+                        nil nil
+                        (let ((filename
+                               (cond
+                                (buffer-file-name)
+                                ((eq major-mode 'dired-mode)
+                                 (dired-get-filename nil t)))))
+                          (and filename (file-relative-name filename))))
     current-prefix-arg
     shell-command-default-error-buffer))
   ;; Look for a handler in case default-directory is a remote file name.
@@ -3640,7 +3648,11 @@ shell-command-on-region
                 ;; Do this before calling region-beginning
                 ;; and region-end, in case subprocess output
                 ;; relocates them while we are in the minibuffer.
-                (setq string (read-shell-command "Shell command on region: "))
+                (setq string (read-shell-command
+                               (format "Shell command on region%s: "
+                                       (if current-prefix-arg
+                                           " and replace with output"
+                                         ""))))
                 ;; call-interactively recognizes region-beginning and
                 ;; region-end specially, leaving them in the history.
                 (list (region-beginning) (region-end)
-- 
2.11.0


reply via email to

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