* mua updates
This commit is contained in:
@ -30,6 +30,8 @@
|
||||
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(require 'ido)
|
||||
|
||||
(defconst mua/log-buffer-name "*mua-log*" "name of the logging buffer")
|
||||
|
||||
(defun mua/warn (frm &rest args)
|
||||
@ -82,79 +84,5 @@ maildir."
|
||||
(chosen (ido-completing-read prompt showfolders)))
|
||||
(concat (if fullpath mua/maildir "") chosen)))
|
||||
|
||||
(defun mua/maildir-flags-from-path (path)
|
||||
"Get the flags for the message at PATH, which does not have to exist.
|
||||
The flags are returned as a list consisting of one or more of
|
||||
DFNPRST, mean resp. Deleted, Flagged, New, Passed Replied, Seen
|
||||
and Trash, as defined in [1]. See `mua/maildir-string-to-flags'
|
||||
and `mua/maildir-flags-to-string'.
|
||||
\[1\] http://cr.yp.to/proto/maildir.html."
|
||||
(when (string-match ",\\(\[A-Z\]*\\)$" path)
|
||||
(mua/maildir-string-to-flags (match-string 1 path))))
|
||||
|
||||
|
||||
|
||||
(defun mua/maildir-from-path (path &optional dont-strip-prefix)
|
||||
"Get the maildir from path; in this context, 'maildir' is the
|
||||
part between the `mua/maildir' and the /cur or /new; so
|
||||
e.g. \"/home/user/Maildir/foo/bar/cur/12345:2,S\" would have
|
||||
\"/foo/bar\" as its maildir. If DONT-STRIP-PREFIX is non-nil,
|
||||
function will instead _not_ remove the `mua/maildir' from the
|
||||
front - so in that case, the example would return
|
||||
\"/home/user/Maildir/foo/bar/\". If the maildir cannot be
|
||||
determined, return `nil'."
|
||||
(when (and (string-match "^\\(.*\\)/\\(cur\\|new\\)/\[^/\]*$" path))
|
||||
(let ((mdir (match-string 1 path)))
|
||||
(when (and (< (length mua/maildir) (length mdir))
|
||||
(string= (substring mdir 0 (length mua/maildir)) mua/maildir))
|
||||
(if dont-strip-prefix
|
||||
mdir
|
||||
(substring mdir (length mua/maildir)))))))
|
||||
|
||||
;; TODO: ensure flag string have the chars in ASCII-order (as per maildir spec)
|
||||
;; TODO: filter-out duplicate flags
|
||||
|
||||
(defun mua/maildir-flags-to-string (flags)
|
||||
"Convert a list of flags into a string as seen in Maildir
|
||||
message files; flags are symbols draft, flagged, new, passed,
|
||||
replied, seen, trashed and the string is the concatenation of the
|
||||
uppercased first letters of these flags, as per [1]. Other flags
|
||||
than the ones listed here are ignored.
|
||||
|
||||
Also see `mua/maildir-string-to-flags'.
|
||||
|
||||
\[1\]: http://cr.yp.to/proto/maildir.html"
|
||||
(when flags
|
||||
(let ((kar
|
||||
(case (car flags)
|
||||
('draft ?D)
|
||||
('flagged ?F)
|
||||
('passed ?P)
|
||||
('replied ?R)
|
||||
('seen ?S)
|
||||
('trashed ?T))))
|
||||
(concat (and kar (string kar))
|
||||
(mua/maildir-flags-to-string (cdr flags))))))
|
||||
|
||||
(defun mua/maildir-string-to-flags (str)
|
||||
"Convert a string with message flags as seen in Maildir
|
||||
messages into a list of flags in; flags are symbols draft,
|
||||
flagged, new, passed, replied, seen, trashed and the string is
|
||||
the concatenation of the uppercased first letters of these flags,
|
||||
as per [1]. Other letters than the ones listed here are ignored.
|
||||
Also see `mua/maildir-flags-to-string'.
|
||||
|
||||
\[1\]: http://cr.yp.to/proto/maildir.html"
|
||||
(when (/= 0 (length str))
|
||||
(let ((flag
|
||||
(case (string-to-char str)
|
||||
(?D 'draft)
|
||||
(?F 'flagged)
|
||||
(?P 'passed)
|
||||
(?R 'replied)
|
||||
(?S 'seen)
|
||||
(?T 'trashed))))
|
||||
(append (when flag (list flag))
|
||||
(mua/maildir-string-to-flags (substring str 1))))))
|
||||
|
||||
(provide 'mua-common)
|
||||
|
||||
Reference in New Issue
Block a user