* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
@ 2017-02-09 15:10 Chunyang Xu
2017-02-09 16:53 ` Tino Calancha
0 siblings, 1 reply; 12+ messages in thread
From: Chunyang Xu @ 2017-02-09 15:10 UTC (permalink / raw)
To: 25665
[-- Attachment #1: Type: text/plain, Size: 331 bytes --]
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.
[-- Attachment #2: 0001-Indicate-prefix-arg-in-minibuffer-prompt-for-shell-c.patch --]
[-- Type: text/plain, Size: 3424 bytes --]
From e395aa9e601bb8071b53704b7aa27b8b28ac22b1 Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail@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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 15:10 Chunyang Xu
@ 2017-02-09 16:53 ` Tino Calancha
2017-02-09 18:08 ` Drew Adams
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Tino Calancha @ 2017-02-09 16:53 UTC (permalink / raw)
To: Chunyang Xu; +Cc: 25665, tino.calancha
Chunyang Xu <mail@xuchunyang.me> writes:
Thanks for the report.
> 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 am not sure about this.
The meaning of the prefix argument must be explained in the docstring.
That and the manual are the source of documentation, not the prompt.
Having a short prompt is also good because there are more space
in the line for the command; a short prompt is also better while tipying
a long command: sometimes you want to change something at the beginning:
< ; `beginning-of-buffer'
Now you need to `C-f' several times to jump out of the prompt. The more
verbose prompt, the more `C-f' you need.
Just my opinion. Let's see what other people think.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 16:53 ` Tino Calancha
@ 2017-02-09 18:08 ` Drew Adams
2017-02-09 20:31 ` Eli Zaretskii
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2017-02-09 18:08 UTC (permalink / raw)
To: Tino Calancha, Chunyang Xu; +Cc: 25665
> I am not sure about this.
> The meaning of the prefix argument must be explained in the docstring.
> That and the manual are the source of documentation, not the prompt.
>
> Having a short prompt is also good because there are more space
> in the line for the command; a short prompt is also better while tipying
> a long command: sometimes you want to change something at the beginning:
> < ; `beginning-of-buffer'
> Now you need to `C-f' several times to jump out of the prompt. The more
> verbose prompt, the more `C-f' you need.
>
> Just my opinion. Let's see what other people think.
+1
The minibuffer should simply echo that the prefix arg has been
used, and just what its numeric value is. It should not try
to explain what the possible values are and what they mean.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 16:53 ` Tino Calancha
2017-02-09 18:08 ` Drew Adams
@ 2017-02-09 20:31 ` Eli Zaretskii
2017-02-10 4:23 ` Chunyang Xu
2017-02-09 22:54 ` npostavs
2019-06-24 23:04 ` Lars Ingebrigtsen
3 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2017-02-09 20:31 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25665, mail
> From: Tino Calancha <tino.calancha@gmail.com>
> Date: Fri, 10 Feb 2017 01:53:56 +0900
> Cc: 25665@debbugs.gnu.org, tino.calancha@gmail.com
>
> I am not sure about this.
> The meaning of the prefix argument must be explained in the docstring.
> That and the manual are the source of documentation, not the prompt.
>
> Having a short prompt is also good because there are more space
> in the line for the command; a short prompt is also better while tipying
> a long command: sometimes you want to change something at the beginning:
> < ; `beginning-of-buffer'
> Now you need to `C-f' several times to jump out of the prompt. The more
> verbose prompt, the more `C-f' you need.
>
> Just my opinion. Let's see what other people think.
I think it goes against Emacs conventions. We have quite a few
commands that insert output into the current buffer when invoked with
an argument.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
[not found] ` <<83r3373y3f.fsf@gnu.org>
@ 2017-02-09 21:00 ` Drew Adams
0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2017-02-09 21:00 UTC (permalink / raw)
To: Eli Zaretskii, Tino Calancha; +Cc: 25665, mail
> > I am not sure about this.
> > The meaning of the prefix argument must be explained in the docstring.
> > That and the manual are the source of documentation, not the prompt.
> >
> > Having a short prompt is also good because there are more space
> > in the line for the command; a short prompt is also better while tipying
> > a long command: sometimes you want to change something at the beginning:
> > < ; `beginning-of-buffer'
> > Now you need to `C-f' several times to jump out of the prompt. The more
> > verbose prompt, the more `C-f' you need.
> >
> > Just my opinion. Let's see what other people think.
>
> I think it goes against Emacs conventions. We have quite a few
> commands that insert output into the current buffer when invoked with
> an argument.
(Sorry, I misunderstood the suggestion. I didn't look at the
patch, and didn't get that this was about changing a _prompt_.)
I don't think the suggestion "goes against Emacs conventions".
Certainly it is the case that we do not do this for most
commands that do something different when invoked with a
prefix arg.
But there is a difference between a command that prompts
and one, such as `eval-last-sexp', that does not. Most
"commands that insert output" when you use a prefix arg
do not prompt, I think.
And I know of no convention that says that a command should
not use a different prompt when a prefix arg is used.
It's a judgment call. For this one I have no opinion.
I don't think, however, that the length of the prompt is
very important here. That's a fairly weak criterion for
deciding whether to change the prompt.
Doing something like what was suggested could be helpful
mainly in a situation where (1) the behavior is very
different if a prefix arg is used and (2) it's not easy
to undo a mistaken use of the command.
If that's not the case here then I don't see a need for it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 16:53 ` Tino Calancha
2017-02-09 18:08 ` Drew Adams
2017-02-09 20:31 ` Eli Zaretskii
@ 2017-02-09 22:54 ` npostavs
2017-02-10 3:05 ` Tino Calancha
2019-06-24 23:04 ` Lars Ingebrigtsen
3 siblings, 1 reply; 12+ messages in thread
From: npostavs @ 2017-02-09 22:54 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25665, Chunyang Xu
On Thu, Feb 9, 2017 at 11:53 AM, Tino Calancha <tino.calancha@gmail.com> wrote:
> The meaning of the prefix argument must be explained in the docstring.
> That and the manual are the source of documentation, not the prompt.
But it's nice if Emacs gives you a different prompt, so that you can be
sure you typed in the command correctly. Just like M-& gives a
different prompt from M-!, even though you could figure out the
different meaning just by reading the docstring of each command.
>
> Having a short prompt is also good because there are more space
> in the line for the command;
Yes, it's better to keep the prompt short if possible. Still, having
the extra feedback might be worth it.
> a short prompt is also better while tipying
> a long command: sometimes you want to change something at the beginning:
> < ; `beginning-of-buffer'
If the command is a single line, you can use C-a instead to avoid the prompt.
> Now you need to `C-f' several times to jump out of the prompt. The more
> verbose prompt, the more `C-f' you need.
M-e leaves the prompt immediately.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 22:54 ` npostavs
@ 2017-02-10 3:05 ` Tino Calancha
2017-02-10 4:16 ` npostavs
0 siblings, 1 reply; 12+ messages in thread
From: Tino Calancha @ 2017-02-10 3:05 UTC (permalink / raw)
To: npostavs; +Cc: 25665, Chunyang Xu, Tino Calancha
On Thu, 9 Feb 2017, npostavs@users.sourceforge.net wrote:
> On Thu, Feb 9, 2017 at 11:53 AM, Tino Calancha <tino.calancha@gmail.com> wrote:
>
>> The meaning of the prefix argument must be explained in the docstring.
>> That and the manual are the source of documentation, not the prompt.
>
> But it's nice if Emacs gives you a different prompt, so that you can be
> sure you typed in the command correctly.
Confirmation for having typed C-u?
Well, sometimes some keys in old keyboards die... ;-)
> Just like M-& gives a
> different prompt from M-!, even though you could figure out the
> different meaning just by reading the docstring of each command.
These are different commands so its Emacs (and whatever editor)
convention to how a different prompt. The OP suggests to use
a different prompt for the same command w/ or w/o prefix.
There are lots of commands in Emacs accepting a raw,
numeric prefix etc. If we change M-! prompt, we might
also want to tune the prompt for all of them. Do we want that?
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-10 3:05 ` Tino Calancha
@ 2017-02-10 4:16 ` npostavs
2017-02-10 7:13 ` Tino Calancha
0 siblings, 1 reply; 12+ messages in thread
From: npostavs @ 2017-02-10 4:16 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25665, Chunyang Xu
Tino Calancha <tino.calancha@gmail.com> writes:
> On Thu, 9 Feb 2017, npostavs@users.sourceforge.net wrote:
>
>> On Thu, Feb 9, 2017 at 11:53 AM, Tino Calancha <tino.calancha@gmail.com> wrote:
>>
>>> The meaning of the prefix argument must be explained in the docstring.
>>> That and the manual are the source of documentation, not the prompt.
>>
>> But it's nice if Emacs gives you a different prompt, so that you can be
>> sure you typed in the command correctly.
> Confirmation for having typed C-u?
> Well, sometimes some keys in old keyboards die... ;-)
We already have that in `echo-keystrokes'.
But I'm thinking also of times when you do C-u M-! and then switch to
another window to copy the command, then maybe when you come back, you
don't remember 100% what you were doing.
>> Just like M-& gives a
>> different prompt from M-!, even though you could figure out the
>> different meaning just by reading the docstring of each command.
> These are different commands so its Emacs (and whatever editor)
> convention to how a different prompt. The OP suggests to use
> a different prompt for the same command w/ or w/o prefix.
M-& and M-! are practically the same command anyway, async-shell-command
is basically just
(defun async-shell-command (command)
(shell-command (concat command "&")))
>
> There are lots of commands in Emacs accepting a raw,
> numeric prefix etc. If we change M-! prompt, we might
> also want to tune the prompt for all of them. Do we want that?
IMO yes, if the difference can be summarized in the prompt concisely
enough.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 20:31 ` Eli Zaretskii
@ 2017-02-10 4:23 ` Chunyang Xu
0 siblings, 0 replies; 12+ messages in thread
From: Chunyang Xu @ 2017-02-10 4:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 25665, Tino Calancha
Eli Zaretskii writes:
>> From: Tino Calancha <tino.calancha@gmail.com>
>> Date: Fri, 10 Feb 2017 01:53:56 +0900
>> Cc: 25665@debbugs.gnu.org, tino.calancha@gmail.com
>>
>> I am not sure about this.
>> The meaning of the prefix argument must be explained in the docstring.
>> That and the manual are the source of documentation, not the prompt.
>>
>> Having a short prompt is also good because there are more space
>> in the line for the command; a short prompt is also better while tipying
>> a long command: sometimes you want to change something at the beginning:
>> < ; `beginning-of-buffer'
>> Now you need to `C-f' several times to jump out of the prompt. The more
>> verbose prompt, the more `C-f' you need.
>>
>> Just my opinion. Let's see what other people think.
>
> I think it goes against Emacs conventions. We have quite a few
> commands that insert output into the current buffer when invoked with
> an argument.
but many of these commands don't have a minibuffer prompt, such as
'C-x C-e', so we don't need to worry about them.
I just notice that 'C-u C-s' ('isearch-forward') is also showing the
meaning of prefix argument in the minibuffer prompt:
C-s I-search:
C-u C-s Regexp I-search:
(of course you can think it is trying to use the same prompt as 'C-M-s')
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-10 4:16 ` npostavs
@ 2017-02-10 7:13 ` Tino Calancha
2017-02-10 16:19 ` Noam Postavsky
0 siblings, 1 reply; 12+ messages in thread
From: Tino Calancha @ 2017-02-10 7:13 UTC (permalink / raw)
To: npostavs; +Cc: 25665, Chunyang Xu, Tino Calancha
On Thu, 9 Feb 2017, npostavs@users.sourceforge.net wrote:
> Tino Calancha <tino.calancha@gmail.com> writes:
>
>> On Thu, 9 Feb 2017, npostavs@users.sourceforge.net wrote:
>>
>>> On Thu, Feb 9, 2017 at 11:53 AM, Tino Calancha <tino.calancha@gmail.com> wrote:
>>>
>>>> The meaning of the prefix argument must be explained in the docstring.
>>>> That and the manual are the source of documentation, not the prompt.
>>>
>>> But it's nice if Emacs gives you a different prompt, so that you can be
>>> sure you typed in the command correctly.
>> Confirmation for having typed C-u?
>> Well, sometimes some keys in old keyboards die... ;-)
>
> We already have that in `echo-keystrokes'.
>
> But I'm thinking also of times when you do C-u M-! and then switch to
> another window to copy the command, then maybe when you come back, you
> don't remember 100% what you were doing.
I see. That's a point. I agree in that edge case would be useful.
>> There are lots of commands in Emacs accepting a raw,
>> numeric prefix etc. If we change M-! prompt, we might
>> also want to tune the prompt for all of them. Do we want that?
>
> IMO yes, if the difference can be summarized in the prompt concisely
> enough.
It might be a pain in the ass to follow such new policy:
emacs -Q:
C-x b foo RET
aeiou
I)
C-x C-s
II)
C-u C-x C-s
III)
C-u C-u C-x C-s
IV)
C-u C-u C-u C-x C-s
All have the same prompt:
File to save in: ~/
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-10 7:13 ` Tino Calancha
@ 2017-02-10 16:19 ` Noam Postavsky
0 siblings, 0 replies; 12+ messages in thread
From: Noam Postavsky @ 2017-02-10 16:19 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25665, Chunyang Xu
On Fri, Feb 10, 2017 at 2:13 AM, Tino Calancha <tino.calancha@gmail.com> wrote:
>>> There are lots of commands in Emacs accepting a raw,
>>> numeric prefix etc. If we change M-! prompt, we might
>>> also want to tune the prompt for all of them. Do we want that?
>>
>>
>> IMO yes, if the difference can be summarized in the prompt concisely
>> enough.
>
> It might be a pain in the ass to follow such new policy:
> emacs -Q:
> C-x b foo RET
> aeiou
> I)
> C-x C-s
> II)
> C-u C-x C-s
> III)
> C-u C-u C-x C-s
> IV)
> C-u C-u C-u C-x C-s
>
> All have the same prompt:
> File to save in: ~/
I think this would fall under the case of too difficult to summarize
into a prompt concisely. Furthermore, C-x C-s does not usually prompt
at all so there is not much benefit anyway. But I would not object if
someone could come up with reasonably short and informative
modifications to the prompts.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command
2017-02-09 16:53 ` Tino Calancha
` (2 preceding siblings ...)
2017-02-09 22:54 ` npostavs
@ 2019-06-24 23:04 ` Lars Ingebrigtsen
3 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2019-06-24 23:04 UTC (permalink / raw)
To: Tino Calancha; +Cc: 25665, Chunyang Xu
Tino Calancha <tino.calancha@gmail.com> writes:
>> 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 am not sure about this.
> The meaning of the prefix argument must be explained in the docstring.
> That and the manual are the source of documentation, not the prompt.
There didn't seem to be much enthusiasm for the proposed change, so I'm
closing this bug report.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2019-06-24 23:04 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <<m2wpczwgay.fsf@xuchunyang.me>
[not found] ` <<8760kjz4nv.fsf@calancha-pc>
[not found] ` <<83r3373y3f.fsf@gnu.org>
2017-02-09 21:00 ` bug#25665: 26.0.50; [PATCH] Indicate prefix arg in minibuffer prompt for shell-command Drew Adams
2017-02-09 15:10 Chunyang Xu
2017-02-09 16:53 ` Tino Calancha
2017-02-09 18:08 ` Drew Adams
2017-02-09 20:31 ` Eli Zaretskii
2017-02-10 4:23 ` Chunyang Xu
2017-02-09 22:54 ` npostavs
2017-02-10 3:05 ` Tino Calancha
2017-02-10 4:16 ` npostavs
2017-02-10 7:13 ` Tino Calancha
2017-02-10 16:19 ` Noam Postavsky
2019-06-24 23:04 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).