From: Austin Clements Date: Fri, 8 Nov 2013 03:30:09 +0000 (+1900) Subject: Re: [PATCH v2 3/5] emacs: help: split out notmuch-describe-key as a function X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4dadd9c77343611a46dc09962bdfd060ca4f3789;p=notmuch-archives.git Re: [PATCH v2 3/5] emacs: help: split out notmuch-describe-key as a function --- diff --git a/24/2da0884845e4896bb3df6f093ad98884156131 b/24/2da0884845e4896bb3df6f093ad98884156131 new file mode 100644 index 000000000..4c68a0704 --- /dev/null +++ b/24/2da0884845e4896bb3df6f093ad98884156131 @@ -0,0 +1,184 @@ +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 1680D431FC4 + for ; Thu, 7 Nov 2013 19:30:20 -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 9kqW3Wyo-leS for ; + Thu, 7 Nov 2013 19:30:13 -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 05CC7431FC0 + for ; Thu, 7 Nov 2013 19:30:12 -0800 (PST) +X-AuditID: 1209190d-b7fa48e0000057cd-e3-527c5ac4e35c +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + (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 B9.27.22477.4CA5C725; Thu, 7 Nov 2013 22:30:12 -0500 (EST) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id rA83UATp020036; + Thu, 7 Nov 2013 22:30:11 -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 rA83U9Ru026423 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Thu, 7 Nov 2013 22:30:10 -0500 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1Veclt-0006T0-2z; Thu, 07 Nov 2013 22:30:09 -0500 +Date: Thu, 7 Nov 2013 22:30:09 -0500 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH v2 3/5] emacs: help: split out notmuch-describe-key as a + function +Message-ID: <20131108033009.GL29298@mit.edu> +References: <1383870096-14627-1-git-send-email-markwalters1009@gmail.com> + <1383870096-14627-4-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-4-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpileLIzCtJLcpLzFFi42IRYrdT0T0SVRNk8G43t8XquTwW12/OZHZg + 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mv5fO8JS0KhUcWLNYZYGxktSXYycHBICJhKT + lm5lgbDFJC7cW8/WxcjFISQwm0niypLfLBDOBkaJ/v9PWSGcU0wSv2ZcYwVpERJYwihxahc3 + iM0ioCLx6+cnJhCbTUBDYtv+5YwgtoiAjsTtQwvYQWxmAWmJb7+bwWqEBcIlTj9/AzaHF6jm + 1Mu3zBALOhklHu84yA6REJQ4OfMJC0SzlsSNfy+BmjnABi3/xwFicgp4SSx5XwpSIQp0wpST + 29gmMArNQtI8C0nzLITmBYzMqxhlU3KrdHMTM3OKU5N1i5MT8/JSi3SN9HIzS/RSU0o3MYKC + mlOSdwfju4NKhxgFOBiVeHhPXKoOEmJNLCuuzD3EKMnBpCTKqxRUEyTEl5SfUpmRWJwRX1Sa + k1p8iFGCg1lJhPeZIlCONyWxsiq1KB8mJc3BoiTOe5PDPkhIID2xJDU7NbUgtQgmK8PBoSTB + +zUSqFGwKDU9tSItM6cEIc3EwQkynAdoeD5IDW9xQWJucWY6RP4Uo6KUOO8NkIQASCKjNA+u + F5Z0XjGKA70izPsRpIoHmLDgul8BDWYCGhzyqxJkcEkiQkqqgfHssa0sDMuvHw3XN1v+PLCF + T/KSw2+eX2sPfo5ZPMdiVmyB61GFXzmJRasuqwpOaE/tXCX20PlNcPvFMwXluRIrV+2qudCx + UuW6uq7Za1+7wAfdmh1eL1PEWLYp2igp1R2+v9yrIzNn2sQ56zc/n/it85ay0+9HbncSLu99 + kL2B+V7rydMp8zWVWIozEg21mIuKEwHzEFcxFQMAAA== +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:30:20 -0000 + +Quoth Mark Walters on Nov 08 at 12:21 am: +> The actual documentation function notmuch-describe-keymap was getting +> rather complicated so split out the code for a single key into its own +> function notmuch-describe-key. +> --- +> emacs/notmuch-lib.el | 42 +++++++++++++++++++++++++----------------- +> 1 files changed, 25 insertions(+), 17 deletions(-) +> +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index 2195166..8852703 100644 +> --- a/emacs/notmuch-lib.el +> +++ b/emacs/notmuch-lib.el +> @@ -237,6 +237,30 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-." +> "M-" +> (concat desc " ")))) +> +> + +> +(defun notmuch-describe-key (actual-key binding prefix ua-keys tail) +> + "Prepend cons cells describing prefix-arg ACTUAL-KEY and ACTUAL-KEY to TAIL +> + +> +It does not prepend if ACTUAL-KEY is already listed in TAIL." + +This obviously works, but I wonder if the interface would be a bit +clearer if, instead of extending tail, this returned a list of just +the descriptions of ACTUAL-KEY. It would still have to take the +existing bindings to eliminate duplicates, but that becomes just the +list of existing bindings, and not *also* the tail to prepend bindings +to. I'm imagining something like, + +(defun notmuch-describe-key (actual-key binding prefix ua-keys existing) + ... + (let ((key-string (concat prefix (format-kbd-macro actual-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) + (cons + ;; Documentation for command + (cons key-string + (or (and (symbolp binding) (get binding 'notmuch-doc)) + (notmuch-documentation-first-line binding))) + ;; Documentation for prefixed command + (when (and ua-keys (symbolp binding) + (get binding 'notmuch-prefix-doc)) + (list + (let ((ua-desc (key-description ua-keys))) + (cons (concat ua-desc " " prefix (format-kbd-macro actual-key)) + (get binding 'notmuch-prefix-doc))))))))) + +Then below, + + (setq tail (nconc (notmuch-describe-key ...) tail)) + +This patch is also fine as is. + +> + (let ((key-string (concat prefix (format-kbd-macro actual-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 actual-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))) +> + tail) +> + +> (defun notmuch-describe-keymap (keymap ua-keys &optional prefix tail) +> "Return a list of cons cells, each describing one binding in KEYMAP. +> +> @@ -256,23 +280,7 @@ prefix argument. PREFIX and TAIL are used internally." +> (notmuch-describe-keymap +> binding ua-keys (notmuch-prefix-key-description key) tail))) +> (binding +> - (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)))))) +> + (setq tail (notmuch-describe-key (vector key) binding prefix ua-keys tail))))) +> keymap) +> tail) +>