]> git.notmuchmail.org Git - notmuch/blob - emacs/notmuch-tag.el
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / emacs / notmuch-tag.el
1 ;;; notmuch-tag.el --- tag messages within emacs  -*- lexical-binding: t -*-
2 ;;
3 ;; Copyright © Damien Cassou
4 ;; Copyright © Carl Worth
5 ;;
6 ;; This file is part of Notmuch.
7 ;;
8 ;; Notmuch is free software: you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12 ;;
13 ;; Notmuch is distributed in the hope that it will be useful, but
14 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 ;; General Public License for more details.
17 ;;
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with Notmuch.  If not, see <https://www.gnu.org/licenses/>.
20 ;;
21 ;; Authors: Carl Worth <cworth@cworth.org>
22 ;;          Damien Cassou <damien.cassou@gmail.com>
23
24 ;;; Code:
25
26 (require 'crm)
27
28 (require 'notmuch-lib)
29
30 (declare-function notmuch-search-tag "notmuch"
31                   (tag-changes &optional beg end only-matched))
32 (declare-function notmuch-show-tag "notmuch-show" (tag-changes))
33 (declare-function notmuch-tree-tag "notmuch-tree" (tag-changes))
34 (declare-function notmuch-jump "notmuch-jump" (action-map prompt))
35
36 ;;; Keys
37
38 (define-widget 'notmuch-tag-key-type 'list
39   "A single key tagging binding."
40   :format "%v"
41   :args '((list :inline t
42                 :format "%v"
43                 (key-sequence :tag "Key")
44                 (radio :tag "Tag operations"
45                        (repeat :tag "Tag list"
46                                (string :format "%v" :tag "change"))
47                        (variable :tag "Tag variable"))
48                 (string :tag "Name"))))
49
50 (defcustom notmuch-tagging-keys
51   `((,(kbd "a") notmuch-archive-tags "Archive")
52     (,(kbd "u") notmuch-show-mark-read-tags "Mark read")
53     (,(kbd "f") ("+flagged") "Flag")
54     (,(kbd "s") ("+spam" "-inbox") "Mark as spam")
55     (,(kbd "d") ("+deleted" "-inbox") "Delete"))
56   "A list of keys and corresponding tagging operations.
57
58 For each key (or key sequence) you can specify a sequence of
59 tagging operations to apply, or a variable which contains a list
60 of tagging operations such as `notmuch-archive-tags'. The final
61 element is a name for this tagging operation. If the name is
62 omitted or empty then the list of tag changes, or the variable
63 name is used as the name.
64
65 The key `notmuch-tag-jump-reverse-key' (k by default) should not
66 be used (either as a key, or as the start of a key sequence) as
67 it is already bound: it switches the menu to a menu of the
68 reverse tagging operations. The reverse of a tagging operation is
69 the same list of individual tag-ops but with `+tag' replaced by
70 `-tag' and vice versa.
71
72 If setting this variable outside of customize then it should be a
73 list of triples (lists of three elements). Each triple should be
74 of the form (key-binding tagging-operations name). KEY-BINDING
75 can be a single character or a key sequence; TAGGING-OPERATIONS
76 should either be a list of individual tag operations each of the
77 form `+tag' or `-tag', or the variable name of a variable that is
78 a list of tagging operations; NAME should be a name for the
79 tagging operation, if omitted or empty than then name is taken
80 from TAGGING-OPERATIONS."
81   :tag "List of tagging bindings"
82   :type '(repeat notmuch-tag-key-type)
83   :group 'notmuch-tag)
84
85 ;;; Faces and Formats
86
87 (define-widget 'notmuch-tag-format-type 'lazy
88   "Customize widget for notmuch-tag-format and friends."
89   :type '(alist :key-type (regexp :tag "Tag")
90                 :extra-offset -3
91                 :value-type
92                 (radio :format "%v"
93                        (const :tag "Hidden" nil)
94                        (set :tag "Modified"
95                             (string :tag "Display as")
96                             (list :tag "Face" :extra-offset -4
97                                   (const :format "" :inline t
98                                          (notmuch-apply-face tag))
99                                   (list :format "%v"
100                                         (const :format "" quote)
101                                         custom-face-edit))
102                             (list :format "%v" :extra-offset -4
103                                   (const :format "" :inline t
104                                          (notmuch-tag-format-image-data tag))
105                                   (choice :tag "Image"
106                                           (const :tag "Star"
107                                                  (notmuch-tag-star-icon))
108                                           (const :tag "Empty star"
109                                                  (notmuch-tag-star-empty-icon))
110                                           (const :tag "Tag"
111                                                  (notmuch-tag-tag-icon))
112                                           (string :tag "Custom")))
113                             (sexp :tag "Custom")))))
114
115 (defface notmuch-tag-unread
116   '((t :foreground "red"))
117   "Default face used for the unread tag.
118
119 Used in the default value of `notmuch-tag-formats'."
120   :group 'notmuch-faces)
121
122 (defface notmuch-tag-flagged
123   '((((class color)
124       (background dark))
125      (:foreground "LightBlue1"))
126     (((class color)
127       (background light))
128      (:foreground "blue")))
129   "Face used for the flagged tag.
130
131 Used in the default value of `notmuch-tag-formats'."
132   :group 'notmuch-faces)
133
134 (defcustom notmuch-tag-formats
135   '(("unread" (propertize tag 'face 'notmuch-tag-unread))
136     ("flagged" (propertize tag 'face 'notmuch-tag-flagged)
137      (notmuch-tag-format-image-data tag (notmuch-tag-star-icon))))
138   "Custom formats for individual tags.
139
140 This is an association list of the form ((MATCH EXPR...)...),
141 mapping tag name regexps to lists of formatting expressions.
142
143 The first entry whose MATCH regexp-matches a tag is used to
144 format that tag.  The regexp is implicitly anchored, so to match
145 a literal tag name, just use that tag name (if it contains
146 special regexp characters like \".\" or \"*\", these have to be
147 escaped).
148
149 The cdr of the matching entry gives a list of Elisp expressions
150 that modify the tag.  If the list is empty, the tag is simply
151 hidden.  Otherwise, each expression EXPR is evaluated in order:
152 for the first expression, the variable `tag' is bound to the tag
153 name; for each later expression, the variable `tag' is bound to
154 the result of the previous expression.  In this way, each
155 expression can build on the formatting performed by the previous
156 expression.  The result of the last expression is displayed in
157 place of the tag.
158
159 For example, to replace a tag with another string, simply use
160 that string as a formatting expression.  To change the foreground
161 of a tag to red, use the expression
162   (propertize tag 'face '(:foreground \"red\"))
163
164 See also `notmuch-tag-format-image', which can help replace tags
165 with images."
166   :group 'notmuch-search
167   :group 'notmuch-show
168   :group 'notmuch-faces
169   :type 'notmuch-tag-format-type)
170
171 (defface notmuch-tag-deleted
172   '((((class color) (supports :strike-through "red")) :strike-through "red")
173     (t :inverse-video t))
174   "Face used to display deleted tags.
175
176 Used in the default value of `notmuch-tag-deleted-formats'."
177   :group 'notmuch-faces)
178
179 (defcustom notmuch-tag-deleted-formats
180   '(("unread" (notmuch-apply-face bare-tag `notmuch-tag-deleted))
181     (".*" (notmuch-apply-face tag `notmuch-tag-deleted)))
182   "Custom formats for tags when deleted.
183
184 For deleted tags the formats in `notmuch-tag-formats' are applied
185 first and then these formats are applied on top; that is `tag'
186 passed to the function is the tag with all these previous
187 formattings applied. The formatted can access the original
188 unformatted tag as `bare-tag'.
189
190 By default this shows deleted tags with strike-through in red,
191 unless strike-through is not available (e.g., emacs is running in
192 a terminal) in which case it uses inverse video. To hide deleted
193 tags completely set this to
194   '((\".*\" nil))
195
196 See `notmuch-tag-formats' for full documentation."
197   :group 'notmuch-show
198   :group 'notmuch-faces
199   :type 'notmuch-tag-format-type)
200
201 (defface notmuch-tag-added
202   '((t :underline "green"))
203   "Default face used for added tags.
204
205 Used in the default value for `notmuch-tag-added-formats'."
206   :group 'notmuch-faces)
207
208 (defcustom notmuch-tag-added-formats
209   '((".*" (notmuch-apply-face tag 'notmuch-tag-added)))
210   "Custom formats for tags when added.
211
212 For added tags the formats in `notmuch-tag-formats' are applied
213 first and then these formats are applied on top.
214
215 To disable special formatting of added tags, set this variable to
216 nil.
217
218 See `notmuch-tag-formats' for full documentation."
219   :group 'notmuch-show
220   :group 'notmuch-faces
221   :type 'notmuch-tag-format-type)
222
223 ;;; Icons
224
225 (defun notmuch-tag-format-image-data (tag data)
226   "Replace TAG with image DATA, if available.
227
228 This function returns a propertized string that will display image
229 DATA in place of TAG.This is designed for use in
230 `notmuch-tag-formats'.
231
232 DATA is the content of an SVG picture (e.g., as returned by
233 `notmuch-tag-star-icon')."
234   (propertize tag 'display
235               `(image :type svg
236                       :data ,data
237                       :ascent center
238                       :mask heuristic)))
239
240 (defun notmuch-tag-star-icon ()
241   "Return SVG data representing a star icon.
242 This can be used with `notmuch-tag-format-image-data'."
243   "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
244 <svg version=\"1.1\" width=\"16\" height=\"16\">
245   <g transform=\"translate(-242.81601,-315.59635)\">
246     <path
247        d=\"m 290.25762,334.31206 -17.64143,-11.77975 -19.70508,7.85447 5.75171,-20.41814 -13.55925,-16.31348 21.19618,-0.83936 11.325,-17.93675 7.34825,19.89939 20.55849,5.22795 -16.65471,13.13786 z\"
248        transform=\"matrix(0.2484147,-0.02623394,0.02623394,0.2484147,174.63605,255.37691)\"
249        style=\"fill:#ffff00;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\" />
250   </g>
251 </svg>")
252
253 (defun notmuch-tag-star-empty-icon ()
254   "Return SVG data representing an empty star icon.
255 This can be used with `notmuch-tag-format-image-data'."
256   "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
257 <svg version=\"1.1\" width=\"16\" height=\"16\">
258   <g transform=\"translate(-242.81601,-315.59635)\">
259     <path
260        d=\"m 290.25762,334.31206 -17.64143,-11.77975 -19.70508,7.85447 5.75171,-20.41814 -13.55925,-16.31348 21.19618,-0.83936 11.325,-17.93675 7.34825,19.89939 20.55849,5.22795 -16.65471,13.13786 z\"
261        transform=\"matrix(0.2484147,-0.02623394,0.02623394,0.2484147,174.63605,255.37691)\"
262        style=\"fill:#d6d6d1;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1\" />
263   </g>
264 </svg>")
265
266 (defun notmuch-tag-tag-icon ()
267   "Return SVG data representing a tag icon.
268 This can be used with `notmuch-tag-format-image-data'."
269   "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>
270 <svg version=\"1.1\" width=\"16\" height=\"16\">
271   <g transform=\"translate(0,-1036.3622)\">
272     <path
273        d=\"m 0.44642857,1040.9336 12.50000043,0 2.700893,3.6161 -2.700893,3.616 -12.50000043,0 z\"
274        style=\"fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.25;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1\" />
275   </g>
276 </svg>")
277
278 ;;; Format Handling
279
280 (defvar notmuch-tag--format-cache (make-hash-table :test 'equal)
281   "Cache of tag format lookup.  Internal to `notmuch-tag-format-tag'.")
282
283 (defun notmuch-tag-clear-cache ()
284   "Clear the internal cache of tag formats."
285   (clrhash notmuch-tag--format-cache))
286
287 (defun notmuch-tag--get-formats (tag alist)
288   "Find the first item whose car regexp-matches TAG."
289   (save-match-data
290     ;; Don't use assoc-default since there's no way to distinguish a
291     ;; missing key from a present key with a null cdr.
292     (cl-assoc tag alist
293               :test (lambda (tag key)
294                       (and (eq (string-match key tag) 0)
295                            (= (match-end 0) (length tag)))))))
296
297 (defun notmuch-tag--do-format (bare-tag tag formats)
298   "Apply a tag-formats entry to TAG."
299   (cond ((null formats)         ;; - Tag not in `formats',
300          tag)                   ;;   the format is the tag itself.
301         ((null (cdr formats))   ;; - Tag was deliberately hidden,
302          nil)                   ;;   no format must be returned
303         (t
304          ;; Tag was found and has formats, we must apply all the
305          ;; formats.  TAG may be null so treat that as a special case.
306          (let ((return-tag (copy-sequence (or tag ""))))
307            (dolist (format (cdr formats))
308              (setq return-tag
309                    (eval format
310                          `((bare-tag . ,bare-tag)
311                            (tag . ,return-tag)))))
312            (if (and (null tag) (equal return-tag ""))
313                nil
314              return-tag)))))
315
316 (defun notmuch-tag-format-tag (tags orig-tags tag)
317   "Format TAG according to `notmuch-tag-formats'.
318
319 TAGS and ORIG-TAGS are lists of the current tags and the original
320 tags; tags which have been deleted (i.e., are in ORIG-TAGS but
321 are not in TAGS) are shown using formats from
322 `notmuch-tag-deleted-formats'; tags which have been added (i.e.,
323 are in TAGS but are not in ORIG-TAGS) are shown using formats
324 from `notmuch-tag-added-formats' and tags which have not been
325 changed (the normal case) are shown using formats from
326 `notmuch-tag-formats'."
327   (let* ((tag-state (cond ((not (member tag tags)) 'deleted)
328                           ((not (member tag orig-tags)) 'added)))
329          (formatted-tag (gethash (cons tag tag-state)
330                                  notmuch-tag--format-cache
331                                  'missing)))
332     (when (eq formatted-tag 'missing)
333       (let ((base (notmuch-tag--get-formats tag notmuch-tag-formats))
334             (over (cl-case tag-state
335                     (deleted (notmuch-tag--get-formats
336                               tag notmuch-tag-deleted-formats))
337                     (added (notmuch-tag--get-formats
338                             tag notmuch-tag-added-formats))
339                     (otherwise nil))))
340         (setq formatted-tag (notmuch-tag--do-format tag tag base))
341         (setq formatted-tag (notmuch-tag--do-format tag formatted-tag over))
342         (puthash (cons tag tag-state) formatted-tag notmuch-tag--format-cache)))
343     formatted-tag))
344
345 (defun notmuch-tag-format-tags (tags orig-tags &optional face)
346   "Return a string representing formatted TAGS."
347   (let ((face (or face 'notmuch-tag-face))
348         (all-tags (sort (delete-dups (append tags orig-tags nil)) #'string<)))
349     (notmuch-apply-face
350      (mapconcat #'identity
351                 ;; nil indicated that the tag was deliberately hidden
352                 (delq nil (mapcar (apply-partially #'notmuch-tag-format-tag
353                                                    tags orig-tags)
354                                   all-tags))
355                 " ")
356      face
357      t)))
358
359 ;;; Hooks
360
361 (defcustom notmuch-before-tag-hook nil
362   "Hooks that are run before tags of a message are modified.
363
364 'tag-changes' will contain the tags that are about to be added or removed as
365 a list of strings of the form \"+TAG\" or \"-TAG\".
366 'query' will be a string containing the search query that determines
367 the messages that are about to be tagged."
368   :type 'hook
369   :options '(notmuch-hl-line-mode)
370   :group 'notmuch-hooks)
371
372 (defcustom notmuch-after-tag-hook nil
373   "Hooks that are run after tags of a message are modified.
374
375 'tag-changes' will contain the tags that were added or removed as
376 a list of strings of the form \"+TAG\" or \"-TAG\".
377 'query' will be a string containing the search query that determines
378 the messages that were tagged."
379   :type 'hook
380   :options '(notmuch-hl-line-mode)
381   :group 'notmuch-hooks)
382
383 ;;; User Input
384
385 (defvar notmuch-select-tag-history nil
386   "Minibuffer history of `notmuch-select-tag-with-completion' function.")
387
388 (defvar notmuch-read-tag-changes-history nil
389   "Minibuffer history of `notmuch-read-tag-changes' function.")
390
391 (defun notmuch-tag-completions (&rest search-terms)
392   "Return a list of tags for messages matching SEARCH-TERMS.
393
394 Return all tags if no search terms are given."
395   (unless search-terms
396     (setq search-terms (list "*")))
397   (split-string
398    (with-output-to-string
399      (with-current-buffer standard-output
400        (apply 'call-process notmuch-command nil t
401               nil "search" "--output=tags" "--exclude=false" search-terms)))
402    "\n+" t))
403
404 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
405   (completing-read prompt
406                    (apply #'notmuch-tag-completions search-terms)
407                    nil nil nil 'notmuch-select-tag-history))
408
409 (defun notmuch-read-tag-changes (current-tags &optional prompt initial-input)
410   "Prompt for tag changes in the minibuffer.
411
412 CURRENT-TAGS is a list of tags that are present on the message
413 or messages to be changed.  These are offered as tag removal
414 completions.  CURRENT-TAGS may contain duplicates.  PROMPT, if
415 non-nil, is the query string to present in the minibuffer.  It
416 defaults to \"Tags\".  INITIAL-INPUT, if non-nil, will be the
417 initial input in the minibuffer."
418   (let* ((all-tag-list (notmuch-tag-completions))
419          (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))
420          (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags))
421          (tag-list (append add-tag-list remove-tag-list))
422          (prompt (concat (or prompt "Tags") " (+add -drop): "))
423          (crm-separator " ")
424          ;; By default, space is bound to "complete word" function.
425          ;; Re-bind it to insert a space instead.  Note that <tab>
426          ;; still does the completion.
427          (crm-local-completion-map
428           (let ((map (make-sparse-keymap)))
429             (set-keymap-parent map crm-local-completion-map)
430             (define-key map " " 'self-insert-command)
431             map)))
432     (delete "" (completing-read-multiple
433                 prompt
434                 ;; Append the separator to each completion so when the
435                 ;; user completes a tag they can immediately begin
436                 ;; entering another.  `completing-read-multiple'
437                 ;; ultimately splits the input on crm-separator, so we
438                 ;; don't need to strip this back off (we just need to
439                 ;; delete "empty" entries caused by trailing spaces).
440                 (mapcar (lambda (tag-op) (concat tag-op crm-separator)) tag-list)
441                 nil nil initial-input
442                 'notmuch-read-tag-changes-history))))
443
444 ;;; Tagging
445
446 (defun notmuch-update-tags (tags tag-changes)
447   "Return a copy of TAGS with additions and removals from TAG-CHANGES.
448
449 TAG-CHANGES must be a list of tags names, each prefixed with
450 either a \"+\" to indicate the tag should be added to TAGS if not
451 present or a \"-\" to indicate that the tag should be removed
452 from TAGS if present."
453   (let ((result-tags (copy-sequence tags)))
454     (dolist (tag-change tag-changes)
455       (let ((tag (and (not (string-empty-p tag-change))
456                       (substring tag-change 1))))
457         (cl-case (aref tag-change 0)
458           (?+ (unless (member tag result-tags)
459                 (push tag result-tags)))
460           (?- (setq result-tags (delete tag result-tags)))
461           (otherwise
462            (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))
463     (sort result-tags 'string<)))
464
465 (defconst notmuch-tag-argument-limit 1000
466   "Use batch tagging if the tagging query is longer than this.
467
468 This limits the length of arguments passed to the notmuch CLI to
469 avoid system argument length limits and performance problems.")
470
471 (defun notmuch-tag (query tag-changes)
472   "Add/remove tags in TAG-CHANGES to messages matching QUERY.
473
474 QUERY should be a string containing the search-terms.
475 TAG-CHANGES is a list of strings of the form \"+tag\" or
476 \"-tag\" to add or remove tags, respectively.
477
478 Note: Other code should always use this function to alter tags of
479 messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
480 directly, so that hooks specified in notmuch-before-tag-hook and
481 notmuch-after-tag-hook will be run."
482   ;; Perform some validation
483   (dolist (tag-change tag-changes)
484     (unless (string-match-p "^[-+]\\S-+$" tag-change)
485       (error "Tag must be of the form `+this_tag' or `-that_tag'")))
486   (unless query
487     (error "Nothing to tag!"))
488   (when tag-changes
489     (notmuch-dlet ((tag-changes tag-changes)
490                    (query query))
491       (run-hooks 'notmuch-before-tag-hook))
492     (if (<= (length query) notmuch-tag-argument-limit)
493         (apply 'notmuch-call-notmuch-process "tag"
494                (append tag-changes (list "--" query)))
495       ;; Use batch tag mode to avoid argument length limitations
496       (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ")
497                               " -- " query)))
498         (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch")))
499     (notmuch-dlet ((tag-changes tag-changes)
500                    (query query))
501       (run-hooks 'notmuch-after-tag-hook))))
502
503 (defun notmuch-tag-change-list (tags &optional reverse)
504   "Convert TAGS into a list of tag changes.
505
506 Add a \"+\" prefix to any tag in TAGS list that doesn't already
507 begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
508 \"+\" prefixes with \"-\" and vice versa in the result."
509   (mapcar (lambda (str)
510             (let ((s (if (string-match "^[+-]" str) str (concat "+" str))))
511               (if reverse
512                   (concat (if (= (string-to-char s) ?-) "+" "-")
513                           (substring s 1))
514                 s)))
515           tags))
516
517 (defvar notmuch-tag-jump-reverse-key "k"
518   "The key in tag-jump to switch to the reverse tag changes.")
519
520 (defun notmuch-tag-jump (reverse)
521   "Create a jump menu for tagging operations.
522
523 Creates and displays a jump menu for the tagging operations
524 specified in `notmuch-tagging-keys'. If REVERSE is set then it
525 offers a menu of the reverses of the operations specified in
526 `notmuch-tagging-keys'; i.e. each `+tag' is replaced by `-tag'
527 and vice versa."
528   ;; In principle this function is simple, but it has to deal with
529   ;; lots of cases: different modes (search/show/tree), whether a name
530   ;; is specified, whether the tagging operations is a list of
531   ;; tag-ops, or a symbol that evaluates to such a list, and whether
532   ;; REVERSE is specified.
533   (interactive "P")
534   (let (action-map)
535     (pcase-dolist (`(,key ,tag ,name) notmuch-tagging-keys)
536       (let* ((tag-function (cl-case major-mode
537                              (notmuch-search-mode #'notmuch-search-tag)
538                              (notmuch-show-mode #'notmuch-show-tag)
539                              (notmuch-tree-mode #'notmuch-tree-tag)))
540              (tag (if (symbolp tag)
541                       (symbol-value tag)
542                     tag))
543              (tag-change (if reverse
544                              (notmuch-tag-change-list tag t)
545                            tag))
546              (name (or (and (not (string= name ""))
547                             name)
548                        (and (symbolp name)
549                             (symbol-name name))))
550              (name-string (if name
551                               (if reverse
552                                   (concat "Reverse " name)
553                                 name)
554                             (mapconcat #'identity tag-change " "))))
555         (push (list key name-string
556                     `(lambda () (,tag-function ',tag-change)))
557               action-map)))
558     (push (list notmuch-tag-jump-reverse-key
559                 (if reverse
560                     "Forward tag changes "
561                   "Reverse tag changes")
562                 (apply-partially 'notmuch-tag-jump (not reverse)))
563           action-map)
564     (setq action-map (nreverse action-map))
565     (notmuch-jump action-map "Tag: ")))
566
567 ;;; _
568
569 (provide 'notmuch-tag)
570
571 ;;; notmuch-tag.el ends here