Re: [PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-31 Thread Tomi Ollila
On Mon, Aug 31 2015, David Bremner  wrote:

> Tomi Ollila  writes:
>
>>
>>   emacs -q -L $PWD/emacs -l emacs/notmuch.el -f notmuch --eval '(progn (setq 
>> notmuch-address-command "nottoomuch-addresses.sh") 
>> (notmuch-address-message-insinuate))'
>>

> Ah, I missed notmuch-address-message-insinuate; it does work if I run
> that. I wonder if this can be simplified at all now that
> notmuch-message-mode exists. In general I'm leery of running code when we
> load notmuch*.el, as this has a history of causing problems for people
> using notmuch e.g. as a search tool for gnus.

Currently as both setting notmuch-address-command and
notmuch-address-message-insinunate us required I would not attempt to do any
"magic" there. Whenever we get built-in address completion (i.e built-in
is used when notmuch-address-command is kept nil we could consider to add
some defcustom which can be used to activate address completion -- but 
as there are these *-insinunate -commands in many elisp packages it is
probably best to investigate whether this really can be "automated".
Perhaps some lazy initialization could be in place, then.

> The completion interface takes a little getting used to, but it's
> definitely usable. And of course much better than what we have now ;).
>
> One thing I noticed which I _think_ is a bug, is that after calling
> notmuch-show-resend-message, notmuch-view-raw-message doesn't work
> anymore, complaining about a read-only buffer.

That is interesting in a sense that I could not reproduce. I think I know
exactly why this happens: notmuch-view-raw-message creates read-only buffer
which is not removed after message is resent: re-running
notmuch-view-raw-message on same message will `get-buffer-create' with
same name and pick the old read-only buffer; inserting data to that buffer
fails -- just that in my tests (V C-x b RET V) I could not get the same
outcome.

The simplest change is to change (bury-buffer) with (kill-buffer). The raw
message buffer that was used to send should not be interesting; more
interesting is the current (same) message in notmuch-show buffer -- and 'V'
can be used to re-view the raw message. 
What could be added is printing the message id of the message resent to
*Messages* buffer. This way re-sender can verify what was resent if being
unsure. Just that in the case I've used this I have not looked back...

So, probably I make applicable RFC patch of this feature...


>
> d

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-31 Thread David Bremner
Tomi Ollila  writes:

> That is interesting in a sense that I could not reproduce. I think I know
> exactly why this happens: notmuch-view-raw-message creates read-only buffer
> which is not removed after message is resent: re-running
> notmuch-view-raw-message on same message will `get-buffer-create' with
> same name and pick the old read-only buffer; inserting data to that buffer
> fails -- just that in my tests (V C-x b RET V) I could not get the same
> outcome.

This test actually reproduces the problem for me. Maybe it's emacs
version specific? I mainly 24.5.1, but I can't duplicate the problem in
emacs23.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-30 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:

 The new function notmuch-show-message-resend re-sends
 message to new recipients using #'message-resend.

 Recipients are read from minibuffer as a comma-separated
 string (with some keyboard support including tab completion).


I couldn't get the tab completion to work, at least if I go

  M-x notmuch-show-resend-message

nor when evaluating (notmuch-address-from-minibuffer foo:)

Do I need to bind a key to test this?

 I remember that Emacs VM might have had 'b' bound to this functionality
 but I cannot be sure. A few weeks ago I looked gnus, rmail  mh-e to
 figure out whether 'b' would have been bound to similar functionality
 there but I cannot find it...

mutt uses 'b'. AFAICT, gnus uses some sequence ending in b to resend
bounced messages (i.e. from mailer-daemon).

quoting the manual:

S D b

If you have sent a mail, but the mail was bounced back to you for
some reason (wrong address, transient failure), you can use this
command to resend that bounced mail
(gnus-summary-resend-bounced-mail). [...]

S D r

Not to be confused with the previous command,
gnus-summary-resend-message will prompt you for an address to send
the current message off to, and then send it to that place. [...]

Be that as it may, we already use 'r' for reply, and I'm not sure we
want to go (more) in the way of multi-letter sequences.

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-30 Thread Tomi Ollila
On Sun, Aug 30 2015, David Bremner da...@tethera.net wrote:

 Tomi Ollila tomi.oll...@iki.fi writes:

 The new function notmuch-show-message-resend re-sends
 message to new recipients using #'message-resend.

 Recipients are read from minibuffer as a comma-separated
 string (with some keyboard support including tab completion).


 I couldn't get the tab completion to work, at least if I go

   M-x notmuch-show-resend-message

 nor when evaluating (notmuch-address-from-minibuffer foo:)

 Do I need to bind a key to test this?

