* prefix arg when mouse clicking on header
@ 2008-12-14 23:42 Roland Winkler
2008-12-15 0:01 ` Drew Adams
2008-12-15 4:03 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: Roland Winkler @ 2008-12-14 23:42 UTC (permalink / raw)
To: emacs-devel
I have some difficulties with the command proced-sort-header in
proced.el. This command is called when the mouse is on the header
line. The first arg of this command is the mouse event. I'd like to
give the command an optional prefix arg. But somehow it seems to me
that clicking on the header line is different from clicking
elsewhere. What is the proper way to access the prefix arg when
clicking on the header line?
I used to have (interactive "e\nP"), but that ignores the prefix arg.
Instead of "P", I really would like to have something like
(interactive (list last-input-event (or current-prefix-arg 'no-arg)))
(The 'no-arg is similar to 'toggle in define-derived-mode.)
But again, this ignores the prefix arg. By trial an error I have
found that
(interactive (list last-input-event (or last-prefix-arg 'no-arg)))
seems to work. But is this the right thing? Why last-prefix-arg
instead of current-prefix-arg? Certainly, this is consistent with
the code letter P being ignored by interactive.
Also I was wondering what is the proper replacement for the code
letter e used by interactive when the list is constructed by hand.
last-input-event is used in commands like Buffer-menu-sort-by-column.
Is last-input-event always equivalent to the code letter e?
If yes, that could go into the elisp manual. If not, what would be
the proper replacement?
Thanks!
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: prefix arg when mouse clicking on header
2008-12-14 23:42 prefix arg when mouse clicking on header Roland Winkler
@ 2008-12-15 0:01 ` Drew Adams
2008-12-15 1:25 ` Roland Winkler
2008-12-15 4:03 ` Stefan Monnier
1 sibling, 1 reply; 7+ messages in thread
From: Drew Adams @ 2008-12-15 0:01 UTC (permalink / raw)
To: 'Roland Winkler', emacs-devel
> I have some difficulties with the command proced-sort-header in
> proced.el. This command is called when the mouse is on the header
> line. The first arg of this command is the mouse event. I'd like to
> give the command an optional prefix arg. But somehow it seems to me
> that clicking on the header line is different from clicking
> elsewhere. What is the proper way to access the prefix arg when
> clicking on the header line?
>
> I used to have (interactive "e\nP"), but that ignores the prefix arg.
>
> Instead of "P", I really would like to have something like
>
> (interactive (list last-input-event (or current-prefix-arg 'no-arg)))
>
> (The 'no-arg is similar to 'toggle in define-derived-mode.)
> But again, this ignores the prefix arg. By trial an error I have
> found that
>
> (interactive (list last-input-event (or last-prefix-arg 'no-arg)))
>
> seems to work. But is this the right thing? Why last-prefix-arg
> instead of current-prefix-arg? Certainly, this is consistent with
> the code letter P being ignored by interactive.
>
> Also I was wondering what is the proper replacement for the code
> letter e used by interactive when the list is constructed by hand.
> last-input-event is used in commands like Buffer-menu-sort-by-column.
> Is last-input-event always equivalent to the code letter e?
> If yes, that could go into the elisp manual. If not, what would be
> the proper replacement?
(interactive "e\nP") works for me.
For example, try the version of `mouse-yank-secondary' in `mouse+.el', with
`second-sel.el' also loaded. If `mouse-yank-secondary' is bound to, say,
`M-mouse-2', then `C-u 3 M-mouse-2' yanks the 3rd most recent secondary
selection.
The code for that, as an example, is here:
http://www.emacswiki.org/emacs/mouse%2b.el ; mouse+.el
http://www.emacswiki.org/emacs/second-sel.el
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: prefix arg when mouse clicking on header
2008-12-15 0:01 ` Drew Adams
@ 2008-12-15 1:25 ` Roland Winkler
2008-12-15 1:33 ` Drew Adams
0 siblings, 1 reply; 7+ messages in thread
From: Roland Winkler @ 2008-12-15 1:25 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
On Sun Dec 14 2008 Drew Adams wrote:
> (interactive "e\nP") works for me.
>
> For example, try the version of `mouse-yank-secondary' in `mouse+.el', with
> `second-sel.el' also loaded. If `mouse-yank-secondary' is bound to, say,
> `M-mouse-2', then `C-u 3 M-mouse-2' yanks the 3rd most recent secondary
> selection.
>
> The code for that, as an example, is here:
> http://www.emacswiki.org/emacs/mouse%2b.el ; mouse+.el
> http://www.emacswiki.org/emacs/second-sel.el
Is this code supposed to work for header lines, too? I agree that I
have no problem with (interactive "e\nP") inside the main part of
the buffer. And the following code works too.
(interactive (list last-input-event current-prefix-arg))
Yet for the header line, I need to replace current-prefix-arg by
last-prefix-arg. Why?
And is there a common meaning for the prefix `last-' of
last-input-event and last-prefix-arg? Or is this coincidence accidental?
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: prefix arg when mouse clicking on header
2008-12-14 23:42 prefix arg when mouse clicking on header Roland Winkler
2008-12-15 0:01 ` Drew Adams
@ 2008-12-15 4:03 ` Stefan Monnier
2008-12-15 18:33 ` Roland Winkler
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2008-12-15 4:03 UTC (permalink / raw)
To: Roland Winkler; +Cc: emacs-devel
> (interactive (list last-input-event (or last-prefix-arg 'no-arg)))
> seems to work. But is this the right thing? Why last-prefix-arg
> instead of current-prefix-arg? Certainly, this is consistent with
> the code letter P being ignored by interactive.
Not sure why that is. Maybe some code somewhere catches the click, does
some processing and pushes events back on unread-command-events, so the
real code is only run on the second round?
> Also I was wondering what is the proper replacement for the code
> letter e used by interactive when the list is constructed by hand.
AFAIK it's last-nonmenu-event.
> If yes, that could go into the elisp manual.
It should go somewhere, I agree. I tend to think that
call-interactively should use a table mapping letters to Elisp code, so
it'd be easy to see which code corresponds to while letter.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: prefix arg when mouse clicking on header
2008-12-15 4:03 ` Stefan Monnier
@ 2008-12-15 18:33 ` Roland Winkler
2008-12-15 20:13 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Roland Winkler @ 2008-12-15 18:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
On Sun Dec 14 2008 Stefan Monnier wrote:
> > (interactive (list last-input-event (or last-prefix-arg 'no-arg)))
> > seems to work. But is this the right thing? Why last-prefix-arg
> > instead of current-prefix-arg? Certainly, this is consistent with
> > the code letter P being ignored by interactive.
>
> Not sure why that is. Maybe some code somewhere catches the click, does
> some processing and pushes events back on unread-command-events, so the
> real code is only run on the second round?
This sounds very reasonable, but fixing this goes much beyond my
knowledge of emacs. Should I submit a bug report so that this topic
is properly entered into the system?
> > Also I was wondering what is the proper replacement for the code
> > letter e used by interactive when the list is constructed by hand.
>
> AFAIK it's last-nonmenu-event.
Then I find it confusing that various packages use last-input-event,
and I'd greatly appreciate if someone who knows about these things
could document them.
> I tend to think that call-interactively should use a table mapping
> letters to Elisp code, so it'd be easy to see which code
> corresponds to while letter.
That would be great!
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: prefix arg when mouse clicking on header
2008-12-15 18:33 ` Roland Winkler
@ 2008-12-15 20:13 ` Stefan Monnier
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2008-12-15 20:13 UTC (permalink / raw)
To: Roland Winkler; +Cc: emacs-devel
>> > (interactive (list last-input-event (or last-prefix-arg 'no-arg)))
>> > seems to work. But is this the right thing? Why last-prefix-arg
>> > instead of current-prefix-arg? Certainly, this is consistent with
>> > the code letter P being ignored by interactive.
>>
>> Not sure why that is. Maybe some code somewhere catches the click, does
>> some processing and pushes events back on unread-command-events, so the
>> real code is only run on the second round?
> This sounds very reasonable, but fixing this goes much beyond my
> knowledge of emacs. Should I submit a bug report so that this topic
> is properly entered into the system?
Yes.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-12-15 20:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-14 23:42 prefix arg when mouse clicking on header Roland Winkler
2008-12-15 0:01 ` Drew Adams
2008-12-15 1:25 ` Roland Winkler
2008-12-15 1:33 ` Drew Adams
2008-12-15 4:03 ` Stefan Monnier
2008-12-15 18:33 ` Roland Winkler
2008-12-15 20:13 ` 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.