2023-09-20 21:31:19 +02:00
|
|
|
|
;;; mu4e-compose.el --- Compose and send messages -*- lexical-binding: t -*-
|
2020-02-11 12:23:40 +01:00
|
|
|
|
|
2024-03-02 22:20:06 +01:00
|
|
|
|
;; Copyright (C) 2011-2024 Dirk-Jan C. Binnema
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
|
|
|
|
;; Author: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
|
|
|
;; Maintainer: Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
|
|
|
|
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
2020-02-11 12:23:40 +01:00
|
|
|
|
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; mu4e is free software: you can redistribute it and/or modify
|
2011-09-18 13:39:36 +02:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; mu4e is distributed in the hope that it will be useful,
|
2011-09-18 13:39:36 +02:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2021-05-29 23:36:13 +02:00
|
|
|
|
;; along with mu4e. If not, see <http://www.gnu.org/licenses/>.
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; Implements mu4e-compose-mode, which is a `message-mode' derivative. This is a
|
|
|
|
|
;; *fairly* thin wrapper around the gnus functions for message composition,
|
2023-12-02 11:50:13 +01:00
|
|
|
|
;; integrated with mu4e. Still, quite a bit of code to make it work nicely in
|
|
|
|
|
;; the mu4e context.
|
2011-09-18 13:39:36 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
2024-03-14 18:40:16 +01:00
|
|
|
|
;;; Code:
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(require 'message)
|
2024-03-15 18:46:10 +01:00
|
|
|
|
(require 'sendmail)
|
|
|
|
|
(require 'gnus-msg)
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(require 'nnheader) ;; for make-full-mail-header
|
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(require 'mu4e-obsolete)
|
2021-08-29 18:53:53 +02:00
|
|
|
|
(require 'mu4e-server)
|
2012-09-26 16:28:30 +02:00
|
|
|
|
(require 'mu4e-message)
|
2017-03-18 09:24:51 +01:00
|
|
|
|
(require 'mu4e-context)
|
2023-11-01 18:33:33 +01:00
|
|
|
|
(require 'mu4e-folders)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;; User configuration for compose-mode
|
|
|
|
|
(defgroup mu4e-compose nil
|
|
|
|
|
"Customization for composing/sending messages."
|
|
|
|
|
:group 'mu4e)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-sent-messages-behavior 'sent
|
|
|
|
|
"Determines what mu4e does with sent messages.
|
|
|
|
|
|
|
|
|
|
This is one of the symbols:
|
|
|
|
|
* `sent' move the sent message to the Sent-folder (`mu4e-sent-folder')
|
|
|
|
|
* `trash' move the sent message to the Trash-folder (`mu4e-trash-folder')
|
|
|
|
|
* `delete' delete the sent message.
|
|
|
|
|
|
|
|
|
|
Note, when using GMail/IMAP, you should set this to either
|
|
|
|
|
`trash' or `delete', since GMail already takes care of keeping
|
|
|
|
|
copies in the sent folder.
|
|
|
|
|
|
|
|
|
|
Alternatively, `mu4e-sent-messages-behavior' can be a function
|
|
|
|
|
which takes no arguments, and which should return one of the mentioned
|
|
|
|
|
symbols, for example:
|
|
|
|
|
|
|
|
|
|
(setq mu4e-sent-messages-behavior (lambda ()
|
|
|
|
|
(if (string= (message-sendmail-envelope-from) \"foo@example.com\")
|
|
|
|
|
\\='delete \\='sent)))
|
|
|
|
|
|
|
|
|
|
The various `message-' functions from `message-mode' are available
|
|
|
|
|
for querying the message information."
|
|
|
|
|
:type '(choice (const :tag "move message to mu4e-sent-folder" sent)
|
|
|
|
|
(const :tag "move message to mu4e-trash-folder" trash)
|
|
|
|
|
(const :tag "delete message" delete))
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-compose-switch nil
|
|
|
|
|
"Where to display the new message?
|
|
|
|
|
A symbol:
|
2024-03-02 22:20:06 +01:00
|
|
|
|
- nil : default (new buffer)
|
|
|
|
|
- window : compose in new window
|
|
|
|
|
- frame or t : compose in new frame
|
2024-03-14 18:40:16 +01:00
|
|
|
|
- display-buffer: use `display-buffer' / `display-buffer-alist'
|
2024-03-02 22:20:06 +01:00
|
|
|
|
(for fine-tuning).
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
For backward compatibility with `mu4e-compose-in-new-frame', t is
|
|
|
|
|
treated as =\\'frame."
|
|
|
|
|
:type 'symbol
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-compose-context-policy 'ask
|
|
|
|
|
"Policy for determining the context when composing a new message.
|
|
|
|
|
|
|
|
|
|
If the value is `always-ask', ask the user unconditionally.
|
|
|
|
|
|
|
|
|
|
In all other cases, if any context matches (using its match
|
|
|
|
|
function), this context is used. Otherwise, if none of the
|
|
|
|
|
contexts match, we have the following choices:
|
|
|
|
|
|
|
|
|
|
- `pick-first': pick the first of the contexts available (ie. the default)
|
|
|
|
|
- `ask': ask the user
|
|
|
|
|
- `ask-if-none': ask if there is no context yet, otherwise leave it as it is
|
|
|
|
|
- nil: return nil; leaves the current context as is.
|
|
|
|
|
|
|
|
|
|
Also see `mu4e-context-policy'."
|
|
|
|
|
:type '(choice
|
|
|
|
|
(const :tag "Always ask what context to use" always-ask)
|
|
|
|
|
(const :tag "Ask if none of the contexts match" ask)
|
|
|
|
|
(const :tag "Ask when there's no context yet" ask-if-none)
|
|
|
|
|
(const :tag "Pick the first context if none match" pick-first)
|
|
|
|
|
(const :tag "Don't change the context when none match" nil))
|
|
|
|
|
:safe 'symbolp
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-compose-crypto-policy
|
|
|
|
|
'(encrypt-encrypted-replies sign-encrypted-replies)
|
|
|
|
|
"Policy to control when messages will be signed/encrypted.
|
|
|
|
|
|
|
|
|
|
The value is a list which influence the way draft messages are
|
|
|
|
|
created. Specifically, it might contain:
|
|
|
|
|
|
|
|
|
|
- `sign-all-messages': Always add a signature.
|
|
|
|
|
- `sign-new-messages': Add a signature to new message, ie.
|
|
|
|
|
messages that aren't responses to another message.
|
|
|
|
|
- `sign-forwarded-messages': Add a signature when forwarding
|
|
|
|
|
a message
|
|
|
|
|
- `sign-edited-messages': Add a signature to drafts
|
|
|
|
|
- `sign-all-replies': Add a signature when responding to
|
|
|
|
|
another message.
|
|
|
|
|
- `sign-plain-replies': Add a signature when responding to
|
|
|
|
|
non-encrypted messages.
|
|
|
|
|
- `sign-encrypted-replies': Add a signature when responding
|
|
|
|
|
to encrypted messages.
|
|
|
|
|
|
|
|
|
|
It should be noted that certain symbols have priorities over one
|
|
|
|
|
another. So `sign-all-messages' implies `sign-all-replies', which
|
|
|
|
|
in turn implies `sign-plain-replies'. Adding both to the set, is
|
|
|
|
|
not a contradiction, but a redundant configuration.
|
|
|
|
|
|
|
|
|
|
All `sign-*' options have a `encrypt-*' analogue."
|
|
|
|
|
:type '(set :greedy t
|
|
|
|
|
(const :tag "Sign all messages" sign-all-messages)
|
|
|
|
|
(const :tag "Encrypt all messages" encrypt-all-messages)
|
|
|
|
|
(const :tag "Sign new messages" sign-new-messages)
|
|
|
|
|
(const :tag "Encrypt new messages" encrypt-new-messages)
|
2024-03-04 11:09:56 +01:00
|
|
|
|
(const :tag "Sign forwarded messages" sign-forwarded-messages)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(const :tag "Encrypt forwarded messages"
|
|
|
|
|
encrypt-forwarded-messages)
|
|
|
|
|
(const :tag "Sign edited messages" sign-edited-messages)
|
|
|
|
|
(const :tag "Encrypt edited messages" edited-forwarded-messages)
|
|
|
|
|
(const :tag "Sign all replies" sign-all-replies)
|
|
|
|
|
(const :tag "Encrypt all replies" encrypt-all-replies)
|
|
|
|
|
(const :tag "Sign replies to plain messages" sign-plain-replies)
|
|
|
|
|
(const :tag "Encrypt replies to plain messages"
|
|
|
|
|
encrypt-plain-replies)
|
|
|
|
|
(const :tag "Sign replies to encrypted messages"
|
|
|
|
|
sign-encrypted-replies)
|
|
|
|
|
(const :tag "Encrypt replies to encrypted messages"
|
|
|
|
|
encrypt-encrypted-replies))
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-compose-format-flowed nil
|
|
|
|
|
"Whether to compose messages to be sent as format=flowed.
|
|
|
|
|
\(Or with long lines if variable `use-hard-newlines' is set to
|
|
|
|
|
nil). The variable `fill-flowed-encode-column' lets you customize
|
|
|
|
|
the width beyond which format=flowed lines are wrapped."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:safe 'booleanp
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
|
|
|
|
(defcustom mu4e-compose-pre-hook nil
|
|
|
|
|
"Hook run just *before* message composition starts.
|
|
|
|
|
|
|
|
|
|
If the compose-type is a symbol, either `reply' or `forward', the
|
|
|
|
|
variable `mu4e-compose-parent-message' is the message replied to
|
|
|
|
|
/ being forwarded / edited, and `mu4e-compose-type' contains the
|
|
|
|
|
type of message to be composed.
|
|
|
|
|
|
|
|
|
|
Note that there is no draft message yet when this hook runs, it
|
|
|
|
|
is meant for influencing the how mu4e constructs the draft
|
|
|
|
|
message. If you want to do something with the draft messages
|
|
|
|
|
after it has been constructed, `mu4e-compose-mode-hook' would be
|
|
|
|
|
the place to do that."
|
|
|
|
|
:type 'hook
|
|
|
|
|
:group 'mu4e-compose)
|
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;; Runtime variables; useful for user-hooks etc.
|
|
|
|
|
(defvar-local mu4e-compose-parent-message nil
|
|
|
|
|
"The parent message plist.
|
|
|
|
|
This is the message being replied to, forwarded or edited; used
|
|
|
|
|
in `mu4e-compose-pre-hook'. For new (non-reply, forward etc.)
|
|
|
|
|
messages, it is nil.")
|
2012-04-26 17:08:42 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defvar-local mu4e-compose-type nil
|
|
|
|
|
"The compose-type for the current message.")
|
2021-11-07 10:43:17 +01:00
|
|
|
|
|
2024-03-04 09:48:45 +01:00
|
|
|
|
(defvar mu4e-captured-message)
|
|
|
|
|
(defun mu4e-compose-attach-captured-message ()
|
|
|
|
|
"Insert the last captured message file as an attachment.
|
|
|
|
|
Messages are captured with `mu4e-action-capture-message'."
|
|
|
|
|
(interactive)
|
|
|
|
|
(if-let* ((msg mu4e-captured-message)
|
|
|
|
|
(path (plist-get msg :path))
|
|
|
|
|
(path (and (file-exists-p path) path)))
|
|
|
|
|
(mml-attach-file
|
|
|
|
|
path
|
|
|
|
|
"message/rfc822"
|
|
|
|
|
(or (plist-get msg :subject) "No subject")
|
|
|
|
|
"attachment")
|
|
|
|
|
(mu4e-warn "No valid message has been captured")))
|
2024-03-04 09:50:59 +01:00
|
|
|
|
|
2024-03-12 18:29:07 +01:00
|
|
|
|
;; Go to bottom / top
|
|
|
|
|
|
|
|
|
|
(defun mu4e-compose-goto-top (&optional arg)
|
|
|
|
|
"Go to the beginning of the message or buffer.
|
|
|
|
|
Go to the beginning of the message or, if already there, go to
|
|
|
|
|
the beginning of the buffer.
|
|
|
|
|
|
|
|
|
|
Push mark at previous position, unless either a
|
2024-03-14 18:40:16 +01:00
|
|
|
|
\\[universal-argument] prefix ARG is supplied, or Transient Mark mode
|
2024-03-12 18:29:07 +01:00
|
|
|
|
is enabled and the mark is active."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(or arg
|
|
|
|
|
(region-active-p)
|
|
|
|
|
(push-mark))
|
|
|
|
|
(let ((old-position (point)))
|
|
|
|
|
(message-goto-body)
|
|
|
|
|
(when (equal (point) old-position)
|
|
|
|
|
(goto-char (point-min)))))
|
|
|
|
|
|
|
|
|
|
(defun mu4e-compose-goto-bottom (&optional arg)
|
|
|
|
|
"Go to the end of the message or buffer.
|
|
|
|
|
Go to the end of the message (before signature) or, if already
|
|
|
|
|
there, go to the end of the buffer.
|
|
|
|
|
|
|
|
|
|
Push mark at previous position, unless either a
|
2024-03-14 18:40:16 +01:00
|
|
|
|
\\[universal-argument] prefix ARG is supplied, or Transient Mark mode
|
2024-03-12 18:29:07 +01:00
|
|
|
|
is enabled and the mark is active."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
(or arg
|
|
|
|
|
(region-active-p)
|
|
|
|
|
(push-mark))
|
|
|
|
|
(let ((old-position (point))
|
|
|
|
|
(message-position (save-excursion (message-goto-body) (point))))
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(when (re-search-backward message-signature-separator message-position t)
|
|
|
|
|
(forward-line -1))
|
|
|
|
|
(when (equal (point) old-position)
|
|
|
|
|
(goto-char (point-max)))))
|
|
|
|
|
|
2024-03-04 09:50:59 +01:00
|
|
|
|
(defun mu4e-compose-context-switch (&optional force name)
|
|
|
|
|
"Change the context for the current draft message.
|
|
|
|
|
|
|
|
|
|
With NAME, switch to the context with NAME, and with FORCE non-nil,
|
|
|
|
|
switch even if the switch is to the same context.
|
|
|
|
|
|
|
|
|
|
Like `mu4e-context-switch' but with some changes after switching:
|
|
|
|
|
1. Update the From and Organization headers as per the new context
|
2024-03-14 18:40:16 +01:00
|
|
|
|
2. Update the `message-signature' as per the new context.
|
2024-03-04 09:50:59 +01:00
|
|
|
|
|
|
|
|
|
Unlike some earlier version of this function, does _not_ update
|
|
|
|
|
the draft folder for the messages, as that would require changing
|
|
|
|
|
the file under our feet, which is a bit fragile."
|
|
|
|
|
(interactive "P")
|
|
|
|
|
|
|
|
|
|
(unless (derived-mode-p 'mu4e-compose-mode)
|
|
|
|
|
(mu4e-error "Only available in mu4e compose buffers"))
|
|
|
|
|
|
|
|
|
|
(let ((old-context (mu4e-context-current)))
|
|
|
|
|
(unless (and name (not force) (eq old-context name))
|
|
|
|
|
(unless (and (not force)
|
|
|
|
|
(eq old-context (mu4e-context-switch nil name)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
;; Change From / Organization if needed.
|
|
|
|
|
(message-replace-header "Organization"
|
|
|
|
|
(or (message-make-organization) "")
|
|
|
|
|
'("Subject")) ;; keep in same place
|
|
|
|
|
(message-replace-header "From"
|
|
|
|
|
(or (message-make-from) ""))
|
|
|
|
|
;; Update signature.
|
|
|
|
|
(when (message-goto-signature) ;; delete old signature.
|
|
|
|
|
(if message-signature-insert-empty-line
|
|
|
|
|
(forward-line -2) (forward-line -1))
|
|
|
|
|
(delete-region (point) (point-max)))
|
|
|
|
|
(when message-signature
|
|
|
|
|
(save-excursion (message-insert-signature))))))))
|
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
;;; Filenames
|
|
|
|
|
(defun mu4e--message-basename()
|
|
|
|
|
"Construct a randomized filename for a message with flags FLAGSTR.
|
|
|
|
|
It looks something like
|
|
|
|
|
<time>-<random>.<hostname>
|
|
|
|
|
|
|
|
|
|
This filename is used for the draft message and the sent message,
|
|
|
|
|
depending on `mu4e-sent-messages-behavior'."
|
|
|
|
|
(let* ((sysname (if (fboundp 'system-name)
|
|
|
|
|
(system-name) (with-no-warnings system-name)))
|
|
|
|
|
(sysname (if (string= sysname "") "localhost" sysname))
|
|
|
|
|
(hostname (downcase
|
|
|
|
|
(save-match-data
|
|
|
|
|
(substring sysname
|
|
|
|
|
(string-match "^[^.]+" sysname)
|
|
|
|
|
(match-end 0))))))
|
|
|
|
|
(format "%s.%04x%04x%04x%04x.%s"
|
|
|
|
|
(format-time-string "%s" (current-time))
|
|
|
|
|
(random 65535) (random 65535) (random 65535) (random 65535)
|
|
|
|
|
hostname)))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--draft-message-path (base-name &optional parent)
|
|
|
|
|
"Construct a draft message path, based on PARENT if provided.
|
|
|
|
|
|
|
|
|
|
PARENT is either nil or the original message (being replied
|
|
|
|
|
to/forwarded etc.), and is used to determine the draft folder.
|
|
|
|
|
BASE-NAME is the base filename without any Maildir decoration."
|
|
|
|
|
(let ((draft-dir (mu4e-get-drafts-folder parent)))
|
|
|
|
|
(mu4e-join-paths
|
|
|
|
|
(mu4e-root-maildir) draft-dir "cur"
|
|
|
|
|
(format "%s%s2,DS" base-name mu4e-maildir-info-delimiter))))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--fcc-path (base-name &optional parent)
|
|
|
|
|
"Construct a Fcc: path, based on PARENT and `mu4e-sent-messages-behavior'.
|
|
|
|
|
|
|
|
|
|
PARENT is either nil or the original message (being replied
|
|
|
|
|
to/forwarded etc.), and is used to determine the sent folder,
|
|
|
|
|
together with `mu4e-sent-messages-behavior'. BASE-NAME is the
|
|
|
|
|
base filename without any Maildir decoration.
|
|
|
|
|
|
|
|
|
|
Returns the path for the sent message, either in the sent or
|
|
|
|
|
trash folder, or nil if the message should be removed after
|
|
|
|
|
sending."
|
|
|
|
|
(when-let ((sent-dir
|
|
|
|
|
(pcase mu4e-sent-messages-behavior
|
|
|
|
|
('delete nil)
|
|
|
|
|
('trash (mu4e-get-trash-folder parent))
|
|
|
|
|
('sent (mu4e-get-sent-folder parent))
|
|
|
|
|
((pred functionp) (funcall mu4e-sent-messages-behavior))
|
|
|
|
|
(_ (mu4e-error "Error in `mu4e-sent-messages-behavior'")))))
|
|
|
|
|
(mu4e-join-paths
|
|
|
|
|
(mu4e-root-maildir) sent-dir "cur"
|
|
|
|
|
(format "%s%s2,S" base-name mu4e-maildir-info-delimiter))))
|
2020-11-13 11:38:50 +01:00
|
|
|
|
|
2014-11-30 15:29:10 +01:00
|
|
|
|
|
2020-02-11 15:10:35 +01:00
|
|
|
|
;;; address completion
|
|
|
|
|
|
|
|
|
|
;; inspired by org-contacts.el and
|
2014-11-30 15:29:10 +01:00
|
|
|
|
;; https://github.com/nordlow/elisp/blob/master/mine/completion-styles-cycle.el
|
2020-02-11 15:10:35 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defun mu4e--compose-complete-handler (str pred action)
|
2019-05-25 16:38:58 +02:00
|
|
|
|
"Complete address STR with predication PRED for ACTION."
|
2015-12-29 17:53:57 +01:00
|
|
|
|
(cond
|
2020-02-11 12:00:46 +01:00
|
|
|
|
((eq action nil)
|
2022-05-09 20:22:17 +02:00
|
|
|
|
(try-completion str mu4e--contacts-set pred))
|
2020-02-11 12:00:46 +01:00
|
|
|
|
((eq action t)
|
2022-05-09 20:22:17 +02:00
|
|
|
|
(all-completions str mu4e--contacts-set pred))
|
2020-02-11 12:00:46 +01:00
|
|
|
|
((eq action 'metadata)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; our contacts are already sorted - just need to tell the completion
|
|
|
|
|
;; machinery not to try to undo that...
|
2020-02-11 12:00:46 +01:00
|
|
|
|
'(metadata
|
|
|
|
|
(display-sort-function . identity)
|
|
|
|
|
(cycle-sort-function . identity)))))
|
2012-06-24 15:34:01 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defconst mu4e--header-separator ;; XX properties down work... why not?
|
|
|
|
|
(propertize "--text follows this line--" 'read-only t 'intangible t)
|
|
|
|
|
"Line used to separate headers from text in messages being composed.")
|
|
|
|
|
|
2024-04-01 17:55:03 +02:00
|
|
|
|
(defun mu4e-complete-contact ()
|
|
|
|
|
"Attempt to complete the text at point with a contact.
|
|
|
|
|
I.e., either \"name <email>\" or \"email\". Return nil if not found.
|
|
|
|
|
|
|
|
|
|
This function can be used for `completion-at-point-functions', to
|
2024-04-15 07:19:51 +02:00
|
|
|
|
complete addresses. This can be used from outside mu4e, but mu4e
|
|
|
|
|
must be active (running) for this to work."
|
2024-04-01 17:55:03 +02:00
|
|
|
|
(let* ((end (point))
|
|
|
|
|
(start (save-excursion
|
|
|
|
|
(re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
|
|
|
|
|
(goto-char (match-end 0))
|
|
|
|
|
(point))))
|
|
|
|
|
(list start end #'mu4e--compose-complete-handler)))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-complete-contact-field ()
|
|
|
|
|
"Attempt to complete a contact when in a contact field.
|
|
|
|
|
|
|
|
|
|
This is like `mu4e-compose-complete-contact', but limited to the
|
|
|
|
|
contact fields."
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(let ((mail-abbrev-mode-regexp
|
|
|
|
|
"^\\(To\\|B?Cc\\|Reply-To\\|From\\|Sender\\):")
|
2024-04-01 17:55:03 +02:00
|
|
|
|
(mail-header-separator mu4e--header-separator))
|
|
|
|
|
(when (mail-abbrev-in-expansion-header-p)
|
|
|
|
|
(mu4e-complete-contact))))
|
2015-12-29 17:53:57 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defun mu4e--compose-setup-completion ()
|
2024-04-23 18:45:39 +02:00
|
|
|
|
"Maybe enable auto-completion of addresses.
|
|
|
|
|
Do this when `mu4e-compose-complete-addresses' is non-nil.
|
|
|
|
|
|
|
|
|
|
When enabled, this attempts to put mu4e's completions at the
|
|
|
|
|
start of the buffer-local `completion-at-point-functions'. Other
|
|
|
|
|
completion functions still apply."
|
2024-04-02 06:39:06 +02:00
|
|
|
|
(when mu4e-compose-complete-addresses
|
|
|
|
|
(set (make-local-variable 'completion-ignore-case) t)
|
|
|
|
|
(set (make-local-variable 'completion-cycle-threshold) 7)
|
|
|
|
|
(add-to-list (make-local-variable 'completion-styles) 'substring)
|
|
|
|
|
(add-hook 'completion-at-point-functions
|
2024-04-23 18:45:39 +02:00
|
|
|
|
#'mu4e--compose-complete-contact-field -10 t)))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
(defun mu4e--fcc-handler (msgpath)
|
|
|
|
|
"Handle Fcc: for MSGPATH.
|
|
|
|
|
|
|
|
|
|
This ensures that a copy of a sent messages ends up in the
|
|
|
|
|
appropriate sent-messages folder.
|
|
|
|
|
|
|
|
|
|
If MSGPATH is nil, do nothing."
|
|
|
|
|
(when msgpath
|
|
|
|
|
(let* ((target-dir (file-name-directory msgpath))
|
|
|
|
|
(target-mdir (file-name-directory target-dir)))
|
|
|
|
|
;; create maildir if needed
|
|
|
|
|
(unless (file-exists-p target-mdir)
|
|
|
|
|
(make-directory
|
|
|
|
|
(mu4e-join-paths target-mdir "cur" 'parents))
|
|
|
|
|
(make-directory
|
|
|
|
|
(mu4e-join-paths target-mdir "new" 'parents)))
|
|
|
|
|
(write-file msgpath)
|
|
|
|
|
(mu4e--server-add msgpath))))
|
|
|
|
|
|
|
|
|
|
;; save / send hooks
|
2020-11-13 11:38:50 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defvar-local mu4e--compose-undo nil
|
|
|
|
|
"Remember the undo-state.")
|
2020-11-13 11:38:50 +01:00
|
|
|
|
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(defun mu4e--delimit-headers (&optional undelimit)
|
|
|
|
|
"Delimit or undelimit (with UNDELIMIT) headers."
|
|
|
|
|
(let ((mail-header-separator mu4e--header-separator)
|
|
|
|
|
(inhibit-read-only t))
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(save-excursion
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(mail-sendmail-undelimit-header) ;; clear first
|
|
|
|
|
(unless undelimit (mail-sendmail-delimit-header)))))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-before-save ()
|
|
|
|
|
"Function called just before the draft buffer is saved."
|
|
|
|
|
;; This does 3 things:
|
2023-11-03 20:16:05 +01:00
|
|
|
|
;; - set the Message-Id if not already
|
|
|
|
|
;; - set the Date if not already
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; - (temporarily) remove the mail-header separator
|
|
|
|
|
(setq mu4e--compose-undo buffer-undo-list)
|
2016-05-06 11:12:23 +02:00
|
|
|
|
(save-excursion
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(unless (message-field-value "Message-ID")
|
|
|
|
|
(message-generate-headers '(Message-ID)))
|
|
|
|
|
;; older Emacsen (<= 28 perhaps?) won't update the Date
|
|
|
|
|
;; if there already is one; so make sure it's gone.
|
|
|
|
|
(message-remove-header "Date")
|
|
|
|
|
(message-generate-headers '(Date Subject From))
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(mu4e--delimit-headers 'undelimit))) ;; remove separator
|
2012-04-01 20:36:13 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defvar mu4e--compose-buffer-max-name-length 48)
|
|
|
|
|
(defun mu4e--compose-set-friendly-buffer-name ()
|
|
|
|
|
"Use some friendly name for this composition buffer."
|
2012-04-01 20:36:13 +02:00
|
|
|
|
(let* ((subj (message-field-value "subject"))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(subj (if (or (not subj) (string-match "^[:blank:]*$" subj))
|
|
|
|
|
"No subject" subj)))
|
2012-04-01 20:36:13 +02:00
|
|
|
|
(rename-buffer (generate-new-buffer-name
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(format "\"%s\""
|
|
|
|
|
(truncate-string-to-width subj
|
|
|
|
|
mu4e--compose-buffer-max-name-length
|
|
|
|
|
0 nil t)))
|
|
|
|
|
(buffer-name))))
|
2013-06-16 22:06:38 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defun mu4e--set-parent-flags (path)
|
2022-05-27 20:00:37 +02:00
|
|
|
|
"Set flags for replied-to and forwarded for the message at PATH.
|
|
|
|
|
That is, set the `replied' \"R\" flag on messages we replied to,
|
|
|
|
|
and the `passed' \"F\" flag on message we have forwarded.
|
|
|
|
|
|
|
|
|
|
If a message has an \"In-Reply-To\" header, it is considered a
|
|
|
|
|
reply to the message with the corresponding message id.
|
|
|
|
|
Otherwise, if it does not have an \"In-Reply-To\" header, but
|
|
|
|
|
does have a \"References:\" header, it is considered to be a
|
|
|
|
|
forward message for the message corresponding with the /last/
|
|
|
|
|
message-id in the references header.
|
|
|
|
|
|
|
|
|
|
If the message has been determined to be either a forwarded
|
2011-10-02 20:35:03 +02:00
|
|
|
|
message or a reply, we instruct the server to update that message
|
2022-05-27 20:00:37 +02:00
|
|
|
|
with resp. the \"P\" (passed) flag for a forwarded message, or
|
|
|
|
|
the \"R\" flag for a replied message. The original messages are
|
|
|
|
|
also marked as Seen.
|
2012-03-28 17:58:43 +02:00
|
|
|
|
|
2022-05-27 20:00:37 +02:00
|
|
|
|
Function assumes that it is executed in the context of the
|
|
|
|
|
message buffer."
|
2012-04-26 17:08:42 +02:00
|
|
|
|
(let ((buf (find-file-noselect path)))
|
|
|
|
|
(when buf
|
|
|
|
|
(with-current-buffer buf
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(let ((in-reply-to (message-field-value "in-reply-to"))
|
|
|
|
|
(forwarded-from)
|
|
|
|
|
(references (message-field-value "references")))
|
|
|
|
|
(unless in-reply-to
|
|
|
|
|
(when references
|
|
|
|
|
(with-temp-buffer ;; inspired by `message-shorten-references'.
|
|
|
|
|
(insert references)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(let ((refs))
|
|
|
|
|
(while (re-search-forward "<[^ <]+@[^ <]+>" nil t)
|
|
|
|
|
(push (match-string 0) refs))
|
|
|
|
|
;; the last will be the first
|
|
|
|
|
(setq forwarded-from (car refs))))))
|
|
|
|
|
;; remove the <> and update the flags on the server-side.
|
|
|
|
|
(when (and in-reply-to (string-match "<\\(.*\\)>" in-reply-to))
|
|
|
|
|
(mu4e--server-move (match-string 1 in-reply-to) nil "+R-N"))
|
|
|
|
|
(when (and forwarded-from (string-match "<\\(.*\\)>" forwarded-from))
|
|
|
|
|
(mu4e--server-move (match-string 1 forwarded-from) nil "+P-N")))))))
|
2012-10-29 11:27:32 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defun mu4e--compose-after-save()
|
|
|
|
|
"Function called immediately after the draft buffer is saved."
|
|
|
|
|
;; This does 3 things:
|
|
|
|
|
;; - restore the mail-header-separator (see mu4e--compose-before-save)
|
|
|
|
|
;; - update the buffer name (based on the message subject
|
|
|
|
|
;; - tell the mu server about the updated draft message
|
|
|
|
|
(mu4e--delimit-headers)
|
|
|
|
|
(mu4e--compose-set-friendly-buffer-name)
|
|
|
|
|
;; tell the server
|
|
|
|
|
(mu4e--server-add (buffer-file-name))
|
|
|
|
|
;; restore history.
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(setq buffer-undo-list mu4e--compose-undo))
|
|
|
|
|
|
|
|
|
|
(defun mu4e-sent-handler (docid path)
|
|
|
|
|
"Handler called with DOCID and PATH for the just-sent message.
|
|
|
|
|
For Forwarded ('Passed') and Replied messages, try to set the
|
|
|
|
|
appropriate flag at the message forwarded or replied-to."
|
2024-04-09 22:51:45 +02:00
|
|
|
|
;; XXX we don't need this function anymore here, but
|
|
|
|
|
;; we have an external caller in mu4e-icalendar... we should
|
|
|
|
|
;; update that.
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--set-parent-flags path)
|
|
|
|
|
;; if the draft file exists, remove it now.
|
|
|
|
|
(when (file-exists-p path)
|
|
|
|
|
(mu4e--server-remove docid)))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--send-harden-newlines ()
|
|
|
|
|
"Set the hard property to all newlines."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward "\n" nil t)
|
|
|
|
|
(put-text-property (1- (point)) (point) 'hard t))))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-before-send ()
|
|
|
|
|
"Function called just before sending a message."
|
|
|
|
|
;; Remove References: if In-Reply-To: is missing.
|
|
|
|
|
;; This allows the user to effectively start a new message-thread by
|
|
|
|
|
;; removing the In-Reply-To header.
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(when (eq mu4e-compose-type 'reply)
|
|
|
|
|
(unless (message-field-value "In-Reply-To")
|
|
|
|
|
(message-remove-header "References")))
|
|
|
|
|
(when use-hard-newlines
|
|
|
|
|
(mu4e--send-harden-newlines))
|
|
|
|
|
;; now handle what happens _after_ sending; typically, draft is gone and
|
|
|
|
|
;; the sent message appears in sent. Update flags for related messages,
|
|
|
|
|
;; i.e. for Forwarded ('Passed') and Replied messages, try to set the
|
|
|
|
|
;; appropriate flag at the message forwarded or replied-to.
|
|
|
|
|
(add-hook 'message-sent-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(when-let ((fcc-path (message-field-value "Fcc")))
|
|
|
|
|
(mu4e--set-parent-flags fcc-path)
|
|
|
|
|
;; we end up with a ((buried) buffer here, visiting
|
|
|
|
|
;; the fcc-path; not quite sure why. But let's
|
|
|
|
|
;; get rid of it (#2681)
|
|
|
|
|
(when-let ((buf (find-buffer-visiting fcc-path)))
|
|
|
|
|
(kill-buffer buf))))
|
|
|
|
|
nil t))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
;;; Crypto
|
|
|
|
|
(defun mu4e--compose-setup-crypto (parent compose-type)
|
|
|
|
|
"Possibly encrypt or sign a message based on PARENT and COMPOSE-TYPE.
|
|
|
|
|
See `mu4e-compose-crypto-policy' for more details."
|
|
|
|
|
(let* ((encrypted-p
|
|
|
|
|
(and parent (memq 'encrypted (mu4e-message-field parent :flags))))
|
|
|
|
|
(encrypt
|
|
|
|
|
(or (memq 'encrypt-all-messages mu4e-compose-crypto-policy)
|
|
|
|
|
(and (memq 'encrypt-new-messages mu4e-compose-crypto-policy)
|
|
|
|
|
(eq compose-type 'new)) ;; new messages
|
|
|
|
|
(and (eq compose-type 'forward) ;; forwarded
|
|
|
|
|
(memq 'encrypt-forwarded-messages mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'edit) ;; edit
|
|
|
|
|
(memq 'encrypt-edited-messages mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) ;; all replies
|
|
|
|
|
(memq 'encrypt-all-replies mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) (not encrypted-p) ;; plain replies
|
|
|
|
|
(memq 'encrypt-plain-replies mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) encrypted-p
|
|
|
|
|
(memq 'encrypt-encrypted-replies
|
|
|
|
|
mu4e-compose-crypto-policy)))) ;; encrypted replies
|
|
|
|
|
(sign
|
|
|
|
|
(or (memq 'sign-all-messages mu4e-compose-crypto-policy)
|
|
|
|
|
(and (eq compose-type 'new) ;; new messages
|
|
|
|
|
(memq 'sign-new-messages mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'forward) ;; forwarded messages
|
|
|
|
|
(memq 'sign-forwarded-messages mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'edit) ;; edited messages
|
|
|
|
|
(memq 'sign-edited-messages mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) ;; all replies
|
|
|
|
|
(memq 'sign-all-replies mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) (not encrypted-p) ;; plain replies
|
|
|
|
|
(memq 'sign-plain-replies mu4e-compose-crypto-policy))
|
|
|
|
|
(and (eq compose-type 'reply) encrypted-p ;; encrypted replies
|
|
|
|
|
(memq 'sign-encrypted-replies mu4e-compose-crypto-policy)))))
|
|
|
|
|
(cond ((and sign encrypt) (mml-secure-message-sign-encrypt))
|
|
|
|
|
(sign (mml-secure-message-sign))
|
|
|
|
|
(encrypt (mml-secure-message-encrypt)))))
|
2012-05-01 21:45:54 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;; mu4e-compose-mode
|
|
|
|
|
(defun mu4e--compose-remap-faces ()
|
|
|
|
|
"Remap `message-mode' faces to mu4e ones.
|
|
|
|
|
|
|
|
|
|
Our parent `message-mode' uses font-locking for the compose
|
|
|
|
|
buffers; lets remap its faces so it uses the ones for mu4e."
|
|
|
|
|
;; normal headers
|
|
|
|
|
(face-remap-add-relative 'message-header-name 'mu4e-header-field-face)
|
|
|
|
|
(face-remap-add-relative 'message-header-other 'mu4e-header-value-face)
|
|
|
|
|
;; special headers
|
|
|
|
|
(face-remap-add-relative 'message-header-from 'mu4e-contact-face)
|
|
|
|
|
(face-remap-add-relative 'message-header-to 'mu4e-contact-face)
|
|
|
|
|
(face-remap-add-relative 'message-header-cc 'mu4e-contact-face)
|
|
|
|
|
(face-remap-add-relative 'message-header-bcc 'mu4e-contact-face)
|
|
|
|
|
(face-remap-add-relative 'message-header-subject
|
|
|
|
|
'mu4e-special-header-value-face))
|
|
|
|
|
|
|
|
|
|
(defvar mu4e-compose-mode-map
|
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(set-keymap-parent map message-mode-map)
|
2024-03-04 09:50:59 +01:00
|
|
|
|
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
|
|
|
|
|
(define-key map (kbd "C-c C-u") #'mu4e-update-mail-and-index)
|
|
|
|
|
(define-key map (kbd "C-c ;") #'mu4e-compose-context-switch)
|
2024-03-12 18:29:07 +01:00
|
|
|
|
|
2024-03-15 19:31:44 +01:00
|
|
|
|
;; emacs 29
|
|
|
|
|
;;(keymap-set map "<remap> <beginning-of-buffer>" #'mu4e-compose-goto-top)
|
|
|
|
|
;;(keymap-set map "<remap> <end-of-buffer>" #'mu4e-compose-goto-bottom)
|
|
|
|
|
(define-key map (vector 'remap #'beginning-of-buffer)
|
|
|
|
|
#'mu4e-compose-goto-top)
|
|
|
|
|
(define-key map (vector 'remap #'end-of-buffer)
|
|
|
|
|
#'mu4e-compose-goto-bottom)
|
2024-03-12 18:29:07 +01:00
|
|
|
|
|
|
|
|
|
;; remove some unsupported commands... [remap ..] does not work here
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; XXX remove from menu, too.
|
|
|
|
|
(define-key map (kbd "C-c C-f C-n") nil) ;; message-goto-newsgroups
|
|
|
|
|
(define-key map (kbd "C-c C-n") nil) ;; message-insert-newsgroups
|
|
|
|
|
(define-key map (kbd "C-c C-j") nil) ;; gnus-delay-article
|
|
|
|
|
map)
|
|
|
|
|
"The keymap for mu4e-compose buffers.")
|
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-unsupported (&rest _args)
|
|
|
|
|
"Advise wrapper for Gnus unsupported functions in mu4e."
|
|
|
|
|
(when (eq major-mode 'mu4e-compose-mode)
|
|
|
|
|
(mu4e-warn "Not available in mu4e")))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--neutralize-undesirables ()
|
|
|
|
|
"Beware Gnus commands that do not work with mu4e."
|
|
|
|
|
;; the Field menu contains many items that don't apply.
|
|
|
|
|
(advice-add 'gnus-delay-article
|
|
|
|
|
:before #'mu4e--compose-unsupported) ;; # XXX does not work?!
|
|
|
|
|
(advice-add 'message-goto-newsgroups :before #'mu4e--compose-unsupported)
|
|
|
|
|
(advice-add 'message-insert-newsgroups :before #'mu4e--compose-unsupported))
|
|
|
|
|
|
|
|
|
|
(define-derived-mode mu4e-compose-mode message-mode "mu4e:compose"
|
|
|
|
|
"Major mode for the mu4e message composition, derived from `message-mode'.
|
|
|
|
|
\\{mu4e-compose-mode-map}."
|
|
|
|
|
(progn
|
|
|
|
|
(use-local-map mu4e-compose-mode-map)
|
|
|
|
|
(mu4e-context-minor-mode)
|
|
|
|
|
(mu4e--neutralize-undesirables)
|
|
|
|
|
(mu4e--compose-remap-faces)
|
2023-11-06 19:35:06 +01:00
|
|
|
|
(setq-local nobreak-char-display nil)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; set this to allow mu4e to work when gnus-agent is unplugged in gnus
|
|
|
|
|
(set (make-local-variable 'message-send-mail-real-function) nil)
|
|
|
|
|
;; Set to nil to enable `electric-quote-local-mode' to work:
|
|
|
|
|
(set (make-local-variable 'comment-use-syntax) nil)
|
2024-04-02 06:39:06 +02:00
|
|
|
|
(mu4e--compose-setup-completion) ;; maybe offer address completion
|
|
|
|
|
(if mu4e-compose-format-flowed ;; format-flowed
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(progn
|
|
|
|
|
(turn-off-auto-fill)
|
|
|
|
|
(setq truncate-lines nil
|
|
|
|
|
word-wrap t
|
|
|
|
|
mml-enable-flowed t
|
|
|
|
|
use-hard-newlines t)
|
|
|
|
|
(visual-line-mode t))
|
|
|
|
|
(setq mml-enable-flowed nil))))
|
|
|
|
|
|
|
|
|
|
(declare-function mu4e-view-message-text "mu4e-view")
|
|
|
|
|
|
|
|
|
|
(defun mu4e-message-cite-nothing ()
|
2023-11-30 19:59:17 +01:00
|
|
|
|
"Function for `message-cite-function' that cites _nothing_."
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(save-excursion
|
|
|
|
|
(message-cite-original-without-signature)
|
|
|
|
|
(delete-region (point-min) (point-max))))
|
|
|
|
|
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(defun mu4e--decoded-message (msg &optional headers-only)
|
2023-12-14 07:32:06 +01:00
|
|
|
|
"Get the message MSG, decoded as a string.
|
|
|
|
|
With HEADERS-ONLY non-nil, only include the headers part."
|
2023-11-06 19:35:06 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(setq-local gnus-article-decode-hook
|
|
|
|
|
'(article-decode-charset
|
|
|
|
|
article-decode-encoded-words
|
|
|
|
|
article-decode-idna-rhs
|
|
|
|
|
article-treat-non-ascii
|
2023-12-01 18:11:24 +01:00
|
|
|
|
article-remove-cr
|
2023-11-06 19:35:06 +01:00
|
|
|
|
article-de-base64-unreadable
|
2023-11-10 15:47:34 +01:00
|
|
|
|
article-de-quoted-unreadable)
|
2023-11-30 19:59:17 +01:00
|
|
|
|
gnus-inhibit-mime-unbuttonizing nil
|
|
|
|
|
gnus-unbuttonized-mime-types '(".*/.*")
|
2023-11-06 19:35:06 +01:00
|
|
|
|
gnus-original-article-buffer (current-buffer))
|
|
|
|
|
(insert-file-contents-literally
|
|
|
|
|
(mu4e-message-readable-path msg) nil nil nil t)
|
2023-11-30 19:59:17 +01:00
|
|
|
|
;; remove the body / attachments and what not.
|
|
|
|
|
(when headers-only
|
|
|
|
|
(rfc822-goto-eoh)
|
|
|
|
|
(delete-region (point) (point-max)))
|
|
|
|
|
;; in rare (broken) case, if a message-id is missing use the generated one
|
|
|
|
|
;; from mu.
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(mu4e--delimit-headers)
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(unless (message-field-value "Message-Id")
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(insert (format "Message-Id: <%s>\n" (plist-get msg :message-id))))
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(mu4e--delimit-headers 'undelimit)
|
2023-11-06 19:35:06 +01:00
|
|
|
|
(ignore-errors (run-hooks 'gnus-article-decode-hook))
|
|
|
|
|
(buffer-substring-no-properties (point-min) (point-max))))
|
|
|
|
|
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(defun mu4e--compose-cite (msg)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Return a cited version of the ORIG message MSG (a string).
|
2023-10-05 07:57:22 +02:00
|
|
|
|
This function uses `message-cite-function', and its settings apply."
|
|
|
|
|
(with-temp-buffer
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(insert (mu4e-view-message-text msg))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(push-mark (point-max))
|
|
|
|
|
(let ((message-signature-separator "^-- *$")
|
|
|
|
|
(message-signature-insert-empty-line t))
|
|
|
|
|
(funcall message-cite-function))
|
|
|
|
|
(pop-mark)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(buffer-string)))
|
|
|
|
|
|
|
|
|
|
(defvar mu4e-user-agent-string
|
|
|
|
|
(format "mu4e %s; emacs %s" mu4e-mu-version emacs-version)
|
|
|
|
|
"The User-Agent string for mu4e, or nil.")
|
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-switch-function ()
|
|
|
|
|
"Function to switch & display composition buffer.
|
|
|
|
|
Based on the value of `mu4e-compose-switch'."
|
|
|
|
|
(pcase mu4e-compose-switch
|
2024-03-02 22:20:06 +01:00
|
|
|
|
('nil #'switch-to-buffer)
|
|
|
|
|
('window #'switch-to-buffer-other-window)
|
|
|
|
|
((or 'frame 't) #'switch-to-buffer-other-frame)
|
|
|
|
|
('display-buffer #'display-buffer)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; t for backward compatibility with mu4e-compose-in-new-frame
|
|
|
|
|
(_ (mu4e-error "Invalid mu4e-compose-switch"))))
|
|
|
|
|
|
2024-04-15 07:19:51 +02:00
|
|
|
|
(defun mu4e--fake-pop-to-buffer (name &optional _switch)
|
|
|
|
|
"A fake `message-pop-to-buffer' for creating buffer NAME.
|
|
|
|
|
This is a little glue to use `message-reply', `message-forward'
|
|
|
|
|
etc. We cannot use the normal `message-pop-to-buffer' since we're
|
|
|
|
|
not ready yet to show the buffer in mu4e."
|
|
|
|
|
;; note: we're in a _different_ buffer here, so we need to copy
|
|
|
|
|
;; message-reply-header's buffer-local value.
|
|
|
|
|
(let ((reply-headers message-reply-headers))
|
|
|
|
|
(set-buffer (get-buffer-create name))
|
|
|
|
|
(setq-local message-reply-headers reply-headers)
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(current-buffer)))
|
|
|
|
|
|
2023-11-04 21:42:05 +01:00
|
|
|
|
(defun mu4e--headers (compose-type)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Determine headers needed for message based on COMPOSE-TYPE."
|
2023-11-04 21:42:05 +01:00
|
|
|
|
(seq-filter #'identity ;; ensure needed headers are generated.
|
|
|
|
|
`(From Subject Date Message-ID
|
|
|
|
|
,(when (memq compose-type '(reply forward)) 'References)
|
2023-11-05 09:33:57 +01:00
|
|
|
|
,(when (eq compose-type 'reply) 'In-Reply-To)
|
2023-11-04 21:42:05 +01:00
|
|
|
|
,(when message-newsreader 'User-Agent)
|
|
|
|
|
,(when message-user-organization 'Organization))))
|
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-setup-buffer (compose-type compose-func parent)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Set up a buffer for message composition before `mu4e-compose-mode'.
|
|
|
|
|
|
|
|
|
|
COMPOSE-TYPE is the type of message to creat.
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
COMPOSE-FUNC is a function / lambda to create the specific type
|
|
|
|
|
of message; it should return (but not show) the created buffer.
|
|
|
|
|
|
|
|
|
|
PARENT is the \"parent\" message; nil
|
|
|
|
|
for a \\='new message, set for all others (the message replied to /
|
|
|
|
|
forwarded / ...)."
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
;; call the call message function; turn off the gnus crypto stuff;
|
|
|
|
|
;; we handle that ourselves below
|
|
|
|
|
(let* ((message-this-is-mail t)
|
|
|
|
|
(message-generate-headers-first nil)
|
|
|
|
|
(message-newsreader mu4e-user-agent-string)
|
|
|
|
|
(message-mail-user-agent nil))
|
|
|
|
|
;; we handle it ourselves.
|
|
|
|
|
(setq-local gnus-message-replysign nil
|
|
|
|
|
gnus-message-replyencrypt nil
|
|
|
|
|
gnus-message-replysignencrypted nil)
|
|
|
|
|
(goto-char (point-min))
|
2024-04-15 07:19:51 +02:00
|
|
|
|
;; annoyingly, various message- functions call `message-pop-to-buffer`
|
|
|
|
|
;; (showing the message. But we're not ready for that yet. So
|
|
|
|
|
;; temporarily override that.
|
|
|
|
|
(cl-letf (((symbol-function #'message-pop-to-buffer)
|
|
|
|
|
#'mu4e--fake-pop-to-buffer))
|
|
|
|
|
(funcall compose-func parent))
|
2023-11-30 19:59:17 +01:00
|
|
|
|
;; add some more headers, if needed.
|
|
|
|
|
(message-generate-headers (mu4e--headers compose-type))
|
|
|
|
|
(current-buffer)))) ;; returns new buffer (this is not the tmp buf)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
2023-11-04 21:42:05 +01:00
|
|
|
|
|
|
|
|
|
(defvar mu4e-compose-hidden-headers
|
|
|
|
|
(append message-hidden-headers '("^User-agent:" "^Fcc:"))
|
|
|
|
|
"Message headers to hide when composing.
|
|
|
|
|
This is mu4e's version of `message-hidden-headers'.")
|
|
|
|
|
|
2023-11-22 20:04:59 +01:00
|
|
|
|
(defun mu4e--message-is-yours-p (func &rest args)
|
2023-11-30 19:59:17 +01:00
|
|
|
|
"Mu4e advice for `message-is-yours'.
|
2024-03-14 18:40:16 +01:00
|
|
|
|
FUNC is the original function, and ARGS are its arguments.
|
2023-11-22 20:04:59 +01:00
|
|
|
|
Is this address yours?"
|
|
|
|
|
(if (mu4e-running-p)
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(let ((sender (message-field-value "from"))
|
|
|
|
|
(from (message-field-value "sender")))
|
|
|
|
|
(or (and sender (mu4e-personal-or-alternative-address-p
|
|
|
|
|
(car (mail-header-parse-address sender))))
|
|
|
|
|
(and from (mu4e-personal-or-alternative-address-p
|
|
|
|
|
(car (mail-header-parse-address from))))))
|
2023-11-22 20:04:59 +01:00
|
|
|
|
(apply func args)))
|
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(defun mu4e--compose-setup-post (compose-type &optional parent)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Prepare the new message buffer.
|
|
|
|
|
|
|
|
|
|
COMPOSE-TYPE determines the type of message to create. PARENT
|
|
|
|
|
refers to the optional message to start from, i.e., the message
|
|
|
|
|
replied to or forwarded, etc."
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(mu4e-compose-mode)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; remember some variables, e.g for user hooks.
|
|
|
|
|
(setq-local
|
|
|
|
|
mu4e-compose-parent-message parent
|
2023-11-04 21:42:05 +01:00
|
|
|
|
mu4e-compose-type compose-type)
|
2023-11-03 20:16:05 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--compose-setup-crypto parent compose-type)
|
|
|
|
|
;; set the attachment dir to something more reasonable than the draft
|
|
|
|
|
;; directory.
|
|
|
|
|
(setq default-directory (mu4e-determine-attachment-dir))
|
|
|
|
|
|
|
|
|
|
(add-hook 'before-save-hook #'mu4e--compose-before-save nil t)
|
|
|
|
|
(add-hook 'after-save-hook #'mu4e--compose-after-save nil t)
|
|
|
|
|
(add-hook 'message-send-hook #'mu4e--compose-before-send nil t)
|
|
|
|
|
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(when-let ((fcc-path (mu4e--fcc-path (mu4e--message-basename) parent)))
|
|
|
|
|
(message-add-header (concat "Fcc: " fcc-path "\n")))
|
|
|
|
|
(setq-local message-fcc-handler-function #'mu4e--fcc-handler)
|
|
|
|
|
|
2023-11-04 21:42:05 +01:00
|
|
|
|
(mu4e--compose-set-friendly-buffer-name)
|
|
|
|
|
(let ((message-hidden-headers mu4e-compose-hidden-headers))
|
|
|
|
|
(message-hide-headers))
|
|
|
|
|
|
2023-11-03 20:16:05 +01:00
|
|
|
|
;; jump to some reasonable place.
|
|
|
|
|
(if (not (message-field-value "To"))
|
|
|
|
|
(message-goto-to)
|
|
|
|
|
(if (not (message-field-value "Subject"))
|
|
|
|
|
(message-goto-subject)
|
2024-03-04 15:15:50 +01:00
|
|
|
|
(pcase message-cite-reply-position
|
|
|
|
|
((or 'above 'traditional) (message-goto-body))
|
|
|
|
|
(_ (when (message-goto-signature) (forward-line -2))))))
|
2023-11-04 21:42:05 +01:00
|
|
|
|
;; buffer is not user-modified yet
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(undo-boundary))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
(defun mu4e--compose-setup (compose-type compose-func &optional switch)
|
|
|
|
|
"Set up a new buffer for mu4e message composition.
|
|
|
|
|
|
2023-12-02 14:42:42 +01:00
|
|
|
|
COMPOSE-TYPE is a symbol for message-kind; one of \\='(new reply forward edit)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
PARENT is the \"parent\" message; nil for a \\='new message, set for
|
|
|
|
|
all others (the message replied to / forwarded / ...).
|
|
|
|
|
|
|
|
|
|
COMPOSE-FUNC is a function / lambda to create the specific type
|
2023-12-02 14:42:42 +01:00
|
|
|
|
of message.
|
|
|
|
|
|
|
|
|
|
Optionally, SWITCH determines how to find a buffer for the message
|
2024-03-14 18:40:16 +01:00
|
|
|
|
\(see SWITCH-FUNCTION in `compose-mail').
|
2024-03-03 08:42:58 +01:00
|
|
|
|
|
|
|
|
|
Returns the new buffer."
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(cl-assert (member compose-type '(reply forward edit new)))
|
|
|
|
|
(unless (mu4e-running-p) (mu4e 'background)) ;; start if needed
|
|
|
|
|
(let* ((parent
|
2023-12-04 18:25:55 +01:00
|
|
|
|
(when (member compose-type '(reply forward edit))
|
|
|
|
|
(mu4e-message-at-point)))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e-compose-parent-message parent)
|
2023-12-02 14:42:42 +01:00
|
|
|
|
(mu4e-compose-type compose-type)
|
2024-03-02 22:20:06 +01:00
|
|
|
|
(oldframe (selected-frame)))
|
2023-11-22 20:04:59 +01:00
|
|
|
|
(advice-add 'message-is-yours-p :around #'mu4e--message-is-yours-p)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(run-hooks 'mu4e-compose-pre-hook) ;; run the pre-hook. Still useful?
|
|
|
|
|
(mu4e--context-autoswitch parent mu4e-compose-context-policy)
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(with-current-buffer
|
2023-11-04 21:42:05 +01:00
|
|
|
|
(mu4e--compose-setup-buffer compose-type compose-func parent)
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(unless (eq compose-type 'edit)
|
|
|
|
|
(set-visited-file-name ;; make it a draft file
|
|
|
|
|
(mu4e--draft-message-path (mu4e--message-basename) parent)))
|
2023-12-02 14:42:42 +01:00
|
|
|
|
(mu4e--compose-setup-post compose-type parent)
|
2024-03-02 22:20:06 +01:00
|
|
|
|
(funcall (or switch (mu4e--compose-switch-function)) (current-buffer))
|
2024-02-18 17:02:54 +01:00
|
|
|
|
(let* ((msgframe (selected-frame))
|
|
|
|
|
(actions (list
|
|
|
|
|
(lambda () ;; kill frame when it was created for this
|
|
|
|
|
(unless (eq oldframe msgframe)
|
|
|
|
|
(delete-frame msgframe))))))
|
|
|
|
|
;; handle closing of frames.
|
|
|
|
|
(setq-local ;;message-kill-actions actions
|
|
|
|
|
message-return-actions actions
|
|
|
|
|
message-send-actions actions
|
2024-03-03 08:42:58 +01:00
|
|
|
|
message-kill-actions actions))
|
|
|
|
|
(current-buffer))))
|
2023-11-30 19:59:17 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2023-12-02 11:50:13 +01:00
|
|
|
|
(defun mu4e-compose-new (&optional to subject other-headers continue
|
|
|
|
|
switch-function yank-action send-actions
|
|
|
|
|
return-action &rest _)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Mu4e's implementation of `compose-mail'.
|
|
|
|
|
TO, SUBJECT, OTHER-HEADERS, CONTINUE, SWITCH-FUNCTION,
|
|
|
|
|
YANK-ACTION SEND-ACTIONS RETURN-ACTION are as described in
|
|
|
|
|
`compose-mail', and to the extend that they do not conflict with
|
|
|
|
|
mu4e inner workings."
|
2012-05-01 21:45:54 +02:00
|
|
|
|
(interactive)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--compose-setup
|
2023-12-02 11:50:13 +01:00
|
|
|
|
'new (lambda (_parent)
|
|
|
|
|
(message-mail to subject other-headers continue nil
|
|
|
|
|
yank-action send-actions return-action))
|
|
|
|
|
switch-function))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defalias 'mu4e-compose-mail #'mu4e-compose-new)
|
2012-05-01 21:45:54 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;;###autoload
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(defun mu4e-compose-reply (&optional wide)
|
|
|
|
|
"Reply to the message at point.
|
2023-12-01 18:11:13 +01:00
|
|
|
|
If WIDE is non-nil, make it a \"wide\" reply (a.k.a.
|
|
|
|
|
\"reply-to-all\")."
|
2012-05-01 21:45:54 +02:00
|
|
|
|
(interactive)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--compose-setup
|
|
|
|
|
'reply
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(lambda (parent)
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(insert (mu4e--decoded-message parent 'headers-only))
|
|
|
|
|
(message-reply nil wide)
|
2023-11-04 21:42:05 +01:00
|
|
|
|
(message-goto-body)
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(insert (mu4e--compose-cite parent)))))
|
2012-05-01 21:45:54 +02:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun mu4e-compose-wide-reply ()
|
2023-12-01 18:11:13 +01:00
|
|
|
|
"Wide-reply to the message at point.
|
|
|
|
|
A.k.a., \"reply-to-all\"."
|
2023-11-22 20:04:59 +01:00
|
|
|
|
(interactive) (mu4e-compose-reply 'wide))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun mu4e-compose-supersede ()
|
|
|
|
|
"Supersede message at point.
|
2023-12-01 18:11:13 +01:00
|
|
|
|
|
|
|
|
|
That is, send the message again, with all the same recipients;
|
|
|
|
|
this can be useful to follow-up on a sent message. The message
|
|
|
|
|
must be from current user, as determined through
|
2023-11-22 20:04:59 +01:00
|
|
|
|
`mu4e-personal-or-alternative-address-p'."
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(interactive)
|
|
|
|
|
(mu4e--compose-setup
|
|
|
|
|
'reply ;; it's a special kind of reply.
|
|
|
|
|
(lambda (parent)
|
|
|
|
|
(insert (mu4e--decoded-message parent))
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(message-supersede))))
|
2016-02-16 07:13:03 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun mu4e-compose-forward ()
|
|
|
|
|
"Forward the message at point."
|
2012-05-01 21:45:54 +02:00
|
|
|
|
(interactive)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--compose-setup
|
|
|
|
|
'forward
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(lambda (parent)
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(let ((message-make-forward-subject-function
|
2023-11-30 19:59:17 +01:00
|
|
|
|
#'message-forward-subject-fwd))
|
|
|
|
|
(insert (mu4e--decoded-message parent))
|
|
|
|
|
(mu4e--delimit-headers)
|
|
|
|
|
;; message-forward expects message-reply-headers to be set up; here we
|
|
|
|
|
;; only need message-id & references, rest is for completeness.
|
2024-04-16 18:03:08 +02:00
|
|
|
|
(setq-local message-reply-headers
|
|
|
|
|
(make-full-mail-header
|
|
|
|
|
0
|
|
|
|
|
(or (message-field-value "subject") "none")
|
|
|
|
|
(or (message-field-value "from") "nobody")
|
|
|
|
|
(message-field-value "date")
|
|
|
|
|
(message-field-value "message-id" t)
|
|
|
|
|
(message-field-value "references")
|
|
|
|
|
0 0 ""))
|
2023-11-30 19:59:17 +01:00
|
|
|
|
(mu4e--delimit-headers 'undelimit)
|
|
|
|
|
(set-buffer-modified-p nil)
|
|
|
|
|
(message-forward)))))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(defun mu4e-compose-edit()
|
|
|
|
|
"Edit an existing draft message."
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((msg (mu4e-message-at-point)))
|
2023-11-03 20:16:05 +01:00
|
|
|
|
(unless (member 'draft (mu4e-message-field msg :flags))
|
|
|
|
|
(mu4e-warn "Cannot edit non-draft messages"))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(mu4e--compose-setup
|
2023-11-03 20:16:05 +01:00
|
|
|
|
'edit
|
2023-11-10 15:47:34 +01:00
|
|
|
|
(lambda (parent)
|
2024-04-10 21:57:10 +02:00
|
|
|
|
(let ((buf (find-file-noselect (plist-get parent :path))))
|
2024-04-09 19:17:21 +02:00
|
|
|
|
(with-current-buffer buf
|
|
|
|
|
(mu4e--delimit-headers))
|
2024-04-10 21:57:10 +02:00
|
|
|
|
(switch-to-buffer buf))))))
|
2023-10-05 07:57:22 +02:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun mu4e-compose-resend (address)
|
2024-03-14 18:40:16 +01:00
|
|
|
|
"Re-send the message at point to ADDRESS.
|
2024-03-03 08:42:58 +01:00
|
|
|
|
The message is resent as-is, without any editing."
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(interactive
|
|
|
|
|
(list (completing-read
|
|
|
|
|
"Resend message to address: " mu4e--contacts-set)))
|
|
|
|
|
(unless (mu4e-running-p) (mu4e 'background))
|
|
|
|
|
(let ((path (plist-get (mu4e-message-at-point) :path)))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert-file-contents path)
|
|
|
|
|
(message-resend address))))
|
2012-04-19 07:30:42 +02:00
|
|
|
|
|
2020-02-18 22:39:30 +01:00
|
|
|
|
;;; Compose Mail
|
2012-04-19 07:30:42 +02:00
|
|
|
|
|
2021-08-29 16:30:10 +02:00
|
|
|
|
(declare-function mu4e "mu4e")
|
|
|
|
|
|
2012-11-14 12:55:15 +01:00
|
|
|
|
;;;###autoload
|
2012-04-19 07:30:42 +02:00
|
|
|
|
(define-mail-user-agent 'mu4e-user-agent
|
2023-12-02 11:50:13 +01:00
|
|
|
|
#'mu4e-compose-mail
|
|
|
|
|
#'message-send-and-exit
|
2024-03-02 22:20:06 +01:00
|
|
|
|
#'message-kill-buffer
|
2012-04-19 07:30:42 +02:00
|
|
|
|
'message-send-hook)
|
2023-12-02 11:50:13 +01:00
|
|
|
|
|
2023-10-05 07:57:22 +02:00
|
|
|
|
;; Without this, `mail-user-agent' cannot be set to `mu4e-user-agent'
|
2012-11-14 12:39:37 +01:00
|
|
|
|
;; through customize, as the custom type expects a function. Not
|
|
|
|
|
;; sure whether this function is actually ever used; if it is then
|
|
|
|
|
;; returning the symbol is probably the correct thing to do, as other
|
|
|
|
|
;; such functions suggest.
|
|
|
|
|
(defun mu4e-user-agent ()
|
2017-04-08 14:21:06 +02:00
|
|
|
|
"Return the `mu4e-user-agent' symbol."
|
2012-11-14 12:39:37 +01:00
|
|
|
|
'mu4e-user-agent)
|
2023-10-30 21:54:05 +01:00
|
|
|
|
|
|
|
|
|
;;; minor mode for use in other modes.
|
|
|
|
|
(defvar mu4e-compose-minor-mode-map
|
2023-10-05 07:57:22 +02:00
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map "R" #'mu4e-compose-reply)
|
|
|
|
|
(define-key map "W" #'mu4e-compose-wide-reply)
|
|
|
|
|
(define-key map "F" #'mu4e-compose-forward)
|
|
|
|
|
(define-key map "E" #'mu4e-compose-edit)
|
|
|
|
|
(define-key map "C" #'mu4e-compose-new)
|
2023-10-30 21:54:05 +01:00
|
|
|
|
map)
|
|
|
|
|
"Keymap for compose minor-mode.")
|
|
|
|
|
|
|
|
|
|
(define-minor-mode mu4e-compose-minor-mode
|
|
|
|
|
"Mode for searching for messages."
|
|
|
|
|
:global nil
|
|
|
|
|
:init-value nil ;; disabled by default
|
|
|
|
|
:group 'mu4e
|
|
|
|
|
:lighter ""
|
|
|
|
|
:keymap mu4e-compose-minor-mode-map)
|
2014-01-09 18:07:48 +01:00
|
|
|
|
|
2023-01-09 21:13:24 +01:00
|
|
|
|
(defvar mu4e--compose-menu-items
|
|
|
|
|
'("--"
|
|
|
|
|
["Compose new" mu4e-compose-new
|
|
|
|
|
:help "Compose new message"]
|
|
|
|
|
["Reply" mu4e-compose-reply
|
|
|
|
|
:help "Reply to message"]
|
2023-10-05 07:57:22 +02:00
|
|
|
|
["Reply to all" mu4e-compose-wide-reply
|
|
|
|
|
:help "Reply to all-recipients"]
|
2023-01-09 21:13:24 +01:00
|
|
|
|
["Forward" mu4e-compose-forward
|
2023-10-05 07:57:22 +02:00
|
|
|
|
:help "Forward message"]
|
|
|
|
|
["Resend" mu4e-compose-resend
|
|
|
|
|
:help "Re-send message"])
|
|
|
|
|
"Easy menu items for message composition.")
|
|
|
|
|
;;;
|
2012-05-25 15:51:23 +02:00
|
|
|
|
(provide 'mu4e-compose)
|
2019-05-25 16:38:58 +02:00
|
|
|
|
;;; mu4e-compose.el ends here
|