* read-char doesn't use input-decode-map
@ 2009-12-30 17:44 Rob Giardina
2009-12-30 18:34 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Rob Giardina @ 2009-12-30 17:44 UTC (permalink / raw)
To: emacs-devel
Hi,
I've noticed that read-char doesn't use input-decode-map. I'm
doing some fun things with input-decode-map (code attached) to
convert all the right-side keys to the left using a super prefix
on OSX (allows one hand kdb, one hand mouse). It works nicely in
most cases except for the read-char family of functions. Is this
a bug or the expected behavior?
Thanks,
Rob
;;crazy experiment to mirror right characters onto left hand
(let ((from "`12345qwertasdfgzxcvb~!@#$%QWERTASDFGZXCVB")
(to "-09876poiuy:lkjh/.,mn_)(*&^POIUY;LKJH/<>MN")
(from-v (vconcat ["right" "left"] (mapcar 'char-to-string from)))
(to-v (vconcat [" " " "] (mapcar 'char-to-string to))))
(map 'list
#'(lambda(k to)
(let* ((base-k (list 'super (intern k)))
(base-to (list (intern to))))
(mapc
#'(lambda(pre)
(define-key input-decode-map
(vector (append pre base-k))
(vector (append pre base-to))))
'(() (control) (meta) (control meta)))))
from-v
to-v)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2009-12-30 17:44 read-char doesn't use input-decode-map Rob Giardina
@ 2009-12-30 18:34 ` Stefan Monnier
2009-12-30 19:56 ` Rob Giardina
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2009-12-30 18:34 UTC (permalink / raw)
To: Rob Giardina; +Cc: emacs-devel
> I've noticed that read-char doesn't use input-decode-map.
Indeed. And changing that can introduce bugs elsewhere.
That's why Emacs-23.2 introduced read-key which obeys input-decode-map
and friends (to the extent possible).
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2009-12-30 18:34 ` Stefan Monnier
@ 2009-12-30 19:56 ` Rob Giardina
2009-12-31 2:51 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Rob Giardina @ 2009-12-30 19:56 UTC (permalink / raw)
To: emacs-devel
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:
> > I've noticed that read-char doesn't use input-decode-map.
>
> Indeed. And changing that can introduce bugs elsewhere.
> That's why Emacs-23.2 introduced read-key which obeys input-decode-map
> and friends (to the extent possible).
Wow, read-key is pretty wild. I didn't realize you could do that
with idle timers. Perhaps that's vanilla if you're used to
emacs' event handling :)
This apparently means that code like I attached has no way to
reliably translate all of a certain key into another key, at
least for existing code that uses read-char. For example,
y-or-n-p.
-Rob
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2009-12-30 19:56 ` Rob Giardina
@ 2009-12-31 2:51 ` Stefan Monnier
2010-01-03 1:59 ` Lennart Borgman
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2009-12-31 2:51 UTC (permalink / raw)
To: Rob Giardina; +Cc: emacs-devel
> Wow, read-key is pretty wild. I didn't realize you could do that
> with idle timers. Perhaps that's vanilla if you're used to
> emacs' event handling :)
It's definitely not vanilla: it took me a while to find something that
worked OK, and even the current solution is pretty hackish since it
relies on time to detect "key press boundaries", which is fundamentally
unreliable. Sadly, I think there is fundamentally no reliable way to
solve this problem, so it's probably about as good as it gets.
> This apparently means that code like I attached has no way to
> reliably translate all of a certain key into another key, at
> least for existing code that uses read-char. For example,
> y-or-n-p.
Using read-char makes it pretty much hopeless, yes.
Most uses of reac-char should be replaced by read-key instead.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2009-12-31 2:51 ` Stefan Monnier
@ 2010-01-03 1:59 ` Lennart Borgman
2010-01-04 2:18 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Lennart Borgman @ 2010-01-03 1:59 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Rob Giardina, emacs-devel
On Thu, Dec 31, 2009 at 3:51 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>
> Most uses of reac-char should be replaced by read-key instead.
Then it is perhaps the time to use the prompt face for read-key too?
It is a bit confusing now. I suggest something like:
(progn
(use-global-map read-key-empty-map)
(message (concat (apply 'propertize prompt (member 'face
minibuffer-prompt-properties))
(propertize " " 'face 'cursor)))
(aref (catch 'read-key (read-key-sequence-vector nil nil t)) 0))
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2010-01-03 1:59 ` Lennart Borgman
@ 2010-01-04 2:18 ` Stefan Monnier
2010-01-04 2:31 ` Lennart Borgman
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2010-01-04 2:18 UTC (permalink / raw)
To: Lennart Borgman; +Cc: Rob Giardina, emacs-devel
>> Most uses of reac-char should be replaced by read-key instead.
> Then it is perhaps the time to use the prompt face for read-key too?
I guess so, yes. But if so, the problem should probably be fixed
directly in read-key-sequence(-vector) rather than only in read-key.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: read-char doesn't use input-decode-map
2010-01-04 2:18 ` Stefan Monnier
@ 2010-01-04 2:31 ` Lennart Borgman
0 siblings, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2010-01-04 2:31 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Rob Giardina, emacs-devel
On Mon, Jan 4, 2010 at 3:18 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>> Most uses of reac-char should be replaced by read-key instead.
>> Then it is perhaps the time to use the prompt face for read-key too?
>
> I guess so, yes. But if so, the problem should probably be fixed
> directly in read-key-sequence(-vector) rather than only in read-key.
Ok, there should be code for this in y-or-n-p for example. (If anyone
has time to write it right now.)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-01-04 2:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-30 17:44 read-char doesn't use input-decode-map Rob Giardina
2009-12-30 18:34 ` Stefan Monnier
2009-12-30 19:56 ` Rob Giardina
2009-12-31 2:51 ` Stefan Monnier
2010-01-03 1:59 ` Lennart Borgman
2010-01-04 2:18 ` Stefan Monnier
2010-01-04 2:31 ` Lennart Borgman
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).