* mm updates

This commit is contained in:
djcb
2011-11-13 12:44:54 +02:00
parent 38bd3e5fce
commit b4c32a53b7
3 changed files with 49 additions and 41 deletions

View File

@ -138,38 +138,39 @@ into a string."
(defun mm/hdrs-header-handler (msg &optional point) (defun mm/hdrs-header-handler (msg &optional point)
"Create a one line description of MSG in this buffer, at POINT, "Create a one line description of MSG in this buffer, at POINT,
if provided, or at the end of the buffer otherwise." if provided, or at the end of the buffer otherwise."
(let* ((line (mapconcat (let* ((line
(lambda (f-w) (mapconcat
(let* ((field (car f-w)) (width (cdr f-w)) (lambda (f-w)
(val (plist-get msg field)) (let* ((field (car f-w)) (width (cdr f-w))
(str (val (plist-get msg field))
(case field (str
((:subject :maildir :path) val) (case field
((:to :from :cc :bcc) (mm/hdrs-contact-str val)) ((:subject :maildir :path) val)
;; if we (ie. `user-mail-address' is the 'From', show 'To', otherwise ((:to :from :cc :bcc) (mm/hdrs-contact-str val))
;; show From ;; if we (ie. `user-mail-address' is the 'From', show 'To', otherwise
(:from-or-to ;; show From
(let* ((from-lst (plist-get msg :from)) (:from-or-to
(from (and from-lst (cdar from-lst)))) (let* ((from-lst (plist-get msg :from))
(if (and from (string-match mm/user-mail-address-regexp from)) (from (and from-lst (cdar from-lst))))
(concat (propertize "To " 'face 'mm/system-face) (if (and from (string-match mm/user-mail-address-regexp from))
(mm/hdrs-contact-str (plist-get msg :to))) (concat "To "
(mm/hdrs-contact-str from-lst)))) (mm/hdrs-contact-str (plist-get msg :to)))
(:date (format-time-string mm/headers-date-format val)) (mm/hdrs-contact-str from-lst))))
(:flags (mm/flags-to-string val)) (:date (format-time-string mm/headers-date-format val))
(:size (:flags (mm/flags-to-string val))
(cond (:size
((>= val 1000000) (format "%2.1fM" (/ val 1000000.0))) (cond
((and (>= val 1000) (< val 1000000)) ((>= val 1000000) (format "%2.1fM" (/ val 1000000.0)))
(format "%2.1fK" (/ val 1000.0))) ((and (>= val 1000) (< val 1000000))
((< val 1000) (format "%d" val)))) (format "%2.1fK" (/ val 1000.0)))
(t ((< val 1000) (format "%d" val))))
(error "Unsupported header field (%S)" field))))) (t
(when str (error "Unsupported header field (%S)" field)))))
(if (not width) (when str
str (if (not width)
(truncate-string-to-width str width 0 ?\s t))))) str
mm/headers-fields " ")) (truncate-string-to-width str width 0 ?\s t)))))
mm/headers-fields " "))
(flags (plist-get msg :flags)) (flags (plist-get msg :flags))
(line (cond (line (cond
((member 'draft flags) ((member 'draft flags)
@ -451,7 +452,7 @@ The following marks are available, and the corresponding props:
(when target (when target
(let* ((targetstr (propertize (concat "-> " target " ") (let* ((targetstr (propertize (concat "-> " target " ")
'face 'mm/system-face)) 'face 'mm/system-face))
(start (+ 2 (point))) ;; +2 for the marker fringe (start (+ 2 (line-beginning-position))) ;; +2 for the marker fringe
(overlay (make-overlay start (+ start (length targetstr))))) (overlay (make-overlay start (+ start (length targetstr)))))
(overlay-put overlay 'display targetstr))))))) (overlay-put overlay 'display targetstr)))))))

View File

@ -360,7 +360,15 @@ using Gnus' `message-mode'."
"Move the message in this buffer to the sent folder. This is "Move the message in this buffer to the sent folder. This is
meant to be called from message mode's `message-sent-hook'." meant to be called from message mode's `message-sent-hook'."
(unless mm/sent-folder (error "mm/sent-folder not set")) (unless mm/sent-folder (error "mm/sent-folder not set"))
(let ((docid (gethash (buffer-file-name) mm/path-docid-map))) (save-excursion
(goto-char (point-min))
;; remove the --text follows this line-- separator
(if (search-forward-regexp (concat "^" mail-header-separator "\n"))
(replace-match "")
(error "cannot find mail-header-separator"))
(save-buffer)
(let ((docid (gethash (buffer-file-name) mm/path-docid-map)))
(unless docid (error "unknown message (%S)" (buffer-file-name))) (unless docid (error "unknown message (%S)" (buffer-file-name)))
;; ok, all seems well, well move the message to the sent-folder ;; ok, all seems well, well move the message to the sent-folder
(mm/proc-move-msg docid mm/sent-folder "-T-D+S") (mm/proc-move-msg docid mm/sent-folder "-T-D+S")
@ -368,9 +376,9 @@ using Gnus' `message-mode'."
;; are not other compose buffers using this very same docid... ;; are not other compose buffers using this very same docid...
;; mark the buffer as read-only, as its pointing at a non-existing file ;; mark the buffer as read-only, as its pointing at a non-existing file
;; now... ;; now...
(message "Message has been sent") (kill-buffer-and-window)
(setq buffer-read-only t))) (message "Message has been sent"))))
@ -403,7 +411,6 @@ This is meant to be called from message mode's
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t) (while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
(push (match-string 0) refs)) (push (match-string 0) refs))
(setq forwarded-from (car-safe (last refs))))))) (setq forwarded-from (car-safe (last refs)))))))
;; remove the <> ;; remove the <>
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to)) (when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
(mm/proc-flag (match-string 1 in-reply-to) "+R")) (mm/proc-flag (match-string 1 in-reply-to) "+R"))

View File

@ -342,7 +342,7 @@ removing '^M' etc."
(add-text-properties p (point-max) '(face mm/view-footer-face)))) (add-text-properties p (point-max) '(face mm/view-footer-face))))
;; this is fairly simplistic... ;; this is fairly simplistic...
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "\\(https?://[-a-zA-Z0-9?_.$%/=+&#@!]*\\)\\>" nil t) (while (re-search-forward "\\(https?://[-a-zA-Z0-9?_.$%/=+&#@!~,]*\\)\\>" nil t)
(let ((subst (propertize (match-string-no-properties 0) (let ((subst (propertize (match-string-no-properties 0)
'face 'mm/view-link-face))) 'face 'mm/view-link-face)))
(incf num) (incf num)