Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id C9FBE6DE0C51 for ; Wed, 2 Sep 2015 07:36:19 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.233 X-Spam-Level: X-Spam-Status: No, score=0.233 tagged_above=-999 required=5 tests=[AWL=0.773, RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9Kr-FzGVOxq8 for ; Wed, 2 Sep 2015 07:36:17 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id 1A4026DE0B38 for ; Wed, 2 Sep 2015 07:36:16 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 6054110019C; Wed, 2 Sep 2015 17:34:45 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH 1/4] emacs: notmuch-show-view-raw-message clears buffer, makes it read-only Date: Wed, 2 Sep 2015 17:34:39 +0300 Message-Id: <1441204482-26509-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.0.0 Cc: tomi.ollila@iki.fi X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2015 14:36:19 -0000 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