[PATCH] emacs: Allow user to choose "From" address when composing a new message.

2011-05-26 Thread Thomas Jost
On Wed, 25 May 2011 15:17:05 -0700, Carl Worth  wrote:
> > I'll also send a few additional patches that make it possible to choose
> > the "From" address when forwarding a message and when replying to a
> > message.
> 
> The only real concern I have with the series is that it grabs 'R' for
> reply-with-custom-from where I've been planning to implement 'R' as
> reply-to-sender-only, (a long-missing and often-requested feature).

That would be nice indeed :)

> When I first started implementing the custom-from feature I planned to
> use a prefix argument to get the behavior (such as "C-u m" rather than
> "M" for compose-new-mail-with-custom-from). You might even see I've got
> some code written along those lines.

Good idea, this will probably seem more natural for Emacs users.

> When I went to test it though, it didn't work. That was probably some
> silly mistake on my part, (we do already have working code that changes
> behavior with a prefix argument in the case of "M-RET" for example).
> 
> If you want to update the series to move away from capital-letter
> keybindings in favor of a prefix argument, I'll be glad to accept it.

Done and tested locally, seems OK so far. This makes the code smaller
and IMHO nicer because it eliminates all the -prompt-for-sender
variants. I'll send the updated patch series very soon.

Thanks,

-- 
Thomas/Schnouki
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 



[PATCH] emacs: Allow user to choose "From" address when composing a new message.

2011-05-26 Thread Jameson Graef Rollins
On Thu, 26 May 2011 10:39:58 +0200, Thomas Jost  
wrote:
> > When I first started implementing the custom-from feature I planned to
> > use a prefix argument to get the behavior (such as "C-u m" rather than
> > "M" for compose-new-mail-with-custom-from). You might even see I've got
> > some code written along those lines.
> 
> Good idea, this will probably seem more natural for Emacs users.

The reason I really want to see this feature is because I always forget
to change my from address depending on the context of my email.  Given
that's my issue, I will also always forget to use a different command to
compose/reply.  In other words, I think the real way to enable this
feature should be via a customization variable.  Either that, or I'll
just modify my custom keybindings to always prompt when I just press the
regular compose/reply keys.

Thanks for work on this feature, Thomas.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [PATCH] emacs: Allow user to choose From address when composing a new message.

2011-05-26 Thread Thomas Jost
On Wed, 25 May 2011 15:17:05 -0700, Carl Worth cwo...@cworth.org wrote:
  I'll also send a few additional patches that make it possible to choose
  the From address when forwarding a message and when replying to a
  message.
 
 The only real concern I have with the series is that it grabs 'R' for
 reply-with-custom-from where I've been planning to implement 'R' as
 reply-to-sender-only, (a long-missing and often-requested feature).

That would be nice indeed :)

 When I first started implementing the custom-from feature I planned to
 use a prefix argument to get the behavior (such as C-u m rather than
 M for compose-new-mail-with-custom-from). You might even see I've got
 some code written along those lines.

Good idea, this will probably seem more natural for Emacs users.

 When I went to test it though, it didn't work. That was probably some
 silly mistake on my part, (we do already have working code that changes
 behavior with a prefix argument in the case of M-RET for example).
 
 If you want to update the series to move away from capital-letter
 keybindings in favor of a prefix argument, I'll be glad to accept it.

Done and tested locally, seems OK so far. This makes the code smaller
and IMHO nicer because it eliminates all the -prompt-for-sender
variants. I'll send the updated patch series very soon.

Thanks,

-- 
Thomas/Schnouki


pgpkt88BUhmiW.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Allow user to choose From address when composing a new message.

2011-05-26 Thread Jameson Graef Rollins
On Thu, 26 May 2011 10:39:58 +0200, Thomas Jost schno...@schnouki.net wrote:
  When I first started implementing the custom-from feature I planned to
  use a prefix argument to get the behavior (such as C-u m rather than
  M for compose-new-mail-with-custom-from). You might even see I've got
  some code written along those lines.
 
 Good idea, this will probably seem more natural for Emacs users.

