From: David Bremner <david@tethera.net>
To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
Subject: [PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local
Date: Sat, 1 Aug 2015 11:44:56 +0200 [thread overview]
Message-ID: <1438422296-29087-3-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1438422296-29087-1-git-send-email-david@tethera.net>
Previously we globally modified these variables, which tended to cause
problems for people using message-mode, but not notmuch-mua-mail, to
send mail.
User visible changes:
- calling notmuch-fcc-header-setup is no longer optional. OTOH, it
seems to do the right thing if notmuch-fcc-dirs is set to nil.
- the Fcc header is visible during message composition
- the name in the mode line is changed, and (sadface) no longer
matches the menu label.
- Previously notmuch-mua-send-and-exit was never called. Either we
misunderstood define-mail-user-agent, or it had a bug. So there was
no difference if the user called message-send-and-exit directly. Now
there will be.
---
emacs/notmuch-maildir-fcc.el | 23 +++++++++--------------
emacs/notmuch-mua.el | 6 +++++-
test/test-lib.sh | 4 ++--
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 07eedba..c2f2f4c 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -59,23 +59,19 @@ yet when sending a mail."
:require 'notmuch-fcc-initialization
:group 'notmuch-send)
-(defun notmuch-fcc-initialization ()
- "If notmuch-fcc-directories is set,
- hook them into the message-fcc-handler-function"
- ;; Set up the message-fcc-handler to move mails to the maildir in Fcc
- ;; The parameter is set to mark messages as "seen"
- (setq message-fcc-handler-function
- (lambda (destdir)
- (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))
- ;; add a hook to actually insert the Fcc header when sending
- (add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup))
+(defun notmuch-fcc-handler (destdir)
+ "Write buffer to `destdir', marking it as sent
+
+Intended to be dynamically bound to `message-fcc-handler-function'"
+ (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))
(defun notmuch-fcc-header-setup ()
"Add an Fcc header to the current message buffer.
-Can be added to `message-send-hook' and will set the Fcc header
-based on the values of `notmuch-fcc-dirs'. An existing Fcc header
-will NOT be removed or replaced."
+Sets the Fcc header based on the values of `notmuch-fcc-dirs'.
+
+Originally intended to be use a hook function, but now called directly
+by notmuch-mua-mail"
(let ((subdir
(cond
@@ -213,6 +209,5 @@ return t if successful, and nil otherwise."
(delete-file (concat destdir "/tmp/" msg-id))))
t)))
-(notmuch-fcc-initialization)
(provide 'notmuch-maildir-fcc)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index a7d3eaa..4ae7d1e 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -268,6 +268,8 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
(define-derived-mode notmuch-compose-mode message-mode "notmuch-compose"
"Notmuch message composition mode. Mostly like `message-mode'")
+(define-key notmuch-compose-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)
+
(defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)
"Invoke the notmuch mail composition window.
@@ -285,6 +287,7 @@ OTHER-ARGS are passed through to `message-mail'."
(apply #'message-mail to subject other-headers other-args)
(notmuch-compose-mode)
+ (notmuch-fcc-header-setup)
(message-sort-headers)
(message-hide-headers)
(set-buffer-modified-p nil)
@@ -398,7 +401,8 @@ will be addressed to all recipients of the source message."
(defun notmuch-mua-send-and-exit (&optional arg)
(interactive "P")
- (message-send-and-exit arg))
+ (let ((message-fcc-handler-function #'notmuch-fcc-handler))
+ (message-send-and-exit arg)))
(defun notmuch-mua-kill-buffer ()
(interactive)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 3466e9c..cb8a6cf 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -487,7 +487,7 @@ emacs_deliver_message ()
(message-goto-body)
(insert \"${body}\")
$@
- (message-send-and-exit))"
+ (notmuch-mua-send-and-exit))"
# In case message was sent properly, client waits for confirmation
# before exiting and resuming control here; therefore making sure
@@ -522,7 +522,7 @@ emacs_fcc_message ()
(message-goto-body)
(insert \"${body}\")
$@
- (message-send-and-exit))" || return 1
+ (notmuch-mua-send-and-exit))" || return 1
notmuch new >/dev/null
}
--
2.1.4
next prev parent reply other threads:[~2015-08-01 9:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 20:06 Emacs: notmuch-mua-mail throws error if notmuch-fcc-dirs does not exist Felix Konstantin Maurer
2015-07-11 8:21 ` David Bremner
2015-07-11 9:07 ` Mark Walters
2015-08-01 9:44 ` Stop stomping on global fcc related variables David Bremner
2015-08-01 9:44 ` [PATCH 1/2] emacs: define a notmuch-compose-mode based on message mode David Bremner
2015-08-01 9:44 ` David Bremner [this message]
2015-08-03 7:46 ` [PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local Mark Walters
2015-08-03 8:25 ` David Bremner
2015-08-03 9:03 ` Tomi Ollila
2015-08-04 20:04 ` [PATCH 1/2] emacs: define a notmuch-compose-mode based on message mode David Bremner
2015-08-04 20:04 ` [PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local David Bremner
2015-08-06 19:08 ` Tomi Ollila
2015-08-06 20:54 ` David Bremner
2015-08-07 4:11 ` Tomi Ollila
2017-05-02 12:57 ` David Bremner
2015-08-07 19:31 ` David Bremner
2015-08-07 19:38 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438422296-29087-3-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).