From 22a7cff57182889a0b39b4fc27cd524d86289a5f Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Thu, 6 Aug 2015 22:08:56 +0300 Subject: [PATCH] Re: [PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local --- e7/9b65404bedbe2cb2f0562590fd91890b36626a | 215 ++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 e7/9b65404bedbe2cb2f0562590fd91890b36626a diff --git a/e7/9b65404bedbe2cb2f0562590fd91890b36626a b/e7/9b65404bedbe2cb2f0562590fd91890b36626a new file mode 100644 index 000000000..d452d324a --- /dev/null +++ b/e7/9b65404bedbe2cb2f0562590fd91890b36626a @@ -0,0 +1,215 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 3A6D16DE020B + for ; Thu, 6 Aug 2015 12:09:14 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 1.25 +X-Spam-Level: * +X-Spam-Status: No, score=1.25 tagged_above=-999 required=5 tests=[AWL=-0.146, + SPF_NEUTRAL=0.652, URIBL_SBL=0.644, URIBL_SBL_A=0.1] + autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id HGFhDf0E5kW0 for ; + Thu, 6 Aug 2015 12:09:12 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 7EBA56DE00DE + for ; Thu, 6 Aug 2015 12:09:10 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 7DA60100046; + Thu, 6 Aug 2015 22:08:56 +0300 (EEST) +From: Tomi Ollila +To: David Bremner , + Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH 2/2] emacs: make modifications to message Fcc vars + buffer-local +In-Reply-To: <1438718659-11522-2-git-send-email-david@tethera.net> +References: <87fv4093sl.fsf@maritornes.cs.unb.ca> + <1438718659-11522-1-git-send-email-david@tethera.net> + <1438718659-11522-2-git-send-email-david@tethera.net> +User-Agent: Notmuch/0.20.2+54~g0bf3ee6 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 06 Aug 2015 19:09:14 -0000 + +On Tue, Aug 04 2015, David Bremner wrote: + +> 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. +> +> - user bindings to C-c C-s and C-c C-s in message-mode-map are +> overridden. The user can override them in notmuch-message-mode-map, +> but then they're on their own for Fcc handling. + +This looks pretty good to me -- one of the above is `C-c C-c` and +capitalization could be consistent in the commit message. + +One thing come to my mind: would it be possible to use buffer-local +variable message-fcc-handler-function in notmuch-message-mode buffers so +that such wrapper functions defined below would not be needed. i.e. + + (make-local-variable 'message-fcc-handler-function) + (setq message-fcc-handler-function #'notmuch-fcc-handler) + +(or not? :D) + +one more thing (extra newline) inline below + +Tomi + +> --- +> emacs/notmuch-maildir-fcc.el | 23 +++++++++-------------- +> emacs/notmuch-mua.el | 15 +++++++++++++-- +> test/test-lib.sh | 4 ++-- +> 3 files changed, 24 insertions(+), 18 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 1018321..803459a 100644 +> --- a/emacs/notmuch-mua.el +> +++ b/emacs/notmuch-mua.el +> @@ -268,9 +268,13 @@ Note that these functions use `mail-citation-hook' if that is non-nil." +> (message-goto-body) +> (set-buffer-modified-p nil)) +> +> -(define-derived-mode notmuch-message-mode message-mode "Notmuch Message" +> +(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]" +> "Notmuch message composition mode. Mostly like `message-mode'") +> +> +(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit) +> +(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send) +> + +> + + +2 empty lines above -- nowhere else in notmuch-mua.el is such a thing. + +> (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args) +> "Invoke the notmuch mail composition window. +> +> @@ -288,6 +292,7 @@ OTHER-ARGS are passed through to `message-mail'." +> +> (apply #'message-mail to subject other-headers other-args) +> (notmuch-message-mode) +> + (notmuch-fcc-header-setup) +> (message-sort-headers) +> (message-hide-headers) +> (set-buffer-modified-p nil) +> @@ -401,7 +406,13 @@ 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-send (&optional arg) +> + (interactive "P") +> + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) +> + (message-send arg))) +> +> (defun notmuch-mua-kill-buffer () +> (interactive) +> diff --git a/test/test-lib.sh b/test/test-lib.sh +> index db3b6aa..eeb5487 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 -- 2.26.2