unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: More DWIM when editing messages
@ 2010-04-26 14:01 David Edmondson
  2010-04-26 16:31 ` Dirk Hohndel
  0 siblings, 1 reply; 10+ messages in thread
From: David Edmondson @ 2010-04-26 14:01 UTC (permalink / raw)
  To: notmuch

For composing new messages and forwarding, leave the cursor on the
'To:' field. For replies, leave the cursor at the start of the
body. In all cases, mark the buffer as not modified so that the user
is not prompted if she decides to immediately kill the buffer.
---
 emacs/notmuch-mua.el |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index bca20db..c7a9aee 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -98,21 +98,24 @@ list."
 			      collect header)))
     (message-sort-headers)
     (message-hide-headers)
-    (save-excursion
-      (goto-char (point-max))
-      (insert body))
-    (set-buffer-modified-p nil)))
+    (goto-char (point-max))
+    (insert body))
+    (set-buffer-modified-p nil)
+
+    (message-goto-body))
 
 (defun notmuch-mua-forward-message ()
   (message-forward)
-  (save-excursion
-    (when notmuch-mua-user-agent-function
-      (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-	(when (not (string= "" user-agent))
-	  (message-add-header (format "User-Agent: %s" user-agent)))))
-    (message-sort-headers)
-    (message-hide-headers))
-  (set-buffer-modified-p nil))
+
+  (when notmuch-mua-user-agent-function
+    (let ((user-agent (funcall notmuch-mua-user-agent-function)))
+      (when (not (string= "" user-agent))
+	(message-add-header (format "User-Agent: %s" user-agent)))))
+  (message-sort-headers)
+  (message-hide-headers)
+  (set-buffer-modified-p nil)
+
+  (message-goto-to))
 
 (defun notmuch-mua-mail (&optional to subject other-headers continue
 				   switch-function yank-action send-actions)
@@ -126,7 +129,10 @@ list."
   (message-mail to subject other-headers continue
 		switch-function yank-action send-actions)
   (message-sort-headers)
-  (message-hide-headers))
+  (message-hide-headers)
+  (set-buffer-modified-p nil)
+
+  (message-goto-to))
 
 (defun notmuch-mua-send-and-exit (&optional arg)
   (interactive "P")
-- 
1.7.0

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 14:01 [PATCH] emacs: More DWIM when editing messages David Edmondson
@ 2010-04-26 16:31 ` Dirk Hohndel
  2010-04-26 17:28   ` Carl Worth
  0 siblings, 1 reply; 10+ messages in thread
From: Dirk Hohndel @ 2010-04-26 16:31 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Mon, 26 Apr 2010 15:01:25 +0100, David Edmondson <dme@dme.org> wrote:
> For composing new messages and forwarding, leave the cursor on the
> 'To:' field. For replies, leave the cursor at the start of the
> body. In all cases, mark the buffer as not modified so that the user
> is not prompted if she decides to immediately kill the buffer.

YES! Brilliant. I didn't realize how much I wanted it till you sent
this. Carl, please include in 0.3

/D

> ---
>  emacs/notmuch-mua.el |   32 +++++++++++++++++++-------------
>  1 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index bca20db..c7a9aee 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -98,21 +98,24 @@ list."
>  			      collect header)))
>      (message-sort-headers)
>      (message-hide-headers)
> -    (save-excursion
> -      (goto-char (point-max))
> -      (insert body))
> -    (set-buffer-modified-p nil)))
> +    (goto-char (point-max))
> +    (insert body))
> +    (set-buffer-modified-p nil)
> +
> +    (message-goto-body))
>  
>  (defun notmuch-mua-forward-message ()
>    (message-forward)
> -  (save-excursion
> -    (when notmuch-mua-user-agent-function
> -      (let ((user-agent (funcall notmuch-mua-user-agent-function)))
> -	(when (not (string= "" user-agent))
> -	  (message-add-header (format "User-Agent: %s" user-agent)))))
> -    (message-sort-headers)
> -    (message-hide-headers))
> -  (set-buffer-modified-p nil))
> +
> +  (when notmuch-mua-user-agent-function
> +    (let ((user-agent (funcall notmuch-mua-user-agent-function)))
> +      (when (not (string= "" user-agent))
> +	(message-add-header (format "User-Agent: %s" user-agent)))))
> +  (message-sort-headers)
> +  (message-hide-headers)
> +  (set-buffer-modified-p nil)
> +
> +  (message-goto-to))
>  
>  (defun notmuch-mua-mail (&optional to subject other-headers continue
>  				   switch-function yank-action send-actions)
> @@ -126,7 +129,10 @@ list."
>    (message-mail to subject other-headers continue
>  		switch-function yank-action send-actions)
>    (message-sort-headers)
> -  (message-hide-headers))
> +  (message-hide-headers)
> +  (set-buffer-modified-p nil)
> +
> +  (message-goto-to))
>  
>  (defun notmuch-mua-send-and-exit (&optional arg)
>    (interactive "P")
> -- 
> 1.7.0
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

-- 
Dirk Hohndel
Intel Open Source Technology Center

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 16:31 ` Dirk Hohndel
@ 2010-04-26 17:28   ` Carl Worth
  2010-04-26 17:46     ` Dirk Hohndel
  2010-04-26 22:28     ` Dirk Hohndel
  0 siblings, 2 replies; 10+ messages in thread
From: Carl Worth @ 2010-04-26 17:28 UTC (permalink / raw)
  To: Dirk Hohndel, David Edmondson, notmuch

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

On Mon, 26 Apr 2010 09:31:49 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> On Mon, 26 Apr 2010 15:01:25 +0100, David Edmondson <dme@dme.org> wrote:
> > For composing new messages and forwarding, leave the cursor on the
> > 'To:' field. For replies, leave the cursor at the start of the
> > body. In all cases, mark the buffer as not modified so that the user
> > is not prompted if she decides to immediately kill the buffer.
> 
> YES! Brilliant. I didn't realize how much I wanted it till you sent
> this. Carl, please include in 0.3

Agreed! This is *so* pleasant.

Thanks, David! This is pushed.

-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 17:28   ` Carl Worth
@ 2010-04-26 17:46     ` Dirk Hohndel
  2010-04-26 22:28     ` Dirk Hohndel
  1 sibling, 0 replies; 10+ messages in thread
