mirror of https://github.com/djcb/mu.git
* small cleanup of the retagging support
This commit is contained in:
parent
cd138a17dc
commit
0e204fece4
|
@ -407,7 +407,8 @@ cmd_add (ServerContext *ctx, GSList *args, GError **err)
|
||||||
|
|
||||||
msg = mu_store_get_msg (ctx->store, docid, err);
|
msg = mu_store_get_msg (ctx->store, docid, err);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
sexp = mu_msg_to_sexp (msg, docid, NULL, MU_MSG_OPTION_VERIFY);
|
sexp = mu_msg_to_sexp (msg, docid, NULL,
|
||||||
|
MU_MSG_OPTION_VERIFY);
|
||||||
print_expr ("(:update %s :move nil)", sexp);
|
print_expr ("(:update %s :move nil)", sexp);
|
||||||
|
|
||||||
mu_msg_unref(msg);
|
mu_msg_unref(msg);
|
||||||
|
|
|
@ -189,24 +189,24 @@ store your org-contacts."
|
||||||
"Change tags of a message. Example: +tag \"+long tag\" -oldtag
|
"Change tags of a message. Example: +tag \"+long tag\" -oldtag
|
||||||
adds 'tag' and 'long tag', and removes oldtag."
|
adds 'tag' and 'long tag', and removes oldtag."
|
||||||
(let* ((retag (read-string "Tags: "))
|
(let* ((retag (read-string "Tags: "))
|
||||||
(path (mu4e-message-field msg :path))
|
(path (mu4e-message-field msg :path))
|
||||||
(maildir (mu4e-message-field msg :maildir))
|
(maildir (mu4e-message-field msg :maildir))
|
||||||
(oldtags (mu4e-message-field msg :tags))
|
(oldtags (mu4e-message-field msg :tags))
|
||||||
(header mu4e-action-tags-header)
|
(header mu4e-action-tags-header)
|
||||||
(sep (cond ((string= header "Keywords") " ")
|
(sep (cond ((string= header "Keywords") " ")
|
||||||
((string= header "X-Label") " ")
|
((string= header "X-Label") " ")
|
||||||
((string= header "X-Keywords") ", ")
|
((string= header "X-Keywords") ", ")
|
||||||
(t ", ")))
|
(t ", ")))
|
||||||
(taglist (if oldtags (copy-sequence oldtags) '()))
|
(taglist (if oldtags (copy-sequence oldtags) '()))
|
||||||
tagstr)
|
tagstr)
|
||||||
|
|
||||||
(dolist (tag (split-string-and-unquote retag) taglist)
|
(dolist (tag (split-string-and-unquote retag) taglist)
|
||||||
(cond ((string-match "\\+\\(.+\\)" tag)
|
(cond ((string-match "\\+\\(.+\\)" tag)
|
||||||
(setq taglist (push (match-string 1 tag) taglist)))
|
(setq taglist (push (match-string 1 tag) taglist)))
|
||||||
((string-match "\\-\\(.+\\)" tag)
|
((string-match "\\-\\(.+\\)" tag)
|
||||||
(setq taglist (delete (match-string 1 tag) taglist)))
|
(setq taglist (delete (match-string 1 tag) taglist)))
|
||||||
(t
|
(t
|
||||||
(setq taglist (push tag taglist)))))
|
(setq taglist (push tag taglist)))))
|
||||||
|
|
||||||
(setq taglist (sort (delete-dups taglist) 'string<))
|
(setq taglist (sort (delete-dups taglist) 'string<))
|
||||||
(setq tagstr (mapconcat 'identity taglist sep))
|
(setq tagstr (mapconcat 'identity taglist sep))
|
||||||
|
@ -214,10 +214,10 @@ store your org-contacts."
|
||||||
|
|
||||||
;; replaces keywords with sed, restricted to the header
|
;; replaces keywords with sed, restricted to the header
|
||||||
(call-process "sed" nil nil nil "-ine"
|
(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-message (concat "tagging: " (mapconcat 'identity taglist " ")))
|
||||||
(mu4e~proc-add path maildir)))
|
(mu4e-refresh-message path maildir)))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,7 @@ will be called for, resp., a message (header row) or an error."
|
||||||
;; sortfield is e.g. ':subject'; this removes the ':'
|
;; sortfield is e.g. ':subject'; this removes the ':'
|
||||||
(if (null sortfield) "nil" (substring (symbol-name sortfield) 1))
|
(if (null sortfield) "nil" (substring (symbol-name sortfield) 1))
|
||||||
;; TODO: use ascending/descending in backend too (it's clearer than 'reverse'
|
;; TODO: use ascending/descending in backend too (it's clearer than 'reverse'
|
||||||
(if (eq sortdir 'descending) "true" "false")
|
(if (eq sortdir 'descending) "true" "false")
|
||||||
(if maxnum maxnum -1)))
|
(if maxnum maxnum -1)))
|
||||||
|
|
||||||
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags)
|
(defun mu4e~proc-move (docid-or-msgid &optional maildir flags)
|
||||||
|
@ -397,7 +397,7 @@ of 'my' email addresses (see `mu4e-user-mail-address-list')."
|
||||||
"Add the message at PATH to the database.
|
"Add the message at PATH to the database.
|
||||||
With MAILDIR set to the maildir this message resides in,
|
With MAILDIR set to the maildir this message resides in,
|
||||||
e.g. '/drafts'; if this works, we will receive (:info add :path
|
e.g. '/drafts'; if this works, we will receive (:info add :path
|
||||||
<path> :docid <docid>)."
|
<path> :docid <docid>) as well as (:update <msg-sexp>)."
|
||||||
(mu4e~proc-send-command "add path:\"%s\" maildir:\"%s\""
|
(mu4e~proc-send-command "add path:\"%s\" maildir:\"%s\""
|
||||||
path maildir))
|
path maildir))
|
||||||
|
|
||||||
|
|
|
@ -169,14 +169,16 @@ debuggable (backtrace) error."
|
||||||
(mu4e-log 'error (apply 'mu4e-format frm args))
|
(mu4e-log 'error (apply 'mu4e-format frm args))
|
||||||
(error "%s" (apply 'mu4e-format frm args)))
|
(error "%s" (apply 'mu4e-format frm args)))
|
||||||
|
|
||||||
|
;; the user-error function is only available in emacs-trunk
|
||||||
|
(unless (fboundp 'user-error)
|
||||||
|
(defalias 'user-error 'error))
|
||||||
|
|
||||||
(defun mu4e-warn (frm &rest args)
|
(defun mu4e-warn (frm &rest args)
|
||||||
"Create [mu4e]-prefixed warning based on format FRM and ARGS.
|
"Create [mu4e]-prefixed warning based on format FRM and ARGS.
|
||||||
Does a local-exit and does not return. In emacs versions below
|
Does a local-exit and does not return. In emacs versions below
|
||||||
24.2, the functions is the same as `mu4e-error'."
|
24.2, the functions is the same as `mu4e-error'."
|
||||||
(mu4e-log 'error (apply 'mu4e-format frm args))
|
(mu4e-log 'error (apply 'mu4e-format frm args))
|
||||||
(if (fboundp 'user-error)
|
(user-error "%s" (apply 'mu4e-format frm args)))
|
||||||
(user-error "%s" (apply 'mu4e-format frm args)) ;; only in emacs-trunk
|
|
||||||
(error "%s" (apply 'mu4e-format frm args))))
|
|
||||||
|
|
||||||
(defun mu4e~read-char-choice (prompt choices)
|
(defun mu4e~read-char-choice (prompt choices)
|
||||||
"Compatiblity wrapper for `read-char-choice'.
|
"Compatiblity wrapper for `read-char-choice'.
|
||||||
|
@ -218,7 +220,7 @@ Function will return the cdr of the list element."
|
||||||
;; try to detect old-style options, and warn
|
;; try to detect old-style options, and warn
|
||||||
(when (characterp (car-safe (cdr-safe option)))
|
(when (characterp (car-safe (cdr-safe option)))
|
||||||
(mu4e-error (concat "Please use the new format for options/actions; "
|
(mu4e-error (concat "Please use the new format for options/actions; "
|
||||||
"see the manual")))
|
"see the manual")))
|
||||||
(let* ((kar (substring (car option) 0 1))
|
(let* ((kar (substring (car option) 0 1))
|
||||||
(val (cdr option)))
|
(val (cdr option)))
|
||||||
(concat
|
(concat
|
||||||
|
@ -628,7 +630,7 @@ successful, call FUNC (if non-nil) afterwards."
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; getting mail / updating the index
|
;; getting mail / updating the index
|
||||||
;;
|
;;
|
||||||
;;
|
;;
|
||||||
(defvar mu4e~update-timer nil
|
(defvar mu4e~update-timer nil
|
||||||
|
@ -694,7 +696,7 @@ window."
|
||||||
(switch-to-buffer buf)
|
(switch-to-buffer buf)
|
||||||
(set-window-dedicated-p win t)
|
(set-window-dedicated-p win t)
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert "\n"))) ;; FIXME -- needed so output starts
|
(insert "\n"))) ;; FIXME -- needed so output starts
|
||||||
(set-process-sentinel proc
|
(set-process-sentinel proc
|
||||||
(lambda (proc msg)
|
(lambda (proc msg)
|
||||||
(let* ((status (process-status proc))
|
(let* ((status (process-status proc))
|
||||||
|
@ -714,7 +716,7 @@ window."
|
||||||
(process-put proc 'x-interactive (not run-in-background))
|
(process-put proc 'x-interactive (not run-in-background))
|
||||||
(set-process-filter proc 'mu4e~get-mail-process-filter))))
|
(set-process-filter proc 'mu4e~get-mail-process-filter))))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -889,6 +891,11 @@ displaying it). Do _not_ bury the current buffer, though."
|
||||||
(goto-char (point-min)))
|
(goto-char (point-min)))
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defun mu4e-refresh-message (path maildir)
|
||||||
|
"Re-parse message at PATH and MAILDIR; if this works, we will
|
||||||
|
receive (:info add :path <path> :docid <docid>) as well as (:update
|
||||||
|
<msg-sexp>)."
|
||||||
|
(mu4e~proc-add path maildir))
|
||||||
|
|
||||||
(provide 'mu4e-utils)
|
(provide 'mu4e-utils)
|
||||||
;;; End of mu4e-utils.el
|
;;; End of mu4e-utils.el
|
||||||
|
|
Loading…
Reference in New Issue