unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Use the message cite variable instead of a hard coded function
@ 2015-01-09  1:19 Todd
  2015-01-09  7:50 ` David Bremner
  0 siblings, 1 reply; 10+ messages in thread
From: Todd @ 2015-01-09  1:19 UTC (permalink / raw)
  To: notmuch

---
 emacs/notmuch-mua.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2c58886..e90ca55 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -220,8 +220,8 @@ list."
 	    (date (plist-get original-headers :Date))
 	    (start (point)))
 
-	;; message-cite-original constructs a citation line based on the From and Date
-	;; headers of the original message, which are assumed to be in the buffer.
+	;; message-cite-function should construct a citation line based on the From and
+	;; Date headers of the original message, which are assumed to be in the buffer.
 	(insert "From: " from "\n")
 	(insert "Date: " date "\n\n")
 
@@ -233,7 +233,7 @@ list."
 	(set-mark (point))
 	(goto-char start)
 	;; Quote the original message according to the user's configured style.
-	(message-cite-original)))
+	(funcall message-cite-function)))
 
     ;; Crypto processing based crypto content of the original message
     (when process-crypto
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use the message cite variable instead of a hard coded function
  2015-01-09  1:19 [PATCH] Use the message cite variable instead of a hard coded function Todd
@ 2015-01-09  7:50 ` David Bremner
  2015-01-09 12:33   ` Todd
  0 siblings, 1 reply; 10+ messages in thread
From: David Bremner @ 2015-01-09  7:50 UTC (permalink / raw)
  To: Todd, notmuch

Todd <todd@electricoding.com> writes:

> @@ -233,7 +233,7 @@ list."
>  	(set-mark (point))
>  	(goto-char start)
>  	;; Quote the original message according to the user's configured style.
> -	(message-cite-original)))
> +	(funcall message-cite-function)))
>  

Hi Todd;

Thanks for the patch. What happens to the behaviour of notmuch-reply for
people that have not customized this variable?

d

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use the message cite variable instead of a hard coded function
  2015-01-09  7:50 ` David Bremner
@ 2015-01-09 12:33   ` Todd
  2015-01-09 13:56     ` Tomi Ollila
  0 siblings, 1 reply; 10+ messages in thread
From: Todd @ 2015-01-09 12:33 UTC (permalink / raw)
  To: David Bremner, notmuch


It's defaulted to message-cite-original in Emacs 24, and may have been
back to Emacs 22.3 ("This variable was introduced, or its default value
was changed, in version 22.3 of Emacs.").  

I can re-work the patch to fall back to message-cite-original if it's
been unset, if that's preferred.

- Todd


>>>>> "DB" == David Bremner <david@tethera.net> writes:
    DB> Hi Todd;

    DB> Thanks for the patch. What happens to the behaviour of notmuch-reply for
    DB> people that have not customized this variable?

    DB> d

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Use the message cite variable instead of a hard coded function
  2015-01-09 12:33   ` Todd
@ 2015-01-09 13:56     ` Tomi Ollila
  2015-01-09 23:37       ` [PATCH v2] emacs: Use the message cite variable Todd
  0 siblings, 1 reply; 10+ messages in thread
From: Tomi Ollila @ 2015-01-09 13:56 UTC (permalink / raw)
  To: Todd, David Bremner, notmuch

On Fri, Jan 09 2015, Todd <tolchz@gmail.com> wrote:

> It's defaulted to message-cite-original in Emacs 24, and may have been
> back to Emacs 22.3 ("This variable was introduced, or its default value
> was changed, in version 22.3 of Emacs.").  
>
> I can re-work the patch to fall back to message-cite-original if it's
> been unset, if that's preferred.

For reference: in emacs 23.1 the message-yank-original function in
message.el will do nothing in case message-site-function is unset
(if it is set, it does plenty of things, including
(funcall message-site-function) )

Tomi

>
> - Todd
>
>
>>>>>> "DB" == David Bremner <david@tethera.net> writes:
>     DB> Hi Todd;
>
>     DB> Thanks for the patch. What happens to the behaviour of notmuch-reply for
>     DB> people that have not customized this variable?
>
>     DB> d
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] emacs: Use the message cite variable
  2015-01-09 13:56     ` Tomi Ollila
@ 2015-01-09 23:37       ` Todd
  2015-01-10  8:19         ` David Bremner
  0 siblings, 1 reply; 10+ messages in thread
From: Todd @ 2015-01-09 23:37 UTC (permalink / raw)
  To: notmuch

I checked in the Emacs 22.1 source code, and there it was a defaulted
to message-cite-original as well.  This patch falls back to
message-cite-original in the unlikely case that someone has customized
message-cite-function to nil.

- Todd

---
 emacs/notmuch-mua.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2c58886..2a01455 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -220,8 +220,8 @@ list."
 	    (date (plist-get original-headers :Date))
 	    (start (point)))

