[PATCH] test: Produce useful output when the HTML with images test fails

2012-11-20 Thread Austin Clements
Previously, this would simply indicate that the grep failed without
any indication of the Emacs output it failed on.  Now we take
advantage of the test framework's handling of stdout to display the
incorrect Emacs output if the test fails.
---

Besides being a good idea in general, this is the first step toward
fixing this test on the Notmuch buildbot, since right now there's no
indication of why it's failing.

 test/emacs |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/emacs b/test/emacs
index 77265b0..5649d55 100755
--- a/test/emacs
+++ b/test/emacs
@@ -809,9 +809,10 @@ test_emacs "(let ((mm-text-html-renderer
  (notmuch-show \"id:${gen_msg_id}\"))
(test-output)" > /dev/null
 # Different Emacs versions and renderers give very different results,
-# so just check that something reasonable showed up.
+# so just check that something reasonable showed up.  We first cat the
+# output so the test framework will print it if the test fails.
 test_expect_success "Rendering HTML mail with images" \
-'grep -q smiley OUTPUT'
+'cat OUTPUT && grep -q smiley OUTPUT'


 test_done
-- 
1.7.10.4



[PATCH] test: Produce useful output when the HTML with images test fails

2012-11-20 Thread Austin Clements
Previously, this would simply indicate that the grep failed without
any indication of the Emacs output it failed on.  Now we take
advantage of the test framework's handling of stdout to display the
incorrect Emacs output if the test fails.
---

Besides being a good idea in general, this is the first step toward
fixing this test on the Notmuch buildbot, since right now there's no
indication of why it's failing.

 test/emacs |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/emacs b/test/emacs
index 77265b0..5649d55 100755
--- a/test/emacs
+++ b/test/emacs
@@ -809,9 +809,10 @@ test_emacs "(let ((mm-text-html-renderer
  (notmuch-show \"id:${gen_msg_id}\"))
(test-output)" > /dev/null
 # Different Emacs versions and renderers give very different results,
-# so just check that something reasonable showed up.
+# so just check that something reasonable showed up.  We first cat the
+# output so the test framework will print it if the test fails.
 test_expect_success "Rendering HTML mail with images" \
-'grep -q smiley OUTPUT'
+'cat OUTPUT && grep -q smiley OUTPUT'
 
 
 test_done
-- 
1.7.10.4

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


[PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable

2012-11-20 Thread Austin Clements
Quoth Damien Cassou on Nov 18 at  8:18 pm:
> Signed-off-by: Damien Cassou 
> ---
>  emacs/notmuch-show.el   |9 +
>  emacs/notmuch-tagger.el |   33 +
>  2 files changed, 38 insertions(+), 4 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 988e27c..379c8cd 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -431,10 +431,11 @@ message at DEPTH in the current thread."
>   (notmuch-show-clean-address (plist-get headers :From))
>   " ("
>   date
> - ") ("
> - (propertize (mapconcat 'identity tags " ")
> - 'face 'notmuch-tag-face)
> - ")\n")
> + ") "
> + (propertize
> +  (format-mode-line (notmuch-tagger-present-tags tags))
> +  'face 'notmuch-tag-face)
> + "\n")
>  (overlay-put (make-overlay start (point)) 'face 
> 'notmuch-message-summary-face)))
>  
>  (defun notmuch-show-insert-header (header header-value)
> diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
> index 19a6c7e..379a905 100644
> --- a/emacs/notmuch-tagger.el
> +++ b/emacs/notmuch-tagger.el
> @@ -53,12 +53,21 @@ test if the library is present before calling this 
> function."
>(let ((tag (header-button-get button 'notmuch-tagger-tag)))
>  (notmuch-tagger-goto-target tag)))
>  
> +(defun notmuch-tagger-body-button-action (button)
> +  "Open `notmuch-search' for the tag referenced by BUTTON."
> +  (let ((tag (button-get button 'notmuch-tagger-tag)))
> +(notmuch-tagger-goto-target tag)))
> +
>  (eval-after-load "header-button"
>'(define-button-type 'notmuch-tagger-header-button-type
>   'supertype 'header
>   'action#'notmuch-tagger-header-button-action
>   'follow-link t))
>  
> +(define-button-type 'notmuch-tagger-body-button-type
> +  'action#'notmuch-tagger-body-button-action
> +  'follow-link t)
> +
>  (defun notmuch-tagger-really-make-header-link (tag)
> "Return a property list that presents a link to TAG.
>  
> @@ -82,6 +91,19 @@ if not."
>(notmuch-tagger-really-make-header-link tag)
>  tag))
>  
> +(defun notmuch-tagger-make-body-link (tag)
> +  "Return a property list that presents a link to TAG.
> +The returned property list will work everywhere except in the
> +header-line. For a link that works on the header-line, prefer
> +`notmuch-tagger-make-header-link'."
> +  (let ((button (copy-sequence tag)))
> +(make-text-button
> + button nil
> + 'type 'notmuch-tagger-body-button-type
> + 'notmuch-tagger-tag tag
> + 'help-echo (format "%s: Search other messages like this" tag))
> +button))
> +
>  (defun notmuch-tagger-present-tags-header-line (tags)
>"Return a property list to present TAGS in emacs header-line."
>(list
> @@ -91,6 +113,17 @@ if not."
>  " ")
> ")"))
>  
> +(defun notmuch-tagger-present-tags (tags)

notmuch-tagger-format-tags?

> +  "Return a property list to present TAGS in emacs.

Same comment about the comment as in patch 1.

Though is this really the right interface?  Is it useful to return a
mode-line-format template from this, given that it can't be used in
the mode-line or header-line since the buttons won't work?  Should
this just return a string that can be inserted into a buffer?
Something like (untested),

(defun notmuch-tagger-format-tags (tags)
  "Format TAGS as a string suitable for insertion in a buffer."
  (concat "(" (mapconcat #'notmuch-tagger-make-body-link tags " ") ")"))

> +If tags the result of this function is to be used within the
> +header-line, prefer `notmuch-tagger-present-tags-header-line'
> +instead of this function."
> +  (list
> +   "("
> +   (notmuch-tagger-separate-elems
> +(mapcar #'notmuch-tagger-make-body-link tags)
> +" ")
> +   ")"))
>  
>  (provide 'notmuch-tagger)
>  ;;; notmuch-tagger.el ends here


[PATCH 1/4] Add a thread's tags to emacs header-line

2012-11-20 Thread Austin Clements
Sorry, I was a little trigger-happy on the send.  A few more comments
below.

Quoth myself on Nov 20 at 12:13 am:
> Quoth Damien Cassou on Nov 18 at  8:18 pm:
> > Signed-off-by: Damien Cassou 
> > ---
> >  emacs/notmuch-show.el   |   24 +---
> >  emacs/notmuch-tagger.el |   44 
> >  2 files changed, 65 insertions(+), 3 deletions(-)
> >  create mode 100644 emacs/notmuch-tagger.el
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 5b3e70e..988e27c 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -36,6 +36,7 @@
> >  (require 'notmuch-mua)
> >  (require 'notmuch-crypto)
> >  (require 'notmuch-print)
> > +(require 'notmuch-tagger)
> >  
> >  (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
> >  (declare-function notmuch-fontify-headers "notmuch" nil)
> > @@ -1121,11 +1122,28 @@ function is used."
> >  
> >(jit-lock-register #'notmuch-show-buttonise-links)
> >  
> > -  ;; Set the header line to the subject of the first message.
> > -  (setq header-line-format (notmuch-show-strip-re 
> > (notmuch-show-get-subject)))
> > -
> > +  (notmuch-show-update-header-line)
> >(run-hooks 'notmuch-show-hook
> >  
> > +(defun notmuch-show-thread-tags ()
> > +  "Return the list of tags for the current thread."
> > +  (let ((tags (list)))
> > +(notmuch-show-mapc (lambda ()
> > +(mapcar (lambda (elt)
> > +  ;; Avoid adding duplicate tags
> > +  (add-to-list 'tags elt))
> > +(notmuch-show-get-tags
> > +tags))
> > +
> > +(defun notmuch-show-update-header-line ()
> > +  "Make the header-line show the thread's subject and tags."
> > +  (let ((thread-subject (notmuch-show-strip-re 
> > (notmuch-show-get-subject
> > +(setq header-line-format
> > + (list
> > +  thread-subject
> > +  " "
> > +  (notmuch-tagger-present-tags-header-line 
> > (notmuch-show-thread-tags))
> > +
> >  (defun notmuch-show-capture-state ()
> >"Capture the state of the current buffer.
> >  
> > diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
> > new file mode 100644
> > index 000..5ca190e
> > --- /dev/null
> > +++ b/emacs/notmuch-tagger.el
> > @@ -0,0 +1,44 @@
> > +;; notmuch-tagger.el --- Library to improve the way tags are displayed
> > +;;
> > +;; Copyright ? Damien Cassou
> > +;;
> > +;; This file is part of Notmuch.
> > +;;
> > +;; Notmuch is free software: you can redistribute it and/or modify it
> > +;; under the terms of the GNU General Public License as published by
> > +;; the Free Software Foundation, either version 3 of the License, or
> > +;; (at your option) any later version.
> > +;;
> > +;; Notmuch is distributed in the hope that it will be useful, but
> > +;; WITHOUT ANY WARRANTY; without even the implied warranty of
> > +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > +;; General Public License for more details.
> > +;;
> > +;; You should have received a copy of the GNU General Public License
> > +;; along with Notmuch.  If not, see .
> > +;;
> > +;; Authors: Damien Cassou 
> > +;;; Commentary:
> > +;;
> > +;;; Code:
> > +;;
> > +(defun notmuch-tagger-separate-elems (list sep)
> 
> notmuch-tagger-intersperse?
> 
> This could also reasonably go in notmuch-lib.el as a general utility.
> 
> (How do neither Elisp nor 'cl have an intersperse?)
> 
> > +  "Return a list with all elements of LIST separated by SEP."
> > +  (let ((first t)
> > +(res nil))
> > +(dolist (elt (reverse list) res)
> 
> (dolist (elt list (nreverse res)) ...) to save a list copy?
> 
> > +  (unless first
> > +(push sep res))
> > +  (setq first nil)
> > +  (push elt res
> > +
> > +(defun notmuch-tagger-present-tags-header-line (tags)

notmuch-tagger-format-tags-header-line?  It doesn't actually present
them (though "format" isn't great either.)

> > +  "Return a property list to present TAGS in emacs header-line."

This doesn't return a property list, it returns a mode-line-format
template.  Maybe something like,

  "Format TAGS as a mode-line-format template.
The result is suitable for inclusion in `header-line-format' or
`mode-line-format'."

(Is it actually suitable for mode-line-format or do header-line
buttons really only work in the header line?)

> > +  (list
> > +   "("
> > +   (notmuch-tagger-separate-elems tags " ")
> > +   ")"))
> > +
> > +
> > +(provide 'notmuch-tagger)
> > +;;; notmuch-tagger.el ends here


[PATCH 1/4] Add a thread's tags to emacs header-line

2012-11-20 Thread Austin Clements
Quoth Damien Cassou on Nov 18 at  8:18 pm:
> Signed-off-by: Damien Cassou 
> ---
>  emacs/notmuch-show.el   |   24 +---
>  emacs/notmuch-tagger.el |   44 
>  2 files changed, 65 insertions(+), 3 deletions(-)
>  create mode 100644 emacs/notmuch-tagger.el
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5b3e70e..988e27c 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -36,6 +36,7 @@
>  (require 'notmuch-mua)
>  (require 'notmuch-crypto)
>  (require 'notmuch-print)
> +(require 'notmuch-tagger)
>  
>  (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
>  (declare-function notmuch-fontify-headers "notmuch" nil)
> @@ -1121,11 +1122,28 @@ function is used."
>  
>(jit-lock-register #'notmuch-show-buttonise-links)
>  
> -  ;; Set the header line to the subject of the first message.
> -  (setq header-line-format (notmuch-show-strip-re 
> (notmuch-show-get-subject)))
> -
> +  (notmuch-show-update-header-line)
>(run-hooks 'notmuch-show-hook
>  
> +(defun notmuch-show-thread-tags ()
> +  "Return the list of tags for the current thread."
> +  (let ((tags (list)))
> +(notmuch-show-mapc (lambda ()
> +  (mapcar (lambda (elt)
> +;; Avoid adding duplicate tags
> +(add-to-list 'tags elt))
> +  (notmuch-show-get-tags
> +tags))
> +
> +(defun notmuch-show-update-header-line ()
> +  "Make the header-line show the thread's subject and tags."
> +  (let ((thread-subject (notmuch-show-strip-re (notmuch-show-get-subject
> +(setq header-line-format
> +   (list
> +thread-subject
> +" "
> +(notmuch-tagger-present-tags-header-line 
> (notmuch-show-thread-tags))
> +
>  (defun notmuch-show-capture-state ()
>"Capture the state of the current buffer.
>  
> diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
> new file mode 100644
> index 000..5ca190e
> --- /dev/null
> +++ b/emacs/notmuch-tagger.el
> @@ -0,0 +1,44 @@
> +;; notmuch-tagger.el --- Library to improve the way tags are displayed
> +;;
> +;; Copyright ? Damien Cassou
> +;;
> +;; This file is part of Notmuch.
> +;;
> +;; Notmuch is free software: you can redistribute it and/or modify it
> +;; under the terms of the GNU General Public License as published by
> +;; the Free Software Foundation, either version 3 of the License, or
> +;; (at your option) any later version.
> +;;
> +;; Notmuch is distributed in the hope that it will be useful, but
> +;; WITHOUT ANY WARRANTY; without even the implied warranty of
> +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +;; General Public License for more details.
> +;;
> +;; You should have received a copy of the GNU General Public License
> +;; along with Notmuch.  If not, see .
> +;;
> +;; Authors: Damien Cassou 
> +;;; Commentary:
> +;;
> +;;; Code:
> +;;
> +(defun notmuch-tagger-separate-elems (list sep)

notmuch-tagger-intersperse?

This could also reasonably go in notmuch-lib.el as a general utility.

(How do neither Elisp nor 'cl have an intersperse?)

> +  "Return a list with all elements of LIST separated by SEP."
> +  (let ((first t)
> +(res nil))
> +(dolist (elt (reverse list) res)

(dolist (elt list (nreverse res)) ...) to save a list copy?

> +  (unless first
> +(push sep res))
> +  (setq first nil)
> +  (push elt res
> +
> +(defun notmuch-tagger-present-tags-header-line (tags)
> +  "Return a property list to present TAGS in emacs header-line."
> +  (list
> +   "("
> +   (notmuch-tagger-separate-elems tags " ")
> +   ")"))
> +
> +
> +(provide 'notmuch-tagger)
> +;;; notmuch-tagger.el ends here