[PATCH v2 3/3] emacs: Buttonize mid: links

2012-11-10 Thread Austin Clements
This adds support for RFC 2392 mid: message ID links.
---
 emacs/notmuch-show.el |   45 +
 test/emacs-show   |8 +++-
 2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 49961fb..5b3e70e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1014,23 +1014,44 @@ message at DEPTH in the current thread."
"\\)")
   "The regexp used to match id: links in messages.")

+(defvar notmuch-mid-regexp
+  ;; goto-address-url-regexp matched cid: links, which have the same
+  ;; grammar as the message ID part of a mid: link.  Construct the
+  ;; regexp using the same technique as goto-address-url-regexp.
+  (concat "\\ <>
+<>
+<>. <>, <>;
 EOF
 test_expect_equal_file EXPECTED OUTPUT

-- 
1.7.10.4



[PATCH v2 2/3] emacs: Improve the regexp used to match id:'s in messages

2012-11-10 Thread Austin Clements
This regexp agrees with Xapian query syntax much more closely, though
we specifically disallow various cases that would be confusing in the
context of an email body (e.g., punctuation at the end of an id: link
is not considered part of the id: link because it's probably part of
the surrounding text).

In particular, this handles id: links that are not surrounded by
quotes much better, which stash is much more likely to generate now
that we don't quote id's that don't need to be quoted.  It also
handles quoted id: links better.

We update the buttonization test to reflect the new pattern.
---
 emacs/notmuch-show.el |   20 +++-
 test/emacs-show   |   20 ++--
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d061367..49961fb 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -996,6 +996,24 @@ message at DEPTH in the current thread."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))

+(defvar notmuch-id-regexp
+  (concat
+   ;; Match the id: prefix only if it begins a word (to disallow, for
+   ;; example, matching cid:).
+   "\\
-<> <> <> <>
-<> <>
-(<> [<>
-<>
+<>. <>, <>; <>:
+<>? <>!
+(<>) [<>]
+<>...
 <>
 

[PATCH v2 1/3] test: Test buttonization of id: links

2012-11-10 Thread Austin Clements
This matches the current behavior of the buttonizer, so it passes, but
many of these cases are not what you'd want (and some of them aren't
even valid Xapian queries).  The next patch will fix the handling of
these cases and update the test.
---
 test/emacs-show  |   50 ++
 test/test-lib.el |   14 ++
 2 files changed, 64 insertions(+)

diff --git a/test/emacs-show b/test/emacs-show
index 64c38d3..9712633 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -106,5 +106,55 @@ test_emacs '(notmuch-search "from:lars at seas.harvard.edu 
and subject:\"Maildir st
(test-visible-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-indent-thread-content-off

+test_begin_subtest "id buttonization"
+add_message '[body]="
+id:abc
+id:abc.def. id:abc,def, id:abc;def; id:abc:def:
+id:foo at bar.?baz? id:foo at bar!.baz!
+(id:foo at bar.baz) [id:foo at bar.baz]
+id:foo at bar.baz...
+id:2+2=5
+id:=_-:/.[]@$%+
+id:abc)def
+id:ab\"c def
+id:\"abc\"def
+id:\"ab\"\"c\"def
+id:\"ab c\"def
+id:\"abc\".def
+id:\"abc
+\"
+id:)
+id:
+cid:xxx"'
+test_emacs '(notmuch-show "id:'$gen_msg_id'")
+   (notmuch-test-mark-links)
+   (test-visible-output)'
+cat 
+<> <> <> <>
+<> <>
+(<> [<>
+<>
+<>

[PATCH v2 0/3] Better id: link buttonization

2012-11-10 Thread Austin Clements
This is v2 of id:"1351650561-7331-1-git-send-email-amdragon at mit.edu".
This makes Jani's suggested additions to the regexp and adds support
for RFC 2392 mid: links, as suggested by Sascha.



[PATCH] Update notmuch-mutt requirements in README file.

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, "Kevin J. McCarthy"  wrote:

> This updates the notmuch-mutt README file with requirements for the
> recently added duplicate removal patch.

Looks good and matches the notmuch-mutt & README in contrib.

+1

> -Kevin

Tomi



[PATCH] test: expand regex in test/basic

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, David Bremner  wrote:

> david at tethera.net writes:
>
>> -available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 | \
>> -sed -r -e "s,.*/,," -e 
>> "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d"
>>  | \
>> +
>> +
>> +available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111  \
>
> Umm. I thought I killed those blank lines. Pretend they're not there ;).

Great idea -- I suggest you restore the use of | sed 's,.*,,' | instead
of that basename, though.

> d

Tomi


[PATCH] Update notmuch-mutt requirements in README file.

2012-11-10 Thread Stefano Zacchiroli
On Sat, Nov 10, 2012 at 10:20:41PM +0200, Tomi Ollila wrote:
> On Sat, Nov 10 2012, "Kevin J. McCarthy"  wrote:
> 
> > This updates the notmuch-mutt README file with requirements for the
> > recently added duplicate removal patch.
> 
> Looks good and matches the notmuch-mutt & README in contrib.
> 
> +1

FWIW, I AOL patch application.

Thanks Kevin for preparing the patch!
Cheers.
-- 
Stefano Zacchiroli  . . . . . . .  zack at upsilon.cc . . . . o . . . o . o
Ma?tre de conf?rences . . . . . http://upsilon.cc/zack . . . o . . . o o
Debian Project Leader . . . . . . @zack on identi.ca . . o o o . . . o .
? the first rule of tautology club is the first rule of tautology club ?


[PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, Mark Walters  wrote:

> If the user pressed return on the end result status line it gave a
> blank message. Modify the function notmuch-pick-get-message-id to
> return nil rather than an empty message-id in this case to fix this.
>
> This also fixes a bug in the (lack of) quoting of the id string.
> ---

LGTM

Tomi

> Version 1 is at
> id:1351797983-19707-1-git-send-email-markwalters1009 at gmail.com
>
> This version changes the `when' to and `if' and adds the fix for the
> quoting.
>
> Best wishes
>
> Mark
>
>  contrib/notmuch-pick/notmuch-pick.el |4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/notmuch-pick/notmuch-pick.el 
> b/contrib/notmuch-pick/notmuch-pick.el
> index 15ac5e8..bbfa6fb 100644
> --- a/contrib/notmuch-pick/notmuch-pick.el
> +++ b/contrib/notmuch-pick/notmuch-pick.el
> @@ -241,7 +241,9 @@ Some useful entries are:
>  
>  (defun notmuch-pick-get-message-id ()
>"Return the message id of the current message."
> -  (concat "id:\"" (notmuch-pick-get-prop :id) "\""))
> +  (let ((id (notmuch-pick-get-prop :id)))
> +(if id
> + (notmuch-id-to-query id
>  
>  (defun notmuch-pick-get-match ()
>"Return whether the current message is a match."
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: display tags in notmuch-show's header-line with links to search

2012-11-10 Thread Damien Cassou
Please see new version of this patch:
id:1352565719-12397-1-git-send-email-damien.cassou at gmail.com


[PATCH v2] emacs: display tags in notmuch-show with links

2012-11-10 Thread Damien Cassou
This patch obsoletes
id:1352234344-28119-1-git-send-email-damien.cassou at gmail.com

This patch makes clickable all tags that appear in notmuch-show
buffers. Each tag is a link to open a new notmuch-search buffer for
this tag. Additionally, the buffer's header-line now shows the
thread's tags (also clickable).

This patch is the first one of an upcoming series whose goal is to
integrate notmuch-labeler into notmuch. See the following for more
details:
https://github.com/DamienCassou/notmuch-labeler

This patch includes header-button.el, a package contributed by Jonas
Bernoulli that fixes a limitation of the button.el Emacs library.
Jonas gave me the authorization to include the package in notmuch, but
only if the package is first searched in the existing `load-path'. See
this thread:
id:CA+y5ggiGrAcicQLeskaXFoxYyJQVVXZ1VRX=XS8zPFR9_mBFxA at mail.gmail.com

With respect to v1, I took care of the comments you made:
- Renamed tager to tagger;
- Avoided an additional call to notmuch by reading existing data in
  the buffer with `notmuch-show-mapc';
- As a result of previous point, a thread's tags now equals the union
  of the emails' tags that are visible;
- Stopped stripping "thread:" from the thread-id to add it back
  later.

With respect to v1, I added the following:
- Each label on each message is now clickable;
- Moved header-button.el to fallback-libs/ and only load this one when
  it is not already in the `load-path'.

You can follow this patch series on
https://github.com/DamienCassou/notmuch/tree/labeler-integration

Signed-off-by: Damien Cassou 
---
 emacs/fallback-libs/.nosearch|1 +
 emacs/fallback-libs/header-button.el |  138 ++
 emacs/notmuch-show.el|   33 ++--
 emacs/notmuch-tagger.el  |  129 +++
 test/emacs   |   61 +++
 5 files changed, 355 insertions(+), 7 deletions(-)
 create mode 100644 emacs/fallback-libs/.nosearch
 create mode 100644 emacs/fallback-libs/header-button.el
 create mode 100644 emacs/notmuch-tagger.el

diff --git a/emacs/fallback-libs/.nosearch b/emacs/fallback-libs/.nosearch
new file mode 100644
index 000..0a01dc9
--- /dev/null
+++ b/emacs/fallback-libs/.nosearch
@@ -0,0 +1 @@
+This file prevents Emacs from adding the directory to the `load-path'.
diff --git a/emacs/fallback-libs/header-button.el 
b/emacs/fallback-libs/header-button.el
new file mode 100644
index 000..05f6f32
--- /dev/null
+++ b/emacs/fallback-libs/header-button.el
@@ -0,0 +1,138 @@
+;;; header-button.el --- clickable buttons in header lines
+
+;; Copyright (C) 2010-2012  Jonas Bernoulli
+
+;; Author: Jonas Bernoulli 
+;; Created: 20100604
+;; Version: 0.2.2
+;; Homepage: https://github.com/tarsius/header-button
+;; Keywords: extensions
+
+;; This file is not part of GNU Emacs.
+
+;; This file 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, or (at your option)
+;; any later version.
+
+;; This file 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 this program.  If not, see .
+
+;;; Commentary:
+
+;; This package extends `button' by adding support for adding buttons to
+;; the header line.  Since the header line is very limited compared to a
+;; buffer most of the functionality provided by `button' is not available
+;; for buttons in the header line.
+
+;; While `button' provides the function `insert-button' (as well as
+;; others) to insert a button into a buffer at point, something similar
+;; can't be done here, due to the lack of point in header lines.
+
+;; Instead use `header-button-format' like this:
+;;
+;; (setq header-line-format
+;;   (concat "Here's a button: "
+;;   (header-button-format "Click me!" :action 'my-action)))
+
+;; Like with `button' you can create your own derived button types:
+;;
+;; (define-button-type 'my-header
+;;   :supertype 'header
+;;   :action 'my-action)
+;;
+;; (setq header-line-format
+;;   (concat (header-button-format "Click me!" :action 'my-action) " "
+;;   (header-button-format "No me!" :type 'my-header)))
+
+;; The function associated with `:action' is called with the button plist
+;; as only argument.  Do no use `plist-get' to extract a value from it.
+;; Instead use `header-button-get' which will also extract values stored
+;; in it's type.
+;;
+;; (defun my-action (button)
+;;   (message "This button labeled `%s' belongs to category `%s'"
+;;(header-button-label button)
+;;(header-button-get button 'category)))
+
+;;; Code:
+
+(require 

[PATCH v3] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Mark Walters
If the user pressed return on the end result status line it gave a
blank message. Modify the function notmuch-pick-get-message-id to
return nil rather than an empty message-id in this case to fix this.

This also fixes a bug in the (lack of) quoting of the id string.
---

v2 is at id:1352562350-8219-1-git-send-email-markwalters1009 at gmail.com

As suggested by bremner make the nil return from the if clause
explicit (as that is the point of the change).


 contrib/notmuch-pick/notmuch-pick.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 15ac5e8..4db9632 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -241,7 +241,10 @@ Some useful entries are:

 (defun notmuch-pick-get-message-id ()
   "Return the message id of the current message."
-  (concat "id:\"" (notmuch-pick-get-prop :id) "\""))
+  (let ((id (notmuch-pick-get-prop :id)))
+(if id
+   (notmuch-id-to-query id)
+  nil)))

 (defun notmuch-pick-get-match ()
   "Return whether the current message is a match."
-- 
1.7.9.1



emacs: Handling external dependencies

2012-11-10 Thread Damien Cassou
Hi,

I recently sent a patch for notmuch emacs that depends on a particular
library. What is the best way to deal with such dependencies?

I can see different solutions:

1) distribute a rewritten version of the dependency so that the code
now belongs to notmuch (e.g., replace the name of the library by
'notmuch'). This has the disadvantage of requiring maintenance when a
new version of the library is released and can also be considered
'stealing' by some authors.

2) use a package manager to load the library. This has the
disadvantage that the now standard package manager is not in
widespread use yet and is not compatible with other OS-based package
managers (such as apt-get in Debian).

3) distribute the dependency with the rest of notmuch and load this
one. This has the disadvantage of possibly shadowing an already
existing version of this library installed through a different means.

4) distribute the dependency with the rest of notmuch (in a separate
"fallback-libs/" directory) and load it only when requiring the
library with the standard load-path does not work. Jonas Bernoulli
gave me a way to do that:

,
| (or (require 'THE-LIB nil t)
| (let ((load-path
|   (cons (expand-file-name
|  "fallback-libs"
|  (file-name-directory (or load-file-name buffer-file-name)))
| load-path)))
|   (require 'THE-LIB)))
`

What do you think?

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill


[PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Mark Walters
If the user pressed return on the end result status line it gave a
blank message. Modify the function notmuch-pick-get-message-id to
return nil rather than an empty message-id in this case to fix this.

This also fixes a bug in the (lack of) quoting of the id string.
---

Version 1 is at
id:1351797983-19707-1-git-send-email-markwalters1009 at gmail.com

This version changes the `when' to and `if' and adds the fix for the
quoting.

Best wishes

Mark

 contrib/notmuch-pick/notmuch-pick.el |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 15ac5e8..bbfa6fb 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -241,7 +241,9 @@ Some useful entries are:

 (defun notmuch-pick-get-message-id ()
   "Return the message id of the current message."
-  (concat "id:\"" (notmuch-pick-get-prop :id) "\""))
+  (let ((id (notmuch-pick-get-prop :id)))
+(if id
+   (notmuch-id-to-query id

 (defun notmuch-pick-get-match ()
   "Return whether the current message is a match."
-- 
1.7.9.1



[PATCH] test: expand regex in test/basic

2012-11-10 Thread David Bremner
david at tethera.net writes:

> -available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 | \
> -sed -r -e "s,.*/,," -e 
> "/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d"
>  | \
> +
> +
> +available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111  \

Umm. I thought I killed those blank lines. Pretend they're not there ;).

d


[PATCH] test: expand regex in test/basic

2012-11-10 Thread da...@tethera.net
From: David Bremner 

Over time, maintaining this very long regex has become irritating,
especially when resolving conflicts.

This patch replaces the call to sed with multiple extra arguments to
find.  Since each test binary is now on it's own line, this should
make resolving conflicts easier.

The use of basename is clunky, but at least is portable (unlike the
printf option to find)
---
 test/basic |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/basic b/test/basic
index c47197c..7420c7d 100755
--- a/test/basic
+++ b/test/basic
@@ -53,8 +53,17 @@ test_expect_code 2 'failure to clean up causes the test to 
fail' '
 test_begin_subtest 'Ensure that all available tests will be run by 
notmuch-test'
 eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)
 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
-available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 | \
-sed -r -e "s,.*/,," -e 
"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d"
 | \
+
+
+available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111  \
+! -name aggregate-results.sh   \
+! -name arg-test   \
+! -name notmuch-test   \
+! -name parse-time \
+! -name smtp-dummy \
+! -name symbol-test\
+! -name test-verbose   \
+-exec basename {} \; | \
 sort)
 test_expect_equal "$tests_in_suite" "$available"

-- 
1.7.10.4



[PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread David Bremner
Mark Walters  writes:

> This version changes the `when' to and `if' and adds the fix for the
> quoting.

Sorry to be such a pedant about this. Is it obvious to other people that 
(if nil 'something) evaluates to nil? If so, nevermind. But for me, if's
in an expression context need two branches.

d


[PATCH] Update notmuch-mutt requirements in README file.

2012-11-10 Thread Kevin J. McCarthy
This updates the notmuch-mutt README file with requirements for the
recently added duplicate removal patch.

-Kevin

---
 contrib/notmuch-mutt/README |5 +
 1 file changed, 5 insertions(+)

diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README
index 382ac91..e00035c 100644
--- a/contrib/notmuch-mutt/README
+++ b/contrib/notmuch-mutt/README
@@ -41,6 +41,11 @@ To *run* notmuch-mutt you will need Perl with the following 
libraries:
   (Debian package: libstring-shellquote-perl)
 - Term::ReadLine <http://search.cpan.org/~hayashi/Term-ReadLine-Gnu/>
   (Debian package: libterm-readline-gnu-perl)
+- File::Which <http://search.cpan.org/dist/File-Which/>
+  (Debian package: libfile-which-perl)
+
+The --remove-dups option will use fdupes <https://code.google.com/p/fdupes/>
+if it is installed.  Version fdupes-1.50-PR2 or higher is required.

 To *build* notmuch-mutt documentation you will need:

-- 
1.7.10.4

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


[PATCH 0/3] Outline fix for emacs tagging race

2012-11-10 Thread Austin Clements
Quoth Mark Walters on Nov 09 at  6:58 pm:
> For a long time [1] there have been two related races in tagging from
> the search buffer.
> 
> The first is that when tagging (including archiving) a thread message
> which arrived after the buffer was created may also be tagged. This is
> because the tagging is done based on the thread-id not on the
> individual messages.
> 
> The second is when using the '*' command to tag all messages. This is
> not quite the same as this command only tags messages matching the
> query not all messages in all threads that contain a message matching
> the query. Thus if more messages now match than when the buffer was
> created (eg some external tagging script has run) then this command
> can unexpectedly tag these messages too.
> 
> One solution that was discussed in [2] was for the search output of
> notmuch to include the message-ids of both matching and non-matching
> messages. At that time that was difficult to implement as it was
> unclear how to escape the message ids when using the text
> format. Since emacs now uses JSON for search mode this problem is
> solved.
> 
> This patch series implements the above mentioned solution and seems to
> work except for one problem.
> 
> Since emacs now tags each message in a thread in the search buffer it
> is easy to ask it to tag a lot of messages. This could be done
> individually which would be ridiculously slow so instead they are all
> done in one batch. But now it is relatively easy to take notmuch over
> the threshold for ARG_MAX.
> 
> In [3] Tomi did some experiments and found on a standard Debian system
> with getconf ARG_MAX =131072 that command lines with 1 200 byte
> arguments worked. I am a little puzzled by that as I get the same
> results and I getconf ARG_MAX gives 2097152 for me.
> 
> More importantly though, when trying to execute a command from emacs I
> am finding that 131072 is the limit on the command length in bytes and
> we can hit this with something around 1500 messages (see end for a
> very hacky emacs test script). This is probably more than we can
> expect in a single thread so tagging from show is probably safe but it
> does cause a problem when tagging from search.
> 
> I can think of several possible solutions (e.g., batch it in my new
> stuff, put some batching in notmuch-tag, all notmuch tag to read a
> query from stdin). But before any larger more intrusive change do
> people like the general approach? Does anyone have a good way to get
> round the command line size problem?
> 
> Best wishes 
> 
> Mark
> 
> 
> [1] id:87ocmtg9ni.fsf at yoom.home.cworth.org
> [2] id:CAH-f9WticM4EN8F1_ik_-mcBcBtrXwSpO+Drbtp7=UN7McECrg at mail.gmail.com
> [3] id:m2liody7av.fsf at guru.guru-group.fi

I'm glad to see someone picking up this bug.  Besides somehow dealing
with long command-lines, when we were last exploring this race, I had
found that it was 3-4x more efficient to use Xapian document IDs
directly rather than message IDs [1].  It's probably best *not* to do
this initially for the sake of simplicity, but I think a simple tweak
to your approach would let us seamlessly transition to this in the
future.  Rather than extending the JSON output with what are
explicitly message IDs, instead extend the output with opaque queries
that are guaranteed to match the matching/non-matching messages in the
thread and are guaranteed to be combinable, but aren't guaranteed to
be of any particular form.  For now, the CLI can simply output id:
queries for these, but in the future we could easily add a special
query syntax for docid queries or, if we ever move to a custom query
parser, support docids in any query.

For the long command line problem, one easy solution is to support,
say, '-' as a query syntax that means "read the query from stdin."
This would be a simple addition to query_string_from_args and would
work across the CLI.

[1] id:CAH-f9WsPj=1Eu=g3sOePJgCTBFs6HrLdLq18xMEnJ8aZ00yCEg at mail.gmail.com


[PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Mark Walters
If the user pressed return on the end result status line it gave a
blank message. Modify the function notmuch-pick-get-message-id to
return nil rather than an empty message-id in this case to fix this.

This also fixes a bug in the (lack of) quoting of the id string.
---

Version 1 is at
id:1351797983-19707-1-git-send-email-markwalters1...@gmail.com

This version changes the `when' to and `if' and adds the fix for the
quoting.

Best wishes

Mark

 contrib/notmuch-pick/notmuch-pick.el |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 15ac5e8..bbfa6fb 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -241,7 +241,9 @@ Some useful entries are:
 
 (defun notmuch-pick-get-message-id ()
   Return the message id of the current message.
-  (concat id:\ (notmuch-pick-get-prop :id) \))
+  (let ((id (notmuch-pick-get-prop :id)))
+(if id
+   (notmuch-id-to-query id
 
 (defun notmuch-pick-get-match ()
   Return whether the current message is a match.
-- 
1.7.9.1

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


emacs: Handling external dependencies

2012-11-10 Thread Damien Cassou
Hi,

I recently sent a patch for notmuch emacs that depends on a particular
library. What is the best way to deal with such dependencies?

I can see different solutions:

1) distribute a rewritten version of the dependency so that the code
now belongs to notmuch (e.g., replace the name of the library by
'notmuch'). This has the disadvantage of requiring maintenance when a
new version of the library is released and can also be considered
'stealing' by some authors.

2) use a package manager to load the library. This has the
disadvantage that the now standard package manager is not in
widespread use yet and is not compatible with other OS-based package
managers (such as apt-get in Debian).

3) distribute the dependency with the rest of notmuch and load this
one. This has the disadvantage of possibly shadowing an already
existing version of this library installed through a different means.

4) distribute the dependency with the rest of notmuch (in a separate
fallback-libs/ directory) and load it only when requiring the
library with the standard load-path does not work. Jonas Bernoulli
gave me a way to do that:

,
| (or (require 'THE-LIB nil t)
| (let ((load-path
|   (cons (expand-file-name
|  fallback-libs
|  (file-name-directory (or load-file-name buffer-file-name)))
| load-path)))
|   (require 'THE-LIB)))
`

What do you think?

--
Damien Cassou
http://damiencassou.seasidehosting.st

Success is the ability to go from one failure to another without
losing enthusiasm.
Winston Churchill
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, Mark Walters markwalters1...@gmail.com wrote:

 If the user pressed return on the end result status line it gave a
 blank message. Modify the function notmuch-pick-get-message-id to
 return nil rather than an empty message-id in this case to fix this.

 This also fixes a bug in the (lack of) quoting of the id string.
 ---

LGTM

Tomi

 Version 1 is at
 id:1351797983-19707-1-git-send-email-markwalters1...@gmail.com

 This version changes the `when' to and `if' and adds the fix for the
 quoting.

 Best wishes

 Mark

  contrib/notmuch-pick/notmuch-pick.el |4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

 diff --git a/contrib/notmuch-pick/notmuch-pick.el 
 b/contrib/notmuch-pick/notmuch-pick.el
 index 15ac5e8..bbfa6fb 100644
 --- a/contrib/notmuch-pick/notmuch-pick.el
 +++ b/contrib/notmuch-pick/notmuch-pick.el
 @@ -241,7 +241,9 @@ Some useful entries are:
  
  (defun notmuch-pick-get-message-id ()
Return the message id of the current message.
 -  (concat id:\ (notmuch-pick-get-prop :id) \))
 +  (let ((id (notmuch-pick-get-prop :id)))
 +(if id
 + (notmuch-id-to-query id
  
  (defun notmuch-pick-get-match ()
Return whether the current message is a match.
 -- 
 1.7.9.1

 ___
 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 v2] emacs: display tags in notmuch-show with links

2012-11-10 Thread Damien Cassou
This patch obsoletes
id:1352234344-28119-1-git-send-email-damien.cas...@gmail.com

This patch makes clickable all tags that appear in notmuch-show
buffers. Each tag is a link to open a new notmuch-search buffer for
this tag. Additionally, the buffer's header-line now shows the
thread's tags (also clickable).

This patch is the first one of an upcoming series whose goal is to
integrate notmuch-labeler into notmuch. See the following for more
details:
https://github.com/DamienCassou/notmuch-labeler

This patch includes header-button.el, a package contributed by Jonas
Bernoulli that fixes a limitation of the button.el Emacs library.
Jonas gave me the authorization to include the package in notmuch, but
only if the package is first searched in the existing `load-path'. See
this thread:
id:CA+y5ggiGrAcicQLeskaXFoxYyJQVVXZ1VRX=xs8zpfr9_mb...@mail.gmail.com

With respect to v1, I took care of the comments you made:
- Renamed tager to tagger;
- Avoided an additional call to notmuch by reading existing data in
  the buffer with `notmuch-show-mapc';
- As a result of previous point, a thread's tags now equals the union
  of the emails' tags that are visible;
- Stopped stripping thread: from the thread-id to add it back
  later.

With respect to v1, I added the following:
- Each label on each message is now clickable;
- Moved header-button.el to fallback-libs/ and only load this one when
  it is not already in the `load-path'.

You can follow this patch series on
https://github.com/DamienCassou/notmuch/tree/labeler-integration

Signed-off-by: Damien Cassou damien.cas...@gmail.com
---
 emacs/fallback-libs/.nosearch|1 +
 emacs/fallback-libs/header-button.el |  138 ++
 emacs/notmuch-show.el|   33 ++--
 emacs/notmuch-tagger.el  |  129 +++
 test/emacs   |   61 +++
 5 files changed, 355 insertions(+), 7 deletions(-)
 create mode 100644 emacs/fallback-libs/.nosearch
 create mode 100644 emacs/fallback-libs/header-button.el
 create mode 100644 emacs/notmuch-tagger.el

diff --git a/emacs/fallback-libs/.nosearch b/emacs/fallback-libs/.nosearch
new file mode 100644
index 000..0a01dc9
--- /dev/null
+++ b/emacs/fallback-libs/.nosearch
@@ -0,0 +1 @@
+This file prevents Emacs from adding the directory to the `load-path'.
diff --git a/emacs/fallback-libs/header-button.el 
b/emacs/fallback-libs/header-button.el
new file mode 100644
index 000..05f6f32
--- /dev/null
+++ b/emacs/fallback-libs/header-button.el
@@ -0,0 +1,138 @@
+;;; header-button.el --- clickable buttons in header lines
+
+;; Copyright (C) 2010-2012  Jonas Bernoulli
+
+;; Author: Jonas Bernoulli jo...@bernoul.li
+;; Created: 20100604
+;; Version: 0.2.2
+;; Homepage: https://github.com/tarsius/header-button
+;; Keywords: extensions
+
+;; This file is not part of GNU Emacs.
+
+;; This file 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, or (at your option)
+;; any later version.
+
+;; This file 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 this program.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;; This package extends `button' by adding support for adding buttons to
+;; the header line.  Since the header line is very limited compared to a
+;; buffer most of the functionality provided by `button' is not available
+;; for buttons in the header line.
+
+;; While `button' provides the function `insert-button' (as well as
+;; others) to insert a button into a buffer at point, something similar
+;; can't be done here, due to the lack of point in header lines.
+
+;; Instead use `header-button-format' like this:
+;;
+;; (setq header-line-format
+;;   (concat Here's a button: 
+;;   (header-button-format Click me! :action 'my-action)))
+
+;; Like with `button' you can create your own derived button types:
+;;
+;; (define-button-type 'my-header
+;;   :supertype 'header
+;;   :action 'my-action)
+;;
+;; (setq header-line-format
+;;   (concat (header-button-format Click me! :action 'my-action)  
+;;   (header-button-format No me! :type 'my-header)))
+
+;; The function associated with `:action' is called with the button plist
+;; as only argument.  Do no use `plist-get' to extract a value from it.
+;; Instead use `header-button-get' which will also extract values stored
+;; in it's type.
+;;
+;; (defun my-action (button)
+;;   (message This button labeled `%s' belongs to category `%s'
+;;(header-button-label button)
+;;(header-button-get button 'category)))
+
+;;; 

Re: [PATCH v2] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread David Bremner
Mark Walters markwalters1...@gmail.com writes:

 This version changes the `when' to and `if' and adds the fix for the
 quoting.

Sorry to be such a pedant about this. Is it obvious to other people that 
(if nil 'something) evaluates to nil? If so, nevermind. But for me, if's
in an expression context need two branches.

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


Re: [PATCH] emacs: display tags in notmuch-show's header-line with links to search

2012-11-10 Thread Damien Cassou
Please see new version of this patch:
id:1352565719-12397-1-git-send-email-damien.cas...@gmail.com
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3] contrib: pick: bugfix when trying to show a non-message

2012-11-10 Thread Mark Walters
If the user pressed return on the end result status line it gave a
blank message. Modify the function notmuch-pick-get-message-id to
return nil rather than an empty message-id in this case to fix this.

This also fixes a bug in the (lack of) quoting of the id string.
---

v2 is at id:1352562350-8219-1-git-send-email-markwalters1...@gmail.com

As suggested by bremner make the nil return from the if clause
explicit (as that is the point of the change).


 contrib/notmuch-pick/notmuch-pick.el |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/contrib/notmuch-pick/notmuch-pick.el 
b/contrib/notmuch-pick/notmuch-pick.el
index 15ac5e8..4db9632 100644
--- a/contrib/notmuch-pick/notmuch-pick.el
+++ b/contrib/notmuch-pick/notmuch-pick.el
@@ -241,7 +241,10 @@ Some useful entries are:
 
 (defun notmuch-pick-get-message-id ()
   Return the message id of the current message.
-  (concat id:\ (notmuch-pick-get-prop :id) \))
+  (let ((id (notmuch-pick-get-prop :id)))
+(if id
+   (notmuch-id-to-query id)
+  nil)))
 
 (defun notmuch-pick-get-match ()
   Return whether the current message is a match.
-- 
1.7.9.1

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


[PATCH] Update notmuch-mutt requirements in README file.

2012-11-10 Thread Kevin J. McCarthy
This updates the notmuch-mutt README file with requirements for the
recently added duplicate removal patch.

-Kevin

---
 contrib/notmuch-mutt/README |5 +
 1 file changed, 5 insertions(+)

diff --git a/contrib/notmuch-mutt/README b/contrib/notmuch-mutt/README
index 382ac91..e00035c 100644
--- a/contrib/notmuch-mutt/README
+++ b/contrib/notmuch-mutt/README
@@ -41,6 +41,11 @@ To *run* notmuch-mutt you will need Perl with the following 
libraries:
   (Debian package: libstring-shellquote-perl)
 - Term::ReadLine http://search.cpan.org/~hayashi/Term-ReadLine-Gnu/
   (Debian package: libterm-readline-gnu-perl)
+- File::Which http://search.cpan.org/dist/File-Which/
+  (Debian package: libfile-which-perl)
+
+The --remove-dups option will use fdupes https://code.google.com/p/fdupes/
+if it is installed.  Version fdupes-1.50-PR2 or higher is required.
 
 To *build* notmuch-mutt documentation you will need:
 
-- 
1.7.10.4



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


[PATCH] test: expand regex in test/basic

2012-11-10 Thread david
From: David Bremner brem...@debian.org

Over time, maintaining this very long regex has become irritating,
especially when resolving conflicts.

This patch replaces the call to sed with multiple extra arguments to
find.  Since each test binary is now on it's own line, this should
make resolving conflicts easier.

The use of basename is clunky, but at least is portable (unlike the
printf option to find)
---
 test/basic |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/basic b/test/basic
index c47197c..7420c7d 100755
--- a/test/basic
+++ b/test/basic
@@ -53,8 +53,17 @@ test_expect_code 2 'failure to clean up causes the test to 
fail' '
 test_begin_subtest 'Ensure that all available tests will be run by 
notmuch-test'
 eval $(sed -n -e '/^TESTS=$/,/^$/p' $TEST_DIRECTORY/notmuch-test)
 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
-available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111 | \
-sed -r -e s,.*/,, -e 
/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d
 | \
+
+
+available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111  \
+! -name aggregate-results.sh   \
+! -name arg-test   \
+! -name notmuch-test   \
+! -name parse-time \
+! -name smtp-dummy \
+! -name symbol-test\
+! -name test-verbose   \
+-exec basename {} \; | \
 sort)
 test_expect_equal $tests_in_suite $available
 
-- 
1.7.10.4

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


Re: [PATCH] test: expand regex in test/basic

2012-11-10 Thread David Bremner
da...@tethera.net writes:

 -available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111 | \
 -sed -r -e s,.*/,, -e 
 /^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d
  | \
 +
 +
 +available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111  \

Umm. I thought I killed those blank lines. Pretend they're not there ;).

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


Re: [PATCH] test: expand regex in test/basic

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, David Bremner da...@tethera.net wrote:

 da...@tethera.net writes:

 -available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111 | \
 -sed -r -e s,.*/,, -e 
 /^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d
  | \
 +
 +
 +available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -perm +111  \

 Umm. I thought I killed those blank lines. Pretend they're not there ;).

Great idea -- I suggest you restore the use of | sed 's,.*,,' | instead
of that basename, though.

 d

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


Re: [PATCH] Update notmuch-mutt requirements in README file.

2012-11-10 Thread Tomi Ollila
On Sat, Nov 10 2012, Kevin J. McCarthy ke...@8t8.us wrote:

 This updates the notmuch-mutt README file with requirements for the
 recently added duplicate removal patch.

Looks good and matches the notmuch-mutt  README in contrib.

+1

 -Kevin

Tomi

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


[PATCH v2 0/3] Better id: link buttonization

2012-11-10 Thread Austin Clements
This is v2 of id:1351650561-7331-1-git-send-email-amdra...@mit.edu.
This makes Jani's suggested additions to the regexp and adds support
for RFC 2392 mid: links, as suggested by Sascha.

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


[PATCH v2 1/3] test: Test buttonization of id: links

2012-11-10 Thread Austin Clements
This matches the current behavior of the buttonizer, so it passes, but
many of these cases are not what you'd want (and some of them aren't
even valid Xapian queries).  The next patch will fix the handling of
these cases and update the test.
---
 test/emacs-show  |   50 ++
 test/test-lib.el |   14 ++
 2 files changed, 64 insertions(+)

diff --git a/test/emacs-show b/test/emacs-show
index 64c38d3..9712633 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -106,5 +106,55 @@ test_emacs '(notmuch-search from:l...@seas.harvard.edu 
and subject:\Maildir st
(test-visible-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-indent-thread-content-off
 
+test_begin_subtest id buttonization
+add_message '[body]=
+id:abc
+id:abc.def. id:abc,def, id:abc;def; id:abc:def:
+id:foo@bar.?baz? id:foo@bar!.baz!
+(id:f...@bar.baz) [id:f...@bar.baz]
+id:f...@bar.baz...
+id:2+2=5
+id:=_-:/.[]@$%+
+id:abc)def
+id:ab\c def
+id:\abc\def
+id:\ab\\c\def
+id:\ab c\def
+id:\abc\.def
+id:\abc
+\
+id:)
+id:
+cid:xxx'
+test_emacs '(notmuch-show id:'$gen_msg_id')
+   (notmuch-test-mark-links)
+   (test-visible-output)'
+cat EOF EXPECTED
+Notmuch Test Suite test_su...@notmuchmail.org (2001-01-05) (inbox)
+Subject: id buttonization
+To: Notmuch Test Suite test_su...@notmuchmail.org
+Date: Fri, 05 Jan 2001 15:43:57 +
+
+id:abc
+id:abc.def. id:abc,def, id:abc;def; id:abc:def:
+id:foo@bar.?baz? id:foo@bar!.baz!
+(id:f...@bar.baz) [id:f...@bar.baz]
+id:f...@bar.baz...
+id:2+2=5
+id:=_-:/.[]@$%+
+id:abc)def
+id:abc def
+id:abcdef
+id:abcdef
+id:ab cdef
+id:abc.def
+id:abc
+
+id:)
+id:
+cid:xxx
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 
 test_done
diff --git a/test/test-lib.el b/test/test-lib.el
index fa3380c..dece811 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -107,6 +107,20 @@ nothing.
   (ad-set-arg 1 (char-to-string char))
   ad-do-it
 
+(defun notmuch-test-mark-links ()
+  Enclose links in the current buffer with  and .
+  ;; Links are often created by jit-lock functions
+  (jit-lock-fontify-now)
+  (save-excursion
+(let ((inhibit-read-only t))
+  (goto-char (point-min))
+  (let ((button))
+   (while (setq button (next-button (point)))
+ (goto-char (button-start button))
+ (insert )
+ (goto-char (button-end button))
+ (insert ))
+
 (defmacro notmuch-test-run (rest body)
   Evaluate a BODY of test expressions and output the result.
   `(with-temp-buffer
-- 
1.7.10.4

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


[PATCH v2 3/3] emacs: Buttonize mid: links

2012-11-10 Thread Austin Clements
This adds support for RFC 2392 mid: message ID links.
---
 emacs/notmuch-show.el |   45 +
 test/emacs-show   |8 +++-
 2 files changed, 40 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 49961fb..5b3e70e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1014,23 +1014,44 @@ message at DEPTH in the current thread.
\\))
   The regexp used to match id: links in messages.)
 
+(defvar notmuch-mid-regexp
+  ;; goto-address-url-regexp matched cid: links, which have the same
+  ;; grammar as the message ID part of a mid: link.  Construct the
+  ;; regexp using the same technique as goto-address-url-regexp.
+  (concat \\mid:\\( thing-at-point-url-path-regexp \\))
+  The regexp used to match mid: links in messages.
+
+See RFC 2392.)
+
 (defun notmuch-show-buttonise-links (start end)
   Buttonise URLs and mail addresses between START and END.
 
-This also turns id:\message id\-parts into buttons for
-a corresponding notmuch search.
+This also turns id:\message id\-parts and mid: links into
+buttons for a corresponding notmuch search.
   (goto-address-fontify-region start end)
   (save-excursion
-(goto-char start)
-(while (re-search-forward notmuch-id-regexp end t)
-  ;; remove the overlay created by goto-address-mode
-  (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
-  (make-text-button (match-beginning 0) (match-end 0)
-   'action `(lambda (arg)
-  (notmuch-show ,(match-string-no-properties 
0)))
-   'follow-link t
-   'help-echo Mouse-1, RET: search for this message
-   'face goto-address-mail-face
+(let (links)
+  (goto-char start)
+  (while (re-search-forward notmuch-id-regexp end t)
+   (push (list (match-beginning 0) (match-end 0)
+   (match-string-no-properties 0)) links))
+  (goto-char start)
+  (while (re-search-forward notmuch-mid-regexp end t)
+   (let* ((mid-cid (match-string-no-properties 1))
+  (mid (save-match-data
+ (string-match ^[^/]* mid-cid)
+ (url-unhex-string (match-string 0 mid-cid)
+ (push (list (match-beginning 0) (match-end 0)
+ (notmuch-id-to-query mid)) links)))
+  (dolist (link links)
+   ;; Remove the overlay created by goto-address-mode
+   (remove-overlays (first link) (second link) 'goto-address t)
+   (make-text-button (first link) (second link)
+ 'action `(lambda (arg)
+(notmuch-show ,(third link)))
+ 'follow-link t
+ 'help-echo Mouse-1, RET: search for this message
+ 'face goto-address-mail-face)
 
 ;;;###autoload
 (defun notmuch-show (thread-id optional parent-buffer query-context 
buffer-name)
diff --git a/test/emacs-show b/test/emacs-show
index 8944e73..91706ea 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -125,7 +125,10 @@ id:\abc
 \
 id:)
 id:
-cid:xxx'
+cid:xxx
+mid:abc mid:abc/def
+mid:abc%20def
+mid:abc. mid:abc, mid:abc;'
 test_emacs '(notmuch-show id:'$gen_msg_id')
(notmuch-test-mark-links)
(test-visible-output)'
@@ -153,6 +156,9 @@ id:abc
 id:)
 id:
 cid:xxx
+mid:abc mid:abc/def
+mid:abc%20def
+mid:abc. mid:abc, mid:abc;
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-- 
1.7.10.4

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


[PATCH v2 2/3] emacs: Improve the regexp used to match id:'s in messages

2012-11-10 Thread Austin Clements
This regexp agrees with Xapian query syntax much more closely, though
we specifically disallow various cases that would be confusing in the
context of an email body (e.g., punctuation at the end of an id: link
is not considered part of the id: link because it's probably part of
the surrounding text).

In particular, this handles id: links that are not surrounded by
quotes much better, which stash is much more likely to generate now
that we don't quote id's that don't need to be quoted.  It also
handles quoted id: links better.

We update the buttonization test to reflect the new pattern.
---
 emacs/notmuch-show.el |   20 +++-
 test/emacs-show   |   20 ++--
 2 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d061367..49961fb 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -996,6 +996,24 @@ message at DEPTH in the current thread.
   Insert the forest of threads FOREST.
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
+(defvar notmuch-id-regexp
+  (concat
+   ;; Match the id: prefix only if it begins a word (to disallow, for
+   ;; example, matching cid:).
+   \\id:\\(
+   ;; If the term starts with a , then parse Xapian's quoted boolean
+   ;; term syntax, which allows for anything as long as embedded
+   ;; double quotes escaped by doubling them.  We also disallow
+   ;; newlines (which Xapian allows) to prevent runaway terms.
+   \\\([^\\n]\\|)*\
+   ;; Otherwise, parse Xapian's unquoted syntax, which goes up to the
+   ;; next space or ).  We disallow [.,;] as the last character
+   ;; because these are probably part of the surrounding text, and not
+   ;; part of the id.  This doesn't match single character ids; meh.
+   \\|[^\[:space:])][^[:space:])]*[^])[:space:].,:;?!]
+   \\))
+  The regexp used to match id: links in messages.)
+
 (defun notmuch-show-buttonise-links (start end)
   Buttonise URLs and mail addresses between START and END.
 
@@ -1004,7 +1022,7 @@ a corresponding notmuch search.
   (goto-address-fontify-region start end)
   (save-excursion
 (goto-char start)
-(while (re-search-forward id:\\(\?\\)[^[:space:]\]+\\1 end t)
+(while (re-search-forward notmuch-id-regexp end t)
   ;; remove the overlay created by goto-address-mode
   (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
   (make-text-button (match-beginning 0) (match-end 0)
diff --git a/test/emacs-show b/test/emacs-show
index 9712633..8944e73 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -136,23 +136,23 @@ To: Notmuch Test Suite test_su...@notmuchmail.org
 Date: Fri, 05 Jan 2001 15:43:57 +
 
 id:abc
-id:abc.def. id:abc,def, id:abc;def; id:abc:def:
-id:foo@bar.?baz? id:foo@bar!.baz!
-(id:f...@bar.baz) [id:f...@bar.baz]
-id:f...@bar.baz...
+id:abc.def. id:abc,def, id:abc;def; id:abc:def:
+id:foo@bar.?baz? id:foo@bar!.baz!
+(id:f...@bar.baz) [id:f...@bar.baz]
+id:f...@bar.baz...
 id:2+2=5
 id:=_-:/.[]@$%+
-id:abc)def
-id:abc def
+id:abc)def
+id:abc def
 id:abcdef
-id:abcdef
-id:ab cdef
+id:abcdef
+id:ab cdef
 id:abc.def
 id:abc
 
-id:)
+id:)
 id:
-cid:xxx
+cid:xxx
 EOF
 test_expect_equal_file EXPECTED OUTPUT
 
-- 
1.7.10.4

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