From: Dirk Hohndel @ 2010-04-26 17:46 UTC (permalink / raw)
  To: Carl Worth, David Edmondson, notmuch

On Mon, 26 Apr 2010 10:28:33 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Mon, 26 Apr 2010 09:31:49 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> > On Mon, 26 Apr 2010 15:01:25 +0100, David Edmondson <dme@dme.org> wrote:
> > > For composing new messages and forwarding, leave the cursor on the
> > > 'To:' field. For replies, leave the cursor at the start of the
> > > body. In all cases, mark the buffer as not modified so that the user
> > > is not prompted if she decides to immediately kill the buffer.
> > 
> > YES! Brilliant. I didn't realize how much I wanted it till you sent
> > this. Carl, please include in 0.3
> 
> Agreed! This is *so* pleasant.
> 
> Thanks, David! This is pushed.

And here is the promised fix to get signature in the correct spot:

From cbd9c96450f6481433877410bcf075d482b4be1b Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <hohndel@infradead.org>
Date: Mon, 26 Apr 2010 10:41:49 -0700
Subject: [PATCH] Put signatures at the very end of the message

The existing code inserts the signature before inserting the message
body (which it puts at the very end of the buffer - therefore AFTER
the signature). This little snippet makes us search backwards and
insert the message body before a signature, if it exists.

This also fixes a small indentation issue in David's code.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
---
 emacs/notmuch-mua.el |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index c7a9aee..9fbb94a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -98,11 +98,16 @@ list."
 			      collect header)))
     (message-sort-headers)
     (message-hide-headers)
+    ;; insert the message body - but put it in front of the signature
+    ;; if one is present
     (goto-char (point-max))
+    (if (re-search-backward "-- " nil t)
+	  (forward-line -1)
+      (goto-char (point-max)))
     (insert body))
