[PATCH] Ignore encrypted parts when indexing.

2011-12-27 Thread Austin Clements
Quoth Jameson Graef Rollins on Dec 27 at  9:11 am:
> It appears to be an oversight that encrypted parts were indexed
> previously.  The terms generated from encrypted parts are meaningless
> and do nothing but add bloat to the database.  It is not worth
> indexing the encrypted content, just as it's not worth indexing the
> signatures in signed parts.
> ---
>  lib/index.cc |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index e8e9922..0cff9cd 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -339,6 +339,10 @@ _index_mime_part (notmuch_message_t *message,
>   if (i > 1)
>   fprintf (stderr, "Warning: Unexpected extra parts of 
> multipart/signed. Indexing anyway.\n");
>   }
> + if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
> + /* Don't index encrypted parts. */
> + continue

Uh.  Semicolon?

> + }
>   _index_mime_part (message,
> g_mime_multipart_get_part (multipart, i));
>   }


[PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2011-12-27 Thread Austin Clements
LGTM.

Quoth David Edmondson on Dec 27 at  4:47 pm:
> The tags were coloured using text properties. Unfortunately that text
> (the header line) also has an overlay, which overrides the text
> properties. There's not point in applying text properties that will
> never be seen.
> ---
>  emacs/notmuch-show.el |8 ++--
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 8c9d846..24f0b40 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -221,10 +221,7 @@ indentation."
>  (goto-char (notmuch-show-message-top))
>  (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
>   (let ((inhibit-read-only t))
> -   (replace-match (concat "("
> -  (propertize (mapconcat 'identity tags " ")
> -  'face 'notmuch-tag-face)
> -  ")"))
> +   (replace-match (concat "(" (mapconcat 'identity tags " ") ")"))
>  
>  (defun notmuch-show-clean-address (address)
>"Try to clean a single email ADDRESS for display.  Return
> @@ -278,8 +275,7 @@ message at DEPTH in the current thread."
>   " ("
>   date
>   ") ("
> - (propertize (mapconcat 'identity tags " ")
> - 'face 'notmuch-tag-face)
> + (mapconcat 'identity tags " ")
>   ")\n")
>  (overlay-put (make-overlay start (point)) 'face 
> 'notmuch-message-summary-face)))
>  


[PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal.

2011-12-27 Thread Austin Clements
Quoth Daniel Kahn Gillmor on Dec 27 at  9:27 am:
> On 12/23/2011 10:45 PM, Austin Clements wrote:
> > Quoth Dmitry Kurochkin on Dec 10 at  3:25 am:
> >> +   /* For some reason the GMimeSignatureValidity returned
> >> +* here is not a const (inconsistent with that
> >> +* returned by
> >> +* g_mime_multipart_encrypted_get_signature_validity,
> >> +* and therefore needs to be properly disposed of.
> >> +* Hopefully the API will become more consistent. */
> >>
> >> Ouch.  In gmime 2.6 this API has changed, but looks like the
> >> issue is still there.  Is there a bug for it?  If yes, we should
> >> add a reference to the comment.  Otherwise, we should file the
> >> bug and then add a reference to the comment :)
> > 
> > It looks like they're both non-const in 2.6 (which makes more sense to
> > me).  I updated the comment to mention this.
> 
> Here's the bug report where this was discussed with upstream, fwiw:
> 
>   https://bugzilla.gnome.org/show_bug.cgi?id=640911

Oh, are we not supposed to be disposing of the GMimeSignatureValidity
returned by g_mime_multipart_encrypted_get_signature_validity
ourselves?  Comment 1 on that bug report suggests that we shouldn't.
The old show code did, so I ported that behavior over to the new code.


[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 17:13:23 +, David Edmondson  wrote:
> Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
> allows the header line in `notmuch-show-mode' buffers to be coloured
> according to the tags of the message.

Hi David, I've only given this a quick test drive, but so far it seems
to work as expected. I think this would be a useful feature to have.

The patch failed to apply cleanly without "emacs: Don't attempt to
colour tags in `notmuch-show-mode'." Is there a dependency, or was this
accidental?


BR,
Jani.


> ---
>  emacs/notmuch-lib.el  |   18 ++
>  emacs/notmuch-show.el |   32 
>  emacs/notmuch.el  |   17 ++---
>  3 files changed, 48 insertions(+), 19 deletions(-)
> 
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 0f856bf..1f00fe0 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new 
> value."
>(interactive)
>(kill-buffer (current-buffer)))
>  
> +(defun notmuch-color-line (start end line-tag-list spec)
> +  "Colorize a line based on tags."
> +  ;; Create the overlay only if the message has tags which match one
> +  ;; of those specified in `spec'.
> +  (let (overlay)
> +(mapc (lambda (elem)
> + (let ((tag (car elem))
> +   (attributes (cdr elem)))
> +   (when (member tag line-tag-list)
> + (when (not overlay)
> +   (setq overlay (make-overlay start end))
> +   (overlay-put overlay 'priority 5))
> + ;; Merge the specified properties with any already
> + ;; applied from an earlier match.
> + (overlay-put overlay 'face
> +  (append (overlay-get overlay 'face) attributes)
> +   spec)))
> +
>  ;;
>  
>  (defun notmuch-common-do-stash (text)
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 24f0b40..0885bd5 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -88,6 +88,23 @@ any given message."
>notmuch-wash-elide-blank-lines
>notmuch-wash-excerpt-citations))
>  
> +(defcustom notmuch-show-line-faces nil
> +  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.
> +
> +Here is an example of how to color search results based on tags.
> + (the following text would be placed in your ~/.emacs file):
> +
> + (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"
> +   :background \"blue\"))
> +   (\"unread\" . (:foreground \"green\"
> +
> +The attributes defined for matching tags are merged, with later
> +attributes overriding earlier. A message having both \"delete\"
> +and \"unread\" tags with the above settings would have a green
> +foreground and blue background."
> +  :type '(alist :key-type (string) :value-type (custom-face-edit))
> +  :group 'notmuch)
> +
>  ;; Mostly useful for debugging.
>  (defcustom notmuch-show-all-multipart/alternative-parts t
>"Should all parts of multipart/alternative parts be shown?"
> @@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails."
>  (defun notmuch-show-insert-headerline (headers date tags depth)
>"Insert a notmuch style headerline based on HEADERS for a
>  message at DEPTH in the current thread."
> -  (let ((start (point)))
> +  (let ((start (point))
> + overlay)
>  (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
>   (notmuch-show-clean-address (plist-get headers :From))
>   " ("
> @@ -277,7 +295,9 @@ message at DEPTH in the current thread."
>   ") ("
>   (mapconcat 'identity tags " ")
>   ")\n")
> -(overlay-put (make-overlay start (point)) 'face 
> 'notmuch-message-summary-face)))
> +(setq overlay (make-overlay start (point)))
> +(overlay-put overlay 'face 'notmuch-message-summary-face)
> +(overlay-put overlay 'priority 2)))
>  
>  (defun notmuch-show-insert-header (header header-value)
>"Insert a single header."
> @@ -712,7 +732,8 @@ current buffer, if possible."
>body-start body-end
>(headers-invis-spec (notmuch-show-make-symbol "header"))
>(message-invis-spec (notmuch-show-make-symbol "message"))
> -  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject
> +  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
> +  (tags (plist-get msg :tags)))
>  
>  ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
>  ;; removing items from `buffer-invisibility-spec' (which is what
> @@ -737,10 +758,13 @@ current buffer, if possible."
>   (plist-get msg :date_relative)
> nil)
>   (plist-get headers :Date))
> - (plist-get msg :tags) 

list of notmuch frontend

2011-12-27 Thread Xavier Maillard
On Tue, 27 Dec 2011 21:29:33 +0100, Antoine Amarilli  wrote:

> > Out of curiosity, how can people contribute to the "wiki" ? I do not see
> > any 'Edit this page' button.
> 
> It's a git repository which you can clone, edit and push back. See
>  (linked at the very bottom of
> ).

Good catch !

Thank you

/Xavier


list of notmuch frontend

2011-12-27 Thread Xavier Maillard
On Mon, 26 Dec 2011 22:12:52 +0100, Antoine Amarilli  wrote:
> On Sun, Dec 18, 2011 at 06:10:13PM +0200, Tomi Ollila wrote:
> > On Sun, 18 Dec 2011 15:34:23 +0100, Olivier Schwander  > chadok.info> wrote:
> > > Is there a somewhere a list of the various notmuch frontend ? It would
> > > be very valuable for people who are not completly happy with the main
> > > emacs frontend.
> > 
> > If not, Someone(TM) should create such a page in notmuch-wiki
> > (http://notmuchmail.org/)
> 
> I tried to be that someone. See . I did no
> effort to find more information or frontends, though.

Thank you Antoine.

Out of curiosity, how can people contribute to the "wiki" ? I do not see
any 'Edit this page' button.

Thanks

/Xavier


list of notmuch frontend

2011-12-27 Thread Antoine Amarilli
On Tue, Dec 27, 2011 at 09:43:50PM +0100, Xavier Maillard wrote:
> On Mon, 26 Dec 2011 22:12:52 +0100, Antoine Amarilli  wrote:
> > On Sun, Dec 18, 2011 at 06:10:13PM +0200, Tomi Ollila wrote:
> > > On Sun, 18 Dec 2011 15:34:23 +0100, Olivier Schwander  > > at chadok.info> wrote:
> > > > Is there a somewhere a list of the various notmuch frontend ? It would
> > > > be very valuable for people who are not completly happy with the main
> > > > emacs frontend.
> > > 
> > > If not, Someone(TM) should create such a page in notmuch-wiki
> > > (http://notmuchmail.org/)
> > 
> > I tried to be that someone. See <http://notmuchmail.org/frontends/>. I did 
> > no
> > effort to find more information or frontends, though.
> 
> Out of curiosity, how can people contribute to the "wiki" ? I do not see
> any 'Edit this page' button.

It's a git repository which you can clone, edit and push back. See
<http://notmuchmail.org/wikiwriteaccess/> (linked at the very bottom of
<http://notmuchmail.org/>).

-- 
Antoine

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111227/a2426e52/attachment.pgp>


[PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 10:50:44 +, David Edmondson  wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.

Hi David, thanks for submitting this. It works nicely, and IMHO it's
*much* more useful than notmuch-jump-to-recent-buffer.

I'm wondering whether message-mode should be included. I tried it, and
it's useful in my interrupted-more-often-than-I'd-like-to workflow...

BR,
Jani.



> ---
>  emacs/notmuch.el |   39 +++
>  1 files changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index c678c93..4844385 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -1056,20 +1056,35 @@ current search results AND that are tagged with the 
> given tag."
>(notmuch-hello))
>  
>  ;;;###autoload
> -(defun notmuch-jump-to-recent-buffer ()
> -  "Jump to the most recent notmuch buffer (search, show or hello).
> +(defun notmuch-cycle-notmuch-buffers ()
> +  "Cycle through any existing notmuch buffers (search, show or hello).
>  
> -If no recent buffer is found, run `notmuch'."
> +If the current buffer is the only notmuch buffer, bury it. If no
> +notmuch buffers exist, run `notmuch'."
>(interactive)
> -  (let ((last
> -  (loop for buffer in (buffer-list)
> -if (with-current-buffer buffer
> - (memq major-mode '(notmuch-show-mode
> -notmuch-search-mode
> -notmuch-hello-mode)))
> -return buffer)))
> -(if last
> - (switch-to-buffer last)
> +
> +  (let (start first)
> +;; If the current buffer is a notmuch buffer, remember it and then
> +;; bury it.
> +(when (memq major-mode '(notmuch-show-mode
> +  notmuch-search-mode
> +  notmuch-hello-mode))
> +  (setq start (current-buffer))
> +  (bury-buffer))
> +
> +;; Find the first notmuch buffer.
> +(setq first (loop for buffer in (buffer-list)
> +  if (with-current-buffer buffer
> +   (memq major-mode '(notmuch-show-mode
> +  notmuch-search-mode
> +  notmuch-hello-mode)))
> +  return buffer))
> +
> +(if first
> + ;; If the first one we found is any other than the starting
> + ;; buffer, switch to it.
> + (unless (eq first start)
> +   (switch-to-buffer first))
>(notmuch
>  
>  (setq mail-user-agent 'notmuch-user-agent)
> -- 
> 1.7.7.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 3/3] test: emacs: test notmuch-wash-subject-to-* functions

2011-12-27 Thread Jani Nikula
Signed-off-by: Jani Nikula 
---
 test/emacs-subject-to-filename |  138 
 test/notmuch-test  |1 +
 2 files changed, 139 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-subject-to-filename

diff --git a/test/emacs-subject-to-filename b/test/emacs-subject-to-filename
new file mode 100755
index 000..176e685
--- /dev/null
+++ b/test/emacs-subject-to-filename
@@ -0,0 +1,138 @@
+#!/usr/bin/env bash
+
+test_description="emacs: mail subject to filename"
+. test-lib.sh
+
+# emacs server can't be started in a child process with $(test_emacs ...)
+test_emacs '(ignore)'
+
+# test notmuch-wash-subject-to-patch-sequence-number (subject)
+test_begin_subtest "no patch sequence number"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[PATCH] A normal patch subject without numbers")'
+)
+test_expect_equal "$output" ""
+
+test_begin_subtest "patch sequence number #1"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[PATCH 2/3] A most regular patch subject")'
+)
+test_expect_equal "$output" 2
+
+test_begin_subtest "patch sequence number #2"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "  [dummy list prefix]  [RFC PATCH v2 13/42]  Special prefixes")'
+)
+test_expect_equal "$output" 13
+
+test_begin_subtest "patch sequence number #3"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[PATCH 2/3] [PATCH 032/037] use the last prefix")'
+)
+test_expect_equal "$output" 32
+
+test_begin_subtest "patch sequence number #4"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[dummy list prefix] [PATCH 2/3] PATCH 3/3] do not use a broken prefix")'
+)
+test_expect_equal "$output" 2
+
+test_begin_subtest "patch sequence number #5"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[RFC][PATCH 3/5][PATCH 4/5][PATCH 5/5] A made up test")'
+)
+test_expect_equal "$output" 5
+
+test_begin_subtest "patch sequence number #6"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[PATCH 2/3] this -> [PATCH 3/3] is not a prefix anymore [nor this 
4/4]")'
+)
+test_expect_equal "$output" 2
+
+test_begin_subtest "patch sequence number #7"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  "[liberally accept crapola right before123/456and after] the numbers")'
+)
+test_expect_equal "$output" 123
+
+# test notmuch-wash-subject-to-filename (subject  maxlen)
+test_begin_subtest "filename #1"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "just a subject line")'
+)
+test_expect_equal $output '"just-a-subject-line"'
+
+test_begin_subtest "filename #2"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  " [any]  [prefixes are ] [removed!] from the subject")'
+)
+test_expect_equal $output '"from-the-subject"'
+
+test_begin_subtest "filename #3"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "  leading and trailing space  ")'
+)
+test_expect_equal $output '"leading-and-trailing-space"'
+
+test_begin_subtest "filename #4"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "!#  leading ()// &%, and in between_and_trailing garbage ()(&%%")'
+)
+test_expect_equal $output '"-leading-and-in-between_and_trailing-garbage"'
+
+test_begin_subtest "filename #5"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890")'
+)
+test_expect_equal $output 
'"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890"'
+
+test_begin_subtest "filename #6"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "sequences of ... are squashed and trailing are removed ...")'
+)
+test_expect_equal $output 
'"sequences-of-.-are-squashed-and-trailing-are-removed"'
+
+test_begin_subtest "filename #7"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "max length test" 1)'
+)
+test_expect_equal $output '"m"'
+
+test_begin_subtest "filename #8"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "max length test /&(/%&/%%&?%?" 20)'
+)
+test_expect_equal $output '"max-length-test"'
+
+test_begin_subtest "filename #9"
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  "[a prefix] [is only separated] by [spaces], so \"by\" is not okay!")'
+)
+test_expect_equal $output '"by-spaces-so-by-is-not-okay"'
+
+# test notmuch-wash-subject-to-patch-filename (subject)
+test_begin_subtest "patch filename #1"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
+  "[RFC][PATCH 099/100] rewrite notmuch")'
+)
+test_expect_equal "$output" '"0099-rewrite-notmuch.patch"'
+
+test_begin_subtest "patch filename #2"
+output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
+  "[RFC PATCH v1] has no patch number, default to 1")'
+)
+test_expect_equal "$output" '"0001-has-no-patch-number-default-to-1.patch"'
+
+test_begin_subtest "patch 

