Re: [PATCH v2 4/5] emacs: help: add a special function to deal with remaps
authorAustin Clements <amdragon@MIT.EDU>
Fri, 8 Nov 2013 03:35:51 +0000 (22:35 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:05 +0000 (09:58 -0800)
4a/0064e1faf7304d697ac54d67e9ca408e7615b9 [new file with mode: 0644]

diff --git a/4a/0064e1faf7304d697ac54d67e9ca408e7615b9 b/4a/0064e1faf7304d697ac54d67e9ca408e7615b9
new file mode 100644 (file)
index 0000000..adcdcfa
--- /dev/null
@@ -0,0 +1,145 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 6A7CD431FC4\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Nov 2013 19:36:01 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id ZmIR81r+OZWw for <notmuch@notmuchmail.org>;\r
+       Thu,  7 Nov 2013 19:35:54 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+       [18.7.68.35])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 6E82A431FC0\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Nov 2013 19:35:54 -0800 (PST)\r
+X-AuditID: 12074423-b7fac8e00000539e-76-527c5c1941da\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       (using TLS with cipher AES256-SHA (256/256 bits))\r
+       (Client did not present a certificate)\r
+       by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id AF.B5.21406.91C5C725; Thu,  7 Nov 2013 22:35:53 -0500 (EST)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id rA83ZqLm018781; \r
+       Thu, 7 Nov 2013 22:35:53 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id rA83ZpaK028005\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Thu, 7 Nov 2013 22:35:52 -0500\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1VecrP-0006Ut-3p; Thu, 07 Nov 2013 22:35:51 -0500\r
+Date: Thu, 7 Nov 2013 22:35:51 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Mark Walters <markwalters1009@gmail.com>\r
+Subject: Re: [PATCH v2 4/5] emacs: help: add a special function to deal with\r
+       remaps\r
+Message-ID: <20131108033551.GM29298@mit.edu>\r
+References: <1383870096-14627-1-git-send-email-markwalters1009@gmail.com>\r
+       <1383870096-14627-5-git-send-email-markwalters1009@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <1383870096-14627-5-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42IRYrdT15WMqQkyOPRW3WL1XB6L6zdnMjsw\r
+       eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGY9uT2Et+CtUsXxddgPjGb4uRk4OCQETiTsH\r
+       FrBC2GISF+6tZ+ti5OIQEpjNJHGn4zUrhLOBUWLm1l4WCOcUk8SpHZOhypYwSrxZtAusn0VA\r
+       ReL3nLuMIDabgIbEtv3LwWwRAR2J24cWsIPYzALSEt9+NzOB2MICoRLv5s0Ci/MC1fx5t4Ud\r
+       Ymgno8S6p+1sEAlBiZMzn7BANGtJ3Pj3EqiZA2zQ8n8cIGFOAS+JMydXgu0SBbphysltbBMY\r
+       hWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFumZ6uZkleqkppZsYwWHtoryD\r
+       8c9BpUOMAhyMSjy8Jy5VBwmxJpYVV+YeYpTkYFIS5VUKqgkS4kvKT6nMSCzOiC8qzUktPsQo\r
+       wcGsJML7TBEox5uSWFmVWpQPk5LmYFES573FYR8kJJCeWJKanZpakFoEk5Xh4FCS4H0eBdQo\r
+       WJSanlqRlplTgpBm4uAEGc4DNPwGSA1vcUFibnFmOkT+FKOilDgvezRQQgAkkVGaB9cLSzuv\r
+       GMWBXhGGWMEDTFlw3a+ABjMBDQ75VQkyuCQRISXVwGgkHrmiY0OMbt7G+DXvfm/9G3x04n7m\r
+       FU+uZ9l/75+96DRjde/n96UfjASv3LjJHLWjL/6DvkbE3D0197w+hKgIHWUvSV6RMf/oy6z9\r
+       idm/VgRs+SX9YtmGsyUxE83ylldbOO3mmHqlaPppwcnLxWfKWazyuFN0PqWx95ZK5zGrH9PT\r
+       MpZdWfhKiaU4I9FQi7moOBEAx2mAJxYDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 08 Nov 2013 03:36:01 -0000\r
+\r
+I like the way you separated this out.\r
+\r
+Quoth Mark Walters on Nov 08 at 12:21 am:\r
+> remaps are a rather unusual keymap consisting of "first key" 'remap\r
+> and then "second-key" the remapped-function. Thus we do the\r
+> documentation for it separately.\r
+> ---\r
+>  emacs/notmuch-lib.el |   25 ++++++++++++++++++++++---\r
+>  1 files changed, 22 insertions(+), 3 deletions(-)\r
+> \r
+> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+> index 8852703..ef616d5 100644\r
+> --- a/emacs/notmuch-lib.el\r
+> +++ b/emacs/notmuch-lib.el\r
+> @@ -261,6 +261,21 @@ It does not prepend if ACTUAL-KEY is already listed in TAIL."\r
+>          tail)))\r
+>      tail)\r
+>  \r
+> +(defun notmuch-describe-remaps (remap-keymap ua-keys prefix tail)\r
+> +  ;; Remappings are represented as a binding whose first "event" is\r
+> +  ;; 'remap.  Hence, if the keymap has any remappings, it will have a\r
+> +  ;; binding whose "key" is 'remap, and whose "binding" is itself a\r
+> +  ;; keymap that maps not from keys to commands, but from old (remapped)\r
+> +  ;; functions to the commands to use in their stead.\r
+> +  (map-keymap\r
+> +   (lambda (command binding)\r
+> +     (mapc\r
+> +      (lambda (actual-key)\r
+> +    (setq tail (notmuch-describe-key actual-key binding prefix ua-keys tail)))\r
+> +      (where-is-internal command)))\r
+> +   remap-keymap)\r
+> +  tail)\r
+> +\r
+\r
+Hmm.  Maybe holistically the interface change I suggested to the\r
+previous patch isn't the right thing to do, since there ends up being\r
+a lot of symmetry between these three functions.\r
+\r
+>  (defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)\r
+>    "Return a list of cons cells, each describing one binding in KEYMAP.\r
+>  \r
+> @@ -276,9 +291,13 @@ prefix argument.  PREFIX and TAIL are used internally."\r
+>     (lambda (key binding)\r
+>       (cond ((mouse-event-p key) nil)\r
+>         ((keymapp binding)\r
+> -        (setq tail\r
+> -              (notmuch-describe-keymap\r
+> -               binding ua-keys (notmuch-prefix-key-description key) tail)))\r
+> +        (if (eq key 'remap)\r
+> +            (setq tail\r
+> +                  (notmuch-describe-remaps\r
+> +                   binding ua-keys prefix tail))\r
+> +          (setq tail\r
+> +                (notmuch-describe-keymap\r
+> +                 binding ua-keys (notmuch-prefix-key-description key) tail))))\r
+\r
+Maybe swap the if and the setq?\r
+\r
+(setq tail (if (eq key 'remap) ...))\r
+\r
+>         (binding\r
+>          (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail)))))\r
+>     keymap)\r