From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.bugs Subject: bug#19268: 25.0.50; Customize widgets vs keys Date: Fri, 05 Dec 2014 07:35:52 +0100 Message-ID: <87y4qmr4c7.fsf@yahoo.fr> References: <8761dr8tdj.fsf@yahoo.fr> <83mw7349m2.fsf@gnu.org> <878uins0qp.fsf@yahoo.fr> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1417761443 30251 80.91.229.3 (5 Dec 2014 06:37:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Dec 2014 06:37:23 +0000 (UTC) Cc: 19268@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 05 07:37:16 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XwmVv-0002Fp-U6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Dec 2014 07:37:16 +0100 Original-Received: from localhost ([::1]:49024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwmVv-0006A7-Cm for geb-bug-gnu-emacs@m.gmane.org; Fri, 05 Dec 2014 01:37:15 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwmVn-00069x-MA for bug-gnu-emacs@gnu.org; Fri, 05 Dec 2014 01:37:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwmVi-0004MJ-Ra for bug-gnu-emacs@gnu.org; Fri, 05 Dec 2014 01:37:07 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57011) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwmVi-0004M9-Nk for bug-gnu-emacs@gnu.org; Fri, 05 Dec 2014 01:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XwmVi-0007kk-9N for bug-gnu-emacs@gnu.org; Fri, 05 Dec 2014 01:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Nicolas Richard Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 Dec 2014 06:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19268 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 19268-submit@debbugs.gnu.org id=B19268.141776136329730 (code B ref 19268); Fri, 05 Dec 2014 06:37:02 +0000 Original-Received: (at 19268) by debbugs.gnu.org; 5 Dec 2014 06:36:03 +0000 Original-Received: from localhost ([127.0.0.1]:54224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwmUk-0007jS-Uv for submit@debbugs.gnu.org; Fri, 05 Dec 2014 01:36:03 -0500 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:53830) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwmUc-0007iv-Nh for 19268@debbugs.gnu.org; Fri, 05 Dec 2014 01:36:01 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsoEACxRgVSkD4Xn/2dsb2JhbABZhDCzOwEBAQaZFgKBNAEBAQEBfYQCAQEBBHkQCAMRAwECCiUPAQQ7DhOIJQEDEsFnjigBhkoBAQEBAQEBAwEBAQEBARyGJ4I6hUGCLQeENgWEUQZ/kh+BY4EigxKCLDSGGoYPg3A+MIEDBIE8AQEB Original-Received: from pno-math-231.ulb.ac.be (HELO LDLC-portable) ([164.15.133.231]) by smtp.ulb.ac.be with ESMTP; 05 Dec 2014 07:35:53 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 04 Dec 2014 15:35:03 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96880 Archived-At: Stefan Monnier writes: >> (define-key map [t] 'keyboard-quit) > > This is the culprit: such a default binding prevents function-key-map > from being applied, since all keys have a (default) binding. > And the remapping of [kp-5] to [?5] is done in function-key-map. > > So the fix should probably start by removing this default binding. I now realize that the fix to most of my problems is (setq widget-menu-minibuffer-flag t), but here's a fix to the reported bug. Please let me know what you think. FWIW, I do not like that scroll-other-window and negative-argument are special-cased but I don't know what to do with them atm. >From dfbfebd1f403fd566fcffb5448b0450c7d2e746b Mon Sep 17 00:00:00 2001 From: Nicolas Richard Date: Fri, 5 Dec 2014 07:29:26 +0100 Subject: [PATCH] (widget-choose) Let numeric keypad work Fixes: debbugs:19268 * wid-edit.el (widget-choose): Let numeric keypad work and remove old menu-related code. --- lisp/ChangeLog | 5 ++++ lisp/wid-edit.el | 69 +++++++++++++++++++++----------------------------------- 2 files changed, 31 insertions(+), 43 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 26572c3..40dd453 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-12-05 Nicolas Richard + + * wid-edit.el (widget-choose): Let numeric keypad work (bug#19268) + and remove old menu-related code. + 2014-12-05 Juri Linkov Compare with the most recent window by default. diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 92e52bf..e901431 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el @@ -232,23 +232,20 @@ minibuffer." (t ;; Construct a menu of the choices ;; and then use it for prompting for a single character. - (let* ((overriding-terminal-local-map (make-sparse-keymap)) - (next-digit ?0) - map choice some-choice-enabled value) - ;; Define SPC as a prefix char to get to this menu. - (define-key overriding-terminal-local-map " " - (setq map (make-sparse-keymap title))) + (let* ((next-digit ?0) + (map (make-sparse-keymap)) + choice some-choice-enabled value) (with-current-buffer (get-buffer-create " widget-choose") (erase-buffer) (insert "Available choices:\n\n") (while items - (setq choice (car items) items (cdr items)) - (if (consp choice) - (let* ((name (car choice)) - (function (cdr choice))) - (insert (format "%c = %s\n" next-digit name)) - (define-key map (vector next-digit) function) - (setq some-choice-enabled t))) + (setq choice (pop items)) + (when (consp choice) + (let* ((name (car choice)) + (function (cdr choice))) + (insert (format "%c = %s\n" next-digit name)) + (define-key map (vector next-digit) function) + (setq some-choice-enabled t))) ;; Allocate digits to disabled alternatives ;; so that the digit of a given alternative never varies. (setq next-digit (1+ next-digit))) @@ -257,43 +254,29 @@ minibuffer." (forward-line)) (or some-choice-enabled (error "None of the choices is currently meaningful")) - (define-key map [?\C-g] 'keyboard-quit) - (define-key map [t] 'keyboard-quit) (define-key map [?\M-\C-v] 'scroll-other-window) (define-key map [?\M--] 'negative-argument) - (setcdr map (nreverse (cdr map))) - ;; Read a char with the menu, and return the result - ;; that corresponds to it. (save-window-excursion (let ((buf (get-buffer " widget-choose"))) (fit-window-to-buffer (display-buffer buf)) (let ((cursor-in-echo-area t) - keys - (char 0) (arg 1)) - (while (not (or (and (integerp char) - (>= char ?0) (< char next-digit)) - (eq value 'keyboard-quit))) - ;; Unread a SPC to lead to our new menu. - (setq unread-command-events (cons ?\s unread-command-events)) - (setq keys (read-key-sequence title)) - (setq value - (lookup-key overriding-terminal-local-map keys t) - char (aref keys 1)) - (cond ((eq value 'scroll-other-window) - (let ((minibuffer-scroll-window - (get-buffer-window buf))) - (if (> 0 arg) - (scroll-other-window-down - (window-height minibuffer-scroll-window)) - (scroll-other-window)) - (setq arg 1))) - ((eq value 'negative-argument) - (setq arg -1)) - (t - (setq arg 1))))))) - (when (eq value 'keyboard-quit) - (error "Canceled")) + (while (not value) + (setq value (lookup-key map (read-key-sequence (format "%s: " title)))) + (unless value + (user-error "Canceled")) + (when + (cond ((eq value 'scroll-other-window) + (let ((minibuffer-scroll-window + (get-buffer-window buf))) + (if (> 0 arg) + (scroll-other-window-down + (window-height minibuffer-scroll-window)) + (scroll-other-window)) + (setq arg 1))) + ((eq value 'negative-argument) + (setq arg -1))) + (setq value nil)))))) value)))) ;;; Widget text specifications. -- 2.0.2 -- Nicolas Richard