* bug#9751: 23.3; Alternative Keyboard Feature/Bug
@ 2011-10-14 7:05 Nikos Pitsianis
2011-10-14 11:48 ` Juanma Barranquero
0 siblings, 1 reply; 30+ messages in thread
From: Nikos Pitsianis @ 2011-10-14 7:05 UTC (permalink / raw)
To: 9751
There is a behavior that is not correct. When I use a different keyboard
than English, say to enter Greek, the key combinations Ctr and Alt do
not work as intented because Ctr-G for example is interpreted as
Ctr-Gamma which does not bring the intended outcome.
I believe it is a reasonable assumption that Ctr and Alt key
combinations in any alternative keyboard should be interpreted as the
corresponding English keyboard ones.
In GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.35)
of 2011-03-10 on black.porkrind.org
Windowing system distributor `Apple', version 10.3.1038
configured using `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin' '--with-ns' 'build_alias=i686-apple-darwin' 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.5''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: nil
value of $XMODIFIERS: nil
locale-coding-system: nil
default enable-multibyte-characters: t
Major mode: Fundamental
Minor modes in effect:
show-paren-mode: t
tooltip-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
blink-cursor-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
<menu-bar> <help-menu> <send-emacs-bug-report>
Recent messages:
Loading paren...done
For information about GNU Emacs and the GNU system, type M-? C-a.
Load-path shadows:
None found.
Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug jka-compr paren cus-start cus-load
tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 7:05 bug#9751: 23.3; Alternative Keyboard Feature/Bug Nikos Pitsianis
@ 2011-10-14 11:48 ` Juanma Barranquero
2011-10-14 17:06 ` Nikos Pitsianis
0 siblings, 1 reply; 30+ messages in thread
From: Juanma Barranquero @ 2011-10-14 11:48 UTC (permalink / raw)
To: Nikos Pitsianis; +Cc: 9751
On Fri, Oct 14, 2011 at 09:05, Nikos Pitsianis <nikos@cs.duke.edu> wrote:
> There is a behavior that is not correct. When I use a different keyboard
> than English, say to enter Greek, the key combinations Ctr and Alt do
> not work as intented because Ctr-G for example is interpreted as
> Ctr-Gamma which does not bring the intended outcome.
That's a feature (and not a bug) of the Windows keyboard handler.
> I believe it is a reasonable assumption that Ctr and Alt key
> combinations in any alternative keyboard should be interpreted as the
> corresponding English keyboard ones.
Do you also believe that the key just right of the "l" should be
interpreted as ";"? That's going to make difficult to type "ñ" for
me...
Juanma
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 11:48 ` Juanma Barranquero
@ 2011-10-14 17:06 ` Nikos Pitsianis
2011-10-14 17:21 ` Eli Zaretskii
2011-10-14 19:19 ` Juanma Barranquero
0 siblings, 2 replies; 30+ messages in thread
From: Nikos Pitsianis @ 2011-10-14 17:06 UTC (permalink / raw)
To: Juanma Barranquero; +Cc: 9751
Juanma
Thank you following up on my report.
On Windows XP when I type in greek in emacs and I need to save, I simply type Ctr-x Ctr-s irrespective of the keyboard mode (English or Greek).
On the Mac OS version of emacs, I have to turn into english, issue Ctr-x Ctr-s and then return beck to greek to continue.
I assume that all users of alternative keyboards would expect that an Alt or Ctr combination should be sending an emacs command just like the behavior in Windows XP emacs.
I just verified this in
This is GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.35)
of 2011-03-10 on black.porkrind.org
and
This is GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
of 2009-07-30 on SOFT-MJASON
In my humble understanding, the behavior of the Mac emacs is a bug :-)
-- Nikos Pitsianis
On Oct 14, 2011, at 2:48 PM, Juanma Barranquero wrote:
> On Fri, Oct 14, 2011 at 09:05, Nikos Pitsianis <nikos@cs.duke.edu> wrote:
>
>> There is a behavior that is not correct. When I use a different keyboard
>> than English, say to enter Greek, the key combinations Ctr and Alt do
>> not work as intented because Ctr-G for example is interpreted as
>> Ctr-Gamma which does not bring the intended outcome.
>
> That's a feature (and not a bug) of the Windows keyboard handler.
>
>> I believe it is a reasonable assumption that Ctr and Alt key
>> combinations in any alternative keyboard should be interpreted as the
>> corresponding English keyboard ones.
>
> Do you also believe that the key just right of the "l" should be
> interpreted as ";"? That's going to make difficult to type "ñ" for
> me...
>
> Juanma
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 17:06 ` Nikos Pitsianis
@ 2011-10-14 17:21 ` Eli Zaretskii
2011-10-14 17:47 ` Nikos Pitsianis
2011-10-14 19:19 ` Juanma Barranquero
1 sibling, 1 reply; 30+ messages in thread
From: Eli Zaretskii @ 2011-10-14 17:21 UTC (permalink / raw)
To: Nikos Pitsianis; +Cc: lekktu, 9751
> From: Nikos Pitsianis <nikos@cs.duke.edu>
> Date: Fri, 14 Oct 2011 20:06:49 +0300
> Cc: 9751@debbugs.gnu.org
>
> On Windows XP when I type in greek in emacs and I need to save, I simply type Ctr-x Ctr-s irrespective of the keyboard mode (English or Greek).
>
> On the Mac OS version of emacs, I have to turn into english, issue Ctr-x Ctr-s and then return beck to greek to continue.
>
> I assume that all users of alternative keyboards would expect that an Alt or Ctr combination should be sending an emacs command just like the behavior in Windows XP emacs.
There's nothing Emacs can do about this. What you see on Windows is a
general feature of Windows keyboard input. Other systems don't have
that feature.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 17:21 ` Eli Zaretskii
@ 2011-10-14 17:47 ` Nikos Pitsianis
2011-10-14 18:49 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Nikos Pitsianis @ 2011-10-14 17:47 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: lekktu, 9751
What is the way in emacs to alias Ctr-chi to Ctr-x ?
Alternatively, how do I map a few commonly used commands to the alternative keyboard combinations?
(global-set-key "\C-χ\C-ψ" 'save-buffers-kill-emacs)
returns with
error: Invalid modifier in string
Nikos
On Oct 14, 2011, at 8:21 PM, Eli Zaretskii wrote:
>> From: Nikos Pitsianis <nikos@cs.duke.edu>
>> Date: Fri, 14 Oct 2011 20:06:49 +0300
>> Cc: 9751@debbugs.gnu.org
>>
>> On Windows XP when I type in greek in emacs and I need to save, I simply type Ctr-x Ctr-s irrespective of the keyboard mode (English or Greek).
>>
>> On the Mac OS version of emacs, I have to turn into english, issue Ctr-x Ctr-s and then return beck to greek to continue.
>>
>> I assume that all users of alternative keyboards would expect that an Alt or Ctr combination should be sending an emacs command just like the behavior in Windows XP emacs.
>
> There's nothing Emacs can do about this. What you see on Windows is a
> general feature of Windows keyboard input. Other systems don't have
> that feature.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 17:47 ` Nikos Pitsianis
@ 2011-10-14 18:49 ` Stefan Monnier
2011-10-20 0:12 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-14 18:49 UTC (permalink / raw)
To: Nikos Pitsianis; +Cc: lekktu, 9751
> What is the way in emacs to alias Ctr-chi to Ctr-x ?
I'd do it in input-decode-map:
(define-key input-decode-map [?\C-χ] [?\C-x])
(define-key input-decode-map [?\C-ψ] [?\C-s])
> (global-set-key "\C-χ\C-ψ" 'save-buffers-kill-emacs)
> returns with
> error: Invalid modifier in string
Event sequences are vectors, the string syntax is still allowed but only
covers limited cases as you've just discovered.
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 17:06 ` Nikos Pitsianis
2011-10-14 17:21 ` Eli Zaretskii
@ 2011-10-14 19:19 ` Juanma Barranquero
1 sibling, 0 replies; 30+ messages in thread
From: Juanma Barranquero @ 2011-10-14 19:19 UTC (permalink / raw)
To: Nikos Pitsianis; +Cc: 9751
On Fri, Oct 14, 2011 at 19:06, Nikos Pitsianis <nikos@cs.duke.edu> wrote:
> In my humble understanding, the behavior of the Mac emacs is a bug :-)
Sorry, I read Ctrl and Alt and didn't realize you were using Emacs on the Mac.
Juanma
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-14 18:49 ` Stefan Monnier
@ 2011-10-20 0:12 ` Juri Linkov
2011-10-20 2:10 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-20 0:12 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
>> What is the way in emacs to alias Ctr-chi to Ctr-x ?
>
> I'd do it in input-decode-map:
>
> (define-key input-decode-map [?\C-χ] [?\C-x])
> (define-key input-decode-map [?\C-ψ] [?\C-s])
The problem is that this method doesn't work for self-inserting characters,
i.e. to be able to handle keybindings that contain characters without
modifiers like e.g. `C-x b' we can't use
(define-key input-decode-map [?β] [?b])
because it will translate all plain self-inserting characters,
and this is not desirable.
So users have to bother about rebinding all keybindings individually like
(define-key input-decode-map [?\C-χ ?β] [?\C-x ?b])
...
I have no idea how to cover all keybindings automatically.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-20 0:12 ` Juri Linkov
@ 2011-10-20 2:10 ` Stefan Monnier
2011-10-20 6:29 ` Juri Linkov
2012-01-12 0:35 ` Juri Linkov
0 siblings, 2 replies; 30+ messages in thread
From: Stefan Monnier @ 2011-10-20 2:10 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, 9751, Nikos Pitsianis
>>> What is the way in emacs to alias Ctr-chi to Ctr-x ?
>> I'd do it in input-decode-map:
>> (define-key input-decode-map [?\C-χ] [?\C-x])
>> (define-key input-decode-map [?\C-ψ] [?\C-s])
> The problem is that this method doesn't work for self-inserting characters,
> i.e. to be able to handle keybindings that contain characters without
> modifiers like e.g. `C-x b' we can't use
> (define-key input-decode-map [?β] [?b])
That's a problem indeed. I guess we can use function-key-map instead, tho.
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-20 2:10 ` Stefan Monnier
@ 2011-10-20 6:29 ` Juri Linkov
2011-10-20 13:19 ` Stefan Monnier
2012-01-12 0:35 ` Juri Linkov
1 sibling, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-20 6:29 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
> I guess we can use function-key-map instead, tho.
And `function-key-map' really works even for characters
with no modifiers (for the value `nil' below):
(let ((modifiers '(nil (control) (meta) (control meta)))
(map '((?ς . ?w) (?ε . ?e) (?ρ . ?r) (?τ . ?t) (?υ . ?y)
(?θ . ?u) (?ι . ?i) (?ο . ?o) (?π . ?p) (?α . ?a)
(?σ . ?s) (?δ . ?d) (?φ . ?f) (?γ . ?g) (?η . ?h)
(?ξ . ?j) (?κ . ?k) (?λ . ?l) (?ζ . ?z) (?χ . ?x)
(?ψ . ?c) (?ω . ?v) (?β . ?b) (?ν . ?n) (?μ . ?m) (?\; . ?q))))
(dolist (pair map)
(dolist (mod modifiers)
(define-key local-function-key-map
(vector (append mod (list (car pair))))
(vector (append mod (list (cdr pair))))))))
So `C-χ β' runs `switch-to-buffer' whereas self-inserting characters
are inserted as is, without translation.
However, there is another problem. Single-key bindings don't work in modes
where they are bound to other commands, like `v' (`dired-view-file') in Dired,
or `d' (`Info-directory') in Info.
I see no better way than to translate single keys in such modes individually:
(let ((map '((?ς . ?w) (?ε . ?e) (?ρ . ?r) (?τ . ?t) (?υ . ?y)
(?θ . ?u) (?ι . ?i) (?ο . ?o) (?π . ?p) (?α . ?a)
(?σ . ?s) (?δ . ?d) (?φ . ?f) (?γ . ?g) (?η . ?h)
(?ξ . ?j) (?κ . ?k) (?λ . ?l) (?ζ . ?z) (?χ . ?x)
(?ψ . ?c) (?ω . ?v) (?β . ?b) (?ν . ?n) (?μ . ?m) (?\; . ?q))))
(dolist (pair map)
(define-key dired-mode-map (vector (car pair)) (vector (cdr pair)))
(define-key Info-mode-map (vector (car pair)) (vector (cdr pair)))
;; and many other similar modes ...
))
And then some single keys work, some don't. For example, typing a key
that translates to `x' in Dired writes in the echo area:
Keyboard macro terminated by a command ringing the bell
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-20 6:29 ` Juri Linkov
@ 2011-10-20 13:19 ` Stefan Monnier
2011-10-21 14:01 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-20 13:19 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, 9751, Nikos Pitsianis
> And `function-key-map' really works even for characters
> with no modifiers (for the value `nil' below):
> (let ((modifiers '(nil (control) (meta) (control meta)))
> (map '((?ς . ?w) (?ε . ?e) (?ρ . ?r) (?τ . ?t) (?υ . ?y)
> (?θ . ?u) (?ι . ?i) (?ο . ?o) (?π . ?p) (?α . ?a)
> (?σ . ?s) (?δ . ?d) (?φ . ?f) (?γ . ?g) (?η . ?h)
> (?ξ . ?j) (?κ . ?k) (?λ . ?l) (?ζ . ?z) (?χ . ?x)
> (?ψ . ?c) (?ω . ?v) (?β . ?b) (?ν . ?n) (?μ . ?m) (?\; . ?q))))
> (dolist (pair map)
> (dolist (mod modifiers)
> (define-key local-function-key-map
> (vector (append mod (list (car pair))))
> (vector (append mod (list (cdr pair))))))))
> So `C-χ β' runs `switch-to-buffer' whereas self-inserting characters
> are inserted as is, without translation.
Yes, that's what I expected.
> However, there is another problem. Single-key bindings don't work in modes
> where they are bound to other commands, like `v' (`dired-view-file') in Dired,
> or `d' (`Info-directory') in Info.
I don't understand what you mean here. Do you mean that hitting
v/ω/omega will not run dired-view-file? That's very odd. Can you try
and investigate why that is?
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-20 13:19 ` Stefan Monnier
@ 2011-10-21 14:01 ` Juri Linkov
2011-10-21 17:37 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-21 14:01 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
>> However, there is another problem. Single-key bindings don't work in modes
>> where they are bound to other commands, like `v' (`dired-view-file') in Dired,
>> or `d' (`Info-directory') in Info.
>
> I don't understand what you mean here. Do you mean that hitting
> v/ω/omega will not run dired-view-file? That's very odd. Can you try
> and investigate why that is?
Sorry, it seems I did a stupid thing. Major mode maps don't perform
key translation, so
(define-key dired-mode-map [?β] [?b])
binds `β' to a keyboard macro instead of translating keys
like `input-decode-map' does.
I can't find a way to translate keys on a per-mode basis
in modes where single keys are bound to non-self-inserting commands.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-21 14:01 ` Juri Linkov
@ 2011-10-21 17:37 ` Stefan Monnier
2011-10-22 15:36 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-21 17:37 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, 9751, Nikos Pitsianis
> I can't find a way to translate keys on a per-mode basis
> in modes where single keys are bound to non-self-inserting commands.
Well, if you really have to, you can do it with something like:
(define-key function-key-map [β]
(lambda (_prompt) (if (derived-mode-p 'dired-mode) [?a] [?b])))
but I wonder in which circumstance you'd want to do that.
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-21 17:37 ` Stefan Monnier
@ 2011-10-22 15:36 ` Juri Linkov
2011-10-23 20:08 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-22 15:36 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
>> I can't find a way to translate keys on a per-mode basis
>> in modes where single keys are bound to non-self-inserting commands.
>
> Well, if you really have to, you can do it with something like:
>
> (define-key function-key-map [β]
> (lambda (_prompt) (if (derived-mode-p 'dired-mode) [?a] [?b])))
>
> but I wonder in which circumstance you'd want to do that.
The problem common to Greek and Cyrillic is how to configure
keybindings in such a way that single characters bound to
`self-insert-command' remained untranslated as they are typed
with a non-English system input method, but to translate
single characters to English letters when they are bound
to other Emacs commands (like `v' in Dired mode)
that would allow to run commands bound to them.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-22 15:36 ` Juri Linkov
@ 2011-10-23 20:08 ` Stefan Monnier
2011-10-23 20:24 ` Andreas Schwab
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-23 20:08 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, 9751, Nikos Pitsianis
>>> I can't find a way to translate keys on a per-mode basis
>>> in modes where single keys are bound to non-self-inserting commands.
>>
>> Well, if you really have to, you can do it with something like:
>>
>> (define-key function-key-map [β]
>> (lambda (_prompt) (if (derived-mode-p 'dired-mode) [?a] [?b])))
>>
>> but I wonder in which circumstance you'd want to do that.
> The problem common to Greek and Cyrillic is how to configure
> keybindings in such a way that single characters bound to
> `self-insert-command' remained untranslated as they are typed
> with a non-English system input method, but to translate
> single characters to English letters when they are bound
> to other Emacs commands (like `v' in Dired mode)
> that would allow to run commands bound to them.
But
(define-key function-key-map [β] [?b])
does that already.
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-23 20:08 ` Stefan Monnier
@ 2011-10-23 20:24 ` Andreas Schwab
2011-10-24 3:05 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Andreas Schwab @ 2011-10-23 20:24 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> But
>
> (define-key function-key-map [β] [?b])
>
> does that already.
function-key-map applies only to (suffixes of) unbound key sequences.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-23 20:24 ` Andreas Schwab
@ 2011-10-24 3:05 ` Stefan Monnier
2011-10-24 5:17 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-24 3:05 UTC (permalink / raw)
To: Andreas Schwab; +Cc: lekktu, 9751, Nikos Pitsianis
>> But
>> (define-key function-key-map [β] [?b])
>> does that already.
> function-key-map applies only to (suffixes of) unbound key sequences.
Right, which is exactly what he was asking for, AFAIK.
I'm obviously missing something, but I still haven't seen a concrete
example where the function-key-map binding doesn't do what we want (or
maybe I've seen it, but I didn't understand it, if so please spell it
out for me).
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 3:05 ` Stefan Monnier
@ 2011-10-24 5:17 ` Juri Linkov
2011-10-24 13:01 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-24 5:17 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
>>> But
>>> (define-key function-key-map [β] [?b])
>>> does that already.
>> function-key-map applies only to (suffixes of) unbound key sequences.
>
> Right, which is exactly what he was asking for, AFAIK.
> I'm obviously missing something, but I still haven't seen a concrete
> example where the function-key-map binding doesn't do what we want (or
> maybe I've seen it, but I didn't understand it, if so please spell it
> out for me).
Let's consider `Info-mode' instead of `dired-mode' for testing purposes
because `b' is unbound in Dired, but in Info it's bound to
`beginning-of-buffer'.
After evaluating
(define-key function-key-map [?β] [?b])
typing `β' in Info has no effect, it doesn't call `beginning-of-buffer'.
When typing in Info `C-h k β', it says:
β is undefined
What is expected for `C-h k β' to say is that `b' is translated from `β'.
OTOH, after evaluating
(define-key function-key-map [?\C-χ] [?\C-x])
(define-key function-key-map [?β] [?b])
`C-χ β' runs `switch-to-buffer' correctly,
and `C-h k C-χ β' says:
C-x b (translated from C-χ β) runs the command switch-to-buffer
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 5:17 ` Juri Linkov
@ 2011-10-24 13:01 ` Stefan Monnier
2011-10-24 15:35 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-24 13:01 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
> typing `β' in Info has no effect, it doesn't call `beginning-of-buffer'.
> When typing in Info `C-h k β', it says:
> β is undefined
Ah, thanks, now I see.
So the issue is the following one:
1- keymaps provide a way to hide bindings in parent keymaps (by using an
explicit nil binding), but not to hide a binding in subsequent maps
(e.g. a local map can't hide a binding in the global map).
2- for the main keymaps used to bind keys to commands, we can work around
this limitation by binding the key to the command `undefined'.
3- but function-key-map doesn't know about this convention, so
`undefined' is not recognized as "not bound".
I think it would be good to fix (1), but there are very few keymaps that
are both "special in that the bindings are not commands" and have
a "subsequent keymap" at the same time. Also even if we fix (1), we'd
have to update all the code using `undefined' to use the new special
value (unless we choose `undefined' for that new value, of course).
So I think that fixing (3) is the best choice for now.
Does the patch below work for you?
Stefan
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2011-10-03 20:50:54 +0000
+++ src/keyboard.c 2011-10-24 13:00:50 +0000
@@ -9852,7 +9852,9 @@
}
}
- if (first_binding < nmaps && NILP (submaps[first_binding])
+ if (first_binding < nmaps
+ && NILP (submaps[first_binding])
+ && !EQ (defs[first_binding], Qundefined)
&& indec.start >= t)
/* There is a binding and it's not a prefix.
(and it doesn't have any input-decode-map translation pending).
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 13:01 ` Stefan Monnier
@ 2011-10-24 15:35 ` Juri Linkov
2011-10-24 16:05 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-24 15:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
> So I think that fixing (3) is the best choice for now.
> Does the patch below work for you?
Sorry, it doesn't seem to work. After (define-key function-key-map [?β] [?b]),
typing `β' in Info still does nothing.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 15:35 ` Juri Linkov
@ 2011-10-24 16:05 ` Stefan Monnier
2011-10-24 16:20 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-24 16:05 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
>>>>> "Juri" == Juri Linkov <juri@jurta.org> writes:
>> So I think that fixing (3) is the best choice for now.
>> Does the patch below work for you?
> Sorry, it doesn't seem to work. After (define-key function-key-map [?β] [?b]),
> typing `β' in Info still does nothing.
Oh, yes, it wasn't complete. Here is a more complete one which seems to
work to remap 3 to 4 with 3 globally bound to `undefined'.
Stefan
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2011-10-03 20:50:54 +0000
+++ src/keyboard.c 2011-10-24 16:05:31 +0000
@@ -9852,7 +9852,9 @@
}
}
- if (first_binding < nmaps && NILP (submaps[first_binding])
+ if (first_binding < nmaps
+ && NILP (submaps[first_binding])
+ && !EQ (defs[first_binding], Qundefined)
&& indec.start >= t)
/* There is a binding and it's not a prefix.
(and it doesn't have any input-decode-map translation pending).
@@ -9879,7 +9881,9 @@
/* If there's a binding (i.e.
first_binding >= nmaps) we don't want
to apply this function-key-mapping. */
- fkey.end + 1 == t && first_binding >= nmaps,
+ fkey.end + 1 == t
+ && (first_binding >= nmaps
+ || EQ (defs[first_binding], Qundefined)),
&diff, prompt);
UNGCPRO;
if (done)
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 16:05 ` Stefan Monnier
@ 2011-10-24 16:20 ` Juri Linkov
2011-10-24 20:18 ` Stefan Monnier
0 siblings, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-24 16:20 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
> Oh, yes, it wasn't complete. Here is a more complete one which seems to
> work to remap 3 to 4 with 3 globally bound to `undefined'.
It still does nothing. I guess for testing it, a Greek keyboard layout
is not necessary. It's enough to evaluate:
(define-key function-key-map [?*] [?b])
and typing `*' is expected to run `beginning-of-buffer' in Info.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 16:20 ` Juri Linkov
@ 2011-10-24 20:18 ` Stefan Monnier
2011-10-25 4:33 ` Juri Linkov
2011-10-25 12:54 ` Stefan Monnier
0 siblings, 2 replies; 30+ messages in thread
From: Stefan Monnier @ 2011-10-24 20:18 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
>> Oh, yes, it wasn't complete. Here is a more complete one which seems to
>> work to remap 3 to 4 with 3 globally bound to `undefined'.
> It still does nothing. I guess for testing it, a Greek keyboard layout
> is not necessary. It's enough to evaluate:
> (define-key function-key-map [?*] [?b])
> and typing `*' is expected to run `beginning-of-buffer' in Info.
Oh, right because * is not bound to `undefined', instead it's bound to
self-insert-command which is remapped to `undefined'. Damn!
The patch below at least works for this test case,
Stefan
=== modified file 'src/keyboard.c'
--- src/keyboard.c 2011-10-03 20:50:54 +0000
+++ src/keyboard.c 2011-10-24 20:15:14 +0000
@@ -8902,6 +8902,14 @@
return 0;
}
+static int
+test_undefined (Lisp_Object binding)
+{
+ return (EQ (binding, Qundefined)
+ || (!NILP (binding) && SYMBOLP (binding)
+ && EQ (Fcommand_remapping (binding, Qnil, Qnil), Qundefined)));
+}
+
/* Read a sequence of keys that ends with a non prefix character,
storing it in KEYBUF, a buffer of size BUFSIZE.
Prompt with PROMPT.
@@ -9852,7 +9860,9 @@
}
}
- if (first_binding < nmaps && NILP (submaps[first_binding])
+ if (first_binding < nmaps
+ && NILP (submaps[first_binding])
+ && !test_undefined (defs[first_binding])
&& indec.start >= t)
/* There is a binding and it's not a prefix.
(and it doesn't have any input-decode-map translation pending).
@@ -9879,7 +9889,9 @@
/* If there's a binding (i.e.
first_binding >= nmaps) we don't want
to apply this function-key-mapping. */
- fkey.end + 1 == t && first_binding >= nmaps,
+ fkey.end + 1 == t
+ && (first_binding >= nmaps
+ || test_undefined (defs[first_binding])),
&diff, prompt);
UNGCPRO;
if (done)
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 20:18 ` Stefan Monnier
@ 2011-10-25 4:33 ` Juri Linkov
2011-10-25 12:21 ` Stefan Monnier
2011-10-25 12:54 ` Stefan Monnier
1 sibling, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2011-10-25 4:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
>> (define-key function-key-map [?*] [?b])
>> and typing `*' is expected to run `beginning-of-buffer' in Info.
>
> Oh, right because * is not bound to `undefined', instead it's bound to
> self-insert-command which is remapped to `undefined'. Damn!
> The patch below at least works for this test case,
Thanks, now it works! I tested it with single keys in Dired and Info
and it translates all single keys and runs commands bound to them.
The only case where it still doesn't work is `view-mode'.
For example, on Greek keyboards `;' corresponds to `q',
so it's easier to test with:
(define-key function-key-map [?;] [?q])
Now typing `;' in Info quits it by running `Info-exit',
typing `;' in Dired quits it by running `quit-window'.
But typing `;' in View mode does nothing, it doesn't run `View-quit'.
`C-h k ;' in View mode says:
; runs the command self-insert-command
whereas in other modes (e.g. Dired and Help mode) it says:
q (translated from ;) runs the command quit-window
as expected.
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-25 4:33 ` Juri Linkov
@ 2011-10-25 12:21 ` Stefan Monnier
0 siblings, 0 replies; 30+ messages in thread
From: Stefan Monnier @ 2011-10-25 12:21 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
> But typing `;' in View mode does nothing, it doesn't run `View-quit'.
> `C-h k ;' in View mode says:
> ; runs the command self-insert-command
> whereas in other modes (e.g. Dired and Help mode) it says:
That's because view-mode does not change key-bindings, it just overlays
its own and set buffer-read-only, so ; is still bound to
self-insert-command (which just signals an error).
Changing the keyboard.c code so that function-key-map applies also in
such a case would be pushing it too far.
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-24 20:18 ` Stefan Monnier
2011-10-25 4:33 ` Juri Linkov
@ 2011-10-25 12:54 ` Stefan Monnier
2011-10-25 15:45 ` Juri Linkov
1 sibling, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2011-10-25 12:54 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, Andreas Schwab, 9751-done, Nikos Pitsianis
> The patch below at least works for this test case,
Installed,
Stefan
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-25 12:54 ` Stefan Monnier
@ 2011-10-25 15:45 ` Juri Linkov
0 siblings, 0 replies; 30+ messages in thread
From: Juri Linkov @ 2011-10-25 15:45 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, Andreas Schwab, Nikos Pitsianis, 9751
>> The patch below at least works for this test case,
>
> Installed,
Thanks! This old problem is finally solved:
http://lists.gnu.org/archive/html/emacs-devel/2009-05/msg00091.html
Building the reverse mapping is possible now with a function like:
(defun reverse-input-method (input-method)
"Build the reverse mapping of single letters from INPUT-METHOD."
(interactive
(list (read-input-method-name "Use input method (default current): ")))
(if (and input-method (symbolp input-method))
(setq input-method (symbol-name input-method)))
(let ((current current-input-method)
(modifiers '(nil (control) (meta) (control meta))))
(when input-method
(activate-input-method input-method))
(when (and current-input-method quail-keyboard-layout)
(dolist (map (cdr (quail-map)))
(let* ((to (car map))
(from (quail-get-translation
(cadr map) (char-to-string to) 1)))
(when (and (characterp from) (characterp to))
(dolist (mod modifiers)
(define-key function-key-map
(vector (append mod (list from)))
(vector (append mod (list to)))))))))
(when input-method
(activate-input-method current))))
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2011-10-20 2:10 ` Stefan Monnier
2011-10-20 6:29 ` Juri Linkov
@ 2012-01-12 0:35 ` Juri Linkov
2012-01-12 2:48 ` Stefan Monnier
1 sibling, 1 reply; 30+ messages in thread
From: Juri Linkov @ 2012-01-12 0:35 UTC (permalink / raw)
To: Stefan Monnier; +Cc: lekktu, 9751, Nikos Pitsianis
>>>> What is the way in emacs to alias Ctr-chi to Ctr-x ?
>>> I'd do it in input-decode-map:
>>> (define-key input-decode-map [?\C-χ] [?\C-x])
>>> (define-key input-decode-map [?\C-ψ] [?\C-s])
>> The problem is that this method doesn't work for self-inserting characters,
>> i.e. to be able to handle keybindings that contain characters without
>> modifiers like e.g. `C-x b' we can't use
>> (define-key input-decode-map [?β] [?b])
>
> That's a problem indeed. I guess we can use function-key-map instead, tho.
There is a serious problem with using `function-key-map'. The users who
encrypt gpg files in Emacs, can't decrypt them using command line tools.
The reason is that `epa-encrypt-file' uses `read-passwd' to read
a passphrase for symmetric encryption, but some keys are translated
according to `function-key-map'.
Trying to decrypt the file with command line tools using the same
passphrase fails because command line tools don't use `function-key-map'
translation for passphrases.
This problem can be fixed with the following patch:
=== modified file 'lisp/subr.el'
--- lisp/subr.el 2012-01-07 19:50:04 +0000
+++ lisp/subr.el 2012-01-12 00:34:03 +0000
@@ -2092,6 +2092,7 @@ (defun read-passwd (prompt &optional con
(echo-keystrokes 0)
(cursor-in-echo-area t)
(message-log-max nil)
+ (local-function-key-map nil)
(stop-keys (list 'return ?\r ?\n ?\e))
(rubout-keys (list 'backspace ?\b ?\177)))
(add-text-properties 0 (length prompt)
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2012-01-12 0:35 ` Juri Linkov
@ 2012-01-12 2:48 ` Stefan Monnier
2012-01-12 10:33 ` Juri Linkov
0 siblings, 1 reply; 30+ messages in thread
From: Stefan Monnier @ 2012-01-12 2:48 UTC (permalink / raw)
To: Juri Linkov; +Cc: lekktu, 9751, Nikos Pitsianis
> This problem can be fixed with the following patch:
> === modified file 'lisp/subr.el'
> --- lisp/subr.el 2012-01-07 19:50:04 +0000
> +++ lisp/subr.el 2012-01-12 00:34:03 +0000
> @@ -2092,6 +2092,7 @@ (defun read-passwd (prompt &optional con
> (echo-keystrokes 0)
> (cursor-in-echo-area t)
> (message-log-max nil)
> + (local-function-key-map nil)
> (stop-keys (list 'return ?\r ?\n ?\e))
> (rubout-keys (list 'backspace ?\b ?\177)))
> (add-text-properties 0 (length prompt)
I'd rather not go down that path (it might fix this problem but would
introduce others).
I wrote it too late for 24.1, but I'm using now a version of read-passwd
that uses read-string, so function-key-map (as well as all your familiar
key bindings) works just like for normal text. I think it will fix this
problem in a more satisfactory way (but it's too late for 24.1).
Stefan
(defun read-passwd (prompt &optional confirm default)
"Read a password, prompting with PROMPT, and return it.
If optional CONFIRM is non-nil, read the password twice to make sure.
Optional DEFAULT is a default password to use instead of empty input.
This function echoes `.' for each character that the user types.
Once the caller uses the password, it can erase the password
by doing (clear-string STRING)."
(if confirm
(let (success)
(while (not success)
(let ((first (read-passwd prompt nil default))
(second (read-passwd "Confirm password: " nil default)))
(if (equal first second)
(progn
(and (arrayp second) (clear-string second))
(setq success first))
(and (arrayp first) (clear-string first))
(and (arrayp second) (clear-string second))
(message "Password not repeated accurately; please start over")
(sit-for 1))))
success)
(let (minibuf)
(minibuffer-with-setup-hook
(lambda ()
(setq minibuf (current-buffer))
;; Turn off electricity.
(set (make-local-variable 'post-self-insert-hook) nil)
(add-hook 'after-change-functions
(lambda (beg end len)
(clear-this-command-keys)
(setq beg (min end (max (minibuffer-prompt-end)
beg)))
(dotimes (i (- end beg))
(put-text-property (+ i beg) (+ 1 i beg)
'display (string ?.))))
nil t))
(unwind-protect
(read-string prompt nil
(let ((sym (make-symbol "forget-history")))
(set sym nil)
sym)
default)
(when (buffer-live-p minibuf)
(with-current-buffer minibuf (erase-buffer))))))))
^ permalink raw reply [flat|nested] 30+ messages in thread
* bug#9751: 23.3; Alternative Keyboard Feature/Bug
2012-01-12 2:48 ` Stefan Monnier
@ 2012-01-12 10:33 ` Juri Linkov
0 siblings, 0 replies; 30+ messages in thread
From: Juri Linkov @ 2012-01-12 10:33 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 9751
> I'd rather not go down that path (it might fix this problem but would
> introduce others).
> I wrote it too late for 24.1, but I'm using now a version of read-passwd
> that uses read-string, so function-key-map (as well as all your familiar
> key bindings) works just like for normal text. I think it will fix this
> problem in a more satisfactory way (but it's too late for 24.1).
Thanks, using `read-string' will not translate self-inserting characters
thus it will fix this problem (and also with `read-string' it would be
much more convenient to enter passwords). Waiting for it in 24.2...
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2012-01-12 10:33 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-14 7:05 bug#9751: 23.3; Alternative Keyboard Feature/Bug Nikos Pitsianis
2011-10-14 11:48 ` Juanma Barranquero
2011-10-14 17:06 ` Nikos Pitsianis
2011-10-14 17:21 ` Eli Zaretskii
2011-10-14 17:47 ` Nikos Pitsianis
2011-10-14 18:49 ` Stefan Monnier
2011-10-20 0:12 ` Juri Linkov
2011-10-20 2:10 ` Stefan Monnier
2011-10-20 6:29 ` Juri Linkov
2011-10-20 13:19 ` Stefan Monnier
2011-10-21 14:01 ` Juri Linkov
2011-10-21 17:37 ` Stefan Monnier
2011-10-22 15:36 ` Juri Linkov
2011-10-23 20:08 ` Stefan Monnier
2011-10-23 20:24 ` Andreas Schwab
2011-10-24 3:05 ` Stefan Monnier
2011-10-24 5:17 ` Juri Linkov
2011-10-24 13:01 ` Stefan Monnier
2011-10-24 15:35 ` Juri Linkov
2011-10-24 16:05 ` Stefan Monnier
2011-10-24 16:20 ` Juri Linkov
2011-10-24 20:18 ` Stefan Monnier
2011-10-25 4:33 ` Juri Linkov
2011-10-25 12:21 ` Stefan Monnier
2011-10-25 12:54 ` Stefan Monnier
2011-10-25 15:45 ` Juri Linkov
2012-01-12 0:35 ` Juri Linkov
2012-01-12 2:48 ` Stefan Monnier
2012-01-12 10:33 ` Juri Linkov
2011-10-14 19:19 ` Juanma Barranquero
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).