-    (set-buffer-modified-p nil)
+  (set-buffer-modified-p nil)
 
-    (message-goto-body))
+  (message-goto-body))
 
 (defun notmuch-mua-forward-message ()
   (message-forward)
-- 
1.6.6.1



-- 
Dirk Hohndel
Intel Open Source Technology Center

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 17:28   ` Carl Worth
  2010-04-26 17:46     ` Dirk Hohndel
@ 2010-04-26 22:28     ` Dirk Hohndel
  2010-04-26 23:39       ` Carl Worth
  2010-04-27  5:34       ` David Edmondson
  1 sibling, 2 replies; 10+ messages in thread
From: Dirk Hohndel @ 2010-04-26 22:28 UTC (permalink / raw)
  To: Carl Worth, David Edmondson, notmuch

On Mon, 26 Apr 2010 10:28:33 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Mon, 26 Apr 2010 09:31:49 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> > On Mon, 26 Apr 2010 15:01:25 +0100, David Edmondson <dme@dme.org> wrote:
> > > For composing new messages and forwarding, leave the cursor on the
> > > 'To:' field. For replies, leave the cursor at the start of the
> > > body. In all cases, mark the buffer as not modified so that the user
> > > is not prompted if she decides to immediately kill the buffer.
> > 
> > YES! Brilliant. I didn't realize how much I wanted it till you sent
> > this. Carl, please include in 0.3
> 
> Agreed! This is *so* pleasant.
> 
> Thanks, David! This is pushed.

This appears not to have gone out??? Must be that weird MUA that I'm
using...

From cbd9c96450f6481433877410bcf075d482b4be1b Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <hohndel@infradead.org>
Date: Mon, 26 Apr 2010 10:41:49 -0700
Subject: [PATCH] Put signatures at the very end of the message

The existing code inserts the signature before inserting the message
body (which it puts at the very end of the buffer - therefore AFTER
the signature). This little snippet makes us search backwards and
insert the message body before a signature, if it exists.

Signed-off-by: Dirk Hohndel <hohndel@infradead.org>
---
 emacs/notmuch-mua.el |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index c7a9aee..9fbb94a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -98,11 +98,16 @@ list."
 			      collect header)))
     (message-sort-headers)
     (message-hide-headers)
+    ;; insert the message body - but put it in front of the signature
+    ;; if one is present
     (goto-char (point-max))
+    (if (re-search-backward "-- " nil t)
+	  (forward-line -1)
+      (goto-char (point-max)))
     (insert body))
-    (set-buffer-modified-p nil)
+  (set-buffer-modified-p nil)
 
-    (message-goto-body))
+  (message-goto-body))
 
 (defun notmuch-mua-forward-message ()
   (message-forward)
-- 
1.6.6.1



-- 
Dirk Hohndel
Intel Open Source Technology Center

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 22:28     ` Dirk Hohndel
@ 2010-04-26 23:39       ` Carl Worth
  2010-04-27  1:52         ` Dirk Hohndel
  2010-04-27  5:34       ` David Edmondson
  1 sibling, 1 reply; 10+ messages in thread
From: Carl Worth @ 2010-04-26 23:39 UTC (permalink / raw)
  To: Dirk Hohndel, David Edmondson, notmuch

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

On Mon, 26 Apr 2010 15:28:02 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> This appears not to have gone out??? Must be that weird MUA that I'm
> using...

Strange. I couldn't find it earlier, and now I have both versions
here. So blame me, (or the weird MUA that I'm using...).

> The existing code inserts the signature before inserting the message
> body (which it puts at the very end of the buffer - therefore AFTER
> the signature). This little snippet makes us search backwards and
> insert the message body before a signature, if it exists.

Works great. This is pushed.

-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 23:39       ` Carl Worth
@ 2010-04-27  1:52         ` Dirk Hohndel
  0 siblings, 0 replies; 10+ messages in thread
From: Dirk Hohndel @ 2010-04-27  1:52 UTC (permalink / raw)
  To: Carl Worth, David Edmondson, notmuch

On Mon, 26 Apr 2010 16:39:44 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Mon, 26 Apr 2010 15:28:02 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> > This appears not to have gone out??? Must be that weird MUA that I'm
> > using...
> 
> Strange. I couldn't find it earlier, and now I have both versions
> here. So blame me, (or the weird MUA that I'm using...).

Nope, wasn't you - my MTA (not MUA) had stalled the message. When I
noticed, both went out at the same time (which you can see from the
headers)
 
> > The existing code inserts the signature before inserting the message
> > body (which it puts at the very end of the buffer - therefore AFTER
> > the signature). This little snippet makes us search backwards and
> > insert the message body before a signature, if it exists.
> 
> Works great. This is pushed.

Thanks

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-26 22:28     ` Dirk Hohndel
  2010-04-26 23:39       ` Carl Worth
@ 2010-04-27  5:34       ` David Edmondson
  2010-04-27  6:14         ` Carl Worth
  1 sibling, 1 reply; 10+ messages in thread
From: David Edmondson @ 2010-04-27  5:34 UTC (permalink / raw)
  To: Dirk Hohndel, Carl Worth, notmuch

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

On Mon, 26 Apr 2010 15:28:02 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> +    (if (re-search-backward "-- " nil t)

Maybe `message-signature-separator' rather than the literal "-- " here.

dme.
-- 
David Edmondson, http://dme.org

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-27  5:34       ` David Edmondson
@ 2010-04-27  6:14         ` Carl Worth
  2010-04-27 15:22           ` Dirk Hohndel
  0 siblings, 1 reply; 10+ messages in thread
From: Carl Worth @ 2010-04-27  6:14 UTC (permalink / raw)
  To: David Edmondson, Dirk Hohndel, notmuch

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

On Tue, 27 Apr 2010 06:34:51 +0100, David Edmondson <dme@dme.org> wrote:
> On Mon, 26 Apr 2010 15:28:02 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> > +    (if (re-search-backward "-- " nil t)
> 
> Maybe `message-signature-separator' rather than the literal "-- "
> here.

Good catch. Dirk did say he was almost sure he had seen a variable
containing this regexp somewhere... :-)

