[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-02-01 Thread Dmitry Kurochkin
On Wed, 01 Feb 2012 14:46:19 +0100, Pieter Praet  wrote:
> On Mon, 30 Jan 2012 09:23:40 +, David Edmondson  wrote:
> > On Sat, 28 Jan 2012 13:14:45 -0400, David Bremner  
> > wrote:
> > > On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula  
> > > wrote:
> > > > On Jan 28, 2012 2:41 PM, "David Bremner"  wrote:
> > > > 
> > > > Sometimes someone (Dmitry?) sent patches that separated a small 
> > > > functional
> > > > change, and the big non-functional indentation change it caused,
> > > > separately. Would you prefer (or tolerate ;) that style?
> > > 
> > > Hmm, that might be nicer, I'm not 100% sure.
> > > 
> > > I wouldn't say it's mandatory for a patch like this (and I'd say other
> > > peoples views on what's easy to review are at least as important as mine
> > > here).
> > 
> > Each patch should be valid in the repository without any following
> > patches (preceding are obviously okay). Incorrect indentation would
> > disqualify a patch from being 'valid', so it shouldn't be accepted.
> 
> +1.
> 
> Indentation corrections should always be part of the same patch as
> the change(s) that invalidated the indentation in the first place.
> 
> Spotting the *actual* (non-indentation) changes is a non-issue
> when using `diff-refine-hunk' (or a wrapper thereof [1]).
> 

Must... resist... getting... into... this...


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-02-01 Thread Pieter Praet
On Mon, 30 Jan 2012 23:34:12 -0400, David Bremner  wrote:
> On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  wrote:
> > Less code, same results, without sacrificing readability.
> > 
> > ---
> 
> Sorry, it conflicts with Jamie's patches that I just pushed.
> 

Please don't apologize for doing the right thing :)

Rebased patch follows.


> d


Peace

-- 
Pieter


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-02-01 Thread Pieter Praet
On Mon, 30 Jan 2012 09:59:32 +0200, Tomi Ollila  wrote:
> On Mon, 30 Jan 2012 08:03:59 +0100, Pieter Praet  wrote:
> > On Sat, 28 Jan 2012 08:41:36 -0400, David Bremner  
> > wrote:
> > > On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  
> > > wrote:
> > > > Less code, same results, without sacrificing readability.
> > > > 
> > > 
> > > This looks OK, although the re-indenting makes these kind of changes
> > > painful to review (not that I'm suggesting we should re-indent, just
> > > some random complaining).
> > > 
> > 
> > You can use `diff-refine-hunk' to see what the actual changes are.
> > 
> > Try this:
> > 
> >   #+begin_src emacs-lisp
> > (global-set-key (kbd "C-c /")
> > (lambda()
> >   "Refine display of unified diff hunks"
> >   (interactive)
> >   (save-excursion
> > (goto-char (point-min))
> > (while (re-search-forward
> > diff-hunk-header-re-unified
> > nil t)
> >   (diff-refine-hunk)
> >   #+end_src
> > 
> > Work pretty much *anywhere*.
> > 
> > Note: it does NOT work in `notmuch-show-mode' (not even with
> > `notmuch-wash-convert-inline-patch-to-part' disabled), but this is
> > easily solved by first running `notmuch-show-view-raw-message' ("V")
> > and `diff-mode' (to fontify the buffer)...
> 
> What we need is 'notmuch-devel' minor mode which can do this, dme's
> notmuch patching tool, nmbug tag changes and everything...
> 

Full ACK!


> > 
> > > d
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter
> 
> Tomi


Peace

-- 
Pieter


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-02-01 Thread Pieter Praet
On Mon, 30 Jan 2012 09:23:40 +, David Edmondson  wrote:
> On Sat, 28 Jan 2012 13:14:45 -0400, David Bremner  
> wrote:
> > On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula  wrote:
> > > On Jan 28, 2012 2:41 PM, "David Bremner"  wrote:
> > > 
> > > Sometimes someone (Dmitry?) sent patches that separated a small functional
> > > change, and the big non-functional indentation change it caused,
> > > separately. Would you prefer (or tolerate ;) that style?
> > 
> > Hmm, that might be nicer, I'm not 100% sure.
> > 
> > I wouldn't say it's mandatory for a patch like this (and I'd say other
> > peoples views on what's easy to review are at least as important as mine
> > here).
> 
> Each patch should be valid in the repository without any following
> patches (preceding are obviously okay). Incorrect indentation would
> disqualify a patch from being 'valid', so it shouldn't be accepted.

+1.

Indentation corrections should always be part of the same patch as
the change(s) that invalidated the indentation in the first place.

Spotting the *actual* (non-indentation) changes is a non-issue
when using `diff-refine-hunk' (or a wrapper thereof [1]).


> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

[1] id:"8739ax7jts.fsf at praet.org"


Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-02-01 Thread Pieter Praet
On Mon, 30 Jan 2012 09:23:40 +, David Edmondson d...@dme.org wrote:
 On Sat, 28 Jan 2012 13:14:45 -0400, David Bremner da...@tethera.net wrote:
  On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula j...@nikula.org wrote:
   On Jan 28, 2012 2:41 PM, David Bremner da...@tethera.net wrote:
   
   Sometimes someone (Dmitry?) sent patches that separated a small functional
   change, and the big non-functional indentation change it caused,
   separately. Would you prefer (or tolerate ;) that style?
  
  Hmm, that might be nicer, I'm not 100% sure.
  
  I wouldn't say it's mandatory for a patch like this (and I'd say other
  peoples views on what's easy to review are at least as important as mine
  here).
 
 Each patch should be valid in the repository without any following
 patches (preceding are obviously okay). Incorrect indentation would
 disqualify a patch from being 'valid', so it shouldn't be accepted.

+1.

Indentation corrections should always be part of the same patch as
the change(s) that invalidated the indentation in the first place.

Spotting the *actual* (non-indentation) changes is a non-issue
when using `diff-refine-hunk' (or a wrapper thereof [1]).


 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

[1] id:8739ax7jts@praet.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-02-01 Thread Pieter Praet
On Mon, 30 Jan 2012 23:34:12 -0400, David Bremner da...@tethera.net wrote:
 On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet pie...@praet.org wrote:
  Less code, same results, without sacrificing readability.
  
  ---
 
 Sorry, it conflicts with Jamie's patches that I just pushed.
 

Please don't apologize for doing the right thing :)

Rebased patch follows.


 d


Peace

-- 
Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-02-01 Thread Dmitry Kurochkin
On Wed, 01 Feb 2012 14:46:19 +0100, Pieter Praet pie...@praet.org wrote:
 On Mon, 30 Jan 2012 09:23:40 +, David Edmondson d...@dme.org wrote:
  On Sat, 28 Jan 2012 13:14:45 -0400, David Bremner da...@tethera.net wrote:
   On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula j...@nikula.org wrote:
On Jan 28, 2012 2:41 PM, David Bremner da...@tethera.net wrote:

Sometimes someone (Dmitry?) sent patches that separated a small 
functional
change, and the big non-functional indentation change it caused,
separately. Would you prefer (or tolerate ;) that style?
   
   Hmm, that might be nicer, I'm not 100% sure.
   
   I wouldn't say it's mandatory for a patch like this (and I'd say other
   peoples views on what's easy to review are at least as important as mine
   here).
  
  Each patch should be valid in the repository without any following
  patches (preceding are obviously okay). Incorrect indentation would
  disqualify a patch from being 'valid', so it shouldn't be accepted.
 
 +1.
 
 Indentation corrections should always be part of the same patch as
 the change(s) that invalidated the indentation in the first place.
 
 Spotting the *actual* (non-indentation) changes is a non-issue
 when using `diff-refine-hunk' (or a wrapper thereof [1]).
 

Must... resist... getting... into... this...
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-30 Thread David Bremner
On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.
> 
> ---

Sorry, it conflicts with Jamie's patches that I just pushed.

d


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-30 Thread Tomi Ollila
On Mon, 30 Jan 2012 08:03:59 +0100, Pieter Praet  wrote:
> On Sat, 28 Jan 2012 08:41:36 -0400, David Bremner  
> wrote:
> > On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  
> > wrote:
> > > Less code, same results, without sacrificing readability.
> > > 
> > 
> > This looks OK, although the re-indenting makes these kind of changes
> > painful to review (not that I'm suggesting we should re-indent, just
> > some random complaining).
> > 
> 
> You can use `diff-refine-hunk' to see what the actual changes are.
> 
> Try this:
> 
>   #+begin_src emacs-lisp
> (global-set-key (kbd "C-c /")
> (lambda()
>   "Refine display of unified diff hunks"
>   (interactive)
>   (save-excursion
> (goto-char (point-min))
> (while (re-search-forward
> diff-hunk-header-re-unified
> nil t)
>   (diff-refine-hunk)
>   #+end_src
> 
> Work pretty much *anywhere*.
> 
> Note: it does NOT work in `notmuch-show-mode' (not even with
> `notmuch-wash-convert-inline-patch-to-part' disabled), but this is
> easily solved by first running `notmuch-show-view-raw-message' ("V")
> and `diff-mode' (to fontify the buffer)...

What we need is 'notmuch-devel' minor mode which can do this, dme's
notmuch patching tool, nmbug tag changes and everything...

> 
> > d
> 
> 
> Peace
> 
> -- 
> Pieter

Tomi


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-30 Thread David Edmondson
On Sat, 28 Jan 2012 13:14:45 -0400, David Bremner  wrote:
> On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula  wrote:
> > On Jan 28, 2012 2:41 PM, "David Bremner"  wrote:
> > 
> > Sometimes someone (Dmitry?) sent patches that separated a small functional
> > change, and the big non-functional indentation change it caused,
> > separately. Would you prefer (or tolerate ;) that style?
> 
> Hmm, that might be nicer, I'm not 100% sure.
> 
> I wouldn't say it's mandatory for a patch like this (and I'd say other
> peoples views on what's easy to review are at least as important as mine
> here).

Each patch should be valid in the repository without any following
patches (preceding are obviously okay). Incorrect indentation would
disqualify a patch from being 'valid', so it shouldn't be accepted.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-30 Thread Pieter Praet
On Sat, 28 Jan 2012 08:41:36 -0400, David Bremner  wrote:
> On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  wrote:
> > Less code, same results, without sacrificing readability.
> > 
> 
> This looks OK, although the re-indenting makes these kind of changes
> painful to review (not that I'm suggesting we should re-indent, just
> some random complaining).
> 

You can use `diff-refine-hunk' to see what the actual changes are.

Try this:

  #+begin_src emacs-lisp
(global-set-key (kbd "C-c /")
(lambda()
  "Refine display of unified diff hunks"
  (interactive)
  (save-excursion
(goto-char (point-min))
(while (re-search-forward
diff-hunk-header-re-unified
nil t)
  (diff-refine-hunk)
  #+end_src

Work pretty much *anywhere*.

Note: it does NOT work in `notmuch-show-mode' (not even with
`notmuch-wash-convert-inline-patch-to-part' disabled), but this is
easily solved by first running `notmuch-show-view-raw-message' ("V")
and `diff-mode' (to fontify the buffer)...

> d
> 
> 


Peace

-- 
Pieter


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-28 Thread David Bremner
On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula  wrote:
> On Jan 28, 2012 2:41 PM, "David Bremner"  wrote:
> 
> Sometimes someone (Dmitry?) sent patches that separated a small functional
> change, and the big non-functional indentation change it caused,
> separately. Would you prefer (or tolerate ;) that style?

Hmm, that might be nicer, I'm not 100% sure.

I wouldn't say it's mandatory for a patch like this (and I'd say other
peoples views on what's easy to review are at least as important as mine
here).

d




[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-28 Thread David Bremner
On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet  wrote:
> Less code, same results, without sacrificing readability.
> 

This looks OK, although the re-indenting makes these kind of changes
painful to review (not that I'm suggesting we should re-indent, just
some random complaining).

d




Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-01-28 Thread David Bremner
On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet pie...@praet.org wrote:
 Less code, same results, without sacrificing readability.
 

This looks OK, although the re-indenting makes these kind of changes
painful to review (not that I'm suggesting we should re-indent, just
some random complaining).

d


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-01-28 Thread Jani Nikula
On Jan 28, 2012 2:41 PM, David Bremner da...@tethera.net wrote:

 On Sat, 14 Jan 2012 10:17:18 +0100, Pieter Praet pie...@praet.org wrote:
  Less code, same results, without sacrificing readability.
 

 This looks OK, although the re-indenting makes these kind of changes
 painful to review (not that I'm suggesting we should re-indent, just
 some random complaining).

Sometimes someone (Dmitry?) sent patches that separated a small functional
change, and the big non-functional indentation change it caused,
separately. Would you prefer (or tolerate ;) that style?


 d


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-01-28 Thread David Bremner
On Sat, 28 Jan 2012 14:55:22 +0200, Jani Nikula j...@nikula.org wrote:
 On Jan 28, 2012 2:41 PM, David Bremner da...@tethera.net wrote:
 
 Sometimes someone (Dmitry?) sent patches that separated a small functional
 change, and the big non-functional indentation change it caused,
 separately. Would you prefer (or tolerate ;) that style?

Hmm, that might be nicer, I'm not 100% sure.

I wouldn't say it's mandatory for a patch like this (and I'd say other
peoples views on what's easy to review are at least as important as mine
here).

d


___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..."

2012-01-14 Thread Pieter Praet
Less code, same results, without sacrificing readability.

---
 emacs/notmuch-show.el |   20 +---
 emacs/notmuch-wash.el |   47 +++
 emacs/notmuch.el  |   28 +---
 3 files changed, 45 insertions(+), 50 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 0cbf354..1e190ae 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1226,11 +1226,10 @@ any effects from previous calls to
   ;; If a small number of lines from the previous message are
   ;; visible, realign so that the top of the current message is at
   ;; the top of the screen.
-  (if (<= (count-screen-lines (window-start) start-of-message)
- next-screen-context-lines)
- (progn
-   (goto-char (notmuch-show-message-top))
-   (notmuch-show-message-adjust)))
+  (when (<= (count-screen-lines (window-start) start-of-message)
+   next-screen-context-lines)
+   (goto-char (notmuch-show-message-top))
+   (notmuch-show-message-adjust))
   ;; Move to the top left of the window.
   (goto-char (window-start)))
  (t
@@ -1423,12 +1422,11 @@ argument, hide all of the messages."
   ;; Move to the next item in the search results, if any.
   (let ((parent-buffer notmuch-show-parent-buffer))
 (notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+(when parent-buffer
+  (switch-to-buffer parent-buffer)
+  (forward-line)
+  (if show-next
+ (notmuch-search-show-thread)

 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 5c1e830..67143e5 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -336,30 +336,29 @@ patch and then guesses the extent of the patch, there is 
scope
 for error."

   (goto-char (point-min))
-  (if (re-search-forward diff-file-header-re nil t)
-  (progn
-   (beginning-of-line -1)
-   (let ((patch-start (point))
- (patch-end (point-max))
- part)
- (goto-char patch-start)
- (if (or
-  ;; Patch ends with signature.
-  (re-search-forward notmuch-wash-signature-regexp nil t)
-  ;; Patch ends with bugtraq comment.
-  (re-search-forward "^\\*\\*\\* " nil t))
- (setq patch-end (match-beginning 0)))
- (save-restriction
-   (narrow-to-region patch-start patch-end)
-   (setq part (plist-put part :content-type "inline-patch-fake-part"))
-   (setq part (plist-put part :content (buffer-string)))
-   (setq part (plist-put part :id -1))
-   (setq part (plist-put part :filename
- (notmuch-wash-subject-to-patch-filename
-  (plist-get
-   (plist-get msg :headers) :Subject
-   (delete-region (point-min) (point-max))
-   (notmuch-show-insert-bodypart nil part depth))
+  (when (re-search-forward diff-file-header-re nil t)
+(beginning-of-line -1)
+(let ((patch-start (point))
+ (patch-end (point-max))
+ part)
+  (goto-char patch-start)
+  (if (or
+  ;; Patch ends with signature.
+  (re-search-forward notmuch-wash-signature-regexp nil t)
+  ;; Patch ends with bugtraq comment.
+  (re-search-forward "^\\*\\*\\* " nil t))
+ (setq patch-end (match-beginning 0)))
+  (save-restriction
+   (narrow-to-region patch-start patch-end)
+   (setq part (plist-put part :content-type "inline-patch-fake-part"))
+   (setq part (plist-put part :content (buffer-string)))
+   (setq part (plist-put part :id -1))
+   (setq part (plist-put part :filename
+ (notmuch-wash-subject-to-patch-filename
+  (plist-get
+   (plist-get msg :headers) :Subject
+   (delete-region (point-min) (point-max))
+   (notmuch-show-insert-bodypart nil part depth)

 ;;

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ba84494..0d37a74 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -631,17 +631,16 @@ This function advances the next thread when finished."
  (goto-char (point-max))
  (if (eq status 'signal)
  (insert "Incomplete search results (search process was 
killed).\n"))
- (if (eq status 'exit)
- (progn
-   (if notmuch-search-process-filter-data
-   (insert (concat "Error: Unexpected output from 
notmuch search:\n" notmuch-search-process-filter-data)))
-   (insert 

[PATCH] emacs: globally replace non-branching (if COND (progn ... with (when ...

2012-01-14 Thread Pieter Praet
Less code, same results, without sacrificing readability.

---
 emacs/notmuch-show.el |   20 +---
 emacs/notmuch-wash.el |   47 +++
 emacs/notmuch.el  |   28 +---
 3 files changed, 45 insertions(+), 50 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 0cbf354..1e190ae 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1226,11 +1226,10 @@ any effects from previous calls to
   ;; If a small number of lines from the previous message are
   ;; visible, realign so that the top of the current message is at
   ;; the top of the screen.
-  (if (= (count-screen-lines (window-start) start-of-message)
- next-screen-context-lines)
- (progn
-   (goto-char (notmuch-show-message-top))
-   (notmuch-show-message-adjust)))
+  (when (= (count-screen-lines (window-start) start-of-message)
+   next-screen-context-lines)
+   (goto-char (notmuch-show-message-top))
+   (notmuch-show-message-adjust))
   ;; Move to the top left of the window.
   (goto-char (window-start)))
  (t
@@ -1423,12 +1422,11 @@ argument, hide all of the messages.
   ;; Move to the next item in the search results, if any.
   (let ((parent-buffer notmuch-show-parent-buffer))
 (notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+(when parent-buffer
+  (switch-to-buffer parent-buffer)
+  (forward-line)
+  (if show-next
+ (notmuch-search-show-thread)
 
 (defun notmuch-show-archive-thread ()
   Archive each message in thread, then show next thread from search.
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 5c1e830..67143e5 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -336,30 +336,29 @@ patch and then guesses the extent of the patch, there is 
scope
 for error.
 
   (goto-char (point-min))
-  (if (re-search-forward diff-file-header-re nil t)
-  (progn
-   (beginning-of-line -1)
-   (let ((patch-start (point))
- (patch-end (point-max))
- part)
- (goto-char patch-start)
- (if (or
-  ;; Patch ends with signature.
-  (re-search-forward notmuch-wash-signature-regexp nil t)
-  ;; Patch ends with bugtraq comment.
-  (re-search-forward ^\\*\\*\\*  nil t))
- (setq patch-end (match-beginning 0)))
- (save-restriction
-   (narrow-to-region patch-start patch-end)
-   (setq part (plist-put part :content-type inline-patch-fake-part))
-   (setq part (plist-put part :content (buffer-string)))
-   (setq part (plist-put part :id -1))
-   (setq part (plist-put part :filename
- (notmuch-wash-subject-to-patch-filename
-  (plist-get
-   (plist-get msg :headers) :Subject
-   (delete-region (point-min) (point-max))
-   (notmuch-show-insert-bodypart nil part depth))
+  (when (re-search-forward diff-file-header-re nil t)
+(beginning-of-line -1)
+(let ((patch-start (point))
+ (patch-end (point-max))
+ part)
+  (goto-char patch-start)
+  (if (or
+  ;; Patch ends with signature.
+  (re-search-forward notmuch-wash-signature-regexp nil t)
+  ;; Patch ends with bugtraq comment.
+  (re-search-forward ^\\*\\*\\*  nil t))
+ (setq patch-end (match-beginning 0)))
+  (save-restriction
+   (narrow-to-region patch-start patch-end)
+   (setq part (plist-put part :content-type inline-patch-fake-part))
+   (setq part (plist-put part :content (buffer-string)))
+   (setq part (plist-put part :id -1))
+   (setq part (plist-put part :filename
+ (notmuch-wash-subject-to-patch-filename
+  (plist-get
+   (plist-get msg :headers) :Subject
+   (delete-region (point-min) (point-max))
+   (notmuch-show-insert-bodypart nil part depth)
 
 ;;
 
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ba84494..0d37a74 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -631,17 +631,16 @@ This function advances the next thread when finished.
  (goto-char (point-max))
  (if (eq status 'signal)
  (insert Incomplete search results (search process was 
killed).\n))
- (if (eq status 'exit)
- (progn
-   (if notmuch-search-process-filter-data
-   (insert (concat Error: Unexpected output from 
notmuch search:\n notmuch-search-process-filter-data)))
-   (insert End of search