GNU bug report logs - #25665
26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command

Previous Next

Package: emacs;

Reported by: Chunyang Xu <mail <at> xuchunyang.me>

Date: Thu, 9 Feb 2017 15:12:01 UTC

Severity: wishlist

Tags: patch, wontfix

Found in version 26.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Chunyang Xu <mail <at> xuchunyang.me>
To: 25665 <at> debbugs.gnu.org
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
[Message part 1 (text/plain, inline)]
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.

[0001-Indicate-prefix-arg-in-minibuffer-prompt-for-shell-c.patch (text/plain, inline)]
From e395aa9e601bb8071b53704b7aa27b8b28ac22b1 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail <at> xuchunyang.me>
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


This bug report was last modified 5 years and 329 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.