notmuch and "mute" -- useful to anyone?
[notmuch-archives.git] / 6f / 08b3ccfaf11798ee41d5eacbfc5974862cc29c
1 Return-Path: <too@guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id C9FBE6DE0C51\r
6  for <notmuch@notmuchmail.org>; Wed,  2 Sep 2015 07:36:19 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.233\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.233 tagged_above=-999 required=5 tests=[AWL=0.773, \r
12  RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id 9Kr-FzGVOxq8 for <notmuch@notmuchmail.org>;\r
17  Wed,  2 Sep 2015 07:36:17 -0700 (PDT)\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
19  by arlo.cworth.org (Postfix) with ESMTP id 1A4026DE0B38\r
20  for <notmuch@notmuchmail.org>; Wed,  2 Sep 2015 07:36:16 -0700 (PDT)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 6054110019C; Wed,  2 Sep 2015 17:34:45 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org\r
25 Subject: [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer,\r
26  makes it read-only\r
27 Date: Wed,  2 Sep 2015 17:34:39 +0300\r
28 Message-Id: <1441204482-26509-1-git-send-email-tomi.ollila@iki.fi>\r
29 X-Mailer: git-send-email 2.0.0\r
30 Cc: tomi.ollila@iki.fi\r
31 X-BeenThere: notmuch@notmuchmail.org\r
32 X-Mailman-Version: 2.1.18\r
33 Precedence: list\r
34 List-Id: "Use and development of the notmuch mail system."\r
35  <notmuch.notmuchmail.org>\r
36 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
37  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
38 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
39 List-Post: <mailto:notmuch@notmuchmail.org>\r
40 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
41 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
43 X-List-Received-Date: Wed, 02 Sep 2015 14:36:19 -0000\r
44 \r
45 notmuch-show-view-raw-message() re-uses buffer created with same\r
46 name (same Message-Id:) but it did not erase it before filling.\r
47 If this ever happened, there were duplicated (potentially overlapping)\r
48 content in the buffer. Now this is fixed.\r
49 Apparently since emacs 24.5 the (view-buffer) makes the buffer read-only;\r
50 so this problem would not have happened there, just that\r
51 notmuch-show-view-raw-message() failed. This is fixed by setting\r
52 inhibit-read-only t before erasing and filling the buffer. The emacs 24.5\r
53 feature having raw message buffer read-only is also now explicitly set to\r
54 the buffer so the same experience is available with emaces < 24.5.\r
55 ---\r
56  emacs/notmuch-show.el | 9 ++++++---\r
57  1 file changed, 6 insertions(+), 3 deletions(-)\r
58 \r
59 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
60 index 848ec2c870c4..0565ab0725b2 100644\r
61 --- a/emacs/notmuch-show.el\r
62 +++ b/emacs/notmuch-show.el\r
63 @@ -1886,12 +1886,15 @@ (defun notmuch-show-view-raw-message ()\r
64    "View the original source of the current message."\r
65    (interactive)\r
66    (let* ((id (notmuch-show-get-message-id))\r
67 -        (buf (get-buffer-create (concat "*notmuch-raw-" id "*"))))\r
68 -    (let ((coding-system-for-read 'no-conversion))\r
69 -      (call-process notmuch-command nil buf nil "show" "--format=raw" id))\r
70 +        (buf (get-buffer-create (concat "*notmuch-raw-" id "*")))\r
71 +        (inhibit-read-only t))\r
72      (switch-to-buffer buf)\r
73 +    (erase-buffer)\r
74 +    (let ((coding-system-for-read 'no-conversion))\r
75 +      (call-process notmuch-command nil t nil "show" "--format=raw" id))\r
76      (goto-char (point-min))\r
77      (set-buffer-modified-p nil)\r
78 +    (setq buffer-read-only t)\r
79      (view-buffer buf 'kill-buffer-if-not-modified)))\r
80  \r
81  (put 'notmuch-show-pipe-message 'notmuch-doc\r
82 -- \r
83 2.0.0\r
84 \r