* Possible Feature Request: Interactive and mode-names
@ 2021-07-03 2:36 T.V Raman
2021-07-03 4:09 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: T.V Raman @ 2021-07-03 2:36 UTC (permalink / raw)
To: emacs-devel
At present (interactive) doesn't provide the ability to specify that
what is wanted is a mode-name -- one cay declare that what is wanted
is a functionp, commandp or symbolp. Q: should we have such a letter
code? More broadly, does elisp deserve to have a read-mode-name
function?
Lacking either as at present, how does one check if a symbol-name
read from the minibuffer is a defined mode-name?
from
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
--
Thanks,
--Raman(I Search, I Find, I Misplace, I Research)
♉ Id: kg:/m/0285kf1 🦮
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Possible Feature Request: Interactive and mode-names
2021-07-03 2:36 Possible Feature Request: Interactive and mode-names T.V Raman
@ 2021-07-03 4:09 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2021-07-03 4:09 UTC (permalink / raw)
To: T.V Raman; +Cc: emacs-devel
T.V Raman [2021-07-02 19:36:39] wrote:
> At present (interactive) doesn't provide the ability to specify that
> what is wanted is a mode-name -- one cay declare that what is wanted
> is a functionp, commandp or symbolp. Q: should we have such a letter
> code?
No need for a letter, you can just
(interactive (list (my-read-group-name "Foo: ")))
You just need to define `my-read-group-name`. Sadly, there's currently
no official way to reliably get an exhaustive list of major modes and/or
of minor modes.
The best approximation for minor modes (which intends to be exhaustive
and correct) is `minor-mode-list`.
For major modes it's more tricky. You can try looking at the
symbol-property `derived-mode-parent` as an indication that a symbol is
the name of a major mode, that's also the best approximation, but some
major modes won't have it (because they're not defined via
`define-derived-mode`) and also some of those modes don't really want to
be "outed", so the correct list will also depend on what you want to do.
> More broadly, does elisp deserve to have a read-mode-name
> function?
Here's some code I used for a particular case (where the intent was to
write a `customize-mode` command, so I didn't care whether the mode was
major or minor and I only cared about those modes for which I could
find a matching customize group):
(let ((completion-regexp-list '("-mode\\'"))
(group (custom-group-of-mode major-mode)))
(if (and group (not current-prefix-arg))
major-mode
(intern
(completing-read (format-prompt "Mode" (and group major-mode))
obarray
#'custom-group-of-mode
t nil nil (if group (symbol-name major-mode))))))
-- Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-03 4:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-03 2:36 Possible Feature Request: Interactive and mode-names T.V Raman
2021-07-03 4:09 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.