1 Return-Path: <amdragon@mit.edu>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 03A7A431FDA
\r
6 for <notmuch@notmuchmail.org>; Tue, 3 Sep 2013 14:45:53 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id lRayjVe1V9xl for <notmuch@notmuchmail.org>;
\r
16 Tue, 3 Sep 2013 14:45:48 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 84802431FDB
\r
20 for <notmuch@notmuchmail.org>; Tue, 3 Sep 2013 14:45:33 -0700 (PDT)
\r
21 X-AuditID: 1209190f-b7fa58e000000953-7a-5226587c7b59
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 16.F3.02387.C7856225; Tue, 3 Sep 2013 17:45:32 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r83LjUlV019873;
\r
27 Tue, 3 Sep 2013 17:45:30 -0400
\r
28 Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r83LjRTO026859
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Tue, 3 Sep 2013 17:45:28 -0400
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1VGyPe-0004y3-VT; Tue, 03 Sep 2013 17:45:26 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH v2 7/9] emacs: Make notmuch-help work with arbitrary keymaps
\r
40 Date: Tue, 3 Sep 2013 17:45:23 -0400
\r
41 Message-Id: <1378244725-18846-8-git-send-email-amdragon@mit.edu>
\r
42 X-Mailer: git-send-email 1.7.10.4
\r
43 In-Reply-To: <1378244725-18846-1-git-send-email-amdragon@mit.edu>
\r
44 References: <1378244725-18846-1-git-send-email-amdragon@mit.edu>
\r
45 X-Brightmail-Tracker:
\r
46 H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixG6nolsToRZksH6voUXTdGeL1XN5LK7f
\r
47 nMnswOyxc9Zddo9b91+zezxbdYs5gDmKyyYlNSezLLVI3y6BK+PKar6C+1IVGybdYmtg3Cba
\r
48 xcjJISFgIrG36R8LhC0mceHeerYuRi4OIYF9jBJdfw8xQTgbGCXmTj7MAuEcZpLo+HiVEcKZ
\r
49 yyjx/f8JJpB+NgENiW37lzOC2CIC0hI7785mBbGZBaIljlyewQZiCwv4SMxpuwpWzyKgKrHq
\r
50 3jKw3bwCDhLtt2YyQtyhKNH9bAJYPaeAo0TvgkXsILYQUE3TysvsExj5FzAyrGKUTcmt0s1N
\r
51 zMwpTk3WLU5OzMtLLdI10cvNLNFLTSndxAgKLU5J/h2M3w4qHWIU4GBU4uFdcV81SIg1say4
\r
52 MvcQoyQHk5Io75FQtSAhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrwJPkA53pTEyqrUonyYlDQH
\r
53 i5I477OnZwOFBNITS1KzU1MLUotgsjIcHEoSvOXhQI2CRanpqRVpmTklCGkmDk6Q4TxAw3+G
\r
54 gQwvLkjMLc5Mh8ifYlSUEudNB2kWAElklObB9cJi/xWjONArwrz+IFU8wLQB1/0KaDAT0OC0
\r
55 z6ogg0sSEVJSDYztKx43J36RWJmwQLn3kuY5ydyPrXGB3Vc6Lmd9uL8sffOCDVtSGJ5lJdQm
\r
56 PlItnRJw5fVPPeWpunksm/of+9W8mCEntrdFwLHzwqyjPh8X5Mqz7Z7jtYAzJ1TkWvwLL2ad
\r
57 tTttnZnv26S1fZuksUkid7tNZ4fO28YTfqaRYR6T2450fpu/Q0KJpTgj0VCLuag4EQAOyyc1
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Tue, 03 Sep 2013 21:45:53 -0000
\r
73 This converts notmuch-help to use map-keymap for all keymap traversal.
\r
74 This generally cleans up and simplifies construction of keymap
\r
75 documentation, and also makes notmuch-help support anything that can
\r
76 be in a keymap, including more esoteric stuff like multiple
\r
79 emacs/notmuch.el | 58 +++++++++++++++++++++---------------------------------
\r
80 1 file changed, 22 insertions(+), 36 deletions(-)
\r
82 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
83 index 80446be..0304096 100644
\r
84 --- a/emacs/notmuch.el
\r
85 +++ b/emacs/notmuch.el
\r
86 @@ -140,48 +140,34 @@ This is basically just `format-kbd-macro' but we also convert ESC to M-."
\r
88 (concat desc " "))))
\r
90 -;; I would think that emacs would have code handy for walking a keymap
\r
91 -;; and generating strings for each key, and I would prefer to just call
\r
92 -;; that. But I couldn't find any (could be all implemented in C I
\r
93 -;; suppose), so I wrote my own here.
\r
94 -(defun notmuch-substitute-one-command-key-with-prefix (prefix binding)
\r
95 - "For a key binding, return a string showing a human-readable
\r
96 -representation of the prefixed key as well as the first line of
\r
97 -documentation from the bound function.
\r
99 -For a mouse binding, return nil."
\r
100 - (let ((key (car binding))
\r
101 - (action (cdr binding)))
\r
102 - (if (mouse-event-p key)
\r
104 - (if (keymapp action)
\r
105 - (let ((substitute (apply-partially 'notmuch-substitute-one-command-key-with-prefix (notmuch-prefix-key-description key)))
\r
107 - (map-keymap (lambda (a b)
\r
108 - (push (cons a b) as-list))
\r
110 - (mapconcat substitute as-list "\n"))
\r
111 - (concat prefix (format-kbd-macro (vector key))
\r
113 - (notmuch-documentation-first-line action))))))
\r
115 -(defun notmuch-substitute-command-keys-one (key)
\r
116 - ;; A `keymap' key indicates inheritance from a parent keymap - the
\r
117 - ;; inherited mappings follow, so there is nothing to print for
\r
118 - ;; `keymap' itself.
\r
119 - (when (not (eq key 'keymap))
\r
120 - (notmuch-substitute-one-command-key-with-prefix nil key)))
\r
121 +(defun notmuch-describe-keymap (keymap &optional prefix tail)
\r
122 + "Return a list of strings, each describing one key in KEYMAP.
\r
124 +Each string gives a human-readable description of the key and the
\r
125 +first line of documentation for the bound function."
\r
127 + (lambda (key binding)
\r
128 + (cond ((mouse-event-p key) nil)
\r
129 + ((keymapp binding)
\r
131 + (notmuch-describe-keymap
\r
132 + binding (notmuch-prefix-key-description key) tail)))
\r
134 + (push (concat prefix (format-kbd-macro (vector key)) "\t"
\r
135 + (notmuch-documentation-first-line binding))
\r
140 (defun notmuch-substitute-command-keys (doc)
\r
141 "Like `substitute-command-keys' but with documentation, not function names."
\r
143 (while (string-match "\\\\{\\([^}[:space:]]*\\)}" doc beg)
\r
144 (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
\r
145 - (keymap (symbol-value (intern keymap-name))))
\r
146 - (setq doc (replace-match
\r
147 - (mapconcat #'notmuch-substitute-command-keys-one
\r
148 - (cdr keymap) "\n")
\r
150 + (keymap (symbol-value (intern keymap-name)))
\r
151 + (desc-list (notmuch-describe-keymap keymap))
\r
152 + (desc (mapconcat #'identity desc-list "\n")))
\r
153 + (setq doc (replace-match desc 1 1 doc)))
\r
154 (setq beg (match-end 0)))
\r