unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 'ignore hides \r in keymap
@ 2005-11-02  0:05 Lennart Borgman
  2005-11-03 17:26 ` Lennart Borgman
  2005-11-03 21:50 ` Johan Bockgård
  0 siblings, 2 replies; 5+ messages in thread
From: Lennart Borgman @ 2005-11-02  0:05 UTC (permalink / raw)


This is one of those strange errors I wish I did not see. It seems like 
'ignore somehow hides \r in a keymap. To show this start with "emacs -Q" 
and evaluate the following:

  ;; Set up
  (defconst km (make-sparse-keymap))
  (define-key km "\r"   (lambda()(interactive)(message "hit RET")))

  ;; Convinience switching to/from km
  (define-key km [(home)] (lambda()(interactive)(use-local-map nil)))
  (global-set-key [(control meta home)] 
(lambda()(interactive)(use-local-map km)))

  ;; Test using either of these and then hit RET
  (define-key km [?i] (lambda()(interactive)(define-key km '[t] 'ignore)))
  (define-key km [?n] (lambda()(interactive)(define-key km '[t] nil)))

Activate the km keymap with C-M-home. Switch between using 'ignore or 
nil for unbound keys in km by hitting i and n. I see the following:

- Using nil and hitting RET gives the message "hit RET"
- Using 'ignore and hitting RET gives nothing.

I am doing this with CVS Emacs from 2005-10-27 on w32.

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

* Re: 'ignore hides \r in keymap
  2005-11-02  0:05 'ignore hides \r in keymap Lennart Borgman
@ 2005-11-03 17:26 ` Lennart Borgman
  2005-11-03 21:50 ` Johan Bockgård
  1 sibling, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2005-11-03 17:26 UTC (permalink / raw)


Could someone please check this? Am I misunderstanding something here 
too, or? It seems to me that \r is handled different than other keys here.


Lennart Borgman wrote:

> This is one of those strange errors I wish I did not see. It seems 
> like 'ignore somehow hides \r in a keymap. To show this start with 
> "emacs -Q" and evaluate the following:
>
>  ;; Set up
>  (defconst km (make-sparse-keymap))
>  (define-key km "\r"   (lambda()(interactive)(message "hit RET")))
>
>  ;; Convinience switching to/from km
>  (define-key km [(home)] (lambda()(interactive)(use-local-map nil)))
>  (global-set-key [(control meta home)] 
> (lambda()(interactive)(use-local-map km)))
>
>  ;; Test using either of these and then hit RET
>  (define-key km [?i] (lambda()(interactive)(define-key km '[t] 'ignore)))
>  (define-key km [?n] (lambda()(interactive)(define-key km '[t] nil)))
>
> Activate the km keymap with C-M-home. Switch between using 'ignore or 
> nil for unbound keys in km by hitting i and n. I see the following:
>
> - Using nil and hitting RET gives the message "hit RET"
> - Using 'ignore and hitting RET gives nothing.
>
> I am doing this with CVS Emacs from 2005-10-27 on w32.

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

* Re: 'ignore hides \r in keymap
  2005-11-02  0:05 'ignore hides \r in keymap Lennart Borgman
  2005-11-03 17:26 ` Lennart Borgman
@ 2005-11-03 21:50 ` Johan Bockgård
  2005-11-03 22:10   ` Lennart Borgman
  2005-11-04  4:26   ` Stefan Monnier
  1 sibling, 2 replies; 5+ messages in thread
From: Johan Bockgård @ 2005-11-03 21:50 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> This is one of those strange errors I wish I did not see. It seems like 
> 'ignore somehow hides \r in a keymap. To show this start with "emacs -Q" 
> and evaluate the following:
>
>  ;; Set up
>  (defconst km (make-sparse-keymap))
>  (define-key km "\r"   (lambda()(interactive)(message "hit RET")))
>
>  ;; Convinience switching to/from km
>  (define-key km [(home)] (lambda()(interactive)(use-local-map nil)))
>  (global-set-key [(control meta home)] 
> (lambda()(interactive)(use-local-map km)))
>
>  ;; Test using either of these and then hit RET
>  (define-key km [?i] (lambda()(interactive)(define-key km '[t] 'ignore)))
>  (define-key km [?n] (lambda()(interactive)(define-key km '[t] nil)))
>
> Activate the km keymap with C-M-home. Switch between using 'ignore or 
> nil for unbound keys in km by hitting i and n. I see the following:
>
> - Using nil and hitting RET gives the message "hit RET"
> - Using 'ignore and hitting RET gives nothing.
>
> I am doing this with CVS Emacs from 2005-10-27 on w32.

Looks like it's a problem of RET (C-m) vs <return> (function key). You
would see the same thing if you bound TAB (C-i) and pressed <tab> etc.

Apparently the default binding is used before the <return> --> RET
translation is made.

In other words, after you press "i":

(key-binding [return] t) => ignore
(key-binding "\C-m" t)   => (lambda nil (interactive) (message "hit RET"))

-- 
Johan Bockgård

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

* Re: 'ignore hides \r in keymap
  2005-11-03 21:50 ` Johan Bockgård
@ 2005-11-03 22:10   ` Lennart Borgman
  2005-11-04  4:26   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2005-11-03 22:10 UTC (permalink / raw)
  Cc: emacs-devel

Johan Bockgård wrote:

>Lennart Borgman <lennart.borgman.073@student.lu.se> writes:
>
>  
>
>>This is one of those strange errors I wish I did not see. It seems like 
>>'ignore somehow hides \r in a keymap. To show this start with "emacs -Q" 
>>and evaluate the following:
>>
>> ;; Set up
>> (defconst km (make-sparse-keymap))
>> (define-key km "\r"   (lambda()(interactive)(message "hit RET")))
>>
>> ;; Convinience switching to/from km
>> (define-key km [(home)] (lambda()(interactive)(use-local-map nil)))
>> (global-set-key [(control meta home)] 
>>(lambda()(interactive)(use-local-map km)))
>>
>> ;; Test using either of these and then hit RET
>> (define-key km [?i] (lambda()(interactive)(define-key km '[t] 'ignore)))
>> (define-key km [?n] (lambda()(interactive)(define-key km '[t] nil)))
>>
>>Activate the km keymap with C-M-home. Switch between using 'ignore or 
>>nil for unbound keys in km by hitting i and n. I see the following:
>>
>>- Using nil and hitting RET gives the message "hit RET"
>>- Using 'ignore and hitting RET gives nothing.
>>
>>I am doing this with CVS Emacs from 2005-10-27 on w32.
>>    
>>
>
>Looks like it's a problem of RET (C-m) vs <return> (function key). You
>would see the same thing if you bound TAB (C-i) and pressed <tab> etc.
>
>Apparently the default binding is used before the <return> --> RET
>translation is made.
>
>In other words, after you press "i":
>
>(key-binding [return] t) => ignore
>(key-binding "\C-m" t)   => (lambda nil (interactive) (message "hit RET"))
>
>  
>
Yes, thanks, I vaugely thought so. Maybe I should not ask for a 
workaround. We have had much consensus that this is just creating 
problems during a development phase. But I do not at all understand how 
to fix this. I think you need to have a personal history in Emacs to fix 
this the right way.

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

* Re: 'ignore hides \r in keymap
  2005-11-03 21:50 ` Johan Bockgård
  2005-11-03 22:10   ` Lennart Borgman
@ 2005-11-04  4:26   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2005-11-04  4:26 UTC (permalink / raw)


> Looks like it's a problem of RET (C-m) vs <return> (function key). You
> would see the same thing if you bound TAB (C-i) and pressed <tab> etc.

> Apparently the default binding is used before the <return> --> RET
> translation is made.

Indeed.  The problem is that the <return> -> RET mapping is done
conditionally on whether there is a binding for <return>.  Now I think that
this should not take default bindings into account, but last I looked at it
it wasn't easy to fix (this is done in a very big and hairy function with
lots of non-trivial and non-written invariants).


        Stefan

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

end of thread, other threads:[~2005-11-04  4:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-02  0:05 'ignore hides \r in keymap Lennart Borgman
2005-11-03 17:26 ` Lennart Borgman
2005-11-03 21:50 ` Johan Bockgård
2005-11-03 22:10   ` Lennart Borgman
2005-11-04  4:26   ` 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).