[PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a function
authorMark Walters <markwalters1009@gmail.com>
Fri, 8 Nov 2013 17:40:15 +0000 (17:40 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:06 +0000 (09:58 -0800)
e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 [new file with mode: 0644]

diff --git a/e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 b/e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8
new file mode 100644 (file)
index 0000000..cc769e0
--- /dev/null
@@ -0,0 +1,134 @@
+Return-Path: <markwalters1009@gmail.com>\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 BCBC6429E4B\r
+       for <notmuch@notmuchmail.org>; Fri,  8 Nov 2013 09:40:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       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 zCOIkIw9nbNy for <notmuch@notmuchmail.org>;\r
+       Fri,  8 Nov 2013 09:40:35 -0800 (PST)\r
+Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com\r
+       [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 1600B431E84\r
+       for <notmuch@notmuchmail.org>; Fri,  8 Nov 2013 09:40:28 -0800 (PST)\r
+Received: by mail-wi0-f176.google.com with SMTP id m19so620047wiv.15\r
+       for <notmuch@notmuchmail.org>; Fri, 08 Nov 2013 09:40:27 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+       bh=N4YMpZq/47KojcpG7f1UnE8UkxVX65eUWBrE04y5R88=;\r
+       b=cSdkGj/5vHar1L5QPvVqjup5rnhXGabY60Fx4Z1odC3bJPtoZjRe/pGDzJm9lgvNgI\r
+       imK+uE8DUgtyH8ho+nyh7Ah7ke5OEUqZMCY9ieqneEa7m1W8/jLoG/aR7DR5UgL2d1pA\r
+       d0C4LhXvSApTfDHMsA7llj+1XV4UE2ypoAFBSkyAzKiNwrxmnKFImyN8tgIC7tM+hm8B\r
+       PsDLKvYPDKI1Ek4Czpb3aoxslcs4JuPk4IvJr35i+KLPHWuCA5M10oOCsr3h8V+t+gk0\r
+       g7B9HiCrVnnlLMwqGDvkEHJNYVPyUUw3ZIyRkRH7T20A1a2+Kzhos8R83DqgSpr6aqnL\r
+       dt+Q==\r
+X-Received: by 10.194.110.138 with SMTP id ia10mr9470589wjb.3.1383932427954;\r
+       Fri, 08 Nov 2013 09:40:27 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPSA id mw9sm8556740wib.0.2013.11.08.09.40.27\r
+       for <multiple recipients>\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Fri, 08 Nov 2013 09:40:27 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a\r
+       function\r
+Date: Fri,  8 Nov 2013 17:40:15 +0000\r
+Message-Id: <1383932419-12533-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com>\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 17:40:42 -0000\r
+\r
+The actual documentation function notmuch-describe-keymap was getting\r
+rather complicated so split out the code for a single key into its own\r
+function notmuch-describe-key.\r
+---\r
+ emacs/notmuch-lib.el |   42 +++++++++++++++++++++++++-----------------\r
+ 1 files changed, 25 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 2195166..8852703 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -237,6 +237,30 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."\r
+       "M-"\r
+       (concat desc " "))))\r
\r
++\r
++(defun notmuch-describe-key (actual-key binding prefix ua-keys tail)\r
++  "Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL\r
++\r
++It does not prepend if ACTUAL-KEY is already listed in TAIL."\r
++  (let ((key-string (concat prefix (format-kbd-macro actual-key))))\r
++    ;; We don't include documentation if the key-binding is\r
++    ;; over-ridden. Note, over-riding a binding automatically hides the\r
++    ;; prefixed version too.\r
++    (unless (assoc key-string tail)\r
++      (when (and ua-keys (symbolp binding)\r
++               (get binding 'notmuch-prefix-doc))\r
++      ;; Documentation for prefixed command\r
++      (let ((ua-desc (key-description ua-keys)))\r
++        (push (cons (concat ua-desc " " prefix (format-kbd-macro actual-key))\r
++                    (get binding 'notmuch-prefix-doc))\r
++              tail)))\r
++      ;; Documentation for command\r
++      (push (cons key-string\r
++                (or (and (symbolp binding) (get binding 'notmuch-doc))\r
++                    (notmuch-documentation-first-line binding)))\r
++          tail)))\r
++    tail)\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
+@@ -256,23 +280,7 @@ prefix argument.  PREFIX and TAIL are used internally."\r
+                 (notmuch-describe-keymap\r
+                  binding ua-keys (notmuch-prefix-key-description key) tail)))\r
+          (binding\r
+-          (let ((key-string (concat prefix (format-kbd-macro (vector key)))))\r
+-            ;; We don't include documentation if the key-binding is\r
+-            ;; over-ridden. Note, over-riding a binding\r
+-            ;; automatically hides the prefixed version too.\r
+-            (unless (assoc key-string tail)\r
+-              (when (and ua-keys (symbolp binding)\r
+-                         (get binding 'notmuch-prefix-doc))\r
+-                ;; Documentation for prefixed command\r
+-                (let ((ua-desc (key-description ua-keys)))\r
+-                  (push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key)))\r
+-                              (get binding 'notmuch-prefix-doc))\r
+-                        tail)))\r
+-              ;; Documentation for command\r
+-              (push (cons key-string\r
+-                          (or (and (symbolp binding) (get binding 'notmuch-doc))\r
+-                              (notmuch-documentation-first-line binding)))\r
+-                    tail))))))\r
++          (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail)))))\r
+    keymap)\r
+   tail)\r
\r
+-- \r
+1.7.9.1\r
+\r