The reason I really want to see this feature is because I always forget
to change my from address depending on the context of my email.  Given
that's my issue, I will also always forget to use a different command to
compose/reply.  In other words, I think the real way to enable this
feature should be via a customization variable.  Either that, or I'll
just modify my custom keybindings to always prompt when I just press the
regular compose/reply keys.

Thanks for work on this feature, Thomas.

jamie.


pgpXhSzVypJFl.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Allow user to choose "From" address when composing a new message.

2011-05-25 Thread Thomas Jost
On Tue, 24 May 2011 15:02:01 -0700, Carl Worth  wrote:
> In order to select a From address, the user simply presses M instead of
> m to begin composing a message. By default the list of names/addresses
> to be used during completion will be automatically generated by the
> settings in the notmuch configuration file. The user can customize
> the notmuch-identities variable to provide an alternate list.

Thanks, IMHO that's better than my previous solution. And it makes my
.emacs smaller, woohoo! :)

One little issue though: you did not update notmuch-show-mode-map in
notmuch-show.el. I'll reply with a patch that fixes that (or you can
just integrate it in your commit when pushing it).

I'll also send a few additional patches that make it possible to choose
the "From" address when forwarding a message and when replying to a
message.

Regards,

-- 
Thomas/Schnouki
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: 



[PATCH] emacs: Allow user to choose "From" address when composing a new message.

2011-05-25 Thread Carl Worth
On Wed, 25 May 2011 15:21:06 +0200, Thomas Jost  
wrote:
> Thanks, IMHO that's better than my previous solution. And it makes my
> .emacs smaller, woohoo! :)

Thanks for the review.

> One little issue though: you did not update notmuch-show-mode-map in
> notmuch-show.el. I'll reply with a patch that fixes that (or you can
> just integrate it in your commit when pushing it).

Good catch.

> I'll also send a few additional patches that make it possible to choose
> the "From" address when forwarding a message and when replying to a
> message.

The only real concern I have with the series is that it grabs 'R' for
reply-with-custom-from where I've been planning to implement 'R' as
reply-to-sender-only, (a long-missing and often-requested feature).

When I first started implementing the custom-from feature I planned to
use a prefix argument to get the behavior (such as "C-u m" rather than
"M" for compose-new-mail-with-custom-from). You might even see I've got
some code written along those lines.

When I went to test it though, it didn't work. That was probably some
silly mistake on my part, (we do already have working code that changes
behavior with a prefix argument in the case of "M-RET" for example).

If you want to update the series to move away from capital-letter
keybindings in favor of a prefix argument, I'll be glad to accept it.

Otherwise, I might get around to doing that myself at some point.

Thanks again,

-Carl

-- 
carl.d.worth at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



Re: [PATCH] emacs: Allow user to choose From address when composing a new message.

2011-05-25 Thread Thomas Jost
On Tue, 24 May 2011 15:02:01 -0700, Carl Worth cwo...@cworth.org wrote:
 In order to select a From address, the user simply presses M instead of
 m to begin composing a message. By default the list of names/addresses
 to be used during completion will be automatically generated by the
 settings in the notmuch configuration file. The user can customize
 the notmuch-identities variable to provide an alternate list.

Thanks, IMHO that's better than my previous solution. And it makes my
.emacs smaller, woohoo! :)

One little issue though: you did not update notmuch-show-mode-map in
notmuch-show.el. I'll reply with a patch that fixes that (or you can
just integrate it in your commit when pushing it).

I'll also send a few additional patches that make it possible to choose
the From address when forwarding a message and when replying to a
message.

Regards,

-- 
Thomas/Schnouki


pgpdFuT0kSDRr.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Allow user to choose From address when composing a new message.

2011-05-25 Thread Carl Worth
On Wed, 25 May 2011 15:21:06 +0200, Thomas Jost schno...@schnouki.net wrote:
 Thanks, IMHO that's better than my previous solution. And it makes my
 .emacs smaller, woohoo! :)

Thanks for the review.

 One little issue though: you did not update notmuch-show-mode-map in
 notmuch-show.el. I'll reply with a patch that fixes that (or you can
 just integrate it in your commit when pushing it).

Good catch.

 I'll also send a few additional patches that make it possible to choose
 the From address when forwarding a message and when replying to a
 message.

