GNU bug report logs - #9751
23.3; Alternative Keyboard Feature/Bug

Previous Next

Package: emacs;

Reported by: Nikos Pitsianis <nikos <at> cs.duke.edu>

Date: Fri, 14 Oct 2011 07:19:02 UTC

Severity: normal

Found in version 23.3

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9751 in the body.
You can then email your comments to 9751 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 07:19:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nikos Pitsianis <nikos <at> cs.duke.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 14 Oct 2011 07:19:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nikos Pitsianis <nikos <at> cs.duke.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 10:05:10 +0300
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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 11:50:01 GMT) Full text and rfc822 format available.

Message #8 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Nikos Pitsianis <nikos <at> cs.duke.edu>
Cc: 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 13:48:01 +0200
On Fri, Oct 14, 2011 at 09:05, Nikos Pitsianis <nikos <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 17:08:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nikos Pitsianis <nikos <at> cs.duke.edu>
To: Juanma Barranquero <lekktu <at> gmail.com>
Cc: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 20:06:49 +0300
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 <at> 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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 17:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nikos Pitsianis <nikos <at> cs.duke.edu>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 19:21:19 +0200
> From: Nikos Pitsianis <nikos <at> cs.duke.edu>
> Date: Fri, 14 Oct 2011 20:06:49 +0300
> Cc: 9751 <at> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 17:48:01 GMT) Full text and rfc822 format available.

Message #17 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Nikos Pitsianis <nikos <at> cs.duke.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 20:47:12 +0300
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 <at> cs.duke.edu>
>> Date: Fri, 14 Oct 2011 20:06:49 +0300
>> Cc: 9751 <at> 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.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 18:51:01 GMT) Full text and rfc822 format available.

Message #20 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Nikos Pitsianis <nikos <at> cs.duke.edu>
Cc: lekktu <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 14:49:26 -0400
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 14 Oct 2011 19:21:01 GMT) Full text and rfc822 format available.

Message #23 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Nikos Pitsianis <nikos <at> cs.duke.edu>
Cc: 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 14 Oct 2011 21:19:09 +0200
On Fri, Oct 14, 2011 at 19:06, Nikos Pitsianis <nikos <at> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 20 Oct 2011 00:16:01 GMT) Full text and rfc822 format available.

Message #26 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Thu, 20 Oct 2011 03:12:31 +0300
>> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 20 Oct 2011 02:12:01 GMT) Full text and rfc822 format available.

Message #29 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Wed, 19 Oct 2011 22:10:05 -0400
>>> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 20 Oct 2011 06:43:01 GMT) Full text and rfc822 format available.

Message #32 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Thu, 20 Oct 2011 09:29:54 +0300
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 20 Oct 2011 13:21:02 GMT) Full text and rfc822 format available.

Message #35 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Thu, 20 Oct 2011 09:19:09 -0400
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 21 Oct 2011 14:13:02 GMT) Full text and rfc822 format available.

Message #38 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 21 Oct 2011 17:01:33 +0300
>> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Fri, 21 Oct 2011 17:39:02 GMT) Full text and rfc822 format available.

Message #41 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Fri, 21 Oct 2011 13:37:06 -0400
> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Sat, 22 Oct 2011 15:44:02 GMT) Full text and rfc822 format available.

Message #44 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Sat, 22 Oct 2011 18:36:54 +0300
>> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Sun, 23 Oct 2011 20:11:02 GMT) Full text and rfc822 format available.

Message #47 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Sun, 23 Oct 2011 16:08:37 -0400
>>> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Sun, 23 Oct 2011 20:27:02 GMT) Full text and rfc822 format available.

Message #50 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Juri Linkov <juri <at> jurta.org>, lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org,
	Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Sun, 23 Oct 2011 22:24:59 +0200
Stefan Monnier <monnier <at> 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 <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 03:08:01 GMT) Full text and rfc822 format available.

Message #53 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Juri Linkov <juri <at> jurta.org>, lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org,
	Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Sun, 23 Oct 2011 23:05:49 -0400
>> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 05:26:02 GMT) Full text and rfc822 format available.

Message #56 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 08:17:31 +0300
>>> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 13:04:01 GMT) Full text and rfc822 format available.

Message #59 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 09:01:33 -0400
> 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).





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 15:40:01 GMT) Full text and rfc822 format available.

Message #62 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 18:35:46 +0300
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 16:08:02 GMT) Full text and rfc822 format available.

Message #65 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 12:05:52 -0400
>>>>> "Juri" == Juri Linkov <juri <at> 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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 16:25:01 GMT) Full text and rfc822 format available.

Message #68 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 19:20:42 +0300
> 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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Mon, 24 Oct 2011 20:21:01 GMT) Full text and rfc822 format available.

Message #71 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Mon, 24 Oct 2011 16:18:20 -0400
>> 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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Tue, 25 Oct 2011 04:39:01 GMT) Full text and rfc822 format available.

Message #74 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Tue, 25 Oct 2011 07:33:46 +0300
>> (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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Tue, 25 Oct 2011 12:24:02 GMT) Full text and rfc822 format available.

Message #77 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Tue, 25 Oct 2011 08:21:27 -0400
> 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




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Tue, 25 Oct 2011 12:57:02 GMT) Full text and rfc822 format available.

Notification sent to Nikos Pitsianis <nikos <at> cs.duke.edu>:
bug acknowledged by developer. (Tue, 25 Oct 2011 12:57:02 GMT) Full text and rfc822 format available.

Message #82 received at 9751-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	9751-done <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Tue, 25 Oct 2011 08:54:41 -0400
> The patch below at least works for this test case,

Installed,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Tue, 25 Oct 2011 15:58:02 GMT) Full text and rfc822 format available.

Message #85 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, Andreas Schwab <schwab <at> linux-m68k.org>,
	Nikos Pitsianis <nikos <at> cs.duke.edu>, 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Tue, 25 Oct 2011 18:45:01 +0300
>> 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))))




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 23 Nov 2011 12:24:02 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Juri Linkov <juri <at> jurta.org> to control <at> debbugs.gnu.org. (Thu, 12 Jan 2012 00:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 12 Jan 2012 00:42:02 GMT) Full text and rfc822 format available.

Message #92 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Thu, 12 Jan 2012 02:35:54 +0200
>>>> 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)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 12 Jan 2012 02:49:02 GMT) Full text and rfc822 format available.

Message #95 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> jurta.org>
Cc: lekktu <at> gmail.com, 9751 <at> debbugs.gnu.org, Nikos Pitsianis <nikos <at> cs.duke.edu>
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Wed, 11 Jan 2012 21:48:24 -0500
> 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))))))))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#9751; Package emacs. (Thu, 12 Jan 2012 10:38:02 GMT) Full text and rfc822 format available.

Message #98 received at 9751 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 9751 <at> debbugs.gnu.org
Subject: Re: bug#9751: 23.3; Alternative Keyboard Feature/Bug
Date: Thu, 12 Jan 2012 12:33:48 +0200
> 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...




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 09 Feb 2012 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.