]> git.cworth.org Git - notmuch/blob - emacs/notmuch-tag.el
4c974679944871aec3dd8301ea9e820b0b43807c
[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\" xmlns=\"http://www.w3.org/2000/svg\">
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\" xmlns=\"http://www.w3.org/2000/svg\">
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\" xmlns=\"http://www.w3.org/2000/svg\">
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 ;;; track history of tag operations
279 (defvar-local notmuch-tag-history nil
280   "Buffer local history of `notmuch-tag' function.")
281
282 ;;; Format Handling
283
284 (defvar notmuch-tag--format-cache (make-hash-table :test 'equal)
285   "Cache of tag format lookup.  Internal to `notmuch-tag-format-tag'.")
286
287 (defun notmuch-tag-clear-cache ()
288   "Clear the internal cache of tag formats."
289   (clrhash notmuch-tag--format-cache))
290
291 (defun notmuch-tag--get-formats (tag alist)
292   "Find the first item whose car regexp-matches TAG."
293   (save-match-data
294     ;; Don't use assoc-default since there's no way to distinguish a
295     ;; missing key from a present key with a null cdr.
296     (cl-assoc tag alist
297               :test (lambda (tag key)
298                       (and (eq (string-match key tag) 0)
299                            (= (match-end 0) (length tag)))))))
300
301 (defun notmuch-tag--do-format (bare-tag tag formats)
302   "Apply a tag-formats entry to TAG."
303   (cond ((null formats)         ;; - Tag not in `formats',
304          tag)                   ;;   the format is the tag itself.
305         ((null (cdr formats))   ;; - Tag was deliberately hidden,
306          nil)                   ;;   no format must be returned
307         (t
308          ;; Tag was found and has formats, we must apply all the
309          ;; formats.  TAG may be null so treat that as a special case.
310          (let ((return-tag (copy-sequence (or tag ""))))
311            (dolist (format (cdr formats))
312              (setq return-tag
313                    (eval format
314                          `((bare-tag . ,bare-tag)
315                            (tag . ,return-tag)))))
316            (if (and (null tag) (equal return-tag ""))
317                nil
318              return-tag)))))
319
320 (defun notmuch-tag-format-tag (tags orig-tags tag)
321   "Format TAG according to `notmuch-tag-formats'.
322
323 TAGS and ORIG-TAGS are lists of the current tags and the original
324 tags; tags which have been deleted (i.e., are in ORIG-TAGS but
325 are not in TAGS) are shown using formats from
326 `notmuch-tag-deleted-formats'; tags which have been added (i.e.,
327 are in TAGS but are not in ORIG-TAGS) are shown using formats
328 from `notmuch-tag-added-formats' and tags which have not been
329 changed (the normal case) are shown using formats from
330 `notmuch-tag-formats'."
331   (let* ((tag-state (cond ((not (member tag tags)) 'deleted)
332                           ((not (member tag orig-tags)) 'added)))
333          (formatted-tag (gethash (cons tag tag-state)
334                                  notmuch-tag--format-cache
335                                  'missing)))
336     (when (eq formatted-tag 'missing)
337       (let ((base (notmuch-tag--get-formats tag notmuch-tag-formats))
338             (over (cl-case tag-state
339                     (deleted (notmuch-tag--get-formats
340                               tag notmuch-tag-deleted-formats))
341                     (added (notmuch-tag--get-formats
342                             tag notmuch-tag-added-formats))
343                     (otherwise nil))))
344         (setq formatted-tag (notmuch-tag--do-format tag tag base))
345         (setq formatted-tag (notmuch-tag--do-format tag formatted-tag over))
346         (puthash (cons tag tag-state) formatted-tag notmuch-tag--format-cache)))
347     formatted-tag))
348
349 (defun notmuch-tag-format-tags (tags orig-tags &optional face)
350   "Return a string representing formatted TAGS."
351   (let ((face (or face 'notmuch-tag-face))
352         (all-tags (sort (delete-dups (append tags orig-tags nil)) #'string<)))
353     (notmuch-apply-face
354      (mapconcat #'identity
355                 ;; nil indicated that the tag was deliberately hidden
356                 (delq nil (mapcar (apply-partially #'notmuch-tag-format-tag
357                                                    tags orig-tags)
358                                   all-tags))
359                 " ")
360      face
361      t)))
362
363 ;;; Hooks
364
365 (defcustom notmuch-before-tag-hook nil
366   "Hooks that are run before tags of a message are modified.
367
368 'tag-changes' will contain the tags that are about to be added or removed as
369 a list of strings of the form \"+TAG\" or \"-TAG\".
370 'query' will be a string containing the search query that determines
371 the messages that are about to be tagged."
372   :type 'hook
373   :options '(notmuch-hl-line-mode)
374   :group 'notmuch-hooks)
375
376 (defcustom notmuch-after-tag-hook nil
377   "Hooks that are run after tags of a message are modified.
378
379 'tag-changes' will contain the tags that were added or removed as
380 a list of strings of the form \"+TAG\" or \"-TAG\".
381 'query' will be a string containing the search query that determines
382 the messages that were tagged."
383   :type 'hook
384   :options '(notmuch-hl-line-mode)
385   :group 'notmuch-hooks)
386
387 ;;; User Input
388
389 (defvar notmuch-select-tag-history nil
390   "Minibuffer history of `notmuch-select-tag-with-completion' function.")
391
392 (defvar notmuch-read-tag-changes-history nil
393   "Minibuffer history of `notmuch-read-tag-changes' function.")
394
395 (defun notmuch-tag-completions (&rest search-terms)
396   "Return a list of tags for messages matching SEARCH-TERMS.
397
398 Return all tags if no search terms are given."
399   (unless search-terms
400     (setq search-terms (list "*")))
401   (split-string
402    (with-output-to-string
403      (with-current-buffer standard-output
404        (apply 'notmuch--call-process notmuch-command nil t
405               nil "search" "--output=tags" "--exclude=false" search-terms)))
406    "\n+" t))
407
408 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
409   (completing-read prompt
410                    (apply #'notmuch-tag-completions search-terms)
411                    nil nil nil 'notmuch-select-tag-history))
412
413 (defun notmuch-read-tag-changes (current-tags &optional prompt initial-input)
414   "Prompt for tag changes in the minibuffer.
415
416 CURRENT-TAGS is a list of tags that are present on the message
417 or messages to be changed.  These are offered as tag removal
418 completions.  CURRENT-TAGS may contain duplicates.  PROMPT, if
419 non-nil, is the query string to present in the minibuffer.  It
420 defaults to \"Tags\".  INITIAL-INPUT, if non-nil, will be the
421 initial input in the minibuffer."
422   (let* ((all-tag-list (notmuch-tag-completions))
423          (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))
424          (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags))
425          (tag-list (append add-tag-list remove-tag-list))
426          (prompt (concat (or prompt "Tags") " (+add -drop): "))
427          (crm-separator " ")
428          ;; By default, space is bound to "complete word" function.
429          ;; Re-bind it to insert a space instead.  Note that <tab>
430          ;; still does the completion.
431          (crm-local-completion-map
432           (let ((map (make-sparse-keymap)))
433             (set-keymap-parent map crm-local-completion-map)
434             (define-key map " " 'self-insert-command)
435             map)))
436     (completing-read-multiple prompt tag-list
437                               nil nil initial-input
438                               'notmuch-read-tag-changes-history)))
439
440 ;;; Tagging
441
442 (defun notmuch-update-tags (tags tag-changes)
443   "Return a copy of TAGS with additions and removals from TAG-CHANGES.
444
445 TAG-CHANGES must be a list of tags names, each prefixed with
446 either a \"+\" to indicate the tag should be added to TAGS if not
447 present or a \"-\" to indicate that the tag should be removed
448 from TAGS if present."
449   (let ((result-tags (copy-sequence tags)))
450     (dolist (tag-change tag-changes)
451       (let ((tag (and (not (string-empty-p tag-change))
452                       (substring tag-change 1))))
453         (cl-case (aref tag-change 0)
454           (?+ (unless (member tag result-tags)
455                 (push tag result-tags)))
456           (?- (setq result-tags (delete tag result-tags)))
457           (otherwise
458            (error "Changed tag must be of the form `+this_tag' or `-that_tag'")))))
459     (sort result-tags 'string<)))
460
461 (defconst notmuch-tag-argument-limit 1000
462   "Use batch tagging if the tagging query is longer than this.
463
464 This limits the length of arguments passed to the notmuch CLI to
465 avoid system argument length limits and performance problems.
466
467 NOTE: this variable is no longer used.")
468
469 (make-obsolete-variable 'notmuch-tag-argument-limit nil "notmuch 0.36")
470
471 (defun notmuch-tag (query tag-changes &optional omit-hist)
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 \"-tag\"
476 to add or remove tags, respectively.  OMIT-HIST disables history
477 tracking if non-nil.
478
479 Note: Other code should always use this function to alter tags of
480 messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
481 directly, so that hooks specified in notmuch-before-tag-hook and
482 notmuch-after-tag-hook will be run."
483   ;; Perform some validation
484   (dolist (tag-change tag-changes)
485     (unless (string-match-p "^[-+]\\S-+$" tag-change)
486       (error "Tag must be of the form `+this_tag' or `-that_tag'")))
487   (unless query
488     (error "Nothing to tag!"))
489   (when tag-changes
490     (notmuch-dlet ((tag-changes tag-changes)
491                    (query query))
492       (run-hooks 'notmuch-before-tag-hook))
493     (with-temp-buffer
494       (insert (concat (mapconcat #'notmuch-hex-encode tag-changes " ") " -- " query))
495       (unless (= 0
496                  (notmuch--call-process-region
497                   (point-min) (point-max) notmuch-command t t nil "tag" "--batch"))
498         (notmuch-logged-error "notmuch tag failed" (buffer-string))))
499     (unless omit-hist
500       (push (list :query query :tag-changes tag-changes) notmuch-tag-history)))
501   (notmuch-dlet ((tag-changes tag-changes)
502                  (query query))
503     (run-hooks 'notmuch-after-tag-hook)))
504
505 (defun notmuch-tag-change-list (tags &optional reverse)
506   "Convert TAGS into a list of tag changes.
507
508 Add a \"+\" prefix to any tag in TAGS list that doesn't already
509 begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
510 \"+\" prefixes with \"-\" and vice versa in the result."
511   (mapcar (lambda (str)
512             (let ((s (if (string-match "^[+-]" str) str (concat "+" str))))
513               (if reverse
514                   (concat (if (= (string-to-char s) ?-) "+" "-")
515                           (substring s 1))
516                 s)))
517           tags))
518
519 (defvar notmuch-tag-jump-reverse-key "k"
520   "The key in tag-jump to switch to the reverse tag changes.")
521
522 (defun notmuch-tag-jump (reverse)
523   "Create a jump menu for tagging operations.
524
525 Creates and displays a jump menu for the tagging operations
526 specified in `notmuch-tagging-keys'. If REVERSE is set then it
527 offers a menu of the reverses of the operations specified in
528 `notmuch-tagging-keys'; i.e. each `+tag' is replaced by `-tag'
529 and vice versa."
530   ;; In principle this function is simple, but it has to deal with
531   ;; lots of cases: different modes (search/show/tree), whether a name
532   ;; is specified, whether the tagging operations is a list of
533   ;; tag-ops, or a symbol that evaluates to such a list, and whether
534   ;; REVERSE is specified.
535   (interactive "P")
536   (let (action-map)
537     (pcase-dolist (`(,key ,tag ,name) notmuch-tagging-keys)
538       (let* ((tag-function (cl-case major-mode
539                              (notmuch-search-mode #'notmuch-search-tag)
540                              (notmuch-show-mode #'notmuch-show-tag)
541                              (notmuch-tree-mode #'notmuch-tree-tag)))
542              (tag (if (symbolp tag)
543                       (symbol-value tag)
544                     tag))
545              (tag-change (if reverse
546                              (notmuch-tag-change-list tag t)
547                            tag))
548              (name (or (and (not (string= name ""))
549                             name)
550                        (and (symbolp name)
551                             (symbol-name name))))
552              (name-string (if name
553                               (if reverse
554                                   (concat "Reverse " name)
555                                 name)
556                             (mapconcat #'identity tag-change " "))))
557         (push (list key name-string
558                     (lambda () (funcall tag-function tag-change)))
559               action-map)))
560     (push (list notmuch-tag-jump-reverse-key
561                 (if reverse
562                     "Forward tag changes "
563                   "Reverse tag changes")
564                 (apply-partially 'notmuch-tag-jump (not reverse)))
565           action-map)
566     (setq action-map (nreverse action-map))
567     (notmuch-jump action-map "Tag: ")))
568
569 ;;; _
570
571 (provide 'notmuch-tag)
572
573 ;;; notmuch-tag.el ends here