[notmuch] [PATCH] Look for text/html content types ignoring case

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 18:51:00 +, James Westby  
wrote:
> Some people send html parts as text/HTML or similar, so do a
> case-sensitive comparison when checking for html parts.

There are various other places where `equal' is used to compare MIME
types with strings. Shouldn't they all be fixed? (I see TEXT/PLAIN
frequently.)

dme.
-- 
David Edmondson, http://dme.org


[notmuch] [PATCH v2] notmuch.el: add functionality in notmuch search mode to add or remove tags by region

2010-02-16 Thread Jesse Rosenthal
This patch adds `-region' versions of the `notmuch-search-' commands to find
properties. It also splits up  `notmuch-add/remove-tags' into both a
`-thread' and a `-region' version. (This makes us modify
`notmuch-search-archive-thread' to use the
`notmuch-search-remove-tag-thread' function, instead of
`notmuch-search-remove-tag', for consistency.) The add/remove-tag command
called by pressing `+' or `-' will then choose accordingly, based on whether
region is active.

This version fixes a couple of errors in the first version, which led to
incorrect marking of some tags in the search view (though the actual
tagging was still correct). It's also based on current master.

I'm not sure any more if region selection is actually the correct way to
do this, or if a mutt-style message-marking method would be better. But
I didn't want a buggy incorrect version out there.
---
 notmuch.el |   98 +---
 1 files changed, 87 insertions(+), 11 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 0f4ea10..7d9a82f 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1227,18 +1227,41 @@ Complete list of currently available key bindings:
   (set (make-local-variable 'font-lock-defaults)
  '(notmuch-search-font-lock-keywords t)))

+(defun notmuch-search-properties-in-region (property beg end)
+  (save-excursion
+(let ((output nil)
+ (last-line (line-number-at-pos end)))
+  (goto-char beg)
+  (beginning-of-line)
+  (while (<= (line-number-at-pos) last-line)
+   (setq output (cons (get-text-property (point) property) output))
+   (forward-line 1))
+  output)))
+
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
   (get-text-property (point) 'notmuch-search-thread-id))

+(defun notmuch-search-find-thread-id-region (beg end)
+  "Return a list of threads for the current region"
+  (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))
+
 (defun notmuch-search-find-authors ()
   "Return the authors for the current thread"
   (get-text-property (point) 'notmuch-search-authors))

+(defun notmuch-search-find-authors-region (beg end)
+  "Return a list of authors for the current region"
+  (notmuch-search-properties-in-region 'notmuch-search-authors beg end))
+
 (defun notmuch-search-find-subject ()
   "Return the subject for the current thread"
   (get-text-property (point) 'notmuch-search-subject))

+(defun notmuch-search-find-subject-region (beg end)
+  "Return a list of authors for the current region"
+  (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
+
 (defun notmuch-search-show-thread ()
   "Display the currently selected thread."
   (interactive)
@@ -1292,32 +1315,85 @@ and will also appear in a buffer named \"*Notmuch 
errors*\"."
   (let ((end (- (point) 1)))
(split-string (buffer-substring beg end))

+(defun notmuch-search-get-tags-region (beg end)
+  (save-excursion
+(let ((output nil)
+ (last-line (line-number-at-pos end)))
+  (goto-char beg)
+  (while (<= (line-number-at-pos) last-line)
+   (setq output (append output (notmuch-search-get-tags)))
+   (forward-line 1))
+  output)))
+
+(defun notmuch-search-add-tag-thread (tag)
+  (notmuch-call-notmuch-process "tag" (concat "+" tag) 
(notmuch-search-find-thread-id))
+  (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string<
+
+(defun notmuch-search-add-tag-region (tag beg end)
+  (let ((search-id-string (mapconcat 'identity 
(notmuch-search-find-thread-id-region beg end) " or ")))
+(notmuch-call-notmuch-process "tag" (concat "+" tag) search-id-string)
+(save-excursion
+  (let ((last-line (line-number-at-pos end)))
+   (goto-char beg)
+   (while (<= (line-number-at-pos) last-line)
+ (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string<)))
+ (forward-line))
+
+(defun notmuch-search-remove-tag-thread (tag)
+  (notmuch-call-notmuch-process "tag" (concat "-" tag) 
(notmuch-search-find-thread-id))
+  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags
+
+(defun notmuch-search-remove-tag-region (tag beg end)
+  (let ((search-id-string (mapconcat 'identity 
(notmuch-search-find-thread-id-region beg end) " or ")))
+(notmuch-call-notmuch-process "tag" (concat "-" tag) search-id-string)
+(save-excursion
+  (let ((last-line (line-number-at-pos end)))
+   (goto-char beg)
+   (while (<= (line-number-at-pos) last-line)
+ (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))
+ (forward-line))
+
+
 (defun notmuch-search-add-tag (tag)
-  "Add a tag to the currently selected thread.
+  "Add a tag to the currently selected thread or region.

-The tag is added to messages in the currently selected thread
-which match the current search terms."
+The tag is added to messages in the currently selected 

[notmuch] [PATCH] Look for text/html content types ignoring case

2010-02-16 Thread James Westby
Some people send html parts as text/HTML or similar, so do a
case-sensitive comparison when checking for html parts.
---
 notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 0f4ea10..b69c334 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -736,7 +736,7 @@ is what to put on the button."
 (setq mime-type (car (split-string (buffer-substring 
 (match-beginning 1) (match-end 
1))

-  (if (equal mime-type "text/html")
+  (if (equal (downcase mime-type) "text/html")
   (let ((filename (notmuch-show-get-filename)))
 (with-temp-buffer
   (insert-file-contents filename nil nil nil t)
-- 
1.6.6.1



[notmuch] [PATCH] notmuch: Respect maildir message flags

2010-02-16 Thread martin f krafft
also sprach Stewart Smith  [2010.02.16.1521 +1300]:
> What about putting them all in there except for the seen tag, with
> the seen tag dictating if it gets marked 'unread' or not? I cannot
> imagine where somebody would want this not to be the case... it
> was bad enough discovering 100,000 unread messages :)

Well, I do keep messages unread even after I saw them, until I can
actually read them...

> What about this patch (just with those few things fixed)?

Thanks!

-- 
martin | http://madduck.net/ | http://two.sentenc.es/

"i dislike arguments of any kind. they are always vulgar, and often
 convincing."
-- oscar wilde

spamtraps: madduck.bogus at madduck.net
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100216/ba08523a/attachment.pgp>


[notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Avery Pennarun
On Tue, Feb 16, 2010 at 8:06 AM, Michal Sojka  wrote:
> On Tue, 16 Feb 2010 02:27:37 -0800 (PST), Jakub Narebski  gmail.com> wrote:
>> Michal Sojka  writes:
>>
>> > I like the simple and powerful test suite used by Git and I would like
>> > to use something like that in Notmuch project (http://notmuchmail.org/).
>> > [...]
>>
>> Have you thought about using TAP (Test Anything Protocol) format for
>> your testsuite? ?Its page (http://testanything.org) has a TAP-producing
>> bash library: http://testanything.org/wiki/index.php/Tap-functions
>
> Yes, somebody has mentiond TAP on notmuch list. From a quick look at TAP
> shell library it seems to me a bit more complex then git's library and
> it also requires bash.
>
> If we need to use some TAP-based tools, we could easily change the
> output of git's library to conform to TAP. Right?

Another TAP-like option is wvtest:

   http://github.com/apenwarr/wvtest

It's LGPLv2.

Have fun,

Avery


[notmuch] [PATCH] notmuch: Respect maildir message flags

2010-02-16 Thread martin f krafft
also sprach Stewart Smith  [2010.02.16.1458 +1300]:
> + case 'R': /* replied */
> + notmuch_message_add_tag (message, "answered");
> + break;

'r' means replied, not 'answered'.

> + case 'T': /* trashed */
> + notmuch_message_add_tag (message, "deleted");
> + break;

Same. trashed and deleted are not the same thing.

I don't want to get into an argument over this, because I think this
already exposes a problem: you are putting into global namespace
something not everyone might want, or agree with.

Why not use 'maildirflags::replied' instead? People can always map
that to something in the global namespace.

-- 
martin | http://madduck.net/ | http://two.sentenc.es/

"geld ist das brecheisen der macht."
 - friedrich nietzsche

spamtraps: madduck.bogus at madduck.net
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100216/90fe7cf2/attachment.pgp>


[notmuch] Notmuch performance problems on OSX

2010-02-16 Thread Stewart Smith
On Fri, 15 Jan 2010 03:58:50 + (UTC), Olly Betts  wrote:
> One difference between OS X and other systems is that OS X supports the
> F_FULLSYNC ioctl, and other systems don't (currently, at least AFAIK)
> and Xapian uses that if it is available to ensure that changes have
> actually made it to disk:
> 
> http://trac.xapian.org/ticket/288
> 
> On other systems, it uses fdatasync() or fsync(), which typically just
> ensure that the data has left the OS - it can sit in disk controller or
> drive caches for potentially seconds longer.  This call happens once
> per table for every (explicit or implicit) flush on a database.

At least if you OS and file system don't hate you (e.g. XFS on Linux),
then fsync() really does flush the drive cache.

Also keep in mind that the OSX file system (HFS+) was great for
1985. It's essentially single threaded :/

-- 
Stewart Smith


[notmuch] Mail in git

2010-02-16 Thread Ben Gamari
Excerpts from Stewart Smith's message of Sun Feb 14 19:29:14 -0500 2010:
> So... I sketched this out in my head at LCA... and it's taken a bit of
> time to actually properly try it.
> 
In case anyone wanted to play around with this, I've written up my own
little implementation[1] of a git mail import script. It's quite simple,
but I felt it might be nice to have some public code to play around
with. I get around 80 messages/second on my laptop and things are
definitely quite IO bound. You get 1 commit per message, although I'm
not entirely sure if this is the correct way to do things.

- Ben


[1] git://goldnerlab.physics.umass.edu/git-mail


[notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Michal Sojka
On Tue, 16 Feb 2010 02:27:37 -0800 (PST), Jakub Narebski  
wrote:
> Michal Sojka  writes:
> 
> > I like the simple and powerful test suite used by Git and I would like
> > to use something like that in Notmuch project (http://notmuchmail.org/).
> > [...]
>
> Have you thought about using TAP (Test Anything Protocol) format for
> your testsuite?  Its page (http://testanything.org) has a TAP-producing
> bash library: http://testanything.org/wiki/index.php/Tap-functions

Yes, somebody has mentiond TAP on notmuch list. From a quick look at TAP
shell library it seems to me a bit more complex then git's library and
it also requires bash.

If we need to use some TAP-based tools, we could easily change the
output of git's library to conform to TAP. Right?

Michal


[notmuch] [rfc] improved wrapping of long lines

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 09:10:23 +, David Edmondson  wrote:
> It's annoying that the wrapping of long lines doesn't respect the
> indentation of the message. Here's an attempt to improve that.
> 
> The wrapping code is in a separate file and has a silly name[1], but all
> of that is subject to change at the whim of Carl or his minions.
> 
> If anyone tries this then I'd be interested in your feedback,
> particularly if it doesn't work or doesn't look the way that you expect.
> 
> Footnotes: 
> [1]  It's a long-line wrapper...

Here's a better version, derived from longlines.el.

-- next part --
A non-text attachment was scrubbed...
Name: 0001-notmuch.el-Improved-wrapping-of-long-lines-respect-t.patch
Type: text/x-diff
Size: 7810 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100216/028d0c9b/attachment-0001.patch>
-- next part --

dme.
-- 
David Edmondson, http://dme.org


[notmuch] [PATCH] notmuch: Respect maildir message flags

2010-02-16 Thread Stewart Smith
New patch that does it. Pretty much same as the old one, just with
that one bug I mentioned fixed. This is what I've currently used to
import my Maildir. I'm now happy :)

diff --git a/notmuch-new.c b/notmuch-new.c
index f25c71f..43371a3 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -39,6 +39,7 @@ typedef struct {
 int total_files;
 int processed_files;
 int added_messages;
+int tag_maildir;
 struct timeval tv_start;

 _filename_list_t *removed_files;
@@ -169,6 +170,60 @@ _entries_resemble_maildir (struct dirent **entries, int 
count)
 return 0;
 }

+/* Tag new mail according to its Maildir attribute flags.
+ *
+ * Test if the mail file's filename contains any of the
+ * standard Maildir attributes, and translate these to
+ * the corresponding standard notmuch tags.
+ *
+ * If the message is not marked as 'seen', or if no
+ * flags are present, tag as 'inbox, unread'.
+ */
+static void
+derive_tags_from_maildir_flags (notmuch_message_t *message,
+   const char * path)
+{
+int seen = FALSE;
+int end_of_flags = FALSE;
+size_t l = strlen(path);
+
+/* Non-experimental message flags start with this */
+char * i = strstr(path, ":2,");
+i = (i) ? i : strstr(path, "!2,"); /* This format is used on VFAT */
+if (i != NULL) {
+   i += 3;
+   for (; i < (path + l) && !end_of_flags; i++) {
+   switch (*i) {
+   case 'F' :
+   notmuch_message_add_tag (message, "flagged");
+   break;
+   case 'R': /* replied */
+   notmuch_message_add_tag (message, "answered");
+   break;
+   case 'D':
+   notmuch_message_add_tag (message, "draft");
+   break;
+   case 'S': /* seen */
+   seen = TRUE;
+   break;
+   case 'T': /* trashed */
+   notmuch_message_add_tag (message, "deleted");
+   break;
+   case 'P': /* passed */
+   notmuch_message_add_tag (message, "forwarded");
+   break;
+   default:
+   end_of_flags = TRUE;
+   break;
+   }
+   }
+}
+
+if (i == NULL || !seen) {
+   tag_inbox_and_unread (message);
+}
+}
+
 /* Examine 'path' recursively as follows:
  *
  *   o Ask the filesystem for the mtime of 'path' (fs_mtime)
@@ -222,6 +277,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 notmuch_filenames_t *db_subdirs = NULL;
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
+int maildir_detected = -1;

 if (stat (path, )) {
fprintf (stderr, "Error reading directory %s: %s\n",
@@ -301,6 +357,28 @@ add_files_recursive (notmuch_database_t *notmuch,
continue;
}

+   /* If this directory is a Maildir folder, we need to
+* ignore any subdirectories marked tmp/, and scan for
+* Maildir attributes on messages contained in the sub-
+* directories 'new' and 'cur'. */
+   if (maildir_detected != 0 &&
+   (entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
+   ((strcmp (entry->d_name, "tmp") == 0) ||
+(strcmp (entry->d_name, "new") == 0) ||
+(strcmp (entry->d_name, "cur") == 0))) {
+
+if (maildir_detected == -1) {
+  maildir_detected = _entries_resemble_maildir(fs_entries, num_fs_entries);
+}
+if (maildir_detected == 1) {
+  if (strcmp (entry->d_name, "tmp") == 0) {
+continue;
+  } else {
+state->tag_maildir = TRUE;
+  }
+}
+  }
+
next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
status = add_files_recursive (notmuch, next, state);
if (status && ret == NOTMUCH_STATUS_SUCCESS)
@@ -412,7 +490,12 @@ add_files_recursive (notmuch_database_t *notmuch,
/* success */
case NOTMUCH_STATUS_SUCCESS:
state->added_messages++;
-   tag_inbox_and_unread (message);
+   if (state->tag_maildir) {
+   derive_tags_from_maildir_flags (message,
+   entry->d_name);
+   } else {
+   tag_inbox_and_unread (message);
+   }
break;
/* Non-fatal issues (go on to next file) */
case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:


-- 
Stewart Smith


[notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Junio C Hamano
Michal Sojka  writes:

> ... You are mentioned
> as a copyright holder in test-lib.sh and t-basic.sh so I'd like to
> ask you: Would you mind using parts of these files under GPLv3?

I don't mind for the parts I wrote, which is the basic infrastructure
(output redirection, skipping certain tests, expecting failure, etc).
My blessing would be enough to relicense it if you are are going to take
the file from some old version like 04ece59 (GIT_SKIP_TESTS: allow users
to omit tests that are known to break, 2006-12-28) and base your work on
it, but otherwise it would not be nearly sufficient.

Other people worked on polishing it over time and they all hold copyright
on their parts.  Notable parts that are not mine and that are not git
specific are:

 - color output support is mostly by Pierre Habouzit 
 - valgrind support: Johannes Schindelin 
 - conditional test: Johannes Sixt 
 - summarizing the results: Sverre Rabbelier 



[notmuch] [PATCH] notmuch.el: Colour cited regions and signatures with message-cited-text-face.

2010-02-16 Thread Michal Sojka
Nice, it works for me.

On Mon, 15 Feb 2010 10:03:32 +, David Edmondson  wrote:
> This version is over-eager in marking (non-)signatures. The second call
> to 'overlay-put' needs to move inside the 'if' a line below.

Could you please send a fixed patch so that it can be applied easilly.

Michal


[notmuch] [PATCH] notmuch.el: Colour cited regions and signatures with message-cited-text-face.

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 11:22:01 +0100, Michal Sojka  wrote:
> Nice, it works for me.
> 
> On Mon, 15 Feb 2010 10:03:32 +, David Edmondson  wrote:
> > This version is over-eager in marking (non-)signatures. The second call
> > to 'overlay-put' needs to move inside the 'if' a line below.
> 
> Could you please send a fixed patch so that it can be applied easilly.

Sebastian posted one this morning.

dme.
-- 
David Edmondson, http://dme.org


[notmuch] [PATCHv2] notmuch.el: Colour cited regions and signatures with message-cited-text-face.

2010-02-16 Thread Sebastian Spaeth
From: David Edmondson 

Signed-off-by: Sebastian Spaeth 
---
This is the fixed up version as elaborated by David. I find it pretty and 
pretty useful, so applying this makes lots of sense :).

 notmuch.el |   17 ++---
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 77f36d8..4cc97de 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -761,6 +761,7 @@ is what to put on the button."
   (let* ((cite-start (match-beginning 0))
 (cite-end  (match-end 0))
 (cite-lines (count-lines cite-start cite-end)))
+   (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
(when (> cite-lines (1+ notmuch-show-citation-lines-prefix))
  (goto-char cite-start)
  (forward-line notmuch-show-citation-lines-prefix)
@@ -777,13 +778,15 @@ is what to put on the button."
   (sig-end (match-end 0))
   (sig-lines (1- (count-lines sig-start end
  (if (<= sig-lines notmuch-show-signature-lines-max)
- (notmuch-show-region-to-button
-  sig-start
-  end
-  "signature"
-  indent
-  (format notmuch-show-signature-button-format sig-lines)
-  ))
+ (progn
+   (overlay-put (make-overlay sig-start end) 'face 
'message-cited-text-face)
+   (notmuch-show-region-to-button
+sig-start
+end
+"signature"
+indent
+(format notmuch-show-signature-button-format sig-lines)
+)))

 (defun notmuch-show-markup-part (beg end depth)
   (if (re-search-forward notmuch-show-part-begin-regexp nil t)
-- 
1.6.3.3



[notmuch] [PATCH] notmuch: Respect maildir message flags

2010-02-16 Thread Michal Sojka
On Tue, 16 Feb 2010 13:21:28 +1100, Stewart Smith  
wrote:
> What about this patch (just with those few things fixed)?
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index f25c71f..8303047 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -39,6 +39,7 @@ typedef struct {
>  int total_files;
>  int processed_files;
>  int added_messages;
> +int tag_maildir;

I think notmuch_bool_t will be better than int here.

BTW what is the reason for using notmuch_bool_t instead of bool from
stdbool.h?

> @@ -222,6 +277,7 @@ add_files_recursive (notmuch_database_t *notmuch,
>  notmuch_filenames_t *db_subdirs = NULL;
>  struct stat st;
>  notmuch_bool_t is_maildir, new_directory;
> +int maildir_detected = -1;

Again, notmuch_bool_t is IMHO better. You seem only to use values -1 and
1 which is quite confusing.

>  
>  if (stat (path, )) {
>   fprintf (stderr, "Error reading directory %s: %s\n",
> @@ -301,6 +357,28 @@ add_files_recursive (notmuch_database_t *notmuch,
>   continue;
>   }
>  
> + /* If this directory is a Maildir folder, we need to
> +  * ignore any subdirectories marked tmp/, and scan for
> +  * Maildir attributes on messages contained in the sub-
> +  * directories 'new' and 'cur'. */
> + if (maildir_detected != 0 &&
> + (entry->d_type == DT_DIR || entry->d_type == DT_UNKNOWN) &&
> + ((strcmp (entry->d_name, "tmp") == 0) ||
> +  (strcmp (entry->d_name, "new") == 0) ||
> +  (strcmp (entry->d_name, "cur") == 0))) {
> +
> +if (maildir_detected == -1) {
> +  maildir_detected = _entries_resemble_maildir(fs_entries, 
> num_fs_entries);
> +}
> +if (maildir_detected == 1) {
> +  if (strcmp (entry->d_name, "tmp") == 0) {
> +continue;
> +  } else {
> +state->tag_maildir = TRUE;

You might also want to set this to FALSE somewhere. It is very unlikely,
but somebody can create non-maildir under maildir.

> @@ -412,7 +490,12 @@ add_files_recursive (notmuch_database_t *notmuch,
>   /* success */
>   case NOTMUCH_STATUS_SUCCESS:
>   state->added_messages++;
> - tag_inbox_and_unread (message);
> + if (state->tag_maildir) {
> + derive_tags_from_maildir_flags (message,
> + entry->d_name);
> + } else {
> + tag_inbox_and_unread (message);
> + }
>   break;
>   /* Non-fatal issues (go on to next file) */
>   case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:

You add the tags only to newly discovered mails. If a file is renamed
(e.g. because another mail reader removed the S flag), the tags will not
be updated. It is a question, what is the proper behavior. I personally
use something like what is in your patch and then use notmuchsync to
handle renamed files. It has only one problem - notmuchsync is quite
slow, so if this is solved in notmuch, I'd be happy.

Cheers,
 Michal


[notmuch] Mail in git

2010-02-16 Thread Michal Sojka
Hi Stewart,

On Mon, 15 Feb 2010 11:29:14 +1100, Stewart Smith  
wrote:
> Which goes from a 15GB Maildir to a 3.7GB git repo.

That's quite interesting ratio. I've tried a plain git add and git gc on
my mail store and the result was a repo of approximately 50% of mail
store size. Do you think that this difference might be caused by the way
you created the packs?

> 
> The algorithm of evenless.pl is basically:
> 1 get next directory entry
> 2 if is directory, recurse into it
> 3 write item to git (git hash-object -w)
> 4 add item to tree object
> 5 if number of items written = 1000
>   5.1 make pack of last 1000 items
> 6 goto 1

So it seems that you have all you mails in a single tree. How long it
takes to caculate difference of two trees (git diff-tree --name-status)?
This operation will be needed by "notmuch new" to determine which
files/blobs to index. I suppose it will be better if mail blobs are
stored in subtrees. If a subtree is not changed git doesn't need to
descend to it because it has the same sha1.

I think that storing mails in a similar structure as in .git/objects
(i.e. 256 subdirectories based on the first sha1 byte and file names
based on the last 39 sha1 bytes) would be reasonable.

> Next step?
> 
> Make notmuch be able to read mail out of it and add it to an index
> (oh, and some kind of verification and error checking about creating
> the git repo).

Besides using git to compact the size of mail store, another feature that
cames with git for free is synchronization. For this to work, you only
need to store tags in the repo. What might work is to store tags in
files named .tags. The tags would be stored in the files
alphabetically, one tag per line. I guess, that this way makes it easy
to merge tags during synchronization even without writing custom git
merge driver.

Onother point that must be solved if we would like to use git with
notmuch is the license problem. As it was pointed out by Carl in another
thread, Git is licensed under GPLv2 only whereas notmuch under GPLv3 and
these licences are incompatible. So I think we will need some kind of
hooks in notmuch from which external programs (git) will be called.

Cheers,
 Michal


[notmuch] "From:" value containing ':'

2010-02-16 Thread Carl Worth
On Mon, 15 Feb 2010 17:29:57 +, David Edmondson  wrote:
> Given that ';' is used as a delimiter, was the pattern supposed to
> exclude ';'?

Yes. I just pushed a commit for this. Thanks for the reminder.

-Carl

PS. I'd written this patch several days ago, but before pushing it I
wanted to add some emacs-based testing to the test suite---before doing
that I wanted to switch to the new modular test suite---before doing
that I really wanted to fix the message-pipe support in the emacs client
to actually display the output from the piped command.

So, just a not to say that I interrupted this particular yak-shave to
push this commit.


-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100216/92ab28ed/attachment.pgp>


[notmuch] [rfc] improved wrapping of long lines

2010-02-16 Thread David Edmondson
It's annoying that the wrapping of long lines doesn't respect the
indentation of the message. Here's an attempt to improve that.

The wrapping code is in a separate file and has a silly name[1], but all
of that is subject to change at the whim of Carl or his minions.

If anyone tries this then I'd be interested in your feedback,
particularly if it doesn't work or doesn't look the way that you expect.

Footnotes: 
[1]  It's a long-line wrapper...

-- next part --
A non-text attachment was scrubbed...
Name: 0001-notmuch.el-Improved-wrapping-of-long-lines-respect-t.patch
Type: text/x-diff
Size: 3413 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100216/f28285bb/attachment.patch>
-- next part --

dme.
-- 
David Edmondson, http://dme.org


[notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Jakub Narebski
Michal Sojka  writes:

> I like the simple and powerful test suite used by Git and I would like
> to use something like that in Notmuch project (http://notmuchmail.org/).
> Notmuch is licenced under GPLv3 and we think that things will be simpler
> if everything in the repository is licenced the same. You are mentioned
> as a copyright holder in test-lib.sh and t-basic.sh so I'd like to
> ask you: Would you mind using parts of these files under GPLv3?

Have you thought about using TAP (Test Anything Protocol) format for
your testsuite?  Its page (http://testanything.org) has a TAP-producing
bash library: http://testanything.org/wiki/index.php/Tap-functions

-- 
Jakub Narebski
Poland
ShadeHawk on #git


Re: [notmuch] Mail in git

2010-02-16 Thread Michal Sojka
Hi Stewart,

On Mon, 15 Feb 2010 11:29:14 +1100, Stewart Smith stew...@flamingspork.com 
wrote:
 Which goes from a 15GB Maildir to a 3.7GB git repo.

That's quite interesting ratio. I've tried a plain git add and git gc on
my mail store and the result was a repo of approximately 50% of mail
store size. Do you think that this difference might be caused by the way
you created the packs?

 
 The algorithm of evenless.pl is basically:
 1 get next directory entry
 2 if is directory, recurse into it
 3 write item to git (git hash-object -w)
 4 add item to tree object
 5 if number of items written = 1000
   5.1 make pack of last 1000 items
 6 goto 1

So it seems that you have all you mails in a single tree. How long it
takes to caculate difference of two trees (git diff-tree --name-status)?
This operation will be needed by notmuch new to determine which
files/blobs to index. I suppose it will be better if mail blobs are
stored in subtrees. If a subtree is not changed git doesn't need to
descend to it because it has the same sha1.

I think that storing mails in a similar structure as in .git/objects
(i.e. 256 subdirectories based on the first sha1 byte and file names
based on the last 39 sha1 bytes) would be reasonable.

 Next step?
 
 Make notmuch be able to read mail out of it and add it to an index
 (oh, and some kind of verification and error checking about creating
 the git repo).

Besides using git to compact the size of mail store, another feature that
cames with git for free is synchronization. For this to work, you only
need to store tags in the repo. What might work is to store tags in
files named mail-name.tags. The tags would be stored in the files
alphabetically, one tag per line. I guess, that this way makes it easy
to merge tags during synchronization even without writing custom git
merge driver.

Onother point that must be solved if we would like to use git with
notmuch is the license problem. As it was pointed out by Carl in another
thread, Git is licensed under GPLv2 only whereas notmuch under GPLv3 and
these licences are incompatible. So I think we will need some kind of
hooks in notmuch from which external programs (git) will be called.

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


[notmuch] [rfc] improved wrapping of long lines

2010-02-16 Thread David Edmondson
It's annoying that the wrapping of long lines doesn't respect the
indentation of the message. Here's an attempt to improve that.

The wrapping code is in a separate file and has a silly name[1], but all
of that is subject to change at the whim of Carl or his minions.

If anyone tries this then I'd be interested in your feedback,
particularly if it doesn't work or doesn't look the way that you expect.

Footnotes: 
[1]  It's a long-line wrapper...

From d49ff05ef86b652ec4883d7075df4fb65c846342 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Tue, 16 Feb 2010 09:03:18 +
Subject: [PATCH] notmuch.el: Improved wrapping of long lines - respect the indentation
 level.

---
 Makefile.local   |2 +-
 notmuch-coolj.el |   40 
 notmuch.el   |9 ++---
 3 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 notmuch-coolj.el

diff --git a/Makefile.local b/Makefile.local
index 04bac83..44a786a 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,4 @@
-emacs: notmuch.elc
+emacs: notmuch.elc notmuch-coolj.el
 
 notmuch_client_srcs =		\
 	$(notmuch_compat_srcs)	\
diff --git a/notmuch-coolj.el b/notmuch-coolj.el
new file mode 100644
index 000..6b4da6d
--- /dev/null
+++ b/notmuch-coolj.el
@@ -0,0 +1,40 @@
+(defgroup notmuch-coolj nil
+  Automatic wrapping of long lines when displaying notmuch articles.
+  :group 'notmuch)
+
+(defcustom notmuch-coolj-prefix-regexp  *\\(+ +\\)?
+  A regexp matching potential line prefixes.)
+
+(defun notmuch-coolj-wrap-region (beg end)
+  Wrap lines in the region.
+  (goto-char beg)
+  (forward-line -1)
+  (while (not (= (point) end))
+(notmuch-coolj-wrap-line)
+(forward-line)))
+
+(defun notmuch-coolj-wrap-line ()
+  Wrap the current line, if necessary.
+  (let ((prefix (notmuch-coolj-determine-prefix))
+	(start (point))
+	(end (make-marker))
+	(width (window-width)))
+(set-marker end (save-excursion (end-of-line) (point)))
+(while ( end (+ (point) width))
+  (forward-char (window-width))
+  (if (re-search-backward [^ ]\\( \\) start t)
+	  (progn
+	(goto-char (match-beginning 1))
+	(insert-before-markers ?\n)
+	(re-search-forward \\( +\\)[^ ] nil t)
+	(delete-region (match-beginning 1) (match-end 1))
+	(backward-char 1)
+	(insert-before-markers prefix)))
+  (beginning-of-line
+
+(defun notmuch-coolj-determine-prefix ()
+  Determine the prefix for the current line.
+  (if (looking-at notmuch-coolj-prefix-regexp)
+  (buffer-substring-no-properties (match-beginning 0) (match-end 0
+
+(provide 'notmuch-coolj)
diff --git a/notmuch.el b/notmuch.el
index ea74a72..d67b066 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -51,6 +51,8 @@
 (require 'mm-view)
 (require 'message)
 
+(require 'notmuch-coolj)
+
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
 (define-key map ? 'notmuch-help)
@@ -777,7 +779,9 @@ is what to put on the button.
   (mm-display-part mime-message
 )
 	  (if (equal mime-type text/plain)
-		  (notmuch-show-markup-citations-region beg end depth))
+		  (progn
+		(notmuch-show-markup-citations-region beg end depth)
+		(notmuch-coolj-wrap-region beg end)))
   ; Advance to the next part (if any) (so the outer loop can
   ; determine whether we've left the current message.
   (if (re-search-forward notmuch-show-buttonize-begin-regexp nil t)
@@ -1053,8 +1057,7 @@ All currently available key bindings:
 ; Make show mode a bit prettier, highlighting URLs and using word wrap
 
 (defun notmuch-show-pretty-hook ()
-  (goto-address-mode 1)
-  (visual-line-mode))
+  (goto-address-mode 1))
 
 (add-hook 'notmuch-show-hook 'notmuch-show-pretty-hook)
 (add-hook 'notmuch-search-hook
-- 
1.6.6.1


dme.
-- 
David Edmondson, http://dme.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] notmuch: Respect maildir message flags

2010-02-16 Thread Michal Sojka
On Tue, 16 Feb 2010 13:21:28 +1100, Stewart Smith stew...@flamingspork.com 
wrote:
 What about this patch (just with those few things fixed)?
 
 diff --git a/notmuch-new.c b/notmuch-new.c
 index f25c71f..8303047 100644
 --- a/notmuch-new.c
 +++ b/notmuch-new.c
 @@ -39,6 +39,7 @@ typedef struct {
  int total_files;
  int processed_files;
  int added_messages;
 +int tag_maildir;

I think notmuch_bool_t will be better than int here.

BTW what is the reason for using notmuch_bool_t instead of bool from
stdbool.h?

 @@ -222,6 +277,7 @@ add_files_recursive (notmuch_database_t *notmuch,
  notmuch_filenames_t *db_subdirs = NULL;
  struct stat st;
  notmuch_bool_t is_maildir, new_directory;
 +int maildir_detected = -1;

Again, notmuch_bool_t is IMHO better. You seem only to use values -1 and
1 which is quite confusing.

  
  if (stat (path, st)) {
   fprintf (stderr, Error reading directory %s: %s\n,
 @@ -301,6 +357,28 @@ add_files_recursive (notmuch_database_t *notmuch,
   continue;
   }
  
 + /* If this directory is a Maildir folder, we need to
 +  * ignore any subdirectories marked tmp/, and scan for
 +  * Maildir attributes on messages contained in the sub-
 +  * directories 'new' and 'cur'. */
 + if (maildir_detected != 0 
 + (entry-d_type == DT_DIR || entry-d_type == DT_UNKNOWN) 
 + ((strcmp (entry-d_name, tmp) == 0) ||
 +  (strcmp (entry-d_name, new) == 0) ||
 +  (strcmp (entry-d_name, cur) == 0))) {
 +
 +if (maildir_detected == -1) {
 +  maildir_detected = _entries_resemble_maildir(fs_entries, 
 num_fs_entries);
 +}
 +if (maildir_detected == 1) {
 +  if (strcmp (entry-d_name, tmp) == 0) {
 +continue;
 +  } else {
 +state-tag_maildir = TRUE;

You might also want to set this to FALSE somewhere. It is very unlikely,
but somebody can create non-maildir under maildir.

 @@ -412,7 +490,12 @@ add_files_recursive (notmuch_database_t *notmuch,
   /* success */
   case NOTMUCH_STATUS_SUCCESS:
   state-added_messages++;
 - tag_inbox_and_unread (message);
 + if (state-tag_maildir) {
 + derive_tags_from_maildir_flags (message,
 + entry-d_name);
 + } else {
 + tag_inbox_and_unread (message);
 + }
   break;
   /* Non-fatal issues (go on to next file) */
   case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:

You add the tags only to newly discovered mails. If a file is renamed
(e.g. because another mail reader removed the S flag), the tags will not
be updated. It is a question, what is the proper behavior. I personally
use something like what is in your patch and then use notmuchsync to
handle renamed files. It has only one problem - notmuchsync is quite
slow, so if this is solved in notmuch, I'd be happy.

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


[notmuch] [PATCHv2] notmuch.el: Colour cited regions and signatures with message-cited-text-face.

2010-02-16 Thread Sebastian Spaeth
From: David Edmondson d...@dme.org

Signed-off-by: Sebastian Spaeth sebast...@sspaeth.de
---
This is the fixed up version as elaborated by David. I find it pretty and 
pretty useful, so applying this makes lots of sense :).

 notmuch.el |   17 ++---
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 77f36d8..4cc97de 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -761,6 +761,7 @@ is what to put on the button.
   (let* ((cite-start (match-beginning 0))
 (cite-end  (match-end 0))
 (cite-lines (count-lines cite-start cite-end)))
+   (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
(when ( cite-lines (1+ notmuch-show-citation-lines-prefix))
  (goto-char cite-start)
  (forward-line notmuch-show-citation-lines-prefix)
@@ -777,13 +778,15 @@ is what to put on the button.
   (sig-end (match-end 0))
   (sig-lines (1- (count-lines sig-start end
  (if (= sig-lines notmuch-show-signature-lines-max)
- (notmuch-show-region-to-button
-  sig-start
-  end
-  signature
-  indent
-  (format notmuch-show-signature-button-format sig-lines)
-  ))
+ (progn
+   (overlay-put (make-overlay sig-start end) 'face 
'message-cited-text-face)
+   (notmuch-show-region-to-button
+sig-start
+end
+signature
+indent
+(format notmuch-show-signature-button-format sig-lines)
+)))
 
 (defun notmuch-show-markup-part (beg end depth)
   (if (re-search-forward notmuch-show-part-begin-regexp nil t)
-- 
1.6.3.3

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


Re: [notmuch] [PATCH] notmuch.el: Colour cited regions and signatures with message-cited-text-face.

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 11:22:01 +0100, Michal Sojka sojk...@fel.cvut.cz wrote:
 Nice, it works for me.
 
 On Mon, 15 Feb 2010 10:03:32 +, David Edmondson d...@dme.org wrote:
  This version is over-eager in marking (non-)signatures. The second call
  to 'overlay-put' needs to move inside the 'if' a line below.
 
 Could you please send a fixed patch so that it can be applied easilly.

Sebastian posted one this morning.

dme.
-- 
David Edmondson, http://dme.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [rfc] improved wrapping of long lines

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 09:10:23 +, David Edmondson d...@dme.org wrote:
 It's annoying that the wrapping of long lines doesn't respect the
 indentation of the message. Here's an attempt to improve that.
 
 The wrapping code is in a separate file and has a silly name[1], but all
 of that is subject to change at the whim of Carl or his minions.
 
 If anyone tries this then I'd be interested in your feedback,
 particularly if it doesn't work or doesn't look the way that you expect.
 
 Footnotes: 
 [1]  It's a long-line wrapper...

Here's a better version, derived from longlines.el.

From 0fc142a4e8fd4b8648bfdf2246759af1fc31c997 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Tue, 16 Feb 2010 13:34:29 +
Subject: [PATCH] notmuch.el: Improved wrapping of long lines - respect the indentation
 level.

---
 Makefile.local |8 ++-
 coolj.el   |  145 
 notmuch.el |8 ++-
 3 files changed, 156 insertions(+), 5 deletions(-)
 create mode 100644 coolj.el

diff --git a/Makefile.local b/Makefile.local
index 04bac83..0a1f203 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,4 +1,6 @@
-emacs: notmuch.elc
+# -*- mode:makefile -*-
+
+emacs: notmuch.elc coolj.elc
 
 notmuch_client_srcs =		\
 	$(notmuch_compat_srcs)	\
@@ -42,6 +44,8 @@ install-emacs: install emacs
 	done ;
 	install -m0644 notmuch.el $(DESTDIR)$(emacs_lispdir)
 	install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)
+	install -m0644 coolj.el $(DESTDIR)$(emacs_lispdir)
+	install -m0644 coolj.elc $(DESTDIR)$(emacs_lispdir)
 
 install-desktop:
 	install -d $(DESTDIR)$(desktop_dir)
@@ -58,4 +62,4 @@ install-zsh:
 		$(DESTDIR)$(zsh_completion_dir)/notmuch
 
 SRCS  := $(SRCS) $(notmuch_client_srcs)
-CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc notmuch.1.gz
+CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc coolj.elc notmuch.1.gz
diff --git a/coolj.el b/coolj.el
new file mode 100644
index 000..77187dc
--- /dev/null
+++ b/coolj.el
@@ -0,0 +1,145 @@
+;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
+
+;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+;; Authors:Kai Grossjohann kai.grossjoh...@cs.uni-dortmund.de
+;; Alex Schroeder a...@gnu.org
+;; Chong Yidong c...@stupidchicken.com
+;; Maintainer: David Edmondson d...@dme.org
+;; Keywords: convenience, wp
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs 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.
+
+;; GNU Emacs 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 GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;;; This is a simple derivative of some functionality from
+;;; `longlines.el'. The key difference is that this version will
+;;; insert a prefix at the head of each wrapped line. The prefix is
+;;; calculated from the originating long line.
+
+;;; No minor-mode is provided, the caller is expected to call
+;;; `coolj-wrap-region' to wrap the region of interest.
+
+;;; Code:
+
+(defgroup coolj nil
+  Wrapping of long lines with prefix.
+  :group 'fill)
+
+(defcustom coolj-wrap-follows-window-size t
+  Non-nil means wrap text to the window size.
+Otherwise respect `fill-column'.
+  :group 'coolj
+  :type 'boolean)
+
+(defcustom coolj-line-prefix-regexp ^ *\\(+ \\)*
+  Regular expression that matches line prefixes.
+  :group 'coolj
+  :type 'regexp)
+
+(defvar coolj-wrap-point nil)
+
+(make-variable-buffer-local 'coolj-wrap-point)
+
+(defun coolj-determine-prefix ()
+  Determine the prefix for the current line.
+  (save-excursion
+(beginning-of-line)
+(if (re-search-forward coolj-line-prefix-regexp nil t)
+	(buffer-substring (match-beginning 0) (match-end 0))
+  )))
+
+(defun coolj-wrap-buffer ()
+  Wrap the current buffer.
+  (coolj-wrap-region (point-min) (point-max)))
+
+(defun coolj-wrap-region (beg end)
+  Wrap each successive line, starting with the line before BEG.
+Stop when we reach lines after END that don't need wrapping, or the
+end of the buffer.
+  (setq fill-column (if coolj-wrap-follows-window-size
+			(window-width)
+		  fill-column))
+  (let ((mod (buffer-modified-p)))
+(setq coolj-wrap-point (point))
+(goto-char beg)
+(forward-line -1)
+;; Two successful coolj-wrap-line's in a row mean successive
+;; lines don't need wrapping.
+(while (null (and (coolj-wrap-line)
+		  (or (eobp)
+			  (and (= (point) end)
+			   (coolj-wrap-line))
+ 

Re: [notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Jakub Narebski
Michal Sojka sojk...@fel.cvut.cz writes:

 I like the simple and powerful test suite used by Git and I would like
 to use something like that in Notmuch project (http://notmuchmail.org/).
 Notmuch is licenced under GPLv3 and we think that things will be simpler
 if everything in the repository is licenced the same. You are mentioned
 as a copyright holder in test-lib.sh and t-basic.sh so I'd like to
 ask you: Would you mind using parts of these files under GPLv3?

Have you thought about using TAP (Test Anything Protocol) format for
your testsuite?  Its page (http://testanything.org) has a TAP-producing
bash library: http://testanything.org/wiki/index.php/Tap-functions

-- 
Jakub Narebski
Poland
ShadeHawk on #git
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] From: value containing ':'

2010-02-16 Thread Carl Worth
On Mon, 15 Feb 2010 17:29:57 +, David Edmondson d...@dme.org wrote:
 Given that ';' is used as a delimiter, was the pattern supposed to
 exclude ';'?

Yes. I just pushed a commit for this. Thanks for the reminder.

-Carl

PS. I'd written this patch several days ago, but before pushing it I
wanted to add some emacs-based testing to the test suite---before doing
that I wanted to switch to the new modular test suite---before doing
that I really wanted to fix the message-pipe support in the emacs client
to actually display the output from the piped command.

So, just a not to say that I interrupted this particular yak-shave to
push this commit.




pgpBjkJmJcywW.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] Look for text/html content types ignoring case

2010-02-16 Thread James Westby
Some people send html parts as text/HTML or similar, so do a
case-sensitive comparison when checking for html parts.
---
 notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 0f4ea10..b69c334 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -736,7 +736,7 @@ is what to put on the button.
 (setq mime-type (car (split-string (buffer-substring 
 (match-beginning 1) (match-end 
1))
 
-  (if (equal mime-type text/html)
+  (if (equal (downcase mime-type) text/html)
   (let ((filename (notmuch-show-get-filename)))
 (with-temp-buffer
   (insert-file-contents filename nil nil nil t)
-- 
1.6.6.1

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


Re: [notmuch] [PATCH] Look for text/html content types ignoring case

2010-02-16 Thread David Edmondson
On Tue, 16 Feb 2010 18:51:00 +, James Westby jw+deb...@jameswestby.net 
wrote:
 Some people send html parts as text/HTML or similar, so do a
 case-sensitive comparison when checking for html parts.

There are various other places where `equal' is used to compare MIME
types with strings. Shouldn't they all be fixed? (I see TEXT/PLAIN
frequently.)

dme.
-- 
David Edmondson, http://dme.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH v2] notmuch.el: add functionality in notmuch search mode to add or remove tags by region

2010-02-16 Thread Jesse Rosenthal
This patch adds `-region' versions of the `notmuch-search-' commands to find
properties. It also splits up  `notmuch-add/remove-tags' into both a
`-thread' and a `-region' version. (This makes us modify
`notmuch-search-archive-thread' to use the
`notmuch-search-remove-tag-thread' function, instead of
`notmuch-search-remove-tag', for consistency.) The add/remove-tag command
called by pressing `+' or `-' will then choose accordingly, based on whether
region is active.

This version fixes a couple of errors in the first version, which led to
incorrect marking of some tags in the search view (though the actual
tagging was still correct). It's also based on current master.

I'm not sure any more if region selection is actually the correct way to
do this, or if a mutt-style message-marking method would be better. But
I didn't want a buggy incorrect version out there.
---
 notmuch.el |   98 +---
 1 files changed, 87 insertions(+), 11 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 0f4ea10..7d9a82f 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1227,18 +1227,41 @@ Complete list of currently available key bindings:
   (set (make-local-variable 'font-lock-defaults)
  '(notmuch-search-font-lock-keywords t)))
 
+(defun notmuch-search-properties-in-region (property beg end)
+  (save-excursion
+(let ((output nil)
+ (last-line (line-number-at-pos end)))
+  (goto-char beg)
+  (beginning-of-line)
+  (while (= (line-number-at-pos) last-line)
+   (setq output (cons (get-text-property (point) property) output))
+   (forward-line 1))
+  output)))
+
 (defun notmuch-search-find-thread-id ()
   Return the thread for the current thread
   (get-text-property (point) 'notmuch-search-thread-id))
 
+(defun notmuch-search-find-thread-id-region (beg end)
+  Return a list of threads for the current region
+  (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))
+
 (defun notmuch-search-find-authors ()
   Return the authors for the current thread
   (get-text-property (point) 'notmuch-search-authors))
 
+(defun notmuch-search-find-authors-region (beg end)
+  Return a list of authors for the current region
+  (notmuch-search-properties-in-region 'notmuch-search-authors beg end))
+
 (defun notmuch-search-find-subject ()
   Return the subject for the current thread
   (get-text-property (point) 'notmuch-search-subject))
 
+(defun notmuch-search-find-subject-region (beg end)
+  Return a list of authors for the current region
+  (notmuch-search-properties-in-region 'notmuch-search-subject beg end))
+
 (defun notmuch-search-show-thread ()
   Display the currently selected thread.
   (interactive)
@@ -1292,32 +1315,85 @@ and will also appear in a buffer named \*Notmuch 
errors*\.
   (let ((end (- (point) 1)))
(split-string (buffer-substring beg end))
 
+(defun notmuch-search-get-tags-region (beg end)
+  (save-excursion
+(let ((output nil)
+ (last-line (line-number-at-pos end)))
+  (goto-char beg)
+  (while (= (line-number-at-pos) last-line)
+   (setq output (append output (notmuch-search-get-tags)))
+   (forward-line 1))
+  output)))
+
+(defun notmuch-search-add-tag-thread (tag)
+  (notmuch-call-notmuch-process tag (concat + tag) 
(notmuch-search-find-thread-id))
+  (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string
+
+(defun notmuch-search-add-tag-region (tag beg end)
+  (let ((search-id-string (mapconcat 'identity 
(notmuch-search-find-thread-id-region beg end)  or )))
+(notmuch-call-notmuch-process tag (concat + tag) search-id-string)
+(save-excursion
+  (let ((last-line (line-number-at-pos end)))
+   (goto-char beg)
+   (while (= (line-number-at-pos) last-line)
+ (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string)))
+ (forward-line))
+
+(defun notmuch-search-remove-tag-thread (tag)
+  (notmuch-call-notmuch-process tag (concat - tag) 
(notmuch-search-find-thread-id))
+  (notmuch-search-set-tags (delete tag (notmuch-search-get-tags
+
+(defun notmuch-search-remove-tag-region (tag beg end)
+  (let ((search-id-string (mapconcat 'identity 
(notmuch-search-find-thread-id-region beg end)  or )))
+(notmuch-call-notmuch-process tag (concat - tag) search-id-string)
+(save-excursion
+  (let ((last-line (line-number-at-pos end)))
+   (goto-char beg)
+   (while (= (line-number-at-pos) last-line)
+ (notmuch-search-set-tags (delete tag (notmuch-search-get-tags)))
+ (forward-line))
+
+
 (defun notmuch-search-add-tag (tag)
-  Add a tag to the currently selected thread.
+  Add a tag to the currently selected thread or region.
 
-The tag is added to messages in the currently selected thread
-which match the current search terms.
+The tag is added to messages in the currently selected thread or
+region which match the current 

Re: [notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Jakub Narebski
Dnia wtorek 16. lutego 2010 14:06, Michal Sojka napisał:
 On Tue, 16 Feb 2010 02:27:37 -0800 (PST), Jakub Narebski jna...@gmail.com 
 wrote:
  Michal Sojka sojk...@fel.cvut.cz writes:
  
   I like the simple and powerful test suite used by Git and I would like
   to use something like that in Notmuch project (http://notmuchmail.org/).
   [...]
 
  Have you thought about using TAP (Test Anything Protocol) format for
  your testsuite?  Its page (http://testanything.org) has a TAP-producing
  bash library: http://testanything.org/wiki/index.php/Tap-functions
 
 Yes, somebody has mentiond TAP on notmuch list. From a quick look at TAP
 shell library it seems to me a bit more complex then git's library and
 it also requires bash.
 
 If we need to use some TAP-based tools, we could easily change the
 output of git's library to conform to TAP. Right?

Or better yet improve git test suite, so when passed --tap parameter
it would produce TAP output, instead of its own report format.  And
send patches here.

-- 
Jakub Narebski
Poland
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] Mail in git

2010-02-16 Thread martin f krafft
also sprach Stewart Smith stew...@flamingspork.com [2010.02.15.1329 +1300]:
 What about adding more mail to the archive?
 
 So the way I think is that you use a Maildir for day to day mail
 (e.g. delivery) and every so often you run some magic command that
 takes old mail out of the Maildir and stores it in the git repo.

Either that, or the other idea we had (which I prefer), which would
basically be:

  evenless-submit — add a new mail (and return a hash ID)
and invoke a hook, e.g. to let notmuch know
  evenless-cat— print the full mail given ID with headers to stdout
  evenless-delete — unlink a mail identified by hash ID
and invoke a hook, e.g. to let notmuch know

If we expose the submit and delete functionality at the notmuch
level, then we don't need the hooks for then evenless would be
plumbing.

Anything to avoid a cronjob would be good, I think.

Then we need a notmuch backend for mutt etc.. For those who still
want to use a regular Maildir, let them use the worktree.

What I am wondering is if (explicit) tags couldn't be represented as
tree-objects with this.

  evenless-link   — link a message object with a tree object
  evenless–unlink – unlink a message object from tree object
[replaces evenless-unlink]

messages would then be deleted whenever using git-gc.

No idea how this would sync if we don't keep ancestry. Otoh, it
would probably not be very expensive to do just that.

notmuch would then only search and provide the hash ID(s); tags
would be a function of storage.

Is it possible to find out all trees that reference a given object
with Git in constant or sub-linear time?

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
the question of whether computers can think
 is like the question of whether submarines can swim.
 -- edsgar w. dijkstra
 
spamtraps: madduck.bo...@madduck.net


digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Junio C Hamano
Michal Sojka sojk...@fel.cvut.cz writes:

 ... You are mentioned
 as a copyright holder in test-lib.sh and t-basic.sh so I'd like to
 ask you: Would you mind using parts of these files under GPLv3?

I don't mind for the parts I wrote, which is the basic infrastructure
(output redirection, skipping certain tests, expecting failure, etc).
My blessing would be enough to relicense it if you are are going to take
the file from some old version like 04ece59 (GIT_SKIP_TESTS: allow users
to omit tests that are known to break, 2006-12-28) and base your work on
it, but otherwise it would not be nearly sufficient.

Other people worked on polishing it over time and they all hold copyright
on their parts.  Notable parts that are not mine and that are not git
specific are:

 - color output support is mostly by Pierre Habouzit madco...@debian.org
 - valgrind support: Johannes Schindelin johannes.schinde...@gmx.de
 - conditional test: Johannes Sixt j...@kdbg.org
 - summarizing the results: Sverre Rabbelier srabbel...@gmail.com

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


Re: [notmuch] Using test-lib.sh under GPLv3?

2010-02-16 Thread Avery Pennarun
On Tue, Feb 16, 2010 at 8:06 AM, Michal Sojka sojk...@fel.cvut.cz wrote:
 On Tue, 16 Feb 2010 02:27:37 -0800 (PST), Jakub Narebski jna...@gmail.com 
 wrote:
 Michal Sojka sojk...@fel.cvut.cz writes:

  I like the simple and powerful test suite used by Git and I would like
  to use something like that in Notmuch project (http://notmuchmail.org/).
  [...]

 Have you thought about using TAP (Test Anything Protocol) format for
 your testsuite?  Its page (http://testanything.org) has a TAP-producing
 bash library: http://testanything.org/wiki/index.php/Tap-functions

 Yes, somebody has mentiond TAP on notmuch list. From a quick look at TAP
 shell library it seems to me a bit more complex then git's library and
 it also requires bash.

 If we need to use some TAP-based tools, we could easily change the
 output of git's library to conform to TAP. Right?

Another TAP-like option is wvtest:

   http://github.com/apenwarr/wvtest

It's LGPLv2.

Have fun,

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