From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Possible emacs bug when type password fields Date: Fri, 01 May 2009 15:57:32 -0400 Message-ID: References: <1f62569f0905010413k13fde32fsbcd1ebef8f872516@mail.gmail.com> <20090501.184211.227773522.hanche@math.ntnu.no> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1241207874 19596 80.91.229.12 (1 May 2009 19:57:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 May 2009 19:57:54 +0000 (UTC) Cc: borja.tarraso.hueso@googlemail.com, emacs-devel@gnu.org To: Harald Hanche-Olsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 01 21:57:46 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lzyrg-0007Vw-Th for ged-emacs-devel@m.gmane.org; Fri, 01 May 2009 21:57:45 +0200 Original-Received: from localhost ([127.0.0.1]:53360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lzyrg-0005lb-Ca for ged-emacs-devel@m.gmane.org; Fri, 01 May 2009 15:57:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lzyrc-0005lS-1W for emacs-devel@gnu.org; Fri, 01 May 2009 15:57:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LzyrX-0005kv-M5 for emacs-devel@gnu.org; Fri, 01 May 2009 15:57:39 -0400 Original-Received: from [199.232.76.173] (port=45803 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LzyrX-0005ko-CM for emacs-devel@gnu.org; Fri, 01 May 2009 15:57:35 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:53787) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LzyrW-00036H-T9 for emacs-devel@gnu.org; Fri, 01 May 2009 15:57:35 -0400 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id n41JvYMs017150; Fri, 1 May 2009 15:57:34 -0400 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 816443A2EA; Fri, 1 May 2009 15:57:32 -0400 (EDT) In-Reply-To: <20090501.184211.227773522.hanche@math.ntnu.no> (Harald Hanche-Olsen's message of "Fri, 01 May 2009 18:42:11 +0200 (CEST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3266=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:110592 Archived-At: >> I was wondering if this is a known issue or not, but it seems some emacs >> bug, when I tried M-x gnus or M-x erc or any other feature in emacs (it >> means that is not emacs specific feature bug) I cannot use num keypad to >> type the password field. I tried in two different computers, with two >> different emacs versions, and different features, with same results. Can you try the patch below? I don't have any keyboard with a numeric keypad any more ;-) Note that this patch is not acceptable for Emacs-23.1 (which is now too far in the pretest phase for such a change). Stefan --- subr.el.~1.636.~ 2009-04-20 12:12:55.000000000 -0400 +++ subr.el 2009-05-01 15:52:48.000000000 -0400 @@ -1728,6 +1728,47 @@ ;;;; Input and display facilities. +(defconst read-key-empty-map (make-sparse-keymap)) +(defvar read-key-delay 0.1) + +(defun read-key (&optional prompt) + "Read a key from the keyboard. +Contrary to `read-event' this will not return a raw event but instead will +obey the input decoding and translations usually done by `read-key-sequence'. +So escape sequences and keyboard encoding are taken into account. +When there's an ambiguity because the key looks like the prefix of +some sort of escape sequence, the ambiguity is resolved via `read-key-delay'." + (let ((overriding-terminal-local-map read-key-empty-map) + (overriding-local-map nil) + (old-global-map (current-global-map)) + (timer (run-with-idle-timer + ;; Wait long enough that Emacs has the time to receive and + ;; process all the raw events associated with the single-key. + ;; But don't wait too long, or the user may find the delay + ;; annoying (or keep hitting more keys which may then get + ;; lost or misinterpreted). + ;; This is only relevant for keys which Emacs perceives as + ;; "prefixes", such as C-x (because of the C-x 8 map in + ;; key-translate-table and the C-x @ map in function-key-map) + ;; or ESC (because of terminal escape sequences in + ;; input-decode-map). + read-key-delay t + (lambda () + (let ((keys (this-command-keys-vector))) + (unless (zerop (length keys)) + ;; `keys' is non-empty, so the user has hit at least + ;; one key; there's no point waiting any longer, even + ;; though read-key-sequence thinks we should wait + ;; for more input to decide how to interpret the + ;; current input. + (throw 'read-key keys))))))) + (unwind-protect + (progn + (use-global-map read-key-empty-map) + (aref (catch 'read-key (read-key-sequence prompt nil t)) 0)) + (cancel-timer timer) + (use-global-map old-global-map)))) + (defvar read-quoted-char-radix 8 "*Radix for \\[quoted-insert] and other uses of `read-quoted-char'. Legitimate radix values are 8, 10 and 16.") @@ -1844,10 +1885,7 @@ (while (progn (message "%s%s" prompt (make-string (length pass) ?.)) - ;; We used to use read-char-exclusive, but that - ;; gives funny behavior when the user presses, - ;; e.g., the arrow keys. - (setq c (read-event nil t)) + (setq c (read-key)) (not (memq c stop-keys))) (clear-this-command-keys) (cond ((memq c rubout-keys) ; rubout