* (interactive "rP") valid?
@ 2013-05-28 11:15 Thorsten Jolitz
2013-05-28 11:38 ` Andreas Röhler
0 siblings, 1 reply; 12+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 11:15 UTC (permalink / raw)
To: help-gnu-emacs
Hi List,
function 'org-table-convert-region' uses (interactive "rP") and has the
following signature:
,---------------------------------------------------------
| (org-table-convert-region BEG0 END0 &optional SEPARATOR)
`---------------------------------------------------------
Non-interactively, the function works as expected:
different behaviour conditional on SEPARATOR being nil, an integer, '(4)
or '(16).
However, used interactively, SEPARATOR is always nil when 'C-u <digit>
M-x' is used.
Is (interactive "rP") not a valid combination?
Or is this a bug in Emacs?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (interactive "rP") valid?
2013-05-28 11:15 (interactive "rP") valid? Thorsten Jolitz
@ 2013-05-28 11:38 ` Andreas Röhler
2013-05-28 11:42 ` Thorsten Jolitz
0 siblings, 1 reply; 12+ messages in thread
From: Andreas Röhler @ 2013-05-28 11:38 UTC (permalink / raw)
To: help-gnu-emacs
Am 28.05.2013 13:15, schrieb Thorsten Jolitz:
>
> Hi List,
>
> function 'org-table-convert-region' uses (interactive "rP") and has the
> following signature:
>
> ,---------------------------------------------------------
> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
> `---------------------------------------------------------
>
> Non-interactively, the function works as expected:
> different behaviour conditional on SEPARATOR being nil, an integer, '(4)
> or '(16).
>
> However, used interactively, SEPARATOR is always nil when 'C-u <digit>
> M-x' is used.
>
> Is (interactive "rP") not a valid combination?
> Or is this a bug in Emacs?
>
needs a newline:
(interactive "r\nP")
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (interactive "rP") valid?
2013-05-28 11:38 ` Andreas Röhler
@ 2013-05-28 11:42 ` Thorsten Jolitz
2013-05-28 13:20 ` Drew Adams
[not found] ` <mailman.511.1369747231.22516.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 12+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 11:42 UTC (permalink / raw)
To: help-gnu-emacs
Andreas Röhler <andreas.roehler@easy-emacs.de> writes:
> Am 28.05.2013 13:15, schrieb Thorsten Jolitz:
>>
>> Hi List,
>>
>> function 'org-table-convert-region' uses (interactive "rP") and has the
>> following signature:
>>
>> ,---------------------------------------------------------
>> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
>> `---------------------------------------------------------
>>
>> Non-interactively, the function works as expected:
>> different behaviour conditional on SEPARATOR being nil, an integer, '(4)
>> or '(16).
>>
>> However, used interactively, SEPARATOR is always nil when 'C-u <digit>
>> M-x' is used.
>>
>> Is (interactive "rP") not a valid combination?
>> Or is this a bug in Emacs?
>>
>
> needs a newline:
>
> (interactive "r\nP")
Yes, that made it work. Thanks.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: (interactive "rP") valid?
2013-05-28 11:42 ` Thorsten Jolitz
@ 2013-05-28 13:20 ` Drew Adams
2013-05-28 14:36 ` Thorsten Jolitz
[not found] ` <mailman.511.1369747231.22516.help-gnu-emacs@gnu.org>
1 sibling, 1 reply; 12+ messages in thread
From: Drew Adams @ 2013-05-28 13:20 UTC (permalink / raw)
To: Thorsten Jolitz, help-gnu-emacs
> >> Is (interactive "rP") not a valid combination?
> >> Or is this a bug in Emacs?
> >
> > needs a newline:
> > (interactive "r\nP")
>
> Yes, that made it work. Thanks.
C-h i
Click Elisp
i interactive RET
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (interactive "rP") valid?
2013-05-28 13:20 ` Drew Adams
@ 2013-05-28 14:36 ` Thorsten Jolitz
2013-05-28 15:13 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 14:36 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
>> >> Is (interactive "rP") not a valid combination?
>> >> Or is this a bug in Emacs?
>> >
>> > needs a newline:
>> > (interactive "r\nP")
>>
>> Yes, that made it work. Thanks.
>
> C-h i
> Click Elisp
> i interactive RET
Maybe not _that_ obvious at first sight?
This was a bug in core Org-mode I stumbled upon.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: (interactive "rP") valid?
2013-05-28 14:36 ` Thorsten Jolitz
@ 2013-05-28 15:13 ` Drew Adams
2013-05-28 16:42 ` How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?) Thorsten Jolitz
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2013-05-28 15:13 UTC (permalink / raw)
To: Thorsten Jolitz, help-gnu-emacs
> >> >> Is (interactive "rP") not a valid combination?
> >> >> Or is this a bug in Emacs?
> >> > needs a newline: (interactive "r\nP")
> >> Yes, that made it work. Thanks.
> >
> > C-h i
> > Click Elisp
> > i interactive RET
>
> Maybe not _that_ obvious at first sight?
> This was a bug in core Org-mode I stumbled upon.
I did not mean that anything should have been obvious.
I just meant to remind folks that Emacs itself has most of the answers to our questions, and it's not that hard to ask Emacs.
Of course there is nothing wrong with asking here either.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (interactive "rP") valid?
[not found] ` <mailman.511.1369747231.22516.help-gnu-emacs@gnu.org>
@ 2013-05-28 15:35 ` Joost Kremers
[not found] ` <mailman.521.1369756484.22516.help-gnu-emacs@gnu.org>
[not found] ` <<slrnkq9jm0.2vb.joostkremers@j.kremers4.news.arnhem.chello.nl>
1 sibling, 1 reply; 12+ messages in thread
From: Joost Kremers @ 2013-05-28 15:35 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
> C-h i
> Click Elisp
Mmm... if I type that into Emacs, I end up with "Regexp search: p" in
the minibuffer... Or is this "Click" thing some newfangled modifier key
that I haven't heard about? If so, I hope the old method `m Elisp RET`
isn't deprecated? I'd hate to have to buy a new keyboard...
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: (interactive "rP") valid?
[not found] ` <<slrnkq9jm0.2vb.joostkremers@j.kremers4.news.arnhem.chello.nl>
@ 2013-05-28 15:54 ` Drew Adams
0 siblings, 0 replies; 12+ messages in thread
From: Drew Adams @ 2013-05-28 15:54 UTC (permalink / raw)
To: Joost Kremers, help-gnu-emacs
> > C-h i
> > Click Elisp
>
> Mmm... if I type that into Emacs, I end up with "Regexp search: p" in
> the minibuffer... Or is this "Click" thing some newfangled modifier key
> that I haven't heard about? If so, I hope the old method `m Elisp RET`
> isn't deprecated? I'd hate to have to buy a new keyboard...
;-)
No, I just meant that you can "click `mouse-2' (or `mouse-1', depending)
on the `Elisp' link."
Certainly it would be bad if `m Elisp RET' were lost. No disagreement.
^ permalink raw reply [flat|nested] 12+ messages in thread
* How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?)
2013-05-28 15:13 ` Drew Adams
@ 2013-05-28 16:42 ` Thorsten Jolitz
2013-05-28 17:27 ` Drew Adams
0 siblings, 1 reply; 12+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 16:42 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
> Of course there is nothing wrong with asking here either.
OK, I did read the 'interactive' section of the manual again, but I did
not find the answer to this question (although it is most likely there,
somehere):
How to write an interactive function and let the user choose from a list
(an enumeration) of possible solutions as input (like: Item1 | Item2 | Item3)?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?)
2013-05-28 16:42 ` How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?) Thorsten Jolitz
@ 2013-05-28 17:27 ` Drew Adams
2013-05-28 18:46 ` Thorsten Jolitz
0 siblings, 1 reply; 12+ messages in thread
From: Drew Adams @ 2013-05-28 17:27 UTC (permalink / raw)
To: Thorsten Jolitz, help-gnu-emacs
> OK, I did read the 'interactive' section of the manual again, but I did
> not find the answer to this question (although it is most likely there,
> somehere):
Hm. "Most likely there somewhere". Does that mean that you did not spend
time looking for it or you did spend time and couldn't find it?
If the latter, use `M-x report-emacs-bug', to let Emacs Dev know what's
missing - say just how you looked and what you think would have made your
search easier. Emacs Dev is usually open to improvement suggestions, such
as adding index entries or clarifying the text.
If the former, I have only a little sympathy. Sure, it might seem easier
to write a question here (and again, there is nothing wrong with that).
But learning to take advantage of the Emacs doc and help system
(`C-h f interactive') yourself is a win for everyone, especially you.
> How to write an interactive function and let the user choose from a list
> (an enumeration) of possible solutions as input (like: Item1 | Item2 |
> Item3)?
Wrt the original question, (elisp) `Using Interactive' (the first target reached
from `i interactive') gives two examples using \n, and it says:
"It may be a string; its contents are a sequence of elements separated
by newlines, one for each argument(1)."
And that node cross-references node `Interactive Codes', which explains more.
As to your new question, what is each ItemN? Just any old name, or the name
of a particular kind of Emacs object?
Node `Interactive Codes' explains about code chars that allow for completion
(of choices). It says that you get this for choosing the name of a function,
buffer, command, directory, file, user option, or coding system.
Beyond that, node `Using Interactive' explains that the `interactive' spec can
be a Lisp sexp that returns a list of args to be passed to the command. You
really cannot get more general than that: you can do pretty much anything here.
`Using Interactive' explains how to code such a list. As one example, you can
use `completing-read' to read a user choice among any kind of completion
candidates (not just names of functions, buffers, commands, directories, files,
options, and coding systems).
What more do you need? The manual is your friend.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?)
2013-05-28 17:27 ` Drew Adams
@ 2013-05-28 18:46 ` Thorsten Jolitz
0 siblings, 0 replies; 12+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 18:46 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams <drew.adams@oracle.com> writes:
> `Using Interactive' explains how to code such a list. As one example,
> you can use `completing-read' to read a user choice among any kind of
> completion candidates (not just names of functions, buffers, commands,
> directories, files, options, and coding systems).
Ok, thanks for the tip, 'completing-read' was the missing piece of the
puzzle for me.
> What more do you need? The manual is your friend.
I must admit I don't find everything so crystal clear and obvious in the
Elisp manual as you describe it here. Especially in the section about
(interactive), more and more comples examples would be helpful. On the
other hand, a 1000page manual is already thick enough, so I would not
call that a bug.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (interactive "rP") valid?
[not found] ` <mailman.521.1369756484.22516.help-gnu-emacs@gnu.org>
@ 2013-05-30 10:34 ` Joost Kremers
0 siblings, 0 replies; 12+ messages in thread
From: Joost Kremers @ 2013-05-30 10:34 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
>> > C-h i
>> > Click Elisp
>>
>> Mmm... if I type that into Emacs, I end up with "Regexp search: p" in
>> the minibuffer... Or is this "Click" thing some newfangled modifier key
>> that I haven't heard about? If so, I hope the old method `m Elisp RET`
>> isn't deprecated? I'd hate to have to buy a new keyboard...
>
> ;-)
>
> No, I just meant that you can "click `mouse-2' (or `mouse-1', depending)
> on the `Elisp' link."
Yeah, see? One of those newfangled tiny keyboards that won't stay put on
your desk... And only two keys! Can't for the life of me figure out why
anyone would wanna have one of those...
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-05-30 10:34 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-28 11:15 (interactive "rP") valid? Thorsten Jolitz
2013-05-28 11:38 ` Andreas Röhler
2013-05-28 11:42 ` Thorsten Jolitz
2013-05-28 13:20 ` Drew Adams
2013-05-28 14:36 ` Thorsten Jolitz
2013-05-28 15:13 ` Drew Adams
2013-05-28 16:42 ` How to write (interactive) with user-selection from predefined enumeration? (was Re: (interactive "rP") valid?) Thorsten Jolitz
2013-05-28 17:27 ` Drew Adams
2013-05-28 18:46 ` Thorsten Jolitz
[not found] ` <mailman.511.1369747231.22516.help-gnu-emacs@gnu.org>
2013-05-28 15:35 ` (interactive "rP") valid? Joost Kremers
[not found] ` <mailman.521.1369756484.22516.help-gnu-emacs@gnu.org>
2013-05-30 10:34 ` Joost Kremers
[not found] ` <<slrnkq9jm0.2vb.joostkremers@j.kremers4.news.arnhem.chello.nl>
2013-05-28 15:54 ` Drew Adams
[not found] <<87mwrfe4oy.fsf@gmail.com>
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).