The only real concern I have with the series is that it grabs 'R' for
reply-with-custom-from where I've been planning to implement 'R' as
reply-to-sender-only, (a long-missing and often-requested feature).

When I first started implementing the custom-from feature I planned to
use a prefix argument to get the behavior (such as C-u m rather than
M for compose-new-mail-with-custom-from). You might even see I've got
some code written along those lines.

When I went to test it though, it didn't work. That was probably some
silly mistake on my part, (we do already have working code that changes
behavior with a prefix argument in the case of M-RET for example).

If you want to update the series to move away from capital-letter
keybindings in favor of a prefix argument, I'll be glad to accept it.

Otherwise, I might get around to doing that myself at some point.

Thanks again,

-Carl

-- 
carl.d.wo...@intel.com


pgpwmp5evub1B.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Allow user to choose "From" address when composing a new message.

2011-05-24 Thread Carl Worth
In order to select a From address, the user simply presses M instead of
m to begin composing a message. By default the list of names/addresses
to be used during completion will be automatically generated by the
settings in the notmuch configuration file. The user can customize
the notmuch-identities variable to provide an alternate list.
---
 emacs/notmuch-hello.el |3 ++-
 emacs/notmuch-mua.el   |   40 ++--
 emacs/notmuch.el   |3 ++-
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index e58dd24..5f3bcc8 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -298,7 +298,8 @@ should be. Returns a cons cell `(tags-per-line width)'."
 (define-key map "=" 'notmuch-hello-update)
 (define-key map "G" 'notmuch-hello-poll-and-update)
 (define-key map (kbd "") 'widget-backward)
-(define-key map "m" 'notmuch-mua-mail)
+(define-key map "m" 'notmuch-mua-new-mail)
+(define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender)
 (define-key map "s" 'notmuch-hello-goto-search)
 map)
   "Keymap for \"notmuch hello\" buffers.")
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index dc7b386..76bcba4 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -118,8 +118,7 @@ list."

 (defun notmuch-mua-mail ( to subject other-headers continue
   switch-function yank-action send-actions)
-  "Invoke the notmuch mail composition window."
-  (interactive)
+  "Invoke the notmuch mail composition window with optional headers."

   (when notmuch-mua-user-agent-function
 (let ((user-agent (funcall notmuch-mua-user-agent-function)))
@@ -138,6 +137,43 @@ list."

   (message-goto-to))

+(defcustom notmuch-identities nil
+  "Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file."
+  :group 'notmuch
+  :type '(repeat string))
+
+(defun notmuch-mua-sender-collection ()
+  (if notmuch-identities
+  notmuch-identities
+(mapcar (lambda (address)
+ (concat (notmuch-user-name) " <" address ">"))
+   (cons (notmuch-user-primary-email) (notmuch-user-other-email)
+
+(defun notmuch-mua-new-mail-from ( sender)
+  (if sender
+  (notmuch-mua-mail nil nil (list (cons 'from sender)))
+(notmuch-mua-mail)))
+
+(defvar notmuch-mua-sender-history nil)
+
+(defun notmuch-mua-new-mail ( prompt-for-sender)
+  "Begin composing a new email with notmuch."
+  (interactive "P")
+  (if prompt-for-sender
+  (let* ((collection (notmuch-mua-sender-collection))
+(sender (ido-completing-read "Send mail From: " collection
+ nil 'confirm nil 
'notmuch-mua-sender-history (car collection
+   (notmuch-mua-new-mail-from sender))
+(notmuch-mua-mail)))
+
+(defun notmuch-mua-new-mail-prompt-for-sender ()
+  "Begin composing a new email with notmuch, and prompt for the From: address."
+  (interactive)
+  (notmuch-mua-new-mail t))
+
 (defun notmuch-mua-send-and-exit ( arg)
   (interactive "P")
   (message-send-and-exit arg))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 64f72a0..0c1c8d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -204,7 +204,8 @@ For a mouse binding, return nil."
 (define-key map "p" 'notmuch-search-previous-thread)
 (define-key map "n" 'notmuch-search-next-thread)
 (define-key map "r" 'notmuch-search-reply-to-thread)
-(define-key map "m" 'notmuch-mua-mail)
+(define-key map "m" 'notmuch-mua-new-mail)
+(define-key map "M" 'notmuch-mua-new-mail-prompt-for-sender)
 (define-key map "s" 'notmuch-search)
 (define-key map "o" 'notmuch-search-toggle-order)
 (define-key map "c" 'notmuch-search-stash-map)
-- 
1.7.5.1

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: Allow user to choose From address when composing a new message.

2011-05-24 Thread Carl Worth
In order to select a From address, the user simply presses M instead of
m to begin composing a message. By default the list of names/addresses
to be used during completion will be automatically generated by the
settings in the notmuch configuration file. The user can customize
the notmuch-identities variable to provide an alternate list.
---
 emacs/notmuch-hello.el |3 ++-
 emacs/notmuch-mua.el   |   40 ++--
 emacs/notmuch.el   |3 ++-
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index e58dd24..5f3bcc8 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -298,7 +298,8 @@ should be. Returns a cons cell `(tags-per-line width)'.
 (define-key map = 'notmuch-hello-update)
 (define-key map G 'notmuch-hello-poll-and-update)
 (define-key map (kbd C-tab) 'widget-backward)
-(define-key map m 'notmuch-mua-mail)
+(define-key map m 'notmuch-mua-new-mail)
+(define-key map M 'notmuch-mua-new-mail-prompt-for-sender)
 (define-key map s 'notmuch-hello-goto-search)
 map)
   Keymap for \notmuch hello\ buffers.)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index dc7b386..76bcba4 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -118,8 +118,7 @@ list.
 
 (defun notmuch-mua-mail (optional to subject other-headers continue
   switch-function yank-action send-actions)
-  Invoke the notmuch mail composition window.
-  (interactive)
+  Invoke the notmuch mail composition window with optional headers.
 
   (when notmuch-mua-user-agent-function
 (let ((user-agent (funcall notmuch-mua-user-agent-function)))
@@ -138,6 +137,43 @@ list.
 
   (message-goto-to))
 
+(defcustom notmuch-identities nil
+  Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file.
+  :group 'notmuch
+  :type '(repeat string))
+
+(defun notmuch-mua-sender-collection ()
+  (if notmuch-identities
+  notmuch-identities
+(mapcar (lambda (address)
+ (concat (notmuch-user-name)   address ))
+   (cons (notmuch-user-primary-email) (notmuch-user-other-email)
+
+(defun notmuch-mua-new-mail-from (optional sender)
+  (if sender
+  (notmuch-mua-mail nil nil (list (cons 'from sender)))
+(notmuch-mua-mail)))
+
+(defvar notmuch-mua-sender-history nil)
+
+(defun notmuch-mua-new-mail (optional prompt-for-sender)
+  Begin composing a new email with notmuch.
+  (interactive P)
+  (if prompt-for-sender
+  (let* ((collection (notmuch-mua-sender-collection))
+(sender (ido-completing-read Send mail From:  collection
+ nil 'confirm nil 
'notmuch-mua-sender-history (car collection
+   (notmuch-mua-new-mail-from sender))
+(notmuch-mua-mail)))
+
+(defun notmuch-mua-new-mail-prompt-for-sender ()
+  Begin composing a new email with notmuch, and prompt for the From: address.
+  (interactive)
+  (notmuch-mua-new-mail t))
+
 (defun notmuch-mua-send-and-exit (optional arg)
   (interactive P)
   (message-send-and-exit arg))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 64f72a0..0c1c8d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -204,7 +204,8 @@ For a mouse binding, return nil.
 (define-key map p 'notmuch-search-previous-thread)
 (define-key map n 'notmuch-search-next-thread)
 (define-key map r 'notmuch-search-reply-to-thread)
-(define-key map m 'notmuch-mua-mail)
+(define-key map m 'notmuch-mua-new-mail)
+(define-key map M 'notmuch-mua-new-mail-prompt-for-sender)
 (define-key map s 'notmuch-search)
 (define-key map o 'notmuch-search-toggle-order)
 (define-key map c 'notmuch-search-stash-map)
-- 
1.7.5.1



pgpoMLQmYgyHI.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch