Re: RFC: Annotate internal_error with the attribute noreturn 2nd patchset
[notmuch-archives.git] / f9 / 0ca91b24c334b0cc47e30e39f5192fb3aca024
1 Return-Path: <dme@dme.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 EF7184196F0\r
6         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:20:51 -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.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\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 n3q90oQcyyHY for <notmuch@notmuchmail.org>;\r
16         Tue, 27 Apr 2010 03:20:51 -0700 (PDT)\r
17 Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com\r
18  [74.125.82.53])        by olra.theworths.org (Postfix) with ESMTP id BEC78431FC1       for\r
19  <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:20:50 -0700 (PDT)\r
20 Received: by wwi18 with SMTP id 18so1081281wwi.26\r
21         for <notmuch@notmuchmail.org>; Tue, 27 Apr 2010 03:20:49 -0700 (PDT)\r
22 Received: by 10.216.172.71 with SMTP id s49mr2241631wel.195.1272363649413;\r
23         Tue, 27 Apr 2010 03:20:49 -0700 (PDT)\r
24 Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com\r
25         [83.217.165.81])\r
26         by mx.google.com with ESMTPS id v59sm994124wec.15.2010.04.27.03.20.47\r
27         (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
28         Tue, 27 Apr 2010 03:20:48 -0700 (PDT)\r
29 Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
30         id 1829359413B; Tue, 27 Apr 2010 11:21:02 +0100 (BST)\r
31 From: dme@dme.org\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH] emacs/notmuch-wash.el: Add\r
34         `notmuch-wash-convert-inline-patch-to-part'.\r
35 Date: Tue, 27 Apr 2010 11:20:58 +0100\r
36 Message-Id: <1272363658-24500-1-git-send-email-dme@dme.org>\r
37 X-Mailer: git-send-email 1.7.0\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: Tue, 27 Apr 2010 10:20:52 -0000\r
51 \r
52 From: David Edmondson <dme@dme.org>\r
53 \r
54 Detect inline patches and convert them to fake attachments, in order\r
55 that `diff-mode' highlighting can be applied to the patch. This can be\r
56 enabled by customising `notmuch-show-insert-text/plain-hook'.\r
57 ---\r
58  emacs/notmuch-show.el |    3 ++-\r
59  emacs/notmuch-wash.el |   38 ++++++++++++++++++++++++++++++++++++++\r
60  2 files changed, 40 insertions(+), 1 deletions(-)\r
61 \r
62 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
63 index eb5335f..4b1baf3 100644\r
64 --- a/emacs/notmuch-show.el\r
65 +++ b/emacs/notmuch-show.el\r
66 @@ -71,7 +71,8 @@ any given message."\r
67    "Functions used to improve the display of text/plain parts."\r
68    :group 'notmuch\r
69    :type 'hook\r
70 -  :options '(notmuch-wash-wrap-long-lines\r
71 +  :options '(notmuch-wash-convert-inline-patch-to-part\r
72 +            notmuch-wash-wrap-long-lines\r
73              notmuch-wash-tidy-citations\r
74              notmuch-wash-elide-blank-lines\r
75              notmuch-wash-excerpt-citations))\r
76 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
77 index 57f0cc5..bf0a354 100644\r
78 --- a/emacs/notmuch-wash.el\r
79 +++ b/emacs/notmuch-wash.el\r
80 @@ -23,6 +23,8 @@\r
81  \r
82  (require 'coolj)\r
83  \r
84 +(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part depth)\r
85 +\r
86  ;;\r
87  \r
88  (defvar notmuch-wash-signature-regexp\r
89 @@ -231,4 +233,40 @@ When doing so, maintaining citation leaders in the wrapped text."\r
90  \r
91  ;;\r
92  \r
93 +(require 'diff-mode)\r
94 +\r
95 +(defvar diff-file-header-re) ; From `diff-mode.el'.\r
96 +\r
97 +(defun notmuch-wash-convert-inline-patch-to-part (depth)\r
98 +  "Convert an inline patch into a fake 'text/x-diff' attachment.\r
99 +\r
100 +Given that this function guesses whether a buffer includes a\r
101 +patch and then guesses the extent of the patch, there is scope\r
102 +for error."\r
103 +\r
104 +  (goto-char (point-min))\r
105 +  (if (re-search-forward diff-file-header-re nil t)\r
106 +      (progn\r
107 +       (beginning-of-line -1)\r
108 +       (let ((patch-start (point))\r
109 +             (patch-end (point-max))\r
110 +             part)\r
111 +         (goto-char patch-start)\r
112 +         (if (or\r
113 +              ;; Patch ends with signature.\r
114 +              (re-search-forward notmuch-wash-signature-regexp nil t)\r
115 +              ;; Patch ends with bugtraq comment.\r
116 +              (re-search-forward "^\\*\\*\\* " nil t))\r
117 +             (setq patch-end (match-beginning 0)))\r
118 +         (save-restriction\r
119 +           (narrow-to-region patch-start patch-end)\r
120 +           (setq part (plist-put part :content-type "text/x-diff"))\r
121 +           (setq part (plist-put part :content (buffer-string)))\r
122 +           (setq part (plist-put part :id -1))\r
123 +           (setq part (plist-put part :filename "inline patch"))\r
124 +           (delete-region (point-min) (point-max))\r
125 +           (notmuch-show-insert-bodypart nil part depth))))))\r
126 +\r
127 +;;\r
128 +\r
129  (provide 'notmuch-wash)\r
130 -- \r
131 1.7.0\r
132 \r