How does notmuch track mails?
[notmuch-archives.git] / a4 / fef72c5a097c96de9d3340a749e5fc8efa5b49
1 Return-Path: <jani@nikula.org>\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 olra.theworths.org (Postfix) with ESMTP id 67B07431FC9\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Mar 2014 05:18:01 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id oR2+cZTgg9TP for <notmuch@notmuchmail.org>;\r
16         Sat,  1 Mar 2014 05:17:56 -0800 (PST)\r
17 Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com\r
18         [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id B2017431FC4\r
21         for <notmuch@notmuchmail.org>; Sat,  1 Mar 2014 05:17:55 -0800 (PST)\r
22 Received: by mail-ea0-f181.google.com with SMTP id k10so3364208eaj.12\r
23         for <notmuch@notmuchmail.org>; Sat, 01 Mar 2014 05:17:54 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
27         bh=1K5GYlm5ETjYKIphLAoXm1D4hYexu0fYaa9esFCwmOA=;\r
28         b=POoV3gOzsc3ZIyYKRWS7SJhXfWGPvVmSLvpBA1lgYybtTWc13TSJkpm9ieLMgF7JC4\r
29         ahQl0YWxt+1N3Io3S/5rM3DpvbIsvOvcyY3Ps2ygY1u2DMws6GfGC0CHcahd4aFNLRsD\r
30         11hdDVW2dRzoK5Ojpm8oCspddD686hk+ymyKMzHmytsMQ+0rXnhmcP5KgWLSl4M6rdD7\r
31         Fp7RSrUXQRSpQyNXjkPhQRxFoAY0rjgQoxC9l2bciXAUUL3p30c45bH0nrebbITz4WCv\r
32         bmgQboYpI0VcDySLLf6H9N172sr9nGESxqgT1XiXrQw2L+sAg/WDqSGDo4Qqe0L6Qt0W\r
33         YvRA==\r
34 X-Gm-Message-State:\r
35  ALoCoQldM/cUBh8+pvcANCHRiRi+rrwaOQq8F7ZN+a/IsYr74nxTN29cYHw1MCIGLHP7Nbvot/c1\r
36 X-Received: by 10.14.209.8 with SMTP id r8mr42618eeo.85.1393679873025;\r
37         Sat, 01 Mar 2014 05:17:53 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
39         [88.195.111.91])\r
40         by mx.google.com with ESMTPSA id y51sm23463857eeu.0.2014.03.01.05.17.51\r
41         for <multiple recipients>\r
42         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
43         Sat, 01 Mar 2014 05:17:52 -0800 (PST)\r
44 From: Jani Nikula <jani@nikula.org>\r
45 To: notmuch@notmuchmail.org\r
46 Subject: [PATCH] emacs: use the originating buffer's working directory for\r
47  pipe\r
48 Date: Sat,  1 Mar 2014 15:17:50 +0200\r
49 Message-Id: <1393679870-29557-1-git-send-email-jani@nikula.org>\r
50 X-Mailer: git-send-email 1.8.5.3\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sat, 01 Mar 2014 13:18:01 -0000\r
64 \r
65 Currently notmuch-show-pipe-message runs the command in the working\r
66 directory of the *notmuch-pipe* buffer if it exists, and the current\r
67 buffer's working directory (which is inherited to the new\r
68 *notmuch-pipe* buffer) otherwise. This is all very surprising to the\r
69 user, and it's difficult to know or change where the command will be\r
70 run.\r
71 \r
72 Always use the current show buffer's working directory for piping. The\r
73 user can check that with M-x pwd and change it with M-x cd. This is\r
74 consistent with notmuch-show-pipe-part.\r
75 \r
76 ---\r
77 \r
78 Mark also suggested printing the working directory in the prompt for\r
79 the command to pipe to, but when I tried it I thought the prompt\r
80 became too crowded with that. It's also less important now that the\r
81 current buffer's working directory is used consistently.\r
82 ---\r
83  emacs/notmuch-show.el | 6 +++++-\r
84  1 file changed, 5 insertions(+), 1 deletion(-)\r
85 \r
86 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
87 index 88752f171930..b8782ddb632e 100644\r
88 --- a/emacs/notmuch-show.el\r
89 +++ b/emacs/notmuch-show.el\r
90 @@ -1781,10 +1781,14 @@ message."\r
91        (setq shell-command\r
92             (concat notmuch-command " show --format=raw "\r
93                     (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))\r
94 -    (let ((buf (get-buffer-create (concat "*notmuch-pipe*"))))\r
95 +    (let ((cwd default-directory)\r
96 +         (buf (get-buffer-create (concat "*notmuch-pipe*"))))\r
97        (with-current-buffer buf\r
98         (setq buffer-read-only nil)\r
99         (erase-buffer)\r
100 +       ;; Use the originating buffer's working directory instead of\r
101 +       ;; that of the pipe buffer.\r
102 +       (cd cwd)\r
103         (let ((exit-code (call-process-shell-command shell-command nil buf)))\r
104           (goto-char (point-max))\r
105           (set-buffer-modified-p nil)\r
106 -- \r
107 1.8.5.3\r
108 \r