From: Felician Nemeth <felician.nemeth@gmail.com>
To: 47215@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#47215: 28.0.50; Let M-x switch between M-x and M-X
Date: Sun, 04 Apr 2021 19:51:17 +0200 [thread overview]
Message-ID: <87k0pi546i.fsf@betli.tmit.bme.hu> (raw)
In-Reply-To: <87tup9t5f6.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 18 Mar 2021 06:08:29 +0100")
>> I wish there was a convenient way to switch back and forth between
>> execute-extended-command and execute-extended-command-for-buffer. I
>> think M-x would be an ideal binding for this as it is easy to press and
>> more useful than the current "Command attempted to use minibuffer while
>> in minibuffer".
>>
>> I'd imagine this feature being somewhat analogous to how ido-find-file
>> falls back to find-file after C-f.
>
> Yes, being able to move from `execute-extended-command-for-buffer' to
> `execute-extended-command' makes sense, but I'm not sure the other
> direction is as useful. And while there's only two of these commands
> today, I think it's likely that (in the future) that we'll grow more of
> these.
I think cycling makes even more sense when there are more than two of
these execute-extended-commands. Currently, going from
`execute-extended-command' to `execute-extended-command-for-buffer'
would be useful for me because I can type M-x M-x more easily than type
M-X.
> I'm not quite sure how to implement this, though -- we basically end up
> in `completing-read', and `execute-extended-command-for-buffer' would
> have to define an `M-x' binding there, I guess... and then somehow call
> `read-extended-command' with the text already in the minibuffer.
>
> Anybody got an idea as to how to implement this without rewriting
> `read-extended-command' completely?
The execute-extended-commands have two undocumented optional arguments
(command-name and typed). What are they used for?
Anyway, following the fallback logic of `ido-find-file', I was able to
rebind `M-x' and save the content of the minibuffer with a non-standard
exit from `execute-extended-command'. Maybe the ugly code below can
give ideas to someone more knowledgeable.
(defun my-exit ()
(interactive)
(throw 'cycle (cons 'cycle (minibuffer-contents))))
(let ((minibuffer-local-completion-map minibuffer-local-completion-map)
ret)
(define-key minibuffer-local-completion-map (kbd "M-x") 'my-exit)
(setq ret (catch 'cycle
(execute-extended-command nil)))
(if (eq 'cycle (car ret))
(message "Should switch to M-X with %s" (cdr ret))
ret))
Thanks.
next prev parent reply other threads:[~2021-04-04 17:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-17 17:56 bug#47215: 28.0.50; Let M-x switch between M-x and M-X Felician Nemeth
2021-03-18 5:08 ` Lars Ingebrigtsen
2021-04-04 17:51 ` Felician Nemeth [this message]
2021-04-04 19:52 ` Lars Ingebrigtsen
2021-04-10 17:56 ` Felician Nemeth
2021-04-11 17:36 ` Lars Ingebrigtsen
2021-04-11 18:29 ` bug#47215: [External] : " Drew Adams
2022-06-24 18:18 ` Lars Ingebrigtsen
2022-06-24 18:55 ` Juri Linkov
2022-06-24 19:00 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0pi546i.fsf@betli.tmit.bme.hu \
--to=felician.nemeth@gmail.com \
--cc=47215@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).