-	;; message-cite-original constructs a citation line based on the From and Date
-	;; headers of the original message, which are assumed to be in the buffer.
+	;; message-cite-function should construct a citation line based on the From and
+	;; Date headers of the original message, which are assumed to be in the buffer.
 	(insert "From: " from "\n")
 	(insert "Date: " date "\n\n")

@@ -233,7 +233,7 @@ list."
 	(set-mark (point))
 	(goto-char start)
 	;; Quote the original message according to the user's configured style.
-	(message-cite-original)))
+	(funcall (or message-cite-function #'message-cite-original))))

     ;; Crypto processing based crypto content of the original message
     (when process-crypto
--
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2] emacs: Use the message cite variable
  2015-01-09 23:37       ` [PATCH v2] emacs: Use the message cite variable Todd
@ 2015-01-10  8:19         ` David Bremner
  2015-01-10 14:28           ` [PATCH v3] emacs: Use the message cite variable instead of a calling cite-message-original directly Todd
  0 siblings, 1 reply; 10+ messages in thread
From: David Bremner @ 2015-01-10  8:19 UTC (permalink / raw)
  To: Todd, notmuch

Todd <todd@electricoding.com> writes:

> I checked in the Emacs 22.1 source code, and there it was a defaulted
> to message-cite-original as well.  This patch falls back to
> message-cite-original in the unlikely case that someone has customized
> message-cite-function to nil.
>

The new patch _looks_ ok, but for some reason it seems to be using the
without-signature version and breaking one of the tests (one of the
subtests of T310-emacs.sh).

d

PS. duplicate message, first one didn't go to the list.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3] emacs: Use the message cite variable instead of a calling cite-message-original directly
  2015-01-10  8:19         ` David Bremner
@ 2015-01-10 14:28           ` Todd
  2015-01-14 19:57             ` [PATCH] emacs: make citation function customizable David Bremner
  0 siblings, 1 reply; 10+ messages in thread
From: Todd @ 2015-01-10 14:28 UTC (permalink / raw)
  To: notmuch

This fixes the test failure.  I didn't have dtach installed, so the
tests were being skipped earlier.  As to why the test fails, it
appears that the default for message-cite-function may depend on the
version of Emacs that you use.

This will likely cause notmuch replying to behave differently for
users if they upgrade, even if they don't customize
message-cite-function (in the case that it is not
message-cite-original).

Regarding the quotation changes in the test, it was not being
interpreted correctly without the double quotes.  I didn't look into
it in much depth, just fixed it for my case.

- Todd


---
 emacs/notmuch-mua.el | 6 +++---
 test/T310-emacs.sh   | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2c58886..66a6b65 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -220,8 +220,8 @@ list."
 	    (date (plist-get original-headers :Date))
 	    (start (point)))
 
-	;; message-cite-original constructs a citation line based on the From and Date
-	;; headers of the original message, which are assumed to be in the buffer.
+	;; message-cite-function should construct a citation line based on the From and
+	;; Date headers of the original message, which are assumed to be in the buffer.
 	(insert "From: " from "\n")
 	(insert "Date: " date "\n\n")
 
@@ -233,7 +233,7 @@ list."
 	(set-mark (point))
 	(goto-char start)
 	;; Quote the original message according to the user's configured style.
-	(message-cite-original)))
+	(funcall (or message-cite-function 'message-cite-original))))
 
     ;; Crypto processing based crypto content of the original message
     (when process-crypto
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index d72799b..74d9f58 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -378,10 +378,11 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest "Reply within emacs to a multipart/mixed message"
-test_emacs '(let ((message-hidden-headers ''()))
-	    (notmuch-show "id:20091118002059.067214ed@hikari")
+test_emacs "(let ((message-hidden-headers '())
+                  (message-cite-function 'message-cite-original))
+	    (notmuch-show \"id:20091118002059.067214ed@hikari\")
 		(notmuch-show-reply)
-		(test-output))'
+		(test-output))"
 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
 cat <<EOF >EXPECTED
 From: Notmuch Test Suite <test_suite@notmuchmail.org>
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] emacs: make citation function customizable.
  2015-01-10 14:28           ` [PATCH v3] emacs: Use the message cite variable instead of a calling cite-message-original directly Todd
@ 2015-01-14 19:57             ` David Bremner
  2015-01-14 23:56               ` Todd
  2015-01-16  8:15               ` David Bremner
  0 siblings, 2 replies; 10+ messages in thread
From: David Bremner @ 2015-01-14 19:57 UTC (permalink / raw)
  To: notmuch

Make a new customizable variable instead of relying on
message-cite-function because the default for the latter changed
between emacs releases.

The defcustom is borrowed from the message.el source, with minor
modifications.
---

Thanks to Todd for tracking down the wibbly wobbly timey wimey behaviour of this variable. I propose to add our own variable to avoid surprising notmuch-emacs users.

 emacs/notmuch-mua.el | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 2c58886..33f1399 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -75,6 +75,22 @@ list."
   :type '(repeat string)
   :group 'notmuch-send)
 
+(defgroup notmuch-reply nil
+  "Replying to messages in notmuch"
+  :group 'notmuch)
+
+(defcustom notmuch-mua-cite-function 'message-cite-original
+  "*Function for citing an original message.
+Predefined functions include `message-cite-original' and
+`message-cite-original-without-signature'.
+Note that these functions use `mail-citation-hook' if that is non-nil."
+  :type '(radio (function-item message-cite-original)
+		(function-item message-cite-original-without-signature)
+		(function-item sc-cite-original)
+		(function :tag "Other"))
+  :link '(custom-manual "(message)Insertion Variables")
+  :group 'notmuch-reply)
+
 ;;
 
 (defun notmuch-mua-get-switch-function ()
@@ -220,8 +236,9 @@ list."
 	    (date (plist-get original-headers :Date))
 	    (start (point)))
 
-	;; message-cite-original constructs a citation line based on the From and Date
-	;; headers of the original message, which are assumed to be in the buffer.
+	;; notmuch-mua-cite-function constructs a citation line based
+	;; on the From and Date headers of the original message, which
+	;; are assumed to be in the buffer.
 	(insert "From: " from "\n")
 	(insert "Date: " date "\n\n")
 
@@ -233,7 +250,7 @@ list."
 	(set-mark (point))
 	(goto-char start)
 	;; Quote the original message according to the user's configured style.
-	(message-cite-original)))
+	(funcall notmuch-mua-cite-function)))
 
     ;; Crypto processing based crypto content of the original message
     (when process-crypto
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] emacs: make citation function customizable.
  2015-01-14 19:57             ` [PATCH] emacs: make citation function customizable David Bremner
@ 2015-01-14 23:56               ` Todd
  2015-01-16  8:15               ` David Bremner
  1 sibling, 0 replies; 10+ messages in thread
From: Todd @ 2015-01-14 23:56 UTC (permalink / raw)
  To: David Bremner, notmuch

[-- Attachment #1: Type: text/plain, Size: 3022 bytes --]


Looks good to me. I applied the patch and it works fine as well.

- Todd

>>>>> "DB" == David Bremner <david@tethera.net> writes:

    DB> Make a new customizable variable instead of relying on
    DB> message-cite-function because the default for the latter changed
    DB> between emacs releases.

    DB> The defcustom is borrowed from the message.el source, with minor
    DB> modifications.
    DB> ---

    DB> Thanks to Todd for tracking down the wibbly wobbly timey wimey behaviour of this variable. I propose to add our own variable to avoid surprising notmuch-emacs users.

    DB>  emacs/notmuch-mua.el | 23 ++++++++++++++++++++---
    DB>  1 file changed, 20 insertions(+), 3 deletions(-)

    DB> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
    DB> index 2c58886..33f1399 100644
    DB> --- a/emacs/notmuch-mua.el
    DB> +++ b/emacs/notmuch-mua.el
    DB> @@ -75,6 +75,22 @@ list."
    DB>    :type '(repeat string)
    DB>    :group 'notmuch-send)
 
    DB> +(defgroup notmuch-reply nil
    DB> +  "Replying to messages in notmuch"
    DB> +  :group 'notmuch)
    DB> +
    DB> +(defcustom notmuch-mua-cite-function 'message-cite-original
    DB> +  "*Function for citing an original message.
    DB> +Predefined functions include `message-cite-original' and
    DB> +`message-cite-original-without-signature'.
    DB> +Note that these functions use `mail-citation-hook' if that is non-nil."
    DB> +  :type '(radio (function-item message-cite-original)
    DB> +		(function-item message-cite-original-without-signature)
    DB> +		(function-item sc-cite-original)
    DB> +		(function :tag "Other"))
    DB> +  :link '(custom-manual "(message)Insertion Variables")
    DB> +  :group 'notmuch-reply)
    DB> +
    DB>  ;;
 
    DB>  (defun notmuch-mua-get-switch-function ()
    DB> @@ -220,8 +236,9 @@ list."
    DB>  	    (date (plist-get original-headers :Date))
    DB>  	    (start (point)))
 
    DB> -	;; message-cite-original constructs a citation line based on the From and Date
    DB> -	;; headers of the original message, which are assumed to be in the buffer.
    DB> +	;; notmuch-mua-cite-function constructs a citation line based
    DB> +	;; on the From and Date headers of the original message, which
    DB> +	;; are assumed to be in the buffer.
    DB>  	(insert "From: " from "\n")
    DB>  	(insert "Date: " date "\n\n")
 
    DB> @@ -233,7 +250,7 @@ list."
    DB>  	(set-mark (point))
    DB>  	(goto-char start)
    DB>  	;; Quote the original message according to the user's configured style.
    DB> -	(message-cite-original)))
    DB> +	(funcall notmuch-mua-cite-function)))
 
    DB>      ;; Crypto processing based crypto content of the original message
    DB>      (when process-crypto
    DB> -- 
    DB> 2.1.4

    DB> _______________________________________________
    DB> notmuch mailing list
    DB> notmuch@notmuchmail.org
    DB> http://notmuchmail.org/mailman/listinfo/notmuch

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] emacs: make citation function customizable.
  2015-01-14 19:57             ` [PATCH] emacs: make citation function customizable David Bremner
  2015-01-14 23:56               ` Todd
@ 2015-01-16  8:15               ` David Bremner
  1 sibling, 0 replies; 10+ messages in thread
From: David Bremner @ 2015-01-16  8:15 UTC (permalink / raw)
  To: notmuch

David Bremner <david@tethera.net> writes:
>
> Thanks to Todd for tracking down the wibbly wobbly timey wimey behaviour of this variable. I propose to add our own variable to avoid surprising notmuch-emacs users.

pushed.

d

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-01-16  8:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-09  1:19 [PATCH] Use the message cite variable instead of a hard coded function Todd
2015-01-09  7:50 ` David Bremner
2015-01-09 12:33   ` Todd
2015-01-09 13:56     ` Tomi Ollila
2015-01-09 23:37       ` [PATCH v2] emacs: Use the message cite variable Todd
2015-01-10  8:19         ` David Bremner
2015-01-10 14:28           ` [PATCH v3] emacs: Use the message cite variable instead of a calling cite-message-original directly Todd
2015-01-14 19:57             ` [PATCH] emacs: make citation function customizable David Bremner
2015-01-14 23:56               ` Todd
2015-01-16  8:15               ` David Bremner

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).