X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-mua.el;h=c679373b175955092858c7bfe8366a4aa088c91e;hp=ac878a619d07e7c4947f1c359b9d6825580516b6;hb=HEAD;hpb=1ef7c75111b84ea19af3186ddc12f2ba434c93de diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index ac878a61..74c62aaf 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -142,6 +142,16 @@ to `notmuch-mua-send-hook'." :type 'regexp :group 'notmuch-send) +(defcustom notmuch-mua-subject-regexp + "[[:blank:]]*$" + "Message subject indicating that something may be amiss. +By default, this checks for empty subject lines. + +This is not used unless `notmuch-mua-subject-check' is added to +`notmuch-mua-send-hook'." + :type 'regexp + :group 'notmuch-send) + ;;; Various functions (defun notmuch-mua-attachment-check () @@ -179,6 +189,19 @@ Typically this is added to `notmuch-mua-send-hook'." ;; ...signal an error. (error "Missing attachment"))) +(defun notmuch-mua-subject-check () + "Signal an error if the subject seems amiss. +More precisely, if the subject conforms to +`notmuch-mua-subject-regexp'. + +Typically this is added to `notmuch-mua-send-hook'." + (or (save-excursion + (message-goto-subject) + (message-beginning-of-header t) + (not (looking-at-p notmuch-mua-subject-regexp))) + (y-or-n-p "Subject may be erroneous – is that okay?") + (error "Erroneous subject"))) + (defun notmuch-mua-get-switch-function () "Get a switch function according to `notmuch-mua-compose-in'." (pcase notmuch-mua-compose-in @@ -356,7 +379,9 @@ Typically this is added to `notmuch-mua-send-hook'." (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]" "Notmuch message composition mode. Mostly like `message-mode'." - (notmuch-address-setup)) + (notmuch-address-setup) + (when (boundp 'untrusted-content) + (setq untrusted-content t))) (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify) @@ -401,9 +426,10 @@ instead of `message-mode' and SWITCH-FUNCTION is mandatory." (addr (and good-tokens (mapconcat #'identity good-tokens ", ")))) (message-replace-header header addr)))))) +;;;###autoload (defun notmuch-mua-mail (&optional to subject other-headers _continue switch-function yank-action send-actions - return-action &rest ignored) + return-action &rest _ignored) "Invoke the notmuch mail composition window. The position of point when the function returns differs depending @@ -416,11 +442,6 @@ moved to the \"To:\" header." (let ((user-agent (funcall notmuch-mua-user-agent-function))) (unless (string-empty-p user-agent) (push (cons 'User-Agent user-agent) other-headers)))) - (unless (assq 'From other-headers) - (push (cons 'From (message-make-from - (notmuch-user-name) - (notmuch-user-primary-email))) - other-headers)) (notmuch-mua-pop-to-buffer (message-buffer-name "mail" to) (or switch-function (notmuch-mua-get-switch-function))) @@ -439,6 +460,11 @@ moved to the \"To:\" header." ;; Cause `message-setup-1' to do things relevant for mail, ;; such as observe `message-default-mail-headers'. (message-this-is-mail t)) + (unless (assq 'From headers) + (push (cons 'From (message-make-from + (notmuch-user-name) + (notmuch-user-primary-email))) + headers)) (message-setup-1 headers yank-action send-actions return-action)) (notmuch-fcc-header-setup) (notmuch-mua--remove-dont-reply-to-names) @@ -622,20 +648,24 @@ unencrypted. Really send? ")))) (message-send-and-exit arg) (message-send arg))))) +;;;###autoload (defun notmuch-mua-send-and-exit (&optional arg) (interactive "P") (notmuch-mua-send-common arg t)) +;;;###autoload (defun notmuch-mua-send (&optional arg) (interactive "P") (notmuch-mua-send-common arg)) +;;;###autoload (defun notmuch-mua-kill-buffer () (interactive) (message-kill-buffer)) ;;; _ +;;;###autoload (define-mail-user-agent 'notmuch-user-agent 'notmuch-mua-mail 'notmuch-mua-send-and-exit