From beaac63118b3e80210d46376e409f2f8ec3676dd Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 9 Nov 2013 15:00:16 +1900 Subject: [PATCH] Re: [PATCH v3 0/7] emacs: help: remap keybindings --- d0/6296238688be3d23bb0adfb9d4cf5117fe1bf9 | 174 ++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 d0/6296238688be3d23bb0adfb9d4cf5117fe1bf9 diff --git a/d0/6296238688be3d23bb0adfb9d4cf5117fe1bf9 b/d0/6296238688be3d23bb0adfb9d4cf5117fe1bf9 new file mode 100644 index 000000000..2f7f3b4c6 --- /dev/null +++ b/d0/6296238688be3d23bb0adfb9d4cf5117fe1bf9 @@ -0,0 +1,174 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1895D429E2E + for ; Fri, 8 Nov 2013 12:00:28 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id m+2bPpDWYvBM for ; + Fri, 8 Nov 2013 12:00:20 -0800 (PST) +Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu + [18.9.25.15]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 94EF4429E35 + for ; Fri, 8 Nov 2013 12:00:20 -0800 (PST) +X-AuditID: 1209190f-b7f7b8e0000053dd-5a-527d42d342d3 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 6F.70.21469.3D24D725; Fri, 8 Nov 2013 15:00:19 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id rA8K0IHv002993; + Fri, 8 Nov 2013 15:00:19 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id rA8K0GAx022589 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Fri, 8 Nov 2013 15:00:17 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1VesE4-0002xQ-8f; Fri, 08 Nov 2013 15:00:16 -0500 +Date: Fri, 8 Nov 2013 15:00:16 -0500 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH v3 0/7] emacs: help: remap keybindings +Message-ID: <20131108200016.GN29298@mit.edu> +References: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFvrHIsWRmVeSWpSXmKPExsUixCmqrXvZqTbI4NUUE4vVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZexdc5elYLpCxaVfGg2M7ZJdjJwcEgImEiee + 7mSHsMUkLtxbz9bFyMUhJDCbSeLDu4VgCSGBDYwSb5cYQiROMUksWjybHcJZwijRvPEEG0gV + i4CKxP53y8E62AQ0JLbtX84IYosI6EjcPrQALM4sIC3x7XczUxcjB4ewgJXEnV92IGFeoJKX + /c+YQcJCAp4SD/ZZQ4QFJU7OfMIC0aklcePfS7BOkCnL/3GAmJwCXhJvrySDVIgC7Z9ychvb + BEahWUiaZyFpnoXQvICReRWjbEpulW5uYmZOcWqybnFyYl5eapGuiV5uZoleakrpJkZwMEvy + 72D8dlDpEKMAB6MSD+8PjdogIdbEsuLK3EOMkhxMSqK8W62BQnxJ+SmVGYnFGfFFpTmpxYcY + JTiYlUR4S1WAcrwpiZVVqUX5MClpDhYlcd6bHPZBQgLpiSWp2ampBalFMFkZDg4lCd55jkCN + gkWp6akVaZk5JQhpJg5OkOE8QMPdQGp4iwsSc4sz0yHypxgVpcR5lYHpQkgAJJFRmgfXC0s2 + rxjFgV4R5v0N0s4DTFRw3a+ABjMBDQ75VQkyuCQRISXVwGgY/bp/eUN5pejBCXPX+kaJvj9c + VRrkwbDI5XNBv+KqNYY/a4+z3nnk1+l18JrC1qUcyRJZXvwCsT3JfApfpjfWzX7dtHJ5lv+X + kMtznm76c0hH8pPPpEjGs76nJuUv1f1XtWhZmdsi24kn2eNrL/14/XFiQtuZ97fiAs5eNPzZ + UPr3oIaD0yolluKMREMt5qLiRADVlghDEQMAAA== +Cc: notmuch@notmuchmail.org +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Fri, 08 Nov 2013 20:00:28 -0000 + +LGTM. + +Quoth Mark Walters on Nov 08 at 5:40 pm: +> This is version 3 of the series. v2 is at +> id:1383870096-14627-1-git-send-email-markwalters1009@gmail.com +> +> The changes are in response to Austin's review of v2. I have not +> changed notmuch-describe-key. +> +> The other change is to add a base-keymap to look up the remapped +> commands in (since notmuch-substitute-command-keys could refer to +> something other than the current keymap). Currently this never happens +> but this makes the code more robust. +> +> The final patch of the series is (probably) just for testing +> purposes. It lets you call notmuch-help and specify which mode you +> want to display help for. This means you can call it without having +> the mode as current-mode and hence test the base-keymap code. +> +> Finally the diff from v2 below (with the testing patch omitted) is below. +> +> Best wishes +> +> Mark +> +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index ef616d5..4b3a86e 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -261,7 +261,7 @@ It does not prepend if ACTUAL-KEY is already listed in TAIL." +> tail))) +> tail) +> +> -(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail) +> +(defun notmuch-describe-remaps (remap-keymap ua-keys base-keymap prefix tail) +> ;; Remappings are represented as a binding whose first "event" is +> ;; 'remap. Hence, if the keymap has any remappings, it will have a +> ;; binding whose "key" is 'remap, and whose "binding" is itself a +> @@ -272,11 +272,11 @@ It does not prepend if ACTUAL-KEY is already listed in TAIL." +> (mapc +> (lambda (actual-key) +> (setq tail (notmuch-describe-key actual-key binding prefix ua-keys tail))) +> - (where-is-internal command))) +> + (where-is-internal command base-keymap))) +> remap-keymap) +> tail) +> +> -(defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail) +> +(defun notmuch-describe-keymap (keymap ua-keys base-keymap &optional prefix tail) +> "Return a list of cons cells, each describing one binding in KEYMAP. +> +> Each cons cell consists of a string giving a human-readable +> @@ -291,13 +291,12 @@ prefix argument. PREFIX and TAIL are used internally." +> (lambda (key binding) +> (cond ((mouse-event-p key) nil) +> ((keymapp binding) +> - (if (eq key 'remap) +> - (setq tail +> + (setq tail +> + (if (eq key 'remap) +> (notmuch-describe-remaps +> - binding ua-keys prefix tail)) +> - (setq tail +> + binding ua-keys base-keymap prefix tail) +> (notmuch-describe-keymap +> - binding ua-keys (notmuch-prefix-key-description key) tail)))) +> + binding ua-keys base-keymap (notmuch-prefix-key-description key) tail)))) +> (binding +> (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail))))) +> keymap) +> @@ -310,7 +309,7 @@ prefix argument. PREFIX and TAIL are used internally." +> (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1))) +> (keymap (symbol-value (intern keymap-name))) +> (ua-keys (where-is-internal 'universal-argument keymap t)) +> - (desc-alist (notmuch-describe-keymap keymap ua-keys)) +> + (desc-alist (notmuch-describe-keymap keymap ua-keys keymap)) +> (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist)) +> (desc (mapconcat #'identity desc-list "\n"))) +> (setq doc (replace-match desc 1 1 doc))) +> +> +> +> Mark Walters (7): +> emacs: help: check for nil key binding +> emacs: help: remove duplicate bindings +> emacs: help: split out notmuch-describe-key as a function +> emacs: help: add base-keymap +> emacs: help: add a special function to deal with remaps +> emacs: tree: use remap for the over-ridden global bindings +> emacs: help: base-keymap-test-help +> +> emacs/notmuch-lib.el | 79 ++++++++++++++++++++++++++++++++++-------------- +> emacs/notmuch-tree.el | 8 ++-- +> 2 files changed, 60 insertions(+), 27 deletions(-) -- 2.26.2