From: Austin Clements Date: Fri, 8 Nov 2013 03:09:28 +0000 (+1900) Subject: Re: [PATCH v2 2/5] emacs: help: remove duplicate bindings X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=28715d218a4db6139f43999c01888ba083b89524;p=notmuch-archives.git Re: [PATCH v2 2/5] emacs: help: remove duplicate bindings --- diff --git a/56/f520f35855c80be5718ca42b38e9496570dde8 b/56/f520f35855c80be5718ca42b38e9496570dde8 new file mode 100644 index 000000000..eeb572429 --- /dev/null +++ b/56/f520f35855c80be5718ca42b38e9496570dde8 @@ -0,0 +1,164 @@ +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 1868A431FC4 + for ; Thu, 7 Nov 2013 19:09:41 -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 XWzYl+GXiIGy for ; + Thu, 7 Nov 2013 19:09:33 -0800 (PST) +Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu + [18.9.25.13]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 149B5431FC0 + for ; Thu, 7 Nov 2013 19:09:32 -0800 (PST) +X-AuditID: 1209190d-b7fa48e0000057cd-22-527c55eb6fb0 +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP + id A9.96.22477.BE55C725; Thu, 7 Nov 2013 22:09:32 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id rA839U45016420; + Thu, 7 Nov 2013 22:09:31 -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 rA839SwX020668 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Thu, 7 Nov 2013 22:09:29 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1VecRs-0006MU-DK; Thu, 07 Nov 2013 22:09:28 -0500 +Date: Thu, 7 Nov 2013 22:09:28 -0500 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH v2 2/5] emacs: help: remove duplicate bindings +Message-ID: <20131108030928.GK29298@mit.edu> +References: <1383870096-14627-1-git-send-email-markwalters1009@gmail.com> + <1383870096-14627-3-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1383870096-14627-3-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT130TWhNksPobk8XquTwW12/OZHZg + 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mh5f/8NacEq+4uyhbsYGxkMSXYwcHBICJhKr + F+t2MXICmWISF+6tZ+ti5OIQEpjNJLFu/UkWCGcDo0TjmZPsEM4pJokZ6++yQjhLGCWO/t3D + AtLPIqAiMeX/VlYQm01AQ2Lb/uWMILaIgI7E7UML2EFsZgFpiW+/m5lAbGEBJ4nPxxvBenmB + ap51/YAa2skosXvTX6iEoMTJmU9YIJq1JG78e8kEcjfIoOX/OEDCnAJeEkfuXQHbKwpyw8lt + bBMYhWYh6Z6FpHsWQvcCRuZVjLIpuVW6uYmZOcWpybrFyYl5ealFukZ6uZkleqkppZsYQWHN + Kcm7g/HdQaVDjAIcjEo8vCcuVQcJsSaWFVfmHmKU5GBSEuVVCqoJEuJLyk+pzEgszogvKs1J + LT7EKMHBrCTC+0wRKMebklhZlVqUD5OS5mBREue9yWEfJCSQnliSmp2aWpBaBJNV5+AQONf2 + J1yKJS8/L1VJglcyBGiGYFFqempFWmZOCUIlEwcnyB4eoD2/QGp4iwsSc4sz0yHypxgVpcR5 + N4IkBEASGaV5cL2wZPSKURzoK2HeEyBVPMBEBtf9CmgwE9DgkF+VIINLEhFSUg2M4mtWzGk2 + 7vSp68hVeaYZ0Ot+0aU1P37azuUvDbM7Vi3g8vRgfS7+JO24ZIzfm/r39rXOC8ME9m5SC+T6 + 9WrFFudDc4/uaTz67PT3Y95+14+sr8xKZzmkrbS/5/OW1Xy7onbe9N5xcMsN1msbQ4u//WW8 + eqbk3Loyj3/7JLNc5wjwL1gv3Tx3tRJLcUaioRZzUXEiAAgxvN4hAwAA +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 03:09:41 -0000 + +Quoth Mark Walters on Nov 08 at 12:21 am: +> If the user (or a mode) overrides a keybinding from the common keymap +> in one of the modes then both help lines appear in the help screen +> even though only one of the is applicable. + +s/the/them/ + +> +> Fix this by checking if we already have that key binding. We do this +> by constructing an list of (key . docstring) pairs so it is easy to +> check if we have already had that binding. Then the actual print help +> routine changes these pairs into strings "key \t docstring" +> --- +> emacs/notmuch-lib.el | 41 ++++++++++++++++++++++++----------------- +> 1 files changed, 24 insertions(+), 17 deletions(-) +> +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index ec5a2cb..2195166 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -238,11 +238,12 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-." +> (concat desc " ")))) +> +> (defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail) +> - "Return a list of strings, each describing one binding in KEYMAP. +> + "Return a list of cons cells, each describing one binding in KEYMAP. +> +> -Each string gives a human-readable description of the key and a +> -one-line description of the bound function. See `notmuch-help' +> -for an overview of how this documentation is extracted. +> +Each cons cell consists of a string giving a human-readable +> +description of the key, and a one-line description of the bound +> +function. See `notmuch-help' for an overview of how this +> +documentation is extracted. +> +> UA-KEYS should be a key sequence bound to `universal-argument'. +> It will be used to describe bindings of commands that support a +> @@ -255,18 +256,23 @@ prefix argument. PREFIX and TAIL are used internally." +> (notmuch-describe-keymap +> binding ua-keys (notmuch-prefix-key-description key) tail))) +> (binding +> - (when (and ua-keys (symbolp binding) +> - (get binding 'notmuch-prefix-doc)) +> - ;; Documentation for prefixed command +> - (let ((ua-desc (key-description ua-keys))) +> - (push (concat ua-desc " " prefix (format-kbd-macro (vector key)) +> - "\t" (get binding 'notmuch-prefix-doc)) +> - tail))) +> - ;; Documentation for command +> - (push (concat prefix (format-kbd-macro (vector key)) "\t" +> - (or (and (symbolp binding) (get binding 'notmuch-doc)) +> - (notmuch-documentation-first-line binding))) +> - tail)))) +> + (let ((key-string (concat prefix (format-kbd-macro (vector key))))) +> + ;; We don't include documentation if the key-binding is +> + ;; over-ridden. Note, over-riding a binding +> + ;; automatically hides the prefixed version too. +> + (unless (assoc key-string tail) +> + (when (and ua-keys (symbolp binding) +> + (get binding 'notmuch-prefix-doc)) +> + ;; Documentation for prefixed command +> + (let ((ua-desc (key-description ua-keys))) +> + (push (cons (concat ua-desc " " prefix (format-kbd-macro (vector key))) +> + (get binding 'notmuch-prefix-doc)) +> + tail))) +> + ;; Documentation for command +> + (push (cons key-string +> + (or (and (symbolp binding) (get binding 'notmuch-doc)) +> + (notmuch-documentation-first-line binding))) +> + tail)))))) +> keymap) +> tail) +> +> @@ -277,7 +283,8 @@ 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-list (notmuch-describe-keymap keymap ua-keys)) +> + (desc-alist (notmuch-describe-keymap keymap ua-keys)) +> + (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))) +> (setq beg (match-end 0)))