From bf3b415b3388dd07d9b13b9f957164fb28033ec0 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Fri, 8 Nov 2013 17:40:15 +0000 Subject: [PATCH] [PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a function --- e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 | 134 ++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 diff --git a/e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 b/e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 new file mode 100644 index 000000000..cc769e0b7 --- /dev/null +++ b/e1/5e46cd8d70f53cfa302e4102b1c9ca031602f8 @@ -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 BCBC6429E4B + for ; Fri, 8 Nov 2013 09:40:41 -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 zCOIkIw9nbNy for ; + Fri, 8 Nov 2013 09:40:35 -0800 (PST) +Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com + [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 1600B431E84 + for ; Fri, 8 Nov 2013 09:40:28 -0800 (PST) +Received: by mail-wi0-f176.google.com with SMTP id m19so620047wiv.15 + for ; Fri, 08 Nov 2013 09:40:27 -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=N4YMpZq/47KojcpG7f1UnE8UkxVX65eUWBrE04y5R88=; + b=cSdkGj/5vHar1L5QPvVqjup5rnhXGabY60Fx4Z1odC3bJPtoZjRe/pGDzJm9lgvNgI + imK+uE8DUgtyH8ho+nyh7Ah7ke5OEUqZMCY9ieqneEa7m1W8/jLoG/aR7DR5UgL2d1pA + d0C4LhXvSApTfDHMsA7llj+1XV4UE2ypoAFBSkyAzKiNwrxmnKFImyN8tgIC7tM+hm8B + PsDLKvYPDKI1Ek4Czpb3aoxslcs4JuPk4IvJr35i+KLPHWuCA5M10oOCsr3h8V+t+gk0 + g7B9HiCrVnnlLMwqGDvkEHJNYVPyUUw3ZIyRkRH7T20A1a2+Kzhos8R83DqgSpr6aqnL + dt+Q== +X-Received: by 10.194.110.138 with SMTP id ia10mr9470589wjb.3.1383932427954; + Fri, 08 Nov 2013 09:40:27 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id mw9sm8556740wib.0.2013.11.08.09.40.27 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Fri, 08 Nov 2013 09:40:27 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH v3 3/7] emacs: help: split out notmuch-describe-key as a + function +Date: Fri, 8 Nov 2013 17:40:15 +0000 +Message-Id: <1383932419-12533-4-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1383932419-12533-1-git-send-email-markwalters1009@gmail.com> +References: <1383932419-12533-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: Fri, 08 Nov 2013 17:40:42 -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 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." ++ (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 + -- 2.26.2