unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only
@ 2015-09-02 14:34 Tomi Ollila
  2015-09-02 14:34 ` [PATCH 2/4] emacs: add function notmuch-address--message-insinuated Tomi Ollila
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Tomi Ollila @ 2015-09-02 14:34 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

notmuch-show-view-raw-message() re-uses buffer created with same
name (same Message-Id:) but it did not erase it before filling.
If this ever happened, there were duplicated (potentially overlapping)
content in the buffer. Now this is fixed.
Apparently since emacs 24.5 the (view-buffer) makes the buffer read-only;
so this problem would not have happened there, just that
notmuch-show-view-raw-message() failed. This is fixed by setting
inhibit-read-only t before erasing and filling the buffer. The emacs 24.5
feature having raw message buffer read-only is also now explicitly set to
the buffer so the same experience is available with emaces < 24.5.
---
 emacs/notmuch-show.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 848ec2c870c4..0565ab0725b2 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1886,12 +1886,15 @@ (defun notmuch-show-view-raw-message ()
   "View the original source of the current message."
   (interactive)
   (let* ((id (notmuch-show-get-message-id))
-	 (buf (get-buffer-create (concat "*notmuch-raw-" id "*"))))
-    (let ((coding-system-for-read 'no-conversion))
-      (call-process notmuch-command nil buf nil "show" "--format=raw" id))
+	 (buf (get-buffer-create (concat "*notmuch-raw-" id "*")))
+	 (inhibit-read-only t))
     (switch-to-buffer buf)
+    (erase-buffer)
+    (let ((coding-system-for-read 'no-conversion))
+      (call-process notmuch-command nil t nil "show" "--format=raw" id))
     (goto-char (point-min))
     (set-buffer-modified-p nil)
+    (setq buffer-read-only t)
     (view-buffer buf 'kill-buffer-if-not-modified)))
 
 (put 'notmuch-show-pipe-message 'notmuch-doc
-- 
2.0.0

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

* [PATCH 2/4] emacs: add function notmuch-address--message-insinuated
  2015-09-02 14:34 [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Tomi Ollila
@ 2015-09-02 14:34 ` Tomi Ollila
  2015-09-02 14:34 ` [PATCH 3/4] emacs: add function to resend message to new recipients Tomi Ollila
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2015-09-02 14:34 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

This function is currently used in notmuch-address-message-insinuate
(to not enable address completion if it is already enabled). In near future
this will be called in other functions to know whether address completion
can be used there, too.
---

Since id:1440619626-18768-1-git-send-email-tomi.ollila@iki.fi
  - changed defsubst to defun

 emacs/notmuch-address.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index fde3c1b2b861..8982a415ce11 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -54,8 +54,11 @@ (defvar notmuch-address-message-alist-member
 
 (defvar notmuch-address-history nil)
 
+(defun notmuch-address--message-insinuated ()
+  (memq notmuch-address-message-alist-member message-completion-alist))
+
 (defun notmuch-address-message-insinuate ()
-  (unless (memq notmuch-address-message-alist-member message-completion-alist)
+  (unless (notmuch-address--message-insinuated)
     (setq message-completion-alist
 	  (push notmuch-address-message-alist-member message-completion-alist))))
 
-- 
2.0.0

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

* [PATCH 3/4] emacs: add function to resend message to new recipients
  2015-09-02 14:34 [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Tomi Ollila
  2015-09-02 14:34 ` [PATCH 2/4] emacs: add function notmuch-address--message-insinuated Tomi Ollila
@ 2015-09-02 14:34 ` Tomi Ollila
  2015-10-28  8:00   ` Mark Walters
  2015-09-02 14:34 ` [PATCH 4/4] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode Tomi Ollila
  2015-11-23 12:55 ` [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only David Bremner
  3 siblings, 1 reply; 6+ messages in thread
From: Tomi Ollila @ 2015-09-02 14:34 UTC (permalink / raw)
  To: notmuch; +Cc: 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.
---

Since id:1440619626-18768-2-git-send-email-tomi.ollila@iki.fi
  - changed (bury-buffer) to (notmuch-bury-or-kill-this-buffer)
    - it is hard to have the buffer been kept around but it is posiible

 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 8982a415ce11..83788efd3c1b 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 0565ab0725b2..046cb0e41f0b 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)
