Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / 8b / 9f3eae441d12e82d73ce0cfd722e0da6f6ecda
1 Return-Path: <jrollins@servo.finestructure.net>\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 763DF431FD0\r
6         for <notmuch@notmuchmail.org>; Sat, 28 May 2011 17:10:10 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.921\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.921 tagged_above=-999 required=5\r
12         tests=[NO_DNS_FOR_FROM=0.379, RCVD_IN_DNSWL_MED=-2.3]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id M2ugFPFRtrBG for <notmuch@notmuchmail.org>;\r
17         Sat, 28 May 2011 17:10:09 -0700 (PDT)\r
18 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
19         [131.215.239.19])\r
20         by olra.theworths.org (Postfix) with ESMTP id B3380431FB6\r
21         for <notmuch@notmuchmail.org>; Sat, 28 May 2011 17:10:09 -0700 (PDT)\r
22 Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
23         by fire-doxen-postvirus (Postfix) with ESMTP id BA79C32808D;\r
24         Sat, 28 May 2011 17:03:41 -0700 (PDT)\r
25 X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
26 Received: from servo.finestructure.net (cpe-98-149-172-122.socal.res.rr.com\r
27         [98.149.172.122]) (Authenticated sender: jrollins)\r
28         by fire-doxen-submit (Postfix) with ESMTP id 7E631328071;\r
29         Sat, 28 May 2011 17:03:34 -0700 (PDT)\r
30 Received: by servo.finestructure.net (Postfix, from userid 1000)\r
31         id 2EA6B4C5; Sat, 28 May 2011 17:10:01 -0700 (PDT)\r
32 From: Jameson Graef Rollins <jrollins@finestructure.net>\r
33 To: Notmuch Mail <notmuch@notmuchmail.org>\r
34 Subject: [PATCH 1/2] emacs: add notmuch-show-refresh-view function\r
35 Date: Sat, 28 May 2011 17:09:43 -0700\r
36 Message-Id: <1306627784-3401-1-git-send-email-jrollins@finestructure.net>\r
37 X-Mailer: git-send-email 1.7.4.4\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.13\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sun, 29 May 2011 00:10:10 -0000\r
51 \r
52 This function, like the equivalent for notmuch-search, just refreshes\r
53 the current show view.  Like in notmuch-search, this new function is\r
54 bound to "=".  If a prefix is given then the rediplay happens with the\r
55 crypto-switch set, which displays the thread with the opposite logic\r
56 of whatever is set in the notmuch-crypto-process-mime customization\r
57 variable.\r
58 ---\r
59  emacs/notmuch-show.el |   42 +++++++++++++++++++++++++++++++++++-------\r
60  1 files changed, 35 insertions(+), 7 deletions(-)\r
61 \r
62 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
63 index a25ad99..3b35b81 100644\r
64 --- a/emacs/notmuch-show.el\r
65 +++ b/emacs/notmuch-show.el\r
66 @@ -780,8 +780,14 @@ current buffer, if possible."\r
67    "Insert the forest of threads FOREST."\r
68    (mapc '(lambda (thread) (notmuch-show-insert-thread thread 0)) forest))\r
69  \r
70 +(defvar notmuch-show-thread-id nil)\r
71 +(make-variable-buffer-local 'notmuch-show-thread-id)\r
72  (defvar notmuch-show-parent-buffer nil)\r
73  (make-variable-buffer-local 'notmuch-show-parent-buffer)\r
74 +(defvar notmuch-show-query-context nil)\r
75 +(make-variable-buffer-local 'notmuch-show-query-context)\r
76 +(defvar notmuch-show-buffer-name nil)\r
77 +(make-variable-buffer-local 'notmuch-show-buffer-name)\r
78  \r
79  ;;;###autoload\r
80  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
81 @@ -801,17 +807,23 @@ which the message thread is shown. If it is nil (which occurs\r
82  when the command is called interactively) the argument to the\r
83  function is used. "\r
84    (interactive "sNotmuch show: ")\r
85 -  (let ((buffer (get-buffer-create (generate-new-buffer-name\r
86 -                                   (or buffer-name\r
87 -                                       (concat "*notmuch-" thread-id "*")))))\r
88 -       (process-crypto (if crypto-switch\r
89 -                           (not notmuch-crypto-process-mime)\r
90 -                         notmuch-crypto-process-mime))\r
91 -       (inhibit-read-only t))\r
92 +  (let* ((buffer-name (generate-new-buffer-name\r
93 +                      (or buffer-name\r
94 +                          (concat "*notmuch-" thread-id "*"))))\r
95 +        (buffer (get-buffer-create buffer-name))\r
96 +        (process-crypto (if crypto-switch\r
97 +                            (not notmuch-crypto-process-mime)\r
98 +                          notmuch-crypto-process-mime))\r
99 +        (inhibit-read-only t))\r
100      (switch-to-buffer buffer)\r
101      (notmuch-show-mode)\r
102 +\r
103 +    (setq notmuch-show-thread-id thread-id)\r
104      (setq notmuch-show-parent-buffer parent-buffer)\r
105 +    (setq notmuch-show-query-context query-context)\r
106 +    (setq notmuch-show-buffer-name buffer-name)\r
107      (setq notmuch-show-process-crypto process-crypto)\r
108 +\r
109      (erase-buffer)\r
110      (goto-char (point-min))\r
111      (save-excursion\r
112 @@ -844,6 +856,21 @@ function is used. "\r
113  \r
114      (notmuch-show-mark-read)))\r
115  \r
116 +(defun notmuch-show-refresh-view (&optional crypto-switch)\r
117 +  "Refresh the current view (with crypto switch if prefix given).\r
118 +\r
119 +Kills the current buffer and reruns notmuch show with the same\r
120 +thread id.  If a prefix is given, the current thread is\r
121 +redisplayed with the crypto switch activated, which switch the\r
122 +logic of the notmuch-crypto-process-mime customization variable."\r
123 +  (interactive "P")\r
124 +  (let ((thread-id notmuch-show-thread-id)\r
125 +       (parent-buffer notmuch-show-parent-buffer)\r
126 +       (query-context notmuch-show-query-context)\r
127 +       (buffer-name notmuch-show-buffer-name))\r
128 +    (notmuch-kill-this-buffer)\r
129 +    (notmuch-show thread-id parent-buffer query-context buffer-name crypto-switch)))\r
130 +\r
131  (defvar notmuch-show-stash-map\r
132    (let ((map (make-sparse-keymap)))\r
133      (define-key map "c" 'notmuch-show-stash-cc)\r
134 @@ -875,6 +902,7 @@ function is used. "\r
135         (define-key map "V" 'notmuch-show-view-raw-message)\r
136         (define-key map "v" 'notmuch-show-view-all-mime-parts)\r
137         (define-key map "c" 'notmuch-show-stash-map)\r
138 +       (define-key map "=" 'notmuch-show-refresh-view)\r
139         (define-key map "h" 'notmuch-show-toggle-headers)\r
140         (define-key map "-" 'notmuch-show-remove-tag)\r
141         (define-key map "+" 'notmuch-show-add-tag)\r
142 -- \r
143 1.7.4.4\r
144 \r