--- /dev/null
+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 0D70C429E37\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Nov 2013 09:40:35 -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 dNvnUtZ4lBup for <notmuch@notmuchmail.org>;\r
+ Fri, 8 Nov 2013 09:40:27 -0800 (PST)\r
+Received: from mail-we0-f171.google.com (mail-we0-f171.google.com\r
+ [74.125.82.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 749F6431FD8\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Nov 2013 09:40:27 -0800 (PST)\r
+Received: by mail-we0-f171.google.com with SMTP id t60so2262554wes.2\r
+ for <notmuch@notmuchmail.org>; Fri, 08 Nov 2013 09:40:26 -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=Fm0Ak7Bnh5SyCxrN12BxddioUn35q6zAGzx3BxMSKq8=;\r
+ b=JW1sTRFpbKZm92hKvfYyJuzDKEjDaU3tPpwDhbWa1TJavv+Tm9yjS1zOWHhewmwx6j\r
+ 8cMQQ9sEHvxxJe/BTiIbrbvxjd6P49cKDeU6kN0qF1c90TQziXGUXIPanC3l400B6tBW\r
+ ISf47aJQTfYs8fb6gS6j44TFzQ0FxIsShYIcXxgWoMPH8uSW2X8e3OTMIUCtlG4AcWVJ\r
+ sVW61pJ/lCdIffr3YF0JNbAai+BwKH50N1X8nvUCN/mYRH/ewMh9EjN7L6Sdm3dqJIgw\r
+ ZLM7tdjHvBnx3bpEYjzZ8HJyIZ2WS58UrAd41lzaR7HTwcfkHB8rSTkEDtC7NvpQYvdQ\r
+ n/Ig==\r
+X-Received: by 10.180.182.47 with SMTP id eb15mr1661244wic.51.1383932426453;\r
+ Fri, 08 Nov 2013 09:40:26 -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 td6sm7510308wic.10.2013.11.08.09.40.25\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Fri, 08 Nov 2013 09:40:26 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 2/7] emacs: help: remove duplicate bindings\r
+Date: Fri, 8 Nov 2013 17:40:14 +0000\r
+Message-Id: <1383932419-12533-3-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:35 -0000\r
+\r
+If the user (or a mode) overrides a keybinding from the common keymap\r
+in one of the modes then both help lines appear in the help screen\r
+even though only one of them is applicable.\r
+\r
+Fix this by checking if we already have that key binding. We do this\r
+by constructing an list of (key . docstring) pairs so it is easy to\r
+check if we have already had that binding. Then the actual print help\r
+routine changes these pairs into strings "key \t docstring"\r
+---\r
+ emacs/notmuch-lib.el | 41 ++++++++++++++++++++++++-----------------\r
+ 1 files changed, 24 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index ec5a2cb..2195166 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."\r
+ (concat desc " "))))\r
+ \r
+ (defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail)\r
+- "Return a list of strings, each describing one binding in KEYMAP.\r
++ "Return a list of cons cells, each describing one binding in KEYMAP.\r
+ \r
+-Each string gives a human-readable description of the key and a\r
+-one-line description of the bound function. See `notmuch-help'\r
+-for an overview of how this documentation is extracted.\r
++Each cons cell consists of a string giving a human-readable\r
++description of the key, and a one-line description of the bound\r
++function. See `notmuch-help' for an overview of how this\r
++documentation is extracted.\r
+ \r
+ UA-KEYS should be a key sequence bound to `universal-argument'.\r
+ It will be used to describe bindings of commands that support a\r
+@@ -255,18 +256,23 @@ 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
+- (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 (concat ua-desc " " prefix (format-kbd-macro (vector key))\r
+- "\t" (get binding 'notmuch-prefix-doc))\r
+- tail)))\r
+- ;; Documentation for command\r
+- (push (concat prefix (format-kbd-macro (vector key)) "\t"\r
+- (or (and (symbolp binding) (get binding 'notmuch-doc))\r
+- (notmuch-documentation-first-line binding)))\r
+- tail))))\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
+ keymap)\r
+ tail)\r
+ \r
+@@ -277,7 +283,8 @@ prefix argument. PREFIX and TAIL are used internally."\r
+ (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))\r
+ (keymap (symbol-value (intern keymap-name)))\r
+ (ua-keys (where-is-internal 'universal-argument keymap t))\r
+- (desc-list (notmuch-describe-keymap keymap ua-keys))\r
++ (desc-alist (notmuch-describe-keymap keymap ua-keys))\r
++ (desc-list (mapcar (lambda (arg) (concat (car arg) "\t" (cdr arg))) desc-alist))\r
+ (desc (mapconcat #'identity desc-list "\n")))\r
+ (setq doc (replace-match desc 1 1 doc)))\r
+ (setq beg (match-end 0)))\r
+-- \r
+1.7.9.1\r
+\r