Nope. both of the above should work -- and worked for me just now
(this is how I tested just now:

  emacs -q -L $PWD/emacs -l emacs/notmuch.el -f notmuch --eval '(progn (setq 
notmuch-address-command nottoomuch-addresses.sh) 
(notmuch-address-message-insinuate))'

)

 I remember that Emacs VM might have had 'b' bound to this functionality
 but I cannot be sure. A few weeks ago I looked gnus, rmail  mh-e to
 figure out whether 'b' would have been bound to similar functionality
 there but I cannot find it...

 mutt uses 'b'. AFAICT, gnus uses some sequence ending in b to resend
 bounced messages (i.e. from mailer-daemon).

 quoting the manual:

 S D b

 If you have sent a mail, but the mail was bounced back to you for
 some reason (wrong address, transient failure), you can use this
 command to resend that bounced mail
 (gnus-summary-resend-bounced-mail). [...]
 
 S D r

 Not to be confused with the previous command,
 gnus-summary-resend-message will prompt you for an address to send
 the current message off to, and then send it to that place. [...]

 Be that as it may, we already use 'r' for reply, and I'm not sure we
 want to go (more) in the way of multi-letter sequences.

I agree that we don't want to to multi-letter sequences (early). I
personally would be fine w/ 'b'...

Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-30 Thread David Bremner
Tomi Ollila tomi.oll...@iki.fi writes:


   emacs -q -L $PWD/emacs -l emacs/notmuch.el -f notmuch --eval '(progn (setq 
 notmuch-address-command nottoomuch-addresses.sh) 
 (notmuch-address-message-insinuate))'

Ah, I missed notmuch-address-message-insinuate; it does work if I run
that. I wonder if this can be simplified at all now that
notmuch-message-mode exists. In general I'm leery of running code when
we load notmuch*.el, as this has a history of causing problems for
people using notmuch e.g. as a search tool for gnus.

The completion interface takes a little getting used to, but it's
definitely usable. And of course much better than what we have now ;).

One thing I noticed which I _think_ is a bug, is that after calling
notmuch-show-resend-message, notmuch-view-raw-message doesn't work
anymore, complaining about a read-only buffer.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] emacs: add function to resend message to new recipients

2015-08-26 Thread Tomi Ollila
The new function notmuch-show-message-resend re-sends
message to new recipients using #'message-resend.

Recipients are read from minibuffer as a comma-separated
string (with some keyboard support including tab completion).

Final confirmation before sending is asked.
---

Note that notmuch-show-message-resend is not (yet) bound to any
keybindings in notmuch-show-mode-map (nor notmuch-tree-mode-map!).

I remember that Emacs VM might have had 'b' bound to this functionality
but I cannot be sure. A few weeks ago I looked gnus, rmail  mh-e to
figure out whether 'b' would have been bound to similar functionality
there but I cannot find it...

A future patch will be done when we've decide where to bind this.

Also, I simplified keybindings in notmuch-address-from-minibuffer --
latest version used to bind ',' in both minibuffer-local-map and
minibuffer-local-completion-map to do some magic. I'll send an RFC
patch having that later.

 emacs/notmuch-address.el | 19 +++
 emacs/notmuch-show.el|  8 
 2 files changed, 27 insertions(+)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 6c93b2a7a820..b08a78f2db46 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -119,4 +119,23 @@ (defun notmuch-address-locate-command (command)
 
 ;;
 
+(defun notmuch-address-from-minibuffer (prompt)
+  (if (not (notmuch-address--message-insinuated))
+  (read-string prompt)
+(let ((rmap (copy-keymap minibuffer-local-map))
+ (omap minibuffer-local-map))
+  ;; Configure TAB to start completion when executing read-string.
+  ;; Original minibuffer keymap is restored just before calling
+  ;; notmuch-address-expand-name as it may also use minibuffer-local-map
+  ;; (completing-read probably does not but if something else is used 
there).
+  (define-key rmap \C-i (lambda () ;; TAB
+  (interactive)
+  (let ((enable-recursive-minibuffers t)
+(minibuffer-local-map omap))
+(notmuch-address-expand-name
+  (let ((minibuffer-local-map rmap))
+   (read-string prompt)
+
+;;
+
 (provide 'notmuch-address)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 848ec2c870c4..62aa696224ca 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1806,6 +1806,14 @@ (defun notmuch-show-forward-message (optional 
prompt-for-sender)
   (with-current-notmuch-show-message
(notmuch-mua-new-forward-message prompt-for-sender)))
 
+(defun notmuch-show-resend-message (addresses)
+  Resend the current message.
+  (interactive (list (notmuch-address-from-minibuffer Resend to: )))
+  (when (yes-or-no-p (concat Confirm resend to  addresses  ))
+(notmuch-show-view-raw-message)
+(message-resend addresses)
+(bury-buffer)))
+
 (defun notmuch-show-next-message (optional pop-at-end)
   Show the next message.
 
-- 
2.0.0

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch