* mu4e-send.el: use more descriptive buffer names, based on Subject:, if any

This commit is contained in:
djcb
2012-04-01 21:36:13 +03:00
parent ac632e9ec8
commit 501885e5da

View File

@ -318,6 +318,7 @@ use the new docid. Returns the full path to the new message."
(add-hook 'before-save-hook 'mu4e-remove-mail-header-separator)
(add-hook 'after-save-hook
(lambda ()
(mu4e-set-buffer-name)
(mu4e-insert-mail-header-separator)
(set-buffer-modified-p nil)))
@ -344,6 +345,23 @@ use the new docid. Returns the full path to the new message."
(setq default-directory (expand-file-name "~/")))
(defconst mu4e-send-buffer-max-name-length 20
"Maximum length of the mu4e-send-buffer-name.")
(defun mu4e-set-buffer-name (&optional compose-type)
"Set some user-friendly buffer name based on the compose type."
(let* ((subj (message-field-value "subject"))
(subj (unless (and subj (string-match "^[:blank:]*$" subj)) subj))
(str (or subj
(case compose-type
(reply "*reply*")
(forward "*forward*")
(otherwise "*draft*")))))
(rename-buffer (generate-new-buffer-name
(truncate-string-to-width str
mu4e-send-buffer-max-name-length
nil nil t)))))
(defun mu4e-send-compose-handler (compose-type &optional original-msg includes)
"Create a new draft message, or open an existing one.
@ -408,6 +426,8 @@ using Gnus' `message-mode'."
(message-goto-to)
(message-goto-body))
(mu4e-set-buffer-name compose-type)
;; buffer is not user-modified yet
(set-buffer-modified-p nil)))