mu4e-compose: fix some overly long lines

This commit is contained in:
Dirk-Jan C. Binnema
2021-09-19 09:57:44 +03:00
parent a8ddc1728d
commit 4dc15334a6

View File

@ -1,4 +1,4 @@
;;; mu4e-compose.el -- part of mu4e, the mu mail user agent for emacs -*- lexical-binding: t -*- ;;; mu4e-compose.el -- part of mu4e -*- lexical-binding: t -*-
;; Copyright (C) 2011-2020 Dirk-Jan C. Binnema ;; Copyright (C) 2011-2020 Dirk-Jan C. Binnema
@ -104,6 +104,7 @@ Messages are captured with `mu4e-action-capture-message'."
;;; Misc ;;; Misc
;; 'fcc' refers to saving a copy of a sent message to a certain folder. that's ;; 'fcc' refers to saving a copy of a sent message to a certain folder. that's
;; what these 'Sent mail' folders are for! ;; what these 'Sent mail' folders are for!
;; ;;
;; We let message mode take care of this by adding a field ;; We let message mode take care of this by adding a field
@ -149,11 +150,13 @@ If needed, set the Fcc header, and register the handler function."
(let ((maildir mdir) (let ((maildir mdir)
(old-handler message-fcc-handler-function)) (old-handler message-fcc-handler-function))
(lambda (file) (lambda (file)
(setq message-fcc-handler-function old-handler) ;; reset the fcc handler (setq message-fcc-handler-function old-handler)
;; reset the fcc handler
(let ((mdir-path (concat (mu4e-root-maildir) maildir))) (let ((mdir-path (concat (mu4e-root-maildir) maildir)))
;; Create the full maildir structure for the sent folder if it doesn't exist. ;; Create the full maildir structure for the sent folder if it
;; `mu4e--server-mkdir` runs asynchronously but no matter whether it runs before or after ;; doesn't exist. `mu4e--server-mkdir` runs asynchronously but
;; `write-file`, the sent maildir ends up in the correct state. ;; no matter whether it runs before or after `write-file`, the
;; sent maildir ends up in the correct state.
(unless (file-exists-p mdir-path) (unless (file-exists-p mdir-path)
(mu4e--server-mkdir mdir-path))) (mu4e--server-mkdir mdir-path)))
(write-file file) ;; writing maildirs files is easy (write-file file) ;; writing maildirs files is easy
@ -453,7 +456,8 @@ buffers; lets remap its faces so it uses the ones for mu4e."
(forward "*forward*") (forward "*forward*")
(otherwise "*draft*"))))) (otherwise "*draft*")))))
(rename-buffer (generate-new-buffer-name (rename-buffer (generate-new-buffer-name
(truncate-string-to-width str mu4e~compose-buffer-max-name-length) (truncate-string-to-width
str mu4e~compose-buffer-max-name-length)
(buffer-name))))) (buffer-name)))))
(defun mu4e-compose-crypto-message (parent compose-type) (defun mu4e-compose-crypto-message (parent compose-type)
@ -480,7 +484,8 @@ See `mu4e-compose-crypto-policy' for more details."
(memq 'encrypt-plain-replies mu4e-compose-crypto-policy)) (memq 'encrypt-plain-replies mu4e-compose-crypto-policy))
;; encrypted replies ;; encrypted replies
(and (eq compose-type 'reply) encrypted-p (and (eq compose-type 'reply) encrypted-p
(memq 'encrypt-encrypted-replies mu4e-compose-crypto-policy)))) (memq 'encrypt-encrypted-replies
mu4e-compose-crypto-policy))))
(sign (sign
(or (memq 'sign-all-messages mu4e-compose-crypto-policy) (or (memq 'sign-all-messages mu4e-compose-crypto-policy)
;; new messages ;; new messages
@ -542,8 +547,7 @@ are optional."
(mu4e--context-autoswitch mu4e-compose-parent-message (mu4e--context-autoswitch mu4e-compose-parent-message
mu4e-compose-context-policy) mu4e-compose-context-policy)
(run-hooks 'mu4e-compose-pre-hook) (run-hooks 'mu4e-compose-pre-hook)
;; this opens (or re-opens) a message with all the basic headers set.
;; this opens (or re-opens) a messages with all the basic headers set.
(let ((winconf (current-window-configuration))) (let ((winconf (current-window-configuration)))
(condition-case nil (condition-case nil
(mu4e-draft-open compose-type original-msg switch-function) (mu4e-draft-open compose-type original-msg switch-function)
@ -647,10 +651,13 @@ when the buffer is in `mu4e-compose-mode':
(unless (and name (not force) (eq old-context name)) (unless (and name (not force) (eq old-context name))
(when (or (not has-file) (when (or (not has-file)
(not (buffer-modified-p)) (not (buffer-modified-p))
(y-or-n-p "Draft must be saved before switching context. Save?")) (y-or-n-p
(unless (and (not force) (eq old-context (mu4e-context-switch nil name))) "Draft must be saved before switching context. Save?"))
(unless (and (not force)
(eq old-context (mu4e-context-switch nil name)))
;; Change From field to user-mail-address ;; Change From field to user-mail-address
(message-replace-header "From" (or (mu4e~draft-from-construct) "")) (message-replace-header "From"
(or (mu4e~draft-from-construct) ""))
;; Move message to mu4e-draft-folder ;; Move message to mu4e-draft-folder
(if has-file (if has-file
(progn (save-buffer) (progn (save-buffer)
@ -659,9 +666,13 @@ when the buffer is in `mu4e-compose-mode':
;; Remove the <> ;; Remove the <>
(when (and msg-id (string-match "<\\(.*\\)>" msg-id)) (when (and msg-id (string-match "<\\(.*\\)>" msg-id))
(save-window-excursion (save-window-excursion
(mu4e--server-move (match-string 1 msg-id) mu4e-drafts-folder nil t) (mu4e--server-move (match-string 1 msg-id)
(kill-buffer buf))))) ;; Kill previous buffer which points to wrong file mu4e-drafts-folder nil t)
;; No file, just change the buffer file name (kill-buffer buf))))) ;; Kill previous buffer
;; which points to wrong
;; file No file, just
;; change the buffer file
;; name
(setq buffer-file-name (setq buffer-file-name
(format "%s/%s/cur/%s" (format "%s/%s/cur/%s"
(mu4e-root-maildir) (mu4e-get-drafts-folder) (mu4e-root-maildir) (mu4e-get-drafts-folder)
@ -815,7 +826,8 @@ draft message."
;;;###autoload ;;;###autoload
(defun mu4e~compose-mail (&optional to subject other-headers _continue (defun mu4e~compose-mail (&optional to subject other-headers _continue
switch-function yank-action _send-actions _return-action) switch-function yank-action
_send-actions _return-action)
"This is mu4e's implementation of `compose-mail'. "This is mu4e's implementation of `compose-mail'.
Quoting its docstring: Quoting its docstring:
Start composing a mail message to send. Start composing a mail message to send.
@ -851,8 +863,8 @@ buffer buried."
(unless (mu4e-running-p) (unless (mu4e-running-p)
(mu4e)) (mu4e))
;; create a new draft message 'resetting' (as below) is not actually needed in this case, but ;; create a new draft message 'resetting' (as below) is not actually needed in
;; let's prepare for the re-edit case as well ;; this case, but let's prepare for the re-edit case as well
(mu4e~compose-handler 'new nil nil switch-function) (mu4e~compose-handler 'new nil nil switch-function)
(when (message-goto-to) ;; reset to-address, if needed (when (message-goto-to) ;; reset to-address, if needed