I've pushed a fix for this.

-Carl

-- 
carl.d.worth@intel.com

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] emacs: More DWIM when editing messages
  2010-04-27  6:14         ` Carl Worth
@ 2010-04-27 15:22           ` Dirk Hohndel
  0 siblings, 0 replies; 10+ messages in thread
From: Dirk Hohndel @ 2010-04-27 15:22 UTC (permalink / raw)
  To: Carl Worth, David Edmondson, notmuch

On Mon, 26 Apr 2010 23:14:49 -0700, Carl Worth <cworth@cworth.org> wrote:
> On Tue, 27 Apr 2010 06:34:51 +0100, David Edmondson <dme@dme.org> wrote:
> > On Mon, 26 Apr 2010 15:28:02 -0700, Dirk Hohndel <hohndel@infradead.org> wrote:
> > > +    (if (re-search-backward "-- " nil t)
> > 
> > Maybe `message-signature-separator' rather than the literal "-- "
> > here.

Thanks

> Good catch. Dirk did say he was almost sure he had seen a variable
> containing this regexp somewhere... :-)

I ran out of time looking - and then forgot.

> I've pushed a fix for this.

Thanks

/D

-- 
Dirk Hohndel
Intel Open Source Technology Center

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

end of thread, other threads:[~2010-04-27 15:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26 14:01 [PATCH] emacs: More DWIM when editing messages David Edmondson
2010-04-26 16:31 ` Dirk Hohndel
2010-04-26 17:28   ` Carl Worth
2010-04-26 17:46     ` Dirk Hohndel
2010-04-26 22:28     ` Dirk Hohndel
2010-04-26 23:39       ` Carl Worth
2010-04-27  1:52         ` Dirk Hohndel
2010-04-27  5:34       ` David Edmondson
2010-04-27  6:14         ` Carl Worth
2010-04-27 15:22           ` Dirk Hohndel

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