unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Why is this-command-keys missing?
@ 2011-01-01 18:59 Lennart Borgman
  2011-01-02  1:57 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2011-01-01 18:59 UTC (permalink / raw)
  To: Emacs-Devel devel

compilation-mode binds

    (define-key map "\t" 'compilation-next-error)

You can use TAB to go to next error because of this.

However if you hit TAB then this-command-keys will contain (something
similar to) TAB and not "\t". So you can't do

   (key-binding (this-command-keys) t)

to get back the binding that is really active, i.e. compilation-next-error.


What are you supposed to do in a case like this to get back the key
binding compilation-next-error?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why is this-command-keys missing?
  2011-01-01 18:59 Why is this-command-keys missing? Lennart Borgman
@ 2011-01-02  1:57 ` Stefan Monnier
  2011-01-02  2:38   ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-01-02  1:57 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Emacs-Devel devel

>     (define-key map "\t" 'compilation-next-error)
> However if you hit TAB then this-command-keys will contain (something
> similar to) TAB and not "\t".

For me it does return "\t".

>    (key-binding (this-command-keys) t)
> to get back the binding that is really active, i.e. compilation-next-error.

It does sound like you're trying to do something that's
fundamentally unreliable.  Can you explain in more detail why you want
to know "the binding that is really active"?


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why is this-command-keys missing?
  2011-01-02  1:57 ` Stefan Monnier
@ 2011-01-02  2:38   ` Lennart Borgman
  2011-01-02  4:19     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2011-01-02  2:38 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-Devel devel

On Sun, Jan 2, 2011 at 2:57 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>     (define-key map "\t" 'compilation-next-error)
>> However if you hit TAB then this-command-keys will contain (something
>> similar to) TAB and not "\t".
>
> For me it does return "\t".
>
>>    (key-binding (this-command-keys) t)
>> to get back the binding that is really active, i.e. compilation-next-error.
>
> It does sound like you're trying to do something that's
> fundamentally unreliable.  Can you explain in more detail why you want
> to know "the binding that is really active"?


I am trying to use orgstruct-mode for a compilation output buffer.
orgstruct-mode binds keys like this:

    ;; Special treatment needed for TAB and RET
    (org-defkey orgstruct-mode-map [(tab)]
		(orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
    (org-defkey orgstruct-mode-map "\C-i"
		(orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))

This is to make it possible to use TAB for cycling the outlines when
on outline headings.

However I would like to get back the normal TAB handling in the
compilaiton output buffer when not on an outline heading.


However it is a little bit more complicated than that. I bind the key
C-i in an emulation mode map. This now gets called when TAB is hit. I
am trying to find out what was really hit.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why is this-command-keys missing?
  2011-01-02  2:38   ` Lennart Borgman
@ 2011-01-02  4:19     ` Stefan Monnier
  2011-01-02  4:29       ` Lennart Borgman
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-01-02  4:19 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Emacs-Devel devel

> I am trying to use orgstruct-mode for a compilation output buffer.
> orgstruct-mode binds keys like this:

>     ;; Special treatment needed for TAB and RET
>     (org-defkey orgstruct-mode-map [(tab)]
> 		(orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
>     (org-defkey orgstruct-mode-map "\C-i"
> 		(orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))

I don't know what this does, nor why it seems to bind both "\C-i" and
[(tab)].

> However I would like to get back the normal TAB handling in the
> compilation output buffer when not on an outline heading.

So, you don't care which command was run, but instead you want to
delegate to the other command which would be run if you ignore the
"currently used" binding.  This is a common need, of course.  With many
different solutions, none of them perfect:
- Use a menu-item binding with a :filter so the binding can be computed
  dynamically (i.e. it's bound to org-cycle if point is on a heading,
  and to nil otherwise).
- lookup with (key-binding (this-command-keys)) disabling your own
  key-binding (easy if it's on a minor-mode map or something similar).
  Usually (this-command-keys) does work, tho you claim it doesn't for
  you (still waiting for details on this problem).
- lookup (key-binding <some-hard-coded-key>).
- use a hard-coded fallback command.
- disable your binding, then push this-command-raw-keys back on
  unread-command-events, while arranging to re-enable the binding
  after the next command.


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why is this-command-keys missing?
  2011-01-02  4:19     ` Stefan Monnier
@ 2011-01-02  4:29       ` Lennart Borgman
  2011-01-02 14:42         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Lennart Borgman @ 2011-01-02  4:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs-Devel devel

On Sun, Jan 2, 2011 at 5:19 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I am trying to use orgstruct-mode for a compilation output buffer.
>> orgstruct-mode binds keys like this:
>
>>     ;; Special treatment needed for TAB and RET
>>     (org-defkey orgstruct-mode-map [(tab)]
>>               (orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i"))
>>     (org-defkey orgstruct-mode-map "\C-i"
>>               (orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)]))
>
> I don't know what this does, nor why it seems to bind both "\C-i" and
> [(tab)].

I beginning to think the problem is in this binding here, but I do not
understand exactly why the binding is done like this.

> So, you don't care which command was run, but instead you want to
> delegate to the other command which would be run if you ignore the
> "currently used" binding.

Yes.

> - disable your binding, then push this-command-raw-keys back on
>  unread-command-events, while arranging to re-enable the binding
>  after the next command.

I do not think it will work here since the key seems to be already
translated in raw-keys.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Why is this-command-keys missing?
  2011-01-02  4:29       ` Lennart Borgman
@ 2011-01-02 14:42         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2011-01-02 14:42 UTC (permalink / raw)
  To: Lennart Borgman; +Cc: Emacs-Devel devel

>> - disable your binding, then push this-command-raw-keys back on
>>  unread-command-events, while arranging to re-enable the binding
>>  after the next command.

> I do not think it will work here since the key seems to be already
> translated in raw-keys.

AFAIK this-command-raw-keys returns raw untranslated keys, as the
name implies.
So as before: if this-command-keys or this-command-raw-keys doesn't
return the data you expect, please send actual concrete data showing
the problem.  Until that time, I'll consider your reports as "pilot
errors".


        Stefan



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-02 14:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-01 18:59 Why is this-command-keys missing? Lennart Borgman
2011-01-02  1:57 ` Stefan Monnier
2011-01-02  2:38   ` Lennart Borgman
2011-01-02  4:19     ` Stefan Monnier
2011-01-02  4:29       ` Lennart Borgman
2011-01-02 14:42         ` Stefan Monnier

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).