From: Mark Walters Date: Tue, 12 Nov 2013 20:10:56 +0000 (+0000) Subject: [PATCH v4 4/7] emacs: help: split out notmuch-describe-key as a function X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d39c406143803ead7961787019524ad83f0b543c;p=notmuch-archives.git [PATCH v4 4/7] emacs: help: split out notmuch-describe-key as a function --- diff --git a/1c/54be9f951952e785f4f8874e4ea26dfe0daf98 b/1c/54be9f951952e785f4f8874e4ea26dfe0daf98 new file mode 100644 index 000000000..fb8734808 --- /dev/null +++ b/1c/54be9f951952e785f4f8874e4ea26dfe0daf98 @@ -0,0 +1,134 @@ +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 404E8429E3E + for ; Tue, 12 Nov 2013 12:18:40 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + 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 d0gMnbaK-sIn for ; + Tue, 12 Nov 2013 12:18:35 -0800 (PST) +Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com + [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 47FEC429E38 + for ; Tue, 12 Nov 2013 12:18:35 -0800 (PST) +Received: by mail-wi0-f181.google.com with SMTP id f4so618211wiw.14 + for ; Tue, 12 Nov 2013 12:18:34 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=y/XXIvwhJ5uICFyxWT/9ORcGrvxoZ6O1n5PEdzVBOZA=; + b=zDyYNdv4rdFuH8nTN+VGcZ6TLSMPaHA37VgTzNluJdOGSjBtdbMZnXs1SrWErg7iiB + 18lTn8YBlSY+sgSPWGIQamPcx/dzFnchID8J/vpP/S/FOrVHxfuBkrKjQz+2/b5yND47 + QJZwIwooJY8clzxlcmt5lkP6A48hXvvBtvy6nMxvHVFJ02mTqASnrlq+HRM165tIeMDV + +kLKSJygzObLH/ECshkueMiq+2ySrlXegO//BAfnfdteX7DNJX50fTAG+MnLSOLEXyaX + /1MiQlXJxlwtLix9dKPC5P8Rcad/xR80qGlfFkCB+rgjahM44JAakfgWySjl5iCTRxt7 + T4nQ== +X-Received: by 10.194.11.38 with SMTP id n6mr29054108wjb.25.1384287071511; + Tue, 12 Nov 2013 12:11:11 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id y20sm11308350wib.0.2013.11.12.12.11.10 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Tue, 12 Nov 2013 12:11:11 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v4 4/7] emacs: help: split out notmuch-describe-key as a + function +Date: Tue, 12 Nov 2013 20:10:56 +0000 +Message-Id: <1384287059-3525-5-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1384287059-3525-1-git-send-email-markwalters1009@gmail.com> +References: <1384287059-3525-1-git-send-email-markwalters1009@gmail.com> +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: Tue, 12 Nov 2013 20:18:40 -0000 + +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 dde636a..33790e2 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." ++ (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) + +-- +1.7.9.1 +