diff --git a/toys/mm/mm-common.el b/toys/mm/mm-common.el index 0f845fbe..d5f5f13b 100644 --- a/toys/mm/mm-common.el +++ b/toys/mm/mm-common.el @@ -31,7 +31,6 @@ - ;;; converting flags->string and vice-versa ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -59,6 +58,7 @@ Also see `mm/flags-to-string'. ('replied ?R) ('seen ?S) ('trashed ?T) + ('attach ?a) ('encrypted ?x) ('signed ?s) ('unread ?u)))) diff --git a/toys/mm/mm-hdrs.el b/toys/mm/mm-hdrs.el index 47b8b146..5c0a62c2 100644 --- a/toys/mm/mm-hdrs.el +++ b/toys/mm/mm-hdrs.el @@ -143,7 +143,7 @@ if provided, or at the end of the buffer otherwise." (lambda (ct) (let ((name (car ct)) (email (cdr ct))) (or name email "?"))) val ", ")) - (:date (format-time-string "%x %X" val)) + (:date (format-time-string "%x %X" val)) (:flags (mm/flags-to-string val)) (:size (cond @@ -151,7 +151,8 @@ if provided, or at the end of the buffer otherwise." ((and (>= val 1000) (< val 1000000)) (format "%2.1fK" (/ val 1000.0))) ((< val 1000) (format "%d" val)))) - (t (error "Unsupported header field (%S)" field))))) + (t + (error "Unsupported header field (%S)" field))))) (when str (if (not width) str @@ -159,16 +160,20 @@ if provided, or at the end of the buffer otherwise." mm/header-fields " ")) (flags (plist-get msg :flags)) (line (cond - ((member 'trashed flags) (propertize line 'face 'mm/trashed-face)) - ((member 'unread flags) (propertize line 'face 'mm/unread-face)) - (t (propertize line 'face 'mm/header-face))))) - (mm/hdrs-add-header line (plist-get msg :docid) + ((member 'draft flags) + (propertize line 'face 'mm/draft-face 'draft t)) + ((member 'trashed flags) + (propertize line 'face 'mm/trashed-face)) + ((member 'unread flags) + (propertize line 'face 'mm/unread-face)) + (t ;; else + (propertize line 'face 'mm/header-face))))) + (mm/hdrs-add-header line (plist-get msg :docid) (if point point (point-max))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - ;;; hdrs-mode and mode-map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -291,8 +296,7 @@ on the screen, when we receive (:update ) notices from the mu server.") (defun mm/hdrs-add-header (str docid point) - "Add header STR with DOCID to the buffer. If POINT is not -provided, put it at the end of the buffer." + "Add header STR with DOCID to the buffer at POINT." (unless docid (error "Invalid message")) (when (buffer-live-p mm/hdrs-buffer) (with-current-buffer mm/hdrs-buffer @@ -465,13 +469,19 @@ start editing it. COMPOSE-TYPE is either `reply', `forward' or `edit'." (if (eq compose-type 'new) (mm/send-compose-handler 'new) - (let ((docid (mm/hdrs-get-docid))) + (let ((docid (mm/hdrs-get-docid)) + ;; note, the first two chars of the line (the mark margin) does *not* + ;; have the 'draft property; thus, we check one char before the end of + ;; the current line instead + (is-draft (get-text-property (- (line-end-position) 1) 'draft))) (unless docid (error "No message at point.")) (cond ((member compose-type '(reply forward)) (mm/proc-compose compose-type docid)) ((eq compose-type 'edit) + (unless is-draft + (error "Cannot edit a non-draft message")) (mm/proc-compose 'edit docid)) (t (error "invalid compose type %S" compose-type)))))) @@ -635,9 +645,6 @@ folder (`mm/trash-folder')." (mm/hdrs-compose 'edit))) - - - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (provide 'mm-hdrs) diff --git a/toys/mm/mm.el b/toys/mm/mm.el index 5d8b71da..5cea07c8 100644 --- a/toys/mm/mm.el +++ b/toys/mm/mm.el @@ -198,10 +198,16 @@ be sure it no longer matches)." :group 'mm/faces) (defface mm/trashed-face - '((t :inherit font-lock-comment-face :strike-though t)) + '((t :inherit font-lock-comment-face :strike-through t)) "Face for an message header in the trash folder." :group 'mm/faces) +(defface mm/draft-face + '((t :inherit font-lock-string-face)) + "Face for a draft message header (i.e., a message with the draft +flag set)." + :group 'mm/faces) + (defface mm/header-face '((t :inherit default)) "Face for an mm header without any special flags."