[PATCH v3 2/3] emacs: create patch filename from subject for inline patch fake parts

2011-12-27 Thread Jani Nikula
Use the mail subject line for creating a descriptive filename for the wash
generated inline patch fake parts. The names are similar to the ones
created by 'git format-patch'.

If the user has notmuch-wash-convert-inline-patch-to-part hook enabled in
notmuch-show-insert-text/plain-hook, this will change the old default
filename of "inline patch" in fake parts:

[ inline patch: inline patch (as text/x-diff) ]

into, for example:

[ 0002-emacs-create-patch-filename-from-subject-for-inline.patch: inline patch 
(as text/x-diff) ]

which is typically the same filename the sender had if he was using 'git
format-patch' and 'git send-email'.

Signed-off-by: Jani Nikula 
---
 emacs/notmuch-wash.el |   43 ++-
 1 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index e9f2dba..5c1e830 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -290,6 +290,44 @@ When doing so, maintaining citation leaders in the wrapped 
text."

 (defvar diff-file-header-re) ; From `diff-mode.el'.

+(defun notmuch-wash-subject-to-filename (subject  maxlen)
+  "Convert a mail SUBJECT into a filename.
+
+The resulting filename is similar to the names generated by \"git
+format-patch\", without the leading patch sequence number
+\"0001-\" and \".patch\" extension. Any leading \"[PREFIX]\"
+style strings are removed prior to conversion.
+
+Optional argument MAXLEN is the maximum length of the resulting
+filename, before trimming any trailing . and - characters."
+  (let* ((s (replace-regexp-in-string "^ *\\(\\[[^]]*\\] *\\)*" "" subject))
+(s (replace-regexp-in-string "[^A-Za-z0-9._]+" "-" s))
+(s (replace-regexp-in-string "\\.+" "." s))
+(s (if maxlen (substring s 0 (min (length s) maxlen)) s))
+(s (replace-regexp-in-string "[.-]*$" "" s)))
+s))
+
+(defun notmuch-wash-subject-to-patch-sequence-number (subject)
+  "Convert a patch mail SUBJECT into a patch sequence number.
+
+Return the patch sequence number N from the last \"[PATCH N/M]\"
+style prefix in SUBJECT, or nil if such a prefix can't be found."
+  (when (string-match
+"^ *\\(\\[[^]]*\\] *\\)*\\[[^]]*?\\([0-9]+\\)/[0-9]+[^]]*\\].*"
+subject)
+  (string-to-number (substring subject (match-beginning 2) (match-end 
2)
+
+(defun notmuch-wash-subject-to-patch-filename (subject)
+  "Convert a patch mail SUBJECT into a filename.
+
+The resulting filename is similar to the names generated by \"git
+format-patch\". If the patch mail was generated and sent using
+\"git format-patch/send-email\", this should re-create the
+original filename the sender had."
+  (format "%04d-%s.patch"
+ (or (notmuch-wash-subject-to-patch-sequence-number subject) 1)
+ (notmuch-wash-subject-to-filename subject 52)))
+
 (defun notmuch-wash-convert-inline-patch-to-part (msg depth)
   "Convert an inline patch into a fake 'text/x-diff' attachment.

@@ -316,7 +354,10 @@ for error."
(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 "inline patch"))
+   (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))

-- 
1.7.5.4



[PATCH v3 1/3] emacs: add inline patch fake parts through a special handler

2011-12-27 Thread Jani Nikula
Add wash generated inline patch fake parts through a special
"inline-patch-fake-part" handler to distinguish them from real MIME
parts. The fake parts are described as "inline patch (as text/x-diff)".

Signed-off-by: Jani Nikula 
---
 emacs/notmuch-show.el |4 
 emacs/notmuch-wash.el |2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index eee4da9..6ef3f90 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -585,6 +585,10 @@ current buffer, if possible."
nil))
  nil

+;; Handler for wash generated inline patch fake parts.
+(defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type 
nth depth declared-type)
+  (notmuch-show-insert-part-*/* msg part "text/x-diff" nth depth "inline 
patch"))
+
 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth 
declared-type)
   ;; This handler _must_ succeed - it is the handler of last resort.
   (notmuch-show-insert-part-header nth content-type declared-type (plist-get 
part :filename))
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 1f420b2..e9f2dba 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -313,7 +313,7 @@ for error."
  (setq patch-end (match-beginning 0)))
  (save-restriction
(narrow-to-region patch-start patch-end)
-   (setq part (plist-put part :content-type "text/x-diff"))
+   (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 "inline patch"))
-- 
1.7.5.4



[PATCH v3 0/3] emacs: patch filename from subject

2011-12-27 Thread Jani Nikula
Hi all, v3 with the following changes:

* new patch 1/3 to add fake parts through a special handler to make them stand
  out from real MIME parts

* make notmuch-wash-subject-to-patch-filename more lispy as suggested by David
  in id:"cun62h3tu51.fsf at hotblack-desiato.hh.sledj.net"

BR,
Jani.

Jani Nikula (3):
  emacs: add inline patch fake parts through a special handler
  emacs: create patch filename from subject for inline patch fake parts
  test: emacs: test notmuch-wash-subject-to-* functions

 emacs/notmuch-show.el  |4 +
 emacs/notmuch-wash.el  |   45 -
 test/emacs-subject-to-filename |  138 
 test/notmuch-test  |1 +
 4 files changed, 186 insertions(+), 2 deletions(-)
 create mode 100755 test/emacs-subject-to-filename

-- 
1.7.5.4



[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread David Edmondson
Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
allows the header line in `notmuch-show-mode' buffers to be coloured
according to the tags of the message.
---
 emacs/notmuch-lib.el  |   18 ++
 emacs/notmuch-show.el |   32 
 emacs/notmuch.el  |   17 ++---
 3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..1f00fe0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new value."
   (interactive)
   (kill-buffer (current-buffer)))

