* small cleanup of the retagging support

This commit is contained in:
djcb
2012-12-09 15:07:21 +02:00
parent cd138a17dc
commit 0e204fece4
4 changed files with 37 additions and 29 deletions

View File

@ -189,24 +189,24 @@ store your org-contacts."
"Change tags of a message. Example: +tag \"+long tag\" -oldtag
adds 'tag' and 'long tag', and removes oldtag."
(let* ((retag (read-string "Tags: "))
(path (mu4e-message-field msg :path))
(maildir (mu4e-message-field msg :maildir))
(oldtags (mu4e-message-field msg :tags))
(header mu4e-action-tags-header)
(sep (cond ((string= header "Keywords") " ")
((string= header "X-Label") " ")
((string= header "X-Keywords") ", ")
(t ", ")))
(taglist (if oldtags (copy-sequence oldtags) '()))
tagstr)
(path (mu4e-message-field msg :path))
(maildir (mu4e-message-field msg :maildir))
(oldtags (mu4e-message-field msg :tags))
(header mu4e-action-tags-header)
(sep (cond ((string= header "Keywords") " ")
((string= header "X-Label") " ")
((string= header "X-Keywords") ", ")
(t ", ")))
(taglist (if oldtags (copy-sequence oldtags) '()))
tagstr)
(dolist (tag (split-string-and-unquote retag) taglist)
(cond ((string-match "\\+\\(.+\\)" tag)
(setq taglist (push (match-string 1 tag) taglist)))
((string-match "\\-\\(.+\\)" tag)
(setq taglist (delete (match-string 1 tag) taglist)))
(t
(setq taglist (push tag taglist)))))
(cond ((string-match "\\+\\(.+\\)" tag)
(setq taglist (push (match-string 1 tag) taglist)))
((string-match "\\-\\(.+\\)" tag)
(setq taglist (delete (match-string 1 tag) taglist)))
(t
(setq taglist (push tag taglist)))))
(setq taglist (sort (delete-dups taglist) 'string<))
(setq tagstr (mapconcat 'identity taglist sep))
@ -214,10 +214,10 @@ store your org-contacts."
;; replaces keywords with sed, restricted to the header
(call-process "sed" nil nil nil "-ine"
(format "1,/^$/s/^%s:.*$/%s: %s/" header header tagstr) path)
(format "1,/^$/s/^%s:.*$/%s: %s/" header header tagstr) path)
(message (concat "tagging: " (mapconcat 'identity taglist " ")))
(mu4e~proc-add path maildir)))
(mu4e-message (concat "tagging: " (mapconcat 'identity taglist " ")))
(mu4e-refresh-message path maildir)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;