+    (notmuch-bury-or-kill-this-buffer)))
+
 (defun notmuch-show-next-message (&optional pop-at-end)
   "Show the next message.
 
-- 
2.0.0

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

* [PATCH 4/4] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode
  2015-09-02 14:34 [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Tomi Ollila
  2015-09-02 14:34 ` [PATCH 2/4] emacs: add function notmuch-address--message-insinuated Tomi Ollila
  2015-09-02 14:34 ` [PATCH 3/4] emacs: add function to resend message to new recipients Tomi Ollila
@ 2015-09-02 14:34 ` Tomi Ollila
  2015-11-23 12:55 ` [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2015-09-02 14:34 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

This binding is similar to mutt's, which is

bind {mode} b   "bounce-message"    # remail a message to another user

where {mode} is 'index', 'pager' or 'attach'.
---
 emacs/notmuch-show.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 046cb0e41f0b..e7e381eecc42 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1373,6 +1373,7 @@ (defvar notmuch-show-mode-map
     (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
     (define-key map (kbd "TAB") 'notmuch-show-next-button)
     (define-key map "f" 'notmuch-show-forward-message)
+    (define-key map "b" 'notmuch-show-resend-message)
     (define-key map "l" 'notmuch-show-filter-thread)
     (define-key map "r" 'notmuch-show-reply-sender)
     (define-key map "R" 'notmuch-show-reply)
-- 
2.0.0

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

* Re: [PATCH 3/4] emacs: add function to resend message to new recipients
  2015-09-02 14:34 ` [PATCH 3/4] emacs: add function to resend message to new recipients Tomi Ollila
@ 2015-10-28  8:00   ` Mark Walters
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Walters @ 2015-10-28  8:00 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila


On Wed, 02 Sep 2015, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> 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.
> ---

This series looks good to me modulo three minor comments  (I even
like the choice of binding to b). 

The first comment is that, in light of the recent address series, I
think Patch 2 can be dropped completely, with a small change to this
patch. See below for that, and the other two minor suggestions.

Also, I wonder if when it gets a NEWS item it might be worth mentioning
that a user might have already added this function to their emacs init
file as it has been on the wiki. (It took me way too long to realise
that was why this patch was not working for me!)

Best wishes

Mark


>
> Since id:1440619626-18768-2-git-send-email-tomi.ollila@iki.fi
>   - changed (bury-buffer) to (notmuch-bury-or-kill-this-buffer)
>     - it is hard to have the buffer been kept around but it is posiible
>
>  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 8982a415ce11..83788efd3c1b 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)

This can become 
     (if (not notmuch-address-command)
 
> +    (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

I think this could become (define-key rmap (kbd "TAB") (lambda () ....

which is easy to read and consistent with the definitions of other
keymaps (eg the main notmuch-show keymap).

> +			       (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 0565ab0725b2..046cb0e41f0b 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 " "))

Perhaps y-or-n-p rather than yes-or-no-p?
 
> +    (notmuch-show-view-raw-message)
> +    (message-resend addresses)
> +    (notmuch-bury-or-kill-this-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

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

* Re: [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only
  2015-09-02 14:34 [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Tomi Ollila
                   ` (2 preceding siblings ...)
  2015-09-02 14:34 ` [PATCH 4/4] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode Tomi Ollila
@ 2015-11-23 12:55 ` David Bremner
  3 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2015-11-23 12:55 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> notmuch-show-view-raw-message() re-uses buffer created with same
> name (same Message-Id:) but it did not erase it before filling.
> If this ever happened, there were duplicated (potentially overlapping)
> content in the buffer. Now this is fixed.
> Apparently since emacs 24.5 the (view-buffer) makes the buffer read-only;
> so this problem would not have happened there, just that
> notmuch-show-view-raw-message() failed. This is fixed by setting
> inhibit-read-only t before erasing and filling the buffer. The emacs 24.5
> feature having raw message buffer read-only is also now explicitly set to
> the buffer so the same experience is available with emaces < 24.5.

Applied this one patch to master

d

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

end of thread, other threads:[~2015-11-23 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02 14:34 [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Tomi Ollila
2015-09-02 14:34 ` [PATCH 2/4] emacs: add function notmuch-address--message-insinuated Tomi Ollila
2015-09-02 14:34 ` [PATCH 3/4] emacs: add function to resend message to new recipients Tomi Ollila
2015-10-28  8:00   ` Mark Walters
2015-09-02 14:34 ` [PATCH 4/4] emacs: bind notmuch-show-resend-message to 'b' in notmuch-show mode Tomi Ollila
2015-11-23 12:55 ` [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only 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).