+(defun notmuch-color-line (start end line-tag-list spec)
+  "Colorize a line based on tags."
+  ;; Create the overlay only if the message has tags which match one
+  ;; of those specified in `spec'.
+  (let (overlay)
+(mapc (lambda (elem)
+   (let ((tag (car elem))
+ (attributes (cdr elem)))
+ (when (member tag line-tag-list)
+   (when (not overlay)
+ (setq overlay (make-overlay start end))
+ (overlay-put overlay 'priority 5))
+   ;; Merge the specified properties with any already
+   ;; applied from an earlier match.
+   (overlay-put overlay 'face
+(append (overlay-get overlay 'face) attributes)
+ spec)))
+
 ;;

 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 24f0b40..0885bd5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -88,6 +88,23 @@ any given message."
 notmuch-wash-elide-blank-lines
 notmuch-wash-excerpt-citations))

+(defcustom notmuch-show-line-faces nil
+  "Tag to face mapping for header line highlighting in `notmuch-show-mode'.
+
+Here is an example of how to color search results based on tags.
+ (the following text would be placed in your ~/.emacs file):
+
+ (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"
+ :background \"blue\"))
+   (\"unread\" . (:foreground \"green\"
+
+The attributes defined for matching tags are merged, with later
+attributes overriding earlier. A message having both \"delete\"
+and \"unread\" tags with the above settings would have a green
+foreground and blue background."
+  :type '(alist :key-type (string) :value-type (custom-face-edit))
+  :group 'notmuch)
+
 ;; Mostly useful for debugging.
 (defcustom notmuch-show-all-multipart/alternative-parts t
   "Should all parts of multipart/alternative parts be shown?"
@@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails."
 (defun notmuch-show-insert-headerline (headers date tags depth)
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
-  (let ((start (point)))
+  (let ((start (point))
+   overlay)
 (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
(notmuch-show-clean-address (plist-get headers :From))
" ("
@@ -277,7 +295,9 @@ message at DEPTH in the current thread."
") ("
(mapconcat 'identity tags " ")
")\n")
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(setq overlay (make-overlay start (point)))
+(overlay-put overlay 'face 'notmuch-message-summary-face)
+(overlay-put overlay 'priority 2)))

 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -712,7 +732,8 @@ current buffer, if possible."
 body-start body-end
 (headers-invis-spec (notmuch-show-make-symbol "header"))
 (message-invis-spec (notmuch-show-make-symbol "message"))
-(bare-subject (notmuch-show-strip-re (plist-get headers :Subject
+(bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
+(tags (plist-get msg :tags)))

 ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
 ;; removing items from `buffer-invisibility-spec' (which is what
@@ -737,10 +758,13 @@ current buffer, if possible."
(plist-get msg :date_relative)
  nil)
(plist-get headers :Date))
-   (plist-get msg :tags) depth)
+   tags depth)

 (setq content-start (point-marker))

+;; Colour the header line according to the tags of the message.
+(notmuch-color-line message-start content-start tags 
notmuch-show-line-faces)
+
 (plist-put msg :headers-invis-spec headers-invis-spec)
 (plist-put msg :message-invis-spec message-invis-spec)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 4844385..56d35d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -641,7 +641,7 @@ This 

[PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2011-12-27 Thread David Edmondson
The tags were coloured using text properties. Unfortunately that text
(the header line) also has an overlay, which overrides the text
properties. There's not point in applying text properties that will
never be seen.
---
 emacs/notmuch-show.el |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8c9d846..24f0b40 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -221,10 +221,7 @@ indentation."
 (goto-char (notmuch-show-message-top))
 (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
(let ((inhibit-read-only t))
- (replace-match (concat "("
-(propertize (mapconcat 'identity tags " ")
-'face 'notmuch-tag-face)
-")"))
+ (replace-match (concat "(" (mapconcat 'identity tags " ") ")"))

 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -278,8 +275,7 @@ message at DEPTH in the current thread."
" ("
date
") ("
-   (propertize (mapconcat 'identity tags " ")
-   'face 'notmuch-tag-face)
+   (mapconcat 'identity tags " ")
")\n")
 (overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))

-- 
1.7.7.3



[PATCH] emacs: Enable more text/plain hook functions by default.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 12:00:25 +, David Edmondson  wrote:
> Users are missing out on various functions which usefully improve the
> display of text/plain message parts because they are not enabled by
> default. Enable a useful set.

While I didn't try the patch, I'm very much in favour of having these
enabled as sane defaults.

> `notmuch-wash-convert-inline-patch-to-part' is _not_ enabled by
> default as it is based on a heuristic.

Agreed. And even if it weren't a heuristic, it's a somewhat rare special
case for the average user.


BR,
Jani.


> ---
>  emacs/notmuch-show.el |5 -
>  1 files changed, 4 insertions(+), 1 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index afff6a5..8c9d846 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -75,7 +75,10 @@ any given message."
>:group 'notmuch
>:type 'hook)
>  
> -(defcustom notmuch-show-insert-text/plain-hook 
> '(notmuch-wash-excerpt-citations)
> +(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
> +  notmuch-wash-tidy-citations
> +  notmuch-wash-elide-blank-lines
> +  notmuch-wash-excerpt-citations)
>"Functions used to improve the display of text/plain parts."
>:group 'notmuch
>:type 'hook
> -- 
> 1.7.7.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: Enable more text/plain hook functions by default.

2011-12-27 Thread David Edmondson
Users are missing out on various functions which usefully improve the
display of text/plain message parts because they are not enabled by
default. Enable a useful set.

`notmuch-wash-convert-inline-patch-to-part' is _not_ enabled by
default as it is based on a heuristic.
---
 emacs/notmuch-show.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index afff6a5..8c9d846 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -75,7 +75,10 @@ any given message."
   :group 'notmuch
   :type 'hook)

-(defcustom notmuch-show-insert-text/plain-hook 
'(notmuch-wash-excerpt-citations)
+(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
+notmuch-wash-tidy-citations
+notmuch-wash-elide-blank-lines
+notmuch-wash-excerpt-citations)
   "Functions used to improve the display of text/plain parts."
   :group 'notmuch
   :type 'hook
-- 
1.7.7.3



[PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last.

2011-12-27 Thread David Edmondson
On Tue, 27 Dec 2011 10:50:44 +, David Edmondson  wrote:
> As suggested by j4ni in #notmuch, rename
> `notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
> have it behave accordingly.

This is the reason that I haven't mentioned
`notmuch-jump-to-recent-buffer' in the NEWS file - it should go away
soon after 0.11 ships.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111227/44287933/attachment.pgp>


[PATCH] emacs: Cycle through notmuch buffers rather than jumping to the last.

2011-12-27 Thread David Edmondson
As suggested by j4ni in #notmuch, rename
`notmuch-jump-to-recent-buffer' as `notmuch-cycle-notmuch-buffers' and
have it behave accordingly.
---
 emacs/notmuch.el |   39 +++
 1 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c678c93..4844385 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -1056,20 +1056,35 @@ current search results AND that are tagged with the 
given tag."
   (notmuch-hello))

 ;;;###autoload
-(defun notmuch-jump-to-recent-buffer ()
-  "Jump to the most recent notmuch buffer (search, show or hello).
+(defun notmuch-cycle-notmuch-buffers ()
+  "Cycle through any existing notmuch buffers (search, show or hello).

-If no recent buffer is found, run `notmuch'."
+If the current buffer is the only notmuch buffer, bury it. If no
+notmuch buffers exist, run `notmuch'."
   (interactive)
-  (let ((last
-(loop for buffer in (buffer-list)
-  if (with-current-buffer buffer
-   (memq major-mode '(notmuch-show-mode
-  notmuch-search-mode
-  notmuch-hello-mode)))
-  return buffer)))
-(if last
-   (switch-to-buffer last)
+
+  (let (start first)
+;; If the current buffer is a notmuch buffer, remember it and then
+;; bury it.
+(when (memq major-mode '(notmuch-show-mode
+notmuch-search-mode
+notmuch-hello-mode))
+  (setq start (current-buffer))
+  (bury-buffer))
+
+;; Find the first notmuch buffer.
+(setq first (loop for buffer in (buffer-list)
+if (with-current-buffer buffer
+ (memq major-mode '(notmuch-show-mode
+notmuch-search-mode
+notmuch-hello-mode)))
+return buffer))
+
+(if first
+   ;; If the first one we found is any other than the starting
+   ;; buffer, switch to it.
+   (unless (eq first start)
+ (switch-to-buffer first))
   (notmuch

 (setq mail-user-agent 'notmuch-user-agent)
-- 
1.7.7.3



[PATCH 3/3] test: Correct the expected output of the 'invalid From' test.

2011-12-27 Thread David Edmondson
---
 test/emacs |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/emacs b/test/emacs
index bb4a75f..0168f85 100755
--- a/test/emacs
+++ b/test/emacs
@@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads 
subject:message-with-invalid-from)
 test_emacs "(notmuch-show \"$thread\")
(test-output)"
 cat 

[PATCH 2/3] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2011-12-27 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---
 emacs/notmuch-show.el |   48 +++-
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9328650..afff6a5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -227,21 +227,43 @@ indentation."
   "Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails."
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string "\"" "" name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; "User " style.
+   ((string-match "\\(.*\\) <\\(.*\\)>" address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; "" style.
+   ((string-match "<\\(.*\\)>" address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (t
+   (setq p-address address)))
+  
+  ;; Remove outer double quotes. They might be required during
+  ;; transport, but we don't need to see them.
+  (when (and p-name
+(string-match "^\"\\(.*\\)\"$" p-name))
+(setq p-name (match-string 1 p-name)))
+
   ;; If the address is 'foo at bar.com ' then show just
   ;; 'foo at bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name " <" address ">")))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name " <" p-address ">")))
 (error address)))

 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3



[PATCH 1/3] test: Add tests for `notmuch-show-clean-address'.

2011-12-27 Thread David Edmondson
---

The address containing UTF-8 still fails. This looks like a failure to
properly round-trip UTF-8 in the test suite - the test passes if run
directly within emacs.

 test/emacs |   19 +++
 .../notmuch-address-simplification |9 +
 2 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-address-simplification

diff --git a/test/emacs b/test/emacs
index ca82445..bb4a75f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,23 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 2

+test_begin_subtest "notmuch-show address simplification"
+test_emacs '
+(with-temp-buffer
+  (let ((input (list
+"foo at bar.com"
+""
+"Foo Bar "
+"foo at bar.com "
+"?? "
+"foo (at home) "
+"foo [at home] "
+"\"Foo Bar\" "
+"Foo Bar"
+   )))
+(mapc (lambda (a) (insert (notmuch-show-clean-address a) "\n")) input))
+  (test-output))
+'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-address-simplification
+
 test_done
diff --git a/test/emacs.expected-output/notmuch-address-simplification 
b/test/emacs.expected-output/notmuch-address-simplification
new file mode 100644
index 000..0afe190
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-address-simplification
@@ -0,0 +1,9 @@
+foo at bar.com
+foo at bar.com
+Foo Bar 
+foo at bar.com
+?? 
+foo (at home) 
+foo [at home] 
+Foo Bar 
+Foo Bar
-- 
1.7.7.3



[PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal.

2011-12-27 Thread Daniel Kahn Gillmor
On 12/23/2011 10:45 PM, Austin Clements wrote:
> Quoth Dmitry Kurochkin on Dec 10 at  3:25 am:
>> +   /* For some reason the GMimeSignatureValidity returned
>> +* here is not a const (inconsistent with that
>> +* returned by
>> +* g_mime_multipart_encrypted_get_signature_validity,
>> +* and therefore needs to be properly disposed of.
>> +* Hopefully the API will become more consistent. */
>>
>> Ouch.  In gmime 2.6 this API has changed, but looks like the
>> issue is still there.  Is there a bug for it?  If yes, we should
>> add a reference to the comment.  Otherwise, we should file the
>> bug and then add a reference to the comment :)
> 
> It looks like they're both non-const in 2.6 (which makes more sense to
> me).  I updated the comment to mention this.

Here's the bug report where this was discussed with upstream, fwiw:

  https://bugzilla.gnome.org/show_bug.cgi?id=640911

--dkg

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1030 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111227/7ce64994/attachment.pgp>


S/MIME support in notmuch

2011-12-27 Thread Daniel Kahn Gillmor
On 12/23/2011 11:40 AM, Dan Bryant wrote:
> On Wed, 21 Dec 2011 06:51:01 -0500, Darren McGuicken  fernseed.info> wrote:
>> When you make those changes to the gpg_context are you breaking gpg
>> signature validation?  Or is the one a superset of the other?
> 
> The current assumption in notmuch is that all encrypted/signed messages
> in a mailbox will be using the same crypto algorithm. This is the first
> thing I want to fix: which crypto algorithm (and therefore, context
> object) to use should probably be detected by the MIME type of the
> message part.

This was an issue i was hoping would get resolved in gmime 2.6, but
apparently it's still open:

  https://bugzilla.gnome.org/show_bug.cgi?id=641848

So it does look like we're going to need to do the detection and
selecion ourselves.

--dkg

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1030 bytes
Desc: OpenPGP digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111227/05654dd7/attachment.pgp>


[PATCH] Ignore encrypted parts when indexing.

2011-12-27 Thread Jameson Graef Rollins
It appears to be an oversight that encrypted parts were indexed
previously.  The terms generated from encrypted parts are meaningless
and do nothing but add bloat to the database.  It is not worth
indexing the encrypted content, just as it's not worth indexing the
signatures in signed parts.
---
 lib/index.cc |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index e8e9922..0cff9cd 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -339,6 +339,10 @@ _index_mime_part (notmuch_message_t *message,
if (i > 1)
fprintf (stderr, "Warning: Unexpected extra parts of 
multipart/signed. Indexing anyway.\n");
}
+   if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
+   /* Don't index encrypted parts. */
+   continue
+   }
_index_mime_part (message,
  g_mime_multipart_get_part (multipart, i));
}
-- 
1.7.7.3



[RFC][PATCH v4] emacs: Re-implement advance/rewind functions of notmuch-show-mode.

2011-12-27 Thread David Edmondson
On Mon, 26 Dec 2011 14:24:11 -0800, Jameson Graef Rollins  wrote:
> On Mon, 26 Dec 2011 22:00:21 +, David Edmondson  wrote:
> > Understood. For me this fell inside the 'trivial other change' boundary.
> 
> Fwiw, I don't remember there ever being such a distinction.  I think
> we've always insisted that unrelated changes should be excluded.

I didn't mean to claim that the project had such a rule, just that I did.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111227/cf1debcf/attachment.pgp>


Re: [PATCH] emacs: Enable more text/plain hook functions by default.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 12:00:25 +, David Edmondson d...@dme.org wrote:
 Users are missing out on various functions which usefully improve the
 display of text/plain message parts because they are not enabled by
 default. Enable a useful set.

While I didn't try the patch, I'm very much in favour of having these
enabled as sane defaults.

 `notmuch-wash-convert-inline-patch-to-part' is _not_ enabled by
 default as it is based on a heuristic.

Agreed. And even if it weren't a heuristic, it's a somewhat rare special
case for the average user.


BR,
Jani.


 ---
  emacs/notmuch-show.el |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index afff6a5..8c9d846 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -75,7 +75,10 @@ any given message.
:group 'notmuch
:type 'hook)
  
 -(defcustom notmuch-show-insert-text/plain-hook 
 '(notmuch-wash-excerpt-citations)
 +(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
 +  notmuch-wash-tidy-citations
 +  notmuch-wash-elide-blank-lines
 +  notmuch-wash-excerpt-citations)
Functions used to improve the display of text/plain parts.
:group 'notmuch
:type 'hook
 -- 
 1.7.7.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 0/3] emacs: patch filename from subject

2011-12-27 Thread Jani Nikula
Hi all, v3 with the following changes:

* new patch 1/3 to add fake parts through a special handler to make them stand
  out from real MIME parts

* make notmuch-wash-subject-to-patch-filename more lispy as suggested by David
  in id:cun62h3tu51@hotblack-desiato.hh.sledj.net

BR,
Jani.

Jani Nikula (3):
  emacs: add inline patch fake parts through a special handler
  emacs: create patch filename from subject for inline patch fake parts
  test: emacs: test notmuch-wash-subject-to-* functions

 emacs/notmuch-show.el  |4 +
 emacs/notmuch-wash.el  |   45 -
 test/emacs-subject-to-filename |  138 
 test/notmuch-test  |1 +
 4 files changed, 186 insertions(+), 2 deletions(-)
 create mode 100755 test/emacs-subject-to-filename

-- 
1.7.5.4

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


[PATCH v3 3/3] test: emacs: test notmuch-wash-subject-to-* functions

2011-12-27 Thread Jani Nikula
Signed-off-by: Jani Nikula j...@nikula.org
---
 test/emacs-subject-to-filename |  138 
 test/notmuch-test  |1 +
 2 files changed, 139 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-subject-to-filename

diff --git a/test/emacs-subject-to-filename b/test/emacs-subject-to-filename
new file mode 100755
index 000..176e685
--- /dev/null
+++ b/test/emacs-subject-to-filename
@@ -0,0 +1,138 @@
+#!/usr/bin/env bash
+
+test_description=emacs: mail subject to filename
+. test-lib.sh
+
+# emacs server can't be started in a child process with $(test_emacs ...)
+test_emacs '(ignore)'
+
+# test notmuch-wash-subject-to-patch-sequence-number (subject)
+test_begin_subtest no patch sequence number
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [PATCH] A normal patch subject without numbers)'
+)
+test_expect_equal $output 
+
+test_begin_subtest patch sequence number #1
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [PATCH 2/3] A most regular patch subject)'
+)
+test_expect_equal $output 2
+
+test_begin_subtest patch sequence number #2
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+[dummy list prefix]  [RFC PATCH v2 13/42]  Special prefixes)'
+)
+test_expect_equal $output 13
+
+test_begin_subtest patch sequence number #3
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [PATCH 2/3] [PATCH 032/037] use the last prefix)'
+)
+test_expect_equal $output 32
+
+test_begin_subtest patch sequence number #4
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [dummy list prefix] [PATCH 2/3] PATCH 3/3] do not use a broken prefix)'
+)
+test_expect_equal $output 2
+
+test_begin_subtest patch sequence number #5
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [RFC][PATCH 3/5][PATCH 4/5][PATCH 5/5] A made up test)'
+)
+test_expect_equal $output 5
+
+test_begin_subtest patch sequence number #6
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [PATCH 2/3] this - [PATCH 3/3] is not a prefix anymore [nor this 
4/4])'
+)
+test_expect_equal $output 2
+
+test_begin_subtest patch sequence number #7
+output=$(test_emacs '(notmuch-wash-subject-to-patch-sequence-number
+  [liberally accept crapola right before123/456and after] the numbers)'
+)
+test_expect_equal $output 123
+
+# test notmuch-wash-subject-to-filename (subject optional maxlen)
+test_begin_subtest filename #1
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  just a subject line)'
+)
+test_expect_equal $output 'just-a-subject-line'
+
+test_begin_subtest filename #2
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+   [any]  [prefixes are ] [removed!] from the subject)'
+)
+test_expect_equal $output 'from-the-subject'
+
+test_begin_subtest filename #3
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+leading and trailing space  )'
+)
+test_expect_equal $output 'leading-and-trailing-space'
+
+test_begin_subtest filename #4
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  !#  leading ()// %, and in between_and_trailing garbage ()(%%)'
+)
+test_expect_equal $output '-leading-and-in-between_and_trailing-garbage'
+
+test_begin_subtest filename #5
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890)'
+)
+test_expect_equal $output 
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_01234567890'
+
+test_begin_subtest filename #6
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  sequences of ... are squashed and trailing are removed ...)'
+)
+test_expect_equal $output 
'sequences-of-.-are-squashed-and-trailing-are-removed'
+
+test_begin_subtest filename #7
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  max length test 1)'
+)
+test_expect_equal $output 'm'
+
+test_begin_subtest filename #8
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  max length test /(/%/%%¤%¤ 20)'
+)
+test_expect_equal $output 'max-length-test'
+
+test_begin_subtest filename #9
+output=$(test_emacs '(notmuch-wash-subject-to-filename
+  [a prefix] [is only separated] by [spaces], so \by\ is not okay!)'
+)
+test_expect_equal $output 'by-spaces-so-by-is-not-okay'
+
+# test notmuch-wash-subject-to-patch-filename (subject)
+test_begin_subtest patch filename #1
+output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
+  [RFC][PATCH 099/100] rewrite notmuch)'
+)
+test_expect_equal $output '0099-rewrite-notmuch.patch'
+
+test_begin_subtest patch filename #2
+output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
+  [RFC PATCH v1] has no patch number, default to 1)'
+)
+test_expect_equal $output '0001-has-no-patch-number-default-to-1.patch'
+
+test_begin_subtest patch filename #3
+output=$(test_emacs '(notmuch-wash-subject-to-patch-filename
+  [PATCH 4/5] the maximum 

[PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2011-12-27 Thread David Edmondson
The tags were coloured using text properties. Unfortunately that text
(the header line) also has an overlay, which overrides the text
properties. There's not point in applying text properties that will
never be seen.
---
 emacs/notmuch-show.el |8 ++--
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8c9d846..24f0b40 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -221,10 +221,7 @@ indentation.
 (goto-char (notmuch-show-message-top))
 (if (re-search-forward (\\([^()]*\\))$ (line-end-position) t)
(let ((inhibit-read-only t))
- (replace-match (concat (
-(propertize (mapconcat 'identity tags  )
-'face 'notmuch-tag-face)
-)))
+ (replace-match (concat ( (mapconcat 'identity tags  ) )))
 
 (defun notmuch-show-clean-address (address)
   Try to clean a single email ADDRESS for display.  Return
@@ -278,8 +275,7 @@ message at DEPTH in the current thread.
 (
date
) (
-   (propertize (mapconcat 'identity tags  )
-   'face 'notmuch-tag-face)
+   (mapconcat 'identity tags  )
)\n)
 (overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
 
-- 
1.7.7.3

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


[PATCH v3 2/3] emacs: create patch filename from subject for inline patch fake parts

2011-12-27 Thread Jani Nikula
Use the mail subject line for creating a descriptive filename for the wash
generated inline patch fake parts. The names are similar to the ones
created by 'git format-patch'.

If the user has notmuch-wash-convert-inline-patch-to-part hook enabled in
notmuch-show-insert-text/plain-hook, this will change the old default
filename of inline patch in fake parts:

[ inline patch: inline patch (as text/x-diff) ]

into, for example:

[ 0002-emacs-create-patch-filename-from-subject-for-inline.patch: inline patch 
(as text/x-diff) ]

which is typically the same filename the sender had if he was using 'git
format-patch' and 'git send-email'.

Signed-off-by: Jani Nikula j...@nikula.org
---
 emacs/notmuch-wash.el |   43 ++-
 1 files changed, 42 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index e9f2dba..5c1e830 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -290,6 +290,44 @@ When doing so, maintaining citation leaders in the wrapped 
text.
 
 (defvar diff-file-header-re) ; From `diff-mode.el'.
 
+(defun notmuch-wash-subject-to-filename (subject optional maxlen)
+  Convert a mail SUBJECT into a filename.
+
+The resulting filename is similar to the names generated by \git
+format-patch\, without the leading patch sequence number
+\0001-\ and \.patch\ extension. Any leading \[PREFIX]\
+style strings are removed prior to conversion.
+
+Optional argument MAXLEN is the maximum length of the resulting
+filename, before trimming any trailing . and - characters.
+  (let* ((s (replace-regexp-in-string ^ *\\(\\[[^]]*\\] *\\)*  subject))
+(s (replace-regexp-in-string [^A-Za-z0-9._]+ - s))
+(s (replace-regexp-in-string \\.+ . s))
+(s (if maxlen (substring s 0 (min (length s) maxlen)) s))
+(s (replace-regexp-in-string [.-]*$  s)))
+s))
+
+(defun notmuch-wash-subject-to-patch-sequence-number (subject)
+  Convert a patch mail SUBJECT into a patch sequence number.
+
+Return the patch sequence number N from the last \[PATCH N/M]\
+style prefix in SUBJECT, or nil if such a prefix can't be found.
+  (when (string-match
+^ *\\(\\[[^]]*\\] *\\)*\\[[^]]*?\\([0-9]+\\)/[0-9]+[^]]*\\].*
+subject)
+  (string-to-number (substring subject (match-beginning 2) (match-end 
2)
+
+(defun notmuch-wash-subject-to-patch-filename (subject)
+  Convert a patch mail SUBJECT into a filename.
+
+The resulting filename is similar to the names generated by \git
+format-patch\. If the patch mail was generated and sent using
+\git format-patch/send-email\, this should re-create the
+original filename the sender had.
+  (format %04d-%s.patch
+ (or (notmuch-wash-subject-to-patch-sequence-number subject) 1)
+ (notmuch-wash-subject-to-filename subject 52)))
+
 (defun notmuch-wash-convert-inline-patch-to-part (msg depth)
   Convert an inline patch into a fake 'text/x-diff' attachment.
 
@@ -316,7 +354,10 @@ for error.
(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 inline patch))
+   (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))
 
-- 
1.7.5.4

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


[PATCH] emacs: Enable more text/plain hook functions by default.

2011-12-27 Thread David Edmondson
Users are missing out on various functions which usefully improve the
display of text/plain message parts because they are not enabled by
default. Enable a useful set.

`notmuch-wash-convert-inline-patch-to-part' is _not_ enabled by
default as it is based on a heuristic.
---
 emacs/notmuch-show.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index afff6a5..8c9d846 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -75,7 +75,10 @@ any given message.
   :group 'notmuch
   :type 'hook)
 
-(defcustom notmuch-show-insert-text/plain-hook 
'(notmuch-wash-excerpt-citations)
+(defcustom notmuch-show-insert-text/plain-hook '(notmuch-wash-wrap-long-lines
+notmuch-wash-tidy-citations
+notmuch-wash-elide-blank-lines
+notmuch-wash-excerpt-citations)
   Functions used to improve the display of text/plain parts.
   :group 'notmuch
   :type 'hook
-- 
1.7.7.3

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


[PATCH 2/3] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2011-12-27 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---
 emacs/notmuch-show.el |   48 +++-
 1 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9328650..afff6a5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -227,21 +227,43 @@ indentation.
   Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails.
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string \  name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; User u...@dom.ain style.
+   ((string-match \\(.*\\) \\(.*\\) address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; u...@dom.ain style.
+   ((string-match \\(.*\\) address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (t
+   (setq p-address address)))
+  
+  ;; Remove outer double quotes. They might be required during
+  ;; transport, but we don't need to see them.
+  (when (and p-name
+(string-match ^\\\(.*\\)\$ p-name))
+(setq p-name (match-string 1 p-name)))
+
   ;; If the address is 'f...@bar.com f...@bar.com' then show just
   ;; 'f...@bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name   address )))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name   p-address )))
 (error address)))
 
 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3

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


Re: S/MIME support in notmuch

2011-12-27 Thread Daniel Kahn Gillmor
On 12/23/2011 11:40 AM, Dan Bryant wrote:
 On Wed, 21 Dec 2011 06:51:01 -0500, Darren McGuicken 
 mailing-notm...@fernseed.info wrote:
 When you make those changes to the gpg_context are you breaking gpg
 signature validation?  Or is the one a superset of the other?
 
 The current assumption in notmuch is that all encrypted/signed messages
 in a mailbox will be using the same crypto algorithm. This is the first
 thing I want to fix: which crypto algorithm (and therefore, context
 object) to use should probably be detected by the MIME type of the
 message part.

This was an issue i was hoping would get resolved in gmime 2.6, but
apparently it's still open:

  https://bugzilla.gnome.org/show_bug.cgi?id=641848

So it does look like we're going to need to do the detection and
selecion ourselves.

--dkg



signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/3] test: Add tests for `notmuch-show-clean-address'.

2011-12-27 Thread David Edmondson
---

The address containing UTF-8 still fails. This looks like a failure to
properly round-trip UTF-8 in the test suite - the test passes if run
directly within emacs.

 test/emacs |   19 +++
 .../notmuch-address-simplification |9 +
 2 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-address-simplification

diff --git a/test/emacs b/test/emacs
index ca82445..bb4a75f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,23 @@ counter=$(test_emacs \
 )
 test_expect_equal $counter 2
 
+test_begin_subtest notmuch-show address simplification
+test_emacs '
+(with-temp-buffer
+  (let ((input (list
+f...@bar.com
+f...@bar.com
+Foo Bar f...@bar.com
+f...@bar.com f...@bar.com
+ДБ db-uk...@stop.me.uk
+foo (at home) f...@bar.com
+foo [at home] f...@bar.com
+\Foo Bar\ f...@bar.com
+Foo Bar
+   )))
+(mapc (lambda (a) (insert (notmuch-show-clean-address a) \n)) input))
+  (test-output))
+'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-address-simplification
+
 test_done
diff --git a/test/emacs.expected-output/notmuch-address-simplification 
b/test/emacs.expected-output/notmuch-address-simplification
new file mode 100644
index 000..0afe190
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-address-simplification
@@ -0,0 +1,9 @@
+f...@bar.com
+f...@bar.com
+Foo Bar f...@bar.com
+f...@bar.com
+ДБ db-uk...@stop.me.uk
+foo (at home) f...@bar.com
+foo [at home] f...@bar.com
+Foo Bar f...@bar.com
+Foo Bar
-- 
1.7.7.3

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


Re: [PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal.

2011-12-27 Thread Daniel Kahn Gillmor
On 12/23/2011 10:45 PM, Austin Clements wrote:
 Quoth Dmitry Kurochkin on Dec 10 at  3:25 am:
 +   /* For some reason the GMimeSignatureValidity returned
 +* here is not a const (inconsistent with that
 +* returned by
 +* g_mime_multipart_encrypted_get_signature_validity,
 +* and therefore needs to be properly disposed of.
 +* Hopefully the API will become more consistent. */

 Ouch.  In gmime 2.6 this API has changed, but looks like the
 issue is still there.  Is there a bug for it?  If yes, we should
 add a reference to the comment.  Otherwise, we should file the
 bug and then add a reference to the comment :)
 
 It looks like they're both non-const in 2.6 (which makes more sense to
 me).  I updated the comment to mention this.

Here's the bug report where this was discussed with upstream, fwiw:

  https://bugzilla.gnome.org/show_bug.cgi?id=640911

--dkg



signature.asc
Description: OpenPGP digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 1/3] emacs: add inline patch fake parts through a special handler

2011-12-27 Thread Jani Nikula
Add wash generated inline patch fake parts through a special
inline-patch-fake-part handler to distinguish them from real MIME
parts. The fake parts are described as inline patch (as text/x-diff).

Signed-off-by: Jani Nikula j...@nikula.org
---
 emacs/notmuch-show.el |4 
 emacs/notmuch-wash.el |2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index eee4da9..6ef3f90 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -585,6 +585,10 @@ current buffer, if possible.
nil))
  nil
 
+;; Handler for wash generated inline patch fake parts.
+(defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type 
nth depth declared-type)
+  (notmuch-show-insert-part-*/* msg part text/x-diff nth depth inline 
patch))
+
 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth 
declared-type)
   ;; This handler _must_ succeed - it is the handler of last resort.
   (notmuch-show-insert-part-header nth content-type declared-type (plist-get 
part :filename))
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 1f420b2..e9f2dba 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -313,7 +313,7 @@ for error.
  (setq patch-end (match-beginning 0)))
  (save-restriction
(narrow-to-region patch-start patch-end)
-   (setq part (plist-put part :content-type text/x-diff))
+   (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 inline patch))
-- 
1.7.5.4

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


[PATCH] Ignore encrypted parts when indexing.

2011-12-27 Thread Jameson Graef Rollins
It appears to be an oversight that encrypted parts were indexed
previously.  The terms generated from encrypted parts are meaningless
and do nothing but add bloat to the database.  It is not worth
indexing the encrypted content, just as it's not worth indexing the
signatures in signed parts.
---
 lib/index.cc |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index e8e9922..0cff9cd 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -339,6 +339,10 @@ _index_mime_part (notmuch_message_t *message,
if (i  1)
fprintf (stderr, Warning: Unexpected extra parts of 
multipart/signed. Indexing anyway.\n);
}
+   if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
+   /* Don't index encrypted parts. */
+   continue
+   }
_index_mime_part (message,
  g_mime_multipart_get_part (multipart, i));
}
-- 
1.7.7.3

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


[PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread David Edmondson
Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
allows the header line in `notmuch-show-mode' buffers to be coloured
according to the tags of the message.
---
 emacs/notmuch-lib.el  |   18 ++
 emacs/notmuch-show.el |   32 
 emacs/notmuch.el  |   17 ++---
 3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0f856bf..1f00fe0 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new value.
   (interactive)
   (kill-buffer (current-buffer)))
 
+(defun notmuch-color-line (start end line-tag-list spec)
+  Colorize a line based on tags.
+  ;; Create the overlay only if the message has tags which match one
+  ;; of those specified in `spec'.
+  (let (overlay)
+(mapc (lambda (elem)
+   (let ((tag (car elem))
+ (attributes (cdr elem)))
+ (when (member tag line-tag-list)
+   (when (not overlay)
+ (setq overlay (make-overlay start end))
+ (overlay-put overlay 'priority 5))
+   ;; Merge the specified properties with any already
+   ;; applied from an earlier match.
+   (overlay-put overlay 'face
+(append (overlay-get overlay 'face) attributes)
+ spec)))
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 24f0b40..0885bd5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -88,6 +88,23 @@ any given message.
 notmuch-wash-elide-blank-lines
 notmuch-wash-excerpt-citations))
 
+(defcustom notmuch-show-line-faces nil
+  Tag to face mapping for header line highlighting in `notmuch-show-mode'.
+
+Here is an example of how to color search results based on tags.
+ (the following text would be placed in your ~/.emacs file):
+
+ (setq notmuch-search-line-faces '((\delete\ . (:foreground \red\
+ :background \blue\))
+   (\unread\ . (:foreground \green\
+
+The attributes defined for matching tags are merged, with later
+attributes overriding earlier. A message having both \delete\
+and \unread\ tags with the above settings would have a green
+foreground and blue background.
+  :type '(alist :key-type (string) :value-type (custom-face-edit))
+  :group 'notmuch)
+
 ;; Mostly useful for debugging.
 (defcustom notmuch-show-all-multipart/alternative-parts t
   Should all parts of multipart/alternative parts be shown?
@@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails.
 (defun notmuch-show-insert-headerline (headers date tags depth)
   Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread.
-  (let ((start (point)))
+  (let ((start (point))
+   overlay)
 (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
(notmuch-show-clean-address (plist-get headers :From))
 (
@@ -277,7 +295,9 @@ message at DEPTH in the current thread.
) (
(mapconcat 'identity tags  )
)\n)
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(setq overlay (make-overlay start (point)))
+(overlay-put overlay 'face 'notmuch-message-summary-face)
+(overlay-put overlay 'priority 2)))
 
 (defun notmuch-show-insert-header (header header-value)
   Insert a single header.
@@ -712,7 +732,8 @@ current buffer, if possible.
 body-start body-end
 (headers-invis-spec (notmuch-show-make-symbol header))
 (message-invis-spec (notmuch-show-make-symbol message))
-(bare-subject (notmuch-show-strip-re (plist-get headers :Subject
+(bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
+(tags (plist-get msg :tags)))
 
 ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
 ;; removing items from `buffer-invisibility-spec' (which is what
@@ -737,10 +758,13 @@ current buffer, if possible.
(plist-get msg :date_relative)
  nil)
(plist-get headers :Date))
-   (plist-get msg :tags) depth)
+   tags depth)
 
 (setq content-start (point-marker))
 
+;; Colour the header line according to the tags of the message.
+(notmuch-color-line message-start content-start tags 
notmuch-show-line-faces)
+
 (plist-put msg :headers-invis-spec headers-invis-spec)
 (plist-put msg :message-invis-spec message-invis-spec)
 
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 4844385..56d35d0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -641,7 +641,7 @@ This function advances the next thread 

Re: [PATCH] emacs: Add `notmuch-show-line-faces' and apply it.

2011-12-27 Thread Jani Nikula
On Tue, 27 Dec 2011 17:13:23 +, David Edmondson d...@dme.org wrote:
 Similar to `notmuch-search-line-faces', `notmuch-show-line-faces'
 allows the header line in `notmuch-show-mode' buffers to be coloured
 according to the tags of the message.

Hi David, I've only given this a quick test drive, but so far it seems
to work as expected. I think this would be a useful feature to have.

The patch failed to apply cleanly without emacs: Don't attempt to
colour tags in `notmuch-show-mode'. Is there a dependency, or was this
accidental?


BR,
Jani.


 ---
  emacs/notmuch-lib.el  |   18 ++
  emacs/notmuch-show.el |   32 
  emacs/notmuch.el  |   17 ++---
  3 files changed, 48 insertions(+), 19 deletions(-)
 
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index 0f856bf..1f00fe0 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -96,6 +96,24 @@ the user hasn't set this variable with the old or new 
 value.
(interactive)
(kill-buffer (current-buffer)))
  
 +(defun notmuch-color-line (start end line-tag-list spec)
 +  Colorize a line based on tags.
 +  ;; Create the overlay only if the message has tags which match one
 +  ;; of those specified in `spec'.
 +  (let (overlay)
 +(mapc (lambda (elem)
 + (let ((tag (car elem))
 +   (attributes (cdr elem)))
 +   (when (member tag line-tag-list)
 + (when (not overlay)
 +   (setq overlay (make-overlay start end))
 +   (overlay-put overlay 'priority 5))
 + ;; Merge the specified properties with any already
 + ;; applied from an earlier match.
 + (overlay-put overlay 'face
 +  (append (overlay-get overlay 'face) attributes)
 +   spec)))
 +
  ;;
  
  (defun notmuch-common-do-stash (text)
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 24f0b40..0885bd5 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -88,6 +88,23 @@ any given message.
notmuch-wash-elide-blank-lines
notmuch-wash-excerpt-citations))
  
 +(defcustom notmuch-show-line-faces nil
 +  Tag to face mapping for header line highlighting in `notmuch-show-mode'.
 +
 +Here is an example of how to color search results based on tags.
 + (the following text would be placed in your ~/.emacs file):
 +
 + (setq notmuch-search-line-faces '((\delete\ . (:foreground \red\
 +   :background \blue\))
 +   (\unread\ . (:foreground \green\
 +
 +The attributes defined for matching tags are merged, with later
 +attributes overriding earlier. A message having both \delete\
 +and \unread\ tags with the above settings would have a green
 +foreground and blue background.
 +  :type '(alist :key-type (string) :value-type (custom-face-edit))
 +  :group 'notmuch)
 +
  ;; Mostly useful for debugging.
  (defcustom notmuch-show-all-multipart/alternative-parts t
Should all parts of multipart/alternative parts be shown?
 @@ -269,7 +286,8 @@ unchanged ADDRESS if parsing fails.
  (defun notmuch-show-insert-headerline (headers date tags depth)
Insert a notmuch style headerline based on HEADERS for a
  message at DEPTH in the current thread.
 -  (let ((start (point)))
 +  (let ((start (point))
 + overlay)
  (insert (notmuch-show-spaces-n (* notmuch-indent-messages-width depth))
   (notmuch-show-clean-address (plist-get headers :From))
(
 @@ -277,7 +295,9 @@ message at DEPTH in the current thread.
   ) (
   (mapconcat 'identity tags  )
   )\n)
 -(overlay-put (make-overlay start (point)) 'face 
 'notmuch-message-summary-face)))
 +(setq overlay (make-overlay start (point)))
 +(overlay-put overlay 'face 'notmuch-message-summary-face)
 +(overlay-put overlay 'priority 2)))
  
  (defun notmuch-show-insert-header (header header-value)
Insert a single header.
 @@ -712,7 +732,8 @@ current buffer, if possible.
body-start body-end
(headers-invis-spec (notmuch-show-make-symbol header))
(message-invis-spec (notmuch-show-make-symbol message))
 -  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject
 +  (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))
 +  (tags (plist-get msg :tags)))
  
  ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
  ;; removing items from `buffer-invisibility-spec' (which is what
 @@ -737,10 +758,13 @@ current buffer, if possible.
   (plist-get msg :date_relative)
 nil)
   (plist-get headers :Date))
 - (plist-get msg :tags) depth)
 + tags depth)
  
  (setq content-start (point-marker))
  
 +;; Colour the header line 

Re: list of notmuch frontend

2011-12-27 Thread Xavier Maillard
On Mon, 26 Dec 2011 22:12:52 +0100, Antoine Amarilli a...@a3nm.net wrote:
 On Sun, Dec 18, 2011 at 06:10:13PM +0200, Tomi Ollila wrote:
  On Sun, 18 Dec 2011 15:34:23 +0100, Olivier Schwander 
  olivier.schwan...@chadok.info wrote:
   Is there a somewhere a list of the various notmuch frontend ? It would
   be very valuable for people who are not completly happy with the main
   emacs frontend.
  
  If not, Someone(TM) should create such a page in notmuch-wiki
  (http://notmuchmail.org/)
 
 I tried to be that someone. See http://notmuchmail.org/frontends/. I did no
 effort to find more information or frontends, though.

Thank you Antoine.

Out of curiosity, how can people contribute to the wiki ? I do not see
any 'Edit this page' button.

Thanks

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


Re: list of notmuch frontend

2011-12-27 Thread Antoine Amarilli
On Tue, Dec 27, 2011 at 09:43:50PM +0100, Xavier Maillard wrote:
 On Mon, 26 Dec 2011 22:12:52 +0100, Antoine Amarilli a...@a3nm.net wrote:
  On Sun, Dec 18, 2011 at 06:10:13PM +0200, Tomi Ollila wrote:
   On Sun, 18 Dec 2011 15:34:23 +0100, Olivier Schwander 
   olivier.schwan...@chadok.info wrote:
Is there a somewhere a list of the various notmuch frontend ? It would
be very valuable for people who are not completly happy with the main
emacs frontend.
   
   If not, Someone(TM) should create such a page in notmuch-wiki
   (http://notmuchmail.org/)
  
  I tried to be that someone. See http://notmuchmail.org/frontends/. I did 
  no
  effort to find more information or frontends, though.
 
 Out of curiosity, how can people contribute to the wiki ? I do not see
 any 'Edit this page' button.

It's a git repository which you can clone, edit and push back. See
http://notmuchmail.org/wikiwriteaccess/ (linked at the very bottom of
http://notmuchmail.org/).

-- 
Antoine



signature.asc
Description: Digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/4] Introduce a generic tree-like abstraction for MIME traversal.

2011-12-27 Thread Austin Clements
Quoth Daniel Kahn Gillmor on Dec 27 at  9:27 am:
 On 12/23/2011 10:45 PM, Austin Clements wrote:
  Quoth Dmitry Kurochkin on Dec 10 at  3:25 am:
  +   /* For some reason the GMimeSignatureValidity returned
  +* here is not a const (inconsistent with that
  +* returned by
  +* g_mime_multipart_encrypted_get_signature_validity,
  +* and therefore needs to be properly disposed of.
  +* Hopefully the API will become more consistent. */
 
  Ouch.  In gmime 2.6 this API has changed, but looks like the
  issue is still there.  Is there a bug for it?  If yes, we should
  add a reference to the comment.  Otherwise, we should file the
  bug and then add a reference to the comment :)
  
  It looks like they're both non-const in 2.6 (which makes more sense to
  me).  I updated the comment to mention this.
 
 Here's the bug report where this was discussed with upstream, fwiw:
 
   https://bugzilla.gnome.org/show_bug.cgi?id=640911

Oh, are we not supposed to be disposing of the GMimeSignatureValidity
returned by g_mime_multipart_encrypted_get_signature_validity
ourselves?  Comment 1 on that bug report suggests that we shouldn't.
The old show code did, so I ported that behavior over to the new code.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Don't attempt to colour tags in `notmuch-show-mode'.

2011-12-27 Thread Austin Clements
LGTM.

Quoth David Edmondson on Dec 27 at  4:47 pm:
 The tags were coloured using text properties. Unfortunately that text
 (the header line) also has an overlay, which overrides the text
 properties. There's not point in applying text properties that will
 never be seen.
 ---
  emacs/notmuch-show.el |8 ++--
  1 files changed, 2 insertions(+), 6 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 8c9d846..24f0b40 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -221,10 +221,7 @@ indentation.
  (goto-char (notmuch-show-message-top))
  (if (re-search-forward (\\([^()]*\\))$ (line-end-position) t)
   (let ((inhibit-read-only t))
 -   (replace-match (concat (
 -  (propertize (mapconcat 'identity tags  )
 -  'face 'notmuch-tag-face)
 -  )))
 +   (replace-match (concat ( (mapconcat 'identity tags  ) )))
  
  (defun notmuch-show-clean-address (address)
Try to clean a single email ADDRESS for display.  Return
 @@ -278,8 +275,7 @@ message at DEPTH in the current thread.
(
   date
   ) (
 - (propertize (mapconcat 'identity tags  )
 - 'face 'notmuch-tag-face)
 + (mapconcat 'identity tags  )
   )\n)
  (overlay-put (make-overlay start (point)) 'face 
 'notmuch-message-summary-face)))
  
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Ignore encrypted parts when indexing.

2011-12-27 Thread Austin Clements
Quoth Jameson Graef Rollins on Dec 27 at  9:11 am:
 It appears to be an oversight that encrypted parts were indexed
 previously.  The terms generated from encrypted parts are meaningless
 and do nothing but add bloat to the database.  It is not worth
 indexing the encrypted content, just as it's not worth indexing the
 signatures in signed parts.
 ---
  lib/index.cc |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/lib/index.cc b/lib/index.cc
 index e8e9922..0cff9cd 100644
 --- a/lib/index.cc
 +++ b/lib/index.cc
 @@ -339,6 +339,10 @@ _index_mime_part (notmuch_message_t *message,
   if (i  1)
   fprintf (stderr, Warning: Unexpected extra parts of 
 multipart/signed. Indexing anyway.\n);
   }
 + if (GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
 + /* Don't index encrypted parts. */
 + continue

Uh.  Semicolon?

 + }
   _index_mime_part (message,
 g_mime_multipart_get_part (multipart, i));
   }
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch