[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Mark Walters

This looks fine to me (but I am not a lisp expert).

Mark

On Sat, 10 Mar 2012, Dmitry Kurochkin  wrote:
> This patch removes trailing spaces in notmuch-hello view.
>
> A side effect of this change is that tag/query buttons no longer
> include a space at the end.  This means that pressing RET when the
> point is at the first character after the tag/query button no longer
> works (note that this is the standard behavior for buttons).  We may
> change this behavior in the future (without adding trailing spaces
> back) if people would find this change inconvenient.
> ---
>  emacs/notmuch-hello.el |   30 
> 
>  test/emacs |2 +-
>  test/emacs.expected-output/notmuch-hello   |2 +-
>  .../emacs.expected-output/notmuch-hello-long-names |6 ++--
>  .../notmuch-hello-new-section  |2 +-
>  .../notmuch-hello-section-counts   |4 +-
>  .../notmuch-hello-section-hidden-tag   |2 +-
>  .../notmuch-hello-section-with-empty   |2 +-
>  .../emacs.expected-output/notmuch-hello-with-empty |2 +-
>  9 files changed, 23 insertions(+), 29 deletions(-)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 28f39f1..17f7edd 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -429,7 +429,8 @@ Such a list can be computed with 
> `notmuch-hello-query-counts'."
>(let* ((widest (notmuch-hello-longest-label searches))
>(tags-and-width (notmuch-hello-tags-per-line widest))
>(tags-per-line (car tags-and-width))
> -  (widest (cdr tags-and-width))
> +  (column-width (cdr tags-and-width))
> +  (column-indent 0)
>(count 0)
>(reordered-list (notmuch-hello-reflect searches tags-per-line))
>;; Hack the display of the buttons used.
> @@ -441,32 +442,25 @@ Such a list can be computed with 
> `notmuch-hello-query-counts'."
>  (mapc (lambda (elem)
>   ;; (not elem) indicates an empty slot in the matrix.
>   (when elem
> +   (if (> column-indent 0)
> +   (widget-insert (make-string column-indent ? )))
> (let* ((name (first elem))
>(query (second elem))
> -  (msg-count (third elem))
> -  (formatted-name (format "%s " name)))
> +  (msg-count (third elem)))
>   (widget-insert (format "%8s "
>  (notmuch-hello-nice-number msg-count)))
> - (if (string= formatted-name notmuch-hello-target)
> + (if (string= name notmuch-hello-target)
>   (setq found-target-pos (point-marker)))
>   (widget-create 'push-button
>  :notify #'notmuch-hello-widget-search
>  :notmuch-search-terms query
> -formatted-name)
> - (unless (eq (% count tags-per-line) (1- tags-per-line))
> -   ;; If this is not the last tag on the line, insert
> -   ;; enough space to consume the rest of the column.
> -   ;; Because the button for the name is `(1+ (length
> -   ;; name))' long (due to the trailing space) we can
> -   ;; just insert `(- widest (length name))' spaces - the
> -   ;; column separator is included in the button if
> -   ;; `(equal widest (length name)'.
> -   (widget-insert (make-string (max 0
> -(- widest (length name)))
> -   ? )
> +name)
> + (setq column-indent
> +   (1+ (max 0 (- column-width (length name)))
>   (setq count (1+ count))
> - (if (eq (% count tags-per-line) 0)
> - (widget-insert "\n")))
> + (when (eq (% count tags-per-line) 0)
> +   (setq column-indent 0)
> +   (widget-insert "\n")))
> reordered-list)
>  
>  ;; If the last line was not full (and hence did not include a
> diff --git a/test/emacs b/test/emacs
> index 29a489c..42780af 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search 
> results"
>  test_emacs '(notmuch-hello)
>   (goto-char (point-min))
>   (re-search-forward "inbox")
> - (widget-button-press (point))
> + (widget-button-press (1- (point)))
>   (notmuch-test-wait)
>   (test-output)'
>  test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
> diff --git a/test/emacs.expected-output/notmuch-hello 
> b/test/emacs.expected-output/notmuch-hello
> index 1470790..2d69891 100644
> --- a/test/emacs.expected-output/notmuch-hello
> +++ b/test/emacs.expected-output/notmuch-hello
> @@ -2,7 +2,7 @@
>  
>  Saved searches: [edit]
>  
> -   

[PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread Vladimir Marek
Hi,

> Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
> that's supposed to provide type safety (at least with GCC), and I'd be
> hesitant about adding the casts. Please look in your talloc.h.

It does not compile. It might be that I'm using Sun/Oracle CC instead of
gcc. The error looks like this:

"lib/database.cc", line 1368: Error: Cannot assign void* to const char*.


When looking into talloc documentation, the definition seems to be:

void* talloc_steal ( const void * new_ctx, const void * ptr )

http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c


When looking into talloc.h, it says:

/* try to make talloc_set_destructor() and talloc_steal() type safe,
   if we have a recent gcc */

So, maybe the way to satisfy everyone would be:

notmuch_message_t *tmp_message = message;
talloc_steal(notmuch, tmp_message);
return(tmp_message);

Or alternatively,

#if (__GNUC__ >= 3)
   return talloc_steal (notmuch, message);
#else
   return (notmuch_message_t*) talloc_steal (notmuch, message);
#fi


Of course I'm happy either way :)

Thank you
-- 
Vlad


bug fixes to emacs notmuch-tag-completion function

2012-04-09 Thread Mark Walters

All three of these look good to me and include some genuine bug
fixes. +1

Best wishes

Mark

On Mon, 09 Apr 2012, Jameson Graef Rollins  
wrote:
> I had originally included this fixes as part of a more involved series
> to fix up tagging functions [0].  However, these are actually bug
> fixes that stand alone and should not be bogged down in a series
> that's likely going to take a while to come to fruition.  The changes
> here are pretty trivial, so hopefully they can get pushed quickly and
> I'll rework the rest of tagging fix up series on top of them.
>
> jamie.
>
> [0] id:"154853-25729-1-git-send-email-jrollins at finestructure.net"
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 7/8] emacs: modify show tag functions to use new notmuch-tag interface

2012-04-09 Thread Mark Walters
On Sun, 08 Apr 2012, Jameson Graef Rollins  
wrote:
> The main change here is to modify argument parsing so as to not force
> tag-changes to be a list, and to let notmuch-tag handle prompting the
> user when required.  doc strings are also updated and cleaned up.

One other comment on this patch is that it would be nice to have a tag
region in show view as well. Of course that is a feature request rather
than a requirement for this patch series!

Best wishes

Mark

> ---
>  emacs/notmuch-show.el |   26 +++---
>  1 files changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index a4c313d..69bca02 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1641,22 +1641,26 @@ TAG-CHANGES is a list of tag operations for 
> `notmuch-tag'."
>(let* ((current-tags (notmuch-show-get-tags))
>(new-tags (notmuch-update-tags current-tags tag-changes)))
>  (unless (equal current-tags new-tags)
> -  (apply 'notmuch-tag (notmuch-show-get-message-id) tag-changes)
> +  (funcall 'notmuch-tag (notmuch-show-get-message-id) tag-changes)
>(notmuch-show-set-tags new-tags
>  
> -(defun notmuch-show-tag ( initial-input)
> -  "Change tags for the current message, read input from the minibuffer."
> +(defun notmuch-show-tag ( tag-changes)
> +  "Change tags for the current message.
> +
> +See `notmuch-tag' for information on the format of TAG-CHANGES."
>(interactive)
> -  (let ((tag-changes (notmuch-read-tag-changes
> -   initial-input (notmuch-show-get-message-id
> -(apply 'notmuch-show-tag-message tag-changes)))
> +  (setq tag-changes (funcall 'notmuch-tag (notmuch-show-get-message-id) 
> tag-changes))
> +  (let* ((current-tags (notmuch-show-get-tags))
> +  (new-tags (notmuch-update-tags current-tags tag-changes)))
> +(unless (equal current-tags new-tags)
> +  (notmuch-show-set-tags new-tags
>  
> -(defun notmuch-show-tag-all ( tag-changes)
> -  "Change tags for all messages in the current buffer.
> +(defun notmuch-show-tag-all ( tag-changes)
> +  "Change tags for all messages in the current show buffer.
>  
> -TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> -  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> +See `notmuch-tag' for information on the format of TAG-CHANGES."
> +  (interactive)
> +  (setq tag-changes (funcall 'notmuch-tag 
> (notmuch-show-get-messages-ids-search) tag-changes))
>(notmuch-show-mapc
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5/8] emacs: modify search tag functions to use new notmuch-tag interface

2012-04-09 Thread Mark Walters
On Sun, 08 Apr 2012, Jameson Graef Rollins  
wrote:
> The main change here is to modify argument parsing so as to not force
> tag-changes to be a list, and to let notmuch-tag handle prompting the
> user when required.  doc strings are also updated and cleaned up.
> ---
>  emacs/notmuch.el |   36 +---
>  1 files changed, 13 insertions(+), 23 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 9aec96d..a03a526 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -523,13 +523,10 @@ and will also appear in a buffer named \"*Notmuch 
> errors*\"."
>  See `notmuch-search-tag-region' for details."
>(apply 'notmuch-search-tag-region (point) (point) tag-changes))
>  
> -(defun notmuch-search-tag-region (beg end  tag-changes)
> -  "Change tags for threads in the given region.
> -
> -TAGS is a list of tag operations for `notmuch-tag'.  The tags are
> -added or removed for all threads in the region from BEG to END."
> +(defun notmuch-search-tag-region (beg end  tag-changes)
> +  "Change tags for threads in the given region."
>(let ((search-string (notmuch-search-find-thread-id-region-search beg 
> end)))
> -(apply 'notmuch-tag search-string tag-changes)
> +(setq tag-changes (funcall 'notmuch-tag search-string tag-changes))
>  (save-excursion
>(let ((last-line (line-number-at-pos end))
>   (max-line (- (line-number-at-pos (point-max)) 2)))
> @@ -539,14 +536,14 @@ added or removed for all threads in the region from BEG 
> to END."
>  (notmuch-update-tags (notmuch-search-get-tags) tag-changes))
> (forward-line))
>  
> -(defun notmuch-search-tag ( initial-input)
> -  "Change tags for the currently selected thread or region."
> +(defun notmuch-search-tag ( tag-changes)
> +  "Change tags for the currently selected thread or region.
> +
> +See `notmuch-tag' for information on the format of TAG-CHANGES."
>(interactive)
>(let* ((beg (if (region-active-p) (region-beginning) (point)))
> -  (end (if (region-active-p) (region-end) (point)))
> -  (search-string (notmuch-search-find-thread-id-region-search beg end))
> -  (tags (notmuch-read-tag-changes initial-input search-string)))
> -(apply 'notmuch-search-tag-region beg end tags)))
> +  (end (if (region-active-p) (region-end) (point
> +(funcall 'notmuch-search-tag-region beg end tag-changes)))
>  
>  (defun notmuch-search-add-tag ()
>"Same as `notmuch-search-tag' but sets initial input to '+'."
> @@ -790,18 +787,11 @@ non-authors is found, assume that all of the authors 
> match."
> (goto-char found-target)))
>(delete-process proc
>  
> -(defun notmuch-search-tag-all ( tag-changes)
> -  "Add/remove tags from all matching messages.
> +(defun notmuch-search-tag-all ( tag-changes)
> +  "Add/remove tags from all messages in current search buffer.
>  
> -This command adds or removes tags from all messages matching the
> -current search terms. When called interactively, this command
> -will prompt for tags to be added or removed. Tags prefixed with
> -'+' will be added and tags prefixed with '-' will be removed.
> -
> -Each character of the tag name may consist of alphanumeric
> -characters as well as `_.+-'.
> -"
> -  (interactive (notmuch-read-tag-changes))
> +See `notmuch-tag' for information on the format of TAG-CHANGES."
> +  (interactive)
>(apply 'notmuch-tag notmuch-search-query-string tag-changes))

My only comment here is that I wonder about the tag-all command. I can
see that this is a performance win over applying tag region to the whole
buffer but is it another place where we have a race with incoming mail
(ie we tag everything that now matches rather than everything in the
buffer).

A second advantage with the tag-region form is that it automatically
does excludes. Currently notmuch-tag does not do excludes as it looked
very hairy to implement correctly: thus the tag-all command could spend
a lot of time tagging excluded messages.

OTOH this seems to be a "feature" of the existing code so a "fix" is not
required for this series.

(Note I would not consider this a full review as my lisp is not good
enough; eg I am unsure  why the change from apply to funcall was
needed).

Best wishes

Mark

>  
>  (defun notmuch-search-buffer-title (query)
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Dmitry Kurochkin
David Bremner  writes:

> Dmitry Kurochkin  writes:
>
>> I am going to remove needs-review tag from this one since there seems to
>> be no one interested in reviewing it.  The patch itself may not be
>> trivial, but it is pretty simple and does not make any critical changes.
>> So I believe it is safe to push it.  If there are any issues with the
>> patch discovered later, I am committed to fix them.
>
> Sorry, but if I can't take in the patch at a glance, it needs some
> review before I am willing to push it.
>

Ok.  Tagged as needs-review again.  Let's see if I can attract some
attention to the patch on IRC.

Regards,
  Dmitry

> d


[PATCH 7/8] emacs: modify show tag functions to use new notmuch-tag interface

2012-04-09 Thread Mark Walters
On Mon, 09 Apr 2012, Jameson Graef Rollins  
wrote:
> On Sat, Apr 07 2012, Mark Walters  wrote:
>> I think this is what is making the two tests fail: they count the number
>> of invocations of notmuch and in case there is one invocation of notmuch
>> show and one of notmuch tag -unread message-id, where before it was just
>> the single notmuch show.
>
> Good call, Mark.  After a bit of testing it looks like that is what's
> going on.  I was confused, since I had thought that the call to
> notmuch-show should have involved two notmuch calls originally as well,
> one for retrieving the message and the other removing the unread tag.
> However, it appears the messages in those tests don't have unread tags
> after all.  Not sure why, but that explains it.
>
> So I guess the upshot is that moving all the common prompting and tag
> validation stuff into notmuch-tag means that in certain cases there will
> be extra notmuch calls, even if no tags are changed.  Is that a problem?
>
> What I can do, though, is add extra validation to notmuch-tag to not
> actually call notmuch tag, or any of the pre- and post- tagging hooks,
> if no tags are changing.  This will still require one call to notmuch to
> retrieve the current set of tags for the query, but at least it wont tag
> or call the hooks if nothing is changing.  That seems reasonable to me,
> but please let me know if you think it's not.
>
> I've pasted below a new version of notmuch-tag that addresses these
> issues.  Let me know what you think, and I'll resubmit the series.
>
> jamie.
>
>
> (defun notmuch-tag (query  tag-changes)
>   "Add/remove tags in TAG-CHANGES to messages matching QUERY.
>
> QUERY should be a string containing the search-terms.
> TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of
> strings of the form \"+tag\" or \"-tag\" then those are the tag
> changes applied.  If TAG-CHANGES is a string then it is
> interpreted as a single tag change.  If TAG-CHANGES is the string
> \"-\" or \"+\", or null, then the user is prompted to enter the
> tag changes.
>
> Note: Other code should always use this function alter tags of
> messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
> directly, so that hooks specified in notmuch-before-tag-hook and
> notmuch-after-tag-hook will be run."
>   ;; Perform some validation
>   (if (string-or-null-p tag-changes)
>   (if (or (string= tag-changes "-") (string= tag-changes "+") (null 
> tag-changes))
> (setq tag-changes (notmuch-read-tag-changes tag-changes query))
>   (setq tag-changes (list tag-changes
>   (mapc (lambda (tag-change)
> (unless (string-match-p "^[-+]\\S-+$" tag-change)
>   (error "Tag must be of the form `+this_tag' or `-that_tag'")))
>   tag-changes)
>   (let* ((current-tags (notmuch-tag-completions (list query)))
>(new-tags (notmuch-update-tags current-tags tag-changes)))
> (if (equal current-tags new-tags)
>   ;; if no tags are changing, return nil
>   nil
>   (run-hooks 'notmuch-before-tag-hook)
>   (apply 'notmuch-call-notmuch-process "tag"
>(append tag-changes (list "--" query)))
>   (run-hooks 'notmuch-after-tag-hook)
>   ;; otherwise, return the list of actual changed tags
>   tag-changes)))

Does this actually do the right thing if tagging more than one message?
It looks to me like it would go wrong if you tried +inbox to a thread
where some messages already have tag inbox (but I could be confused)?

Also, I was going to say that I was not sure there was much point in
optimising in the emacs code when the cli does anyway, but there is a
question with xapian locking: with the orginally posted patch you can't
use n or p in show view while the database is locked (eg a background
notmuch new) as you get "A Xapian exception occurred opening database:
Unable to get write lock on ..."

Possibly, you could pass a current-tags variable to notmuch tag (and it
would not add anything in that list or delete anything not in the
list). But the 2 code paths might be viewed as being too different to be
worth unifying. Or possibly have a "tag-single-message" command? 

Best wishes

Mark



[PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-09 Thread David Bremner

Hi Taylor, and thanks for the patch.

In general for notmuch patches we prefer

- some kind of commit message beyond the one line summary explaining the
rationale for the change.

- not to have unrelated changes (/usr/bin/env perl) in the patch.

d




[PATCH 2/8] emacs: update tag-completion function

2012-04-09 Thread Mark Walters
On Sun, 08 Apr 2012, Jameson Graef Rollins  
wrote:
> "search-tags" is deprecated, so we move to the more modern and
> supported "search --output=tags".
> ---
>  emacs/notmuch-tag.el |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
> index 81b4b00..5240d13 100644
> --- a/emacs/notmuch-tag.el
> +++ b/emacs/notmuch-tag.el
> @@ -59,7 +59,7 @@ the messages that were tagged"
> (with-output-to-string
>   (with-current-buffer standard-output
> (apply 'call-process notmuch-command nil t
> -   nil "search-tags" search-terms)))
> +   nil "search" "--output=tags" search-terms)))

Perhaps make this 
  + nil "search" "--output=tags" "--exclude=false" search-terms)))

to fix the existing bug that if the message is excluded the completion
can get confused. Or I can submit that separately if you prefer.

Best wishes

Mark

> "\n+" t))
>  
>  (defun notmuch-select-tag-with-completion (prompt  search-terms)
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] dirent->d_type not available on Soalris

2012-04-09 Thread vladimir.ma...@oracle.com
From: Vladimir Marek 

The inspiration was taken from similar issue in mutt:
http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html

Signed-off-by: Vladimir Marek 
---
 notmuch-new.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 4f13535..3d265bd 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -21,6 +21,9 @@
 #include "notmuch-client.h"

 #include 
+#ifndef _DIRENT_HAVE_D_TYPE
+#include 
+#endif

 typedef struct _filename_node {
 char *filename;
@@ -167,7 +170,14 @@ _entries_resemble_maildir (struct dirent **entries, int 
count)
 int i, found = 0;

 for (i = 0; i < count; i++) {
+#ifdef _DIRENT_HAVE_D_TYPE
if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)
+#else
+   struct stat statbuf;
+   if (stat(entries[i]->d_name, ) == -1)
+   continue;
+   if (! S_ISDIR(statbuf.st_mode))
+#endif
continue;

if (strcmp(entries[i]->d_name, "new") == 0 ||
@@ -258,6 +268,9 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
 const char **tag;
+#ifndef _DIRENT_HAVE_D_TYPE
+struct stat statbuf;
+#endif

 if (stat (path, )) {
fprintf (stderr, "Error reading directory %s: %s\n",
@@ -328,9 +341,16 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
+#ifdef _DIRENT_HAVE_D_TYPE
if (entry->d_type != DT_DIR &&
entry->d_type != DT_LNK &&
entry->d_type != DT_UNKNOWN)
+#else
+   if (stat(entry->d_name, ) == -1)
+   continue;
+   if (!(statbuf.st_mode & S_IFDIR) &&
+   !(statbuf.st_mode & S_IFLNK))
+#endif
{
continue;
}
@@ -427,7 +447,11 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
+#ifdef _DIRENT_HAVE_D_TYPE
if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
+#else
+   if (stat(entry->d_name, ) == -1 || statbuf.st_mode & S_IFLNK) {
+#endif
int err;

next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
@@ -443,7 +467,11 @@ add_files_recursive (notmuch_database_t *notmuch,

if (! S_ISREG (st.st_mode))
continue;
+#ifdef _DIRENT_HAVE_D_TYPE
} else if (entry->d_type != DT_REG) {
+#else
+   } else if (statbuf.st_mode & S_IFREG) {
+#endif
continue;
}

-- 
1.7.3.2



[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Dmitry Kurochkin
Hi all.

I am going to remove needs-review tag from this one since there seems to
be no one interested in reviewing it.  The patch itself may not be
trivial, but it is pretty simple and does not make any critical changes.
So I believe it is safe to push it.  If there are any issues with the
patch discovered later, I am committed to fix them.

Regards,
  Dmitry


[PATCH 2/4] dirent->d_type not available on Soalris

2012-04-09 Thread Vladimir Marek
> Notmuch new is possibly one of the most performance critical bits for
> people with, uh, much mail. The performance impact of the new syscalls
> should be measured. (Can't do this myself atm.)

Fair enough. Is there some performance test suite? Another way would be
to make this compile time option set by configure. Used only when the
system in question does not have dirent->d_type member.

-- 
Vlad


Message deletion wisdom

2012-04-09 Thread green
Mark Anderson wrote at 2012-04-06 15:17 -0500:
> On Thu, 5 Apr 2012 12:20:43 -0400, Antoine Beaupr?  anarcat.ath.cx> wrote:
> > Finally, I want to voice that I feel a "delete" key, even if it doesn't
> > delete mails, seems like an important part of a mail user
> > agent. Archiving mail is one thing, but for the love and respect of
> > sysadmins and the infrastructure they maintain, please consider adding
> > at least a way to *tag* those deleted emails.
> > 
> > Having the above keys being defined as standard in notmuch don't seem
> > like much to ask.
> > 
> > This may be a dissenting view here, but your mail is not that
> > important. :P
> 
> Hear! Hear!

I agree also.  I receive lots of mail that I never want to see again, nor do 
I want to see it still existing anywhere in my /home/user or in my backups.  
Someone might argue "but what if you decide you want it later" but I can use 
an Expires header to mark a message like "delete in 2 months", so I still 
have a chance to retrieve it within an amount of time I choose.

Somewhat related is the concept of saving spam messages.  I can understand 
the reasoning behind training bayesian filters, but I have never kept spam.  
I switched to bogofilter recently, and it was correctly filtering mail very 
quickly, perhaps within a few weeks (I did train it using non-spam messages).
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/e5aebcca/attachment.pgp>


[PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-09 Thread Taylor Carpenter
---
 contrib/notmuch-mutt/notmuch-mutt |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/contrib/notmuch-mutt/notmuch-mutt 
b/contrib/notmuch-mutt/notmuch-mutt
index 71206c3..dbe7f2d 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl -w
 #
 # notmuch-mutt - notmuch (of a) helper for Mutt
 #
@@ -12,6 +12,7 @@ use strict;
 use warnings;

 use File::Path;
+use File::Basename;
 use Getopt::Long qw(:config no_getopt_compat);
 use Mail::Internet;
 use Mail::Box::Maildir;
@@ -41,9 +42,12 @@ sub search($$) {
 $query = shell_quote($query);

 empty_maildir($maildir);
-system("notmuch search --output=files $query"
-  . " | sed -e 's: : :g'"
-  . " | xargs --no-run-if-empty ln -s -t $maildir/cur/");
+my @filelist = `notmuch search --output=files $query`;
+foreach(@filelist) {
+chomp;
+my $target = sprintf("$maildir/cur/%s", basename($_));
+symlink($_, $target);
+}
 }

 sub prompt($$) {
-- 
1.7.7.4



[PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-09 Thread Vladimir Marek
> > Posix /bin/sh is not capable of running this configure and fails.
> 
> What fails? What would it take to make this work on posix sh instead?
> 
> The tests do require bash, but generally I think it would be preferable to
> not depend on bash to build.

Well I gave it a quick stab. This is not posix:

BLAH=$( ... )
BLAH=$(( ... ))
${option%=*}
${option%%=*}
${option#=*}
${option##=*}

First two cases are easy to replace by `...` resp `expr ...`. The rest
leads to external utility like sed. The dirtiest part of configure is
parsing the commandline arguments, but that could be replaced by
/usr/bin/getopts.

If it is appealing way of doing that, I can rework my patch and submit
it for consideration.

Thank you
-- 
Vlad


[PATCH 2/4] dirent->d_type not available on Soalris

2012-04-09 Thread Jani Nikula
On Apr 9, 2012 1:18 PM,  wrote:
>
> From: Vladimir Marek 
>
> The inspiration was taken from similar issue in mutt:
> http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html
>
> Signed-off-by: Vladimir Marek 
> ---
>  notmuch-new.c |   19 +--
>  1 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/notmuch-new.c b/notmuch-new.c
> index 4f13535..20bc580 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -21,6 +21,7 @@
>  #include "notmuch-client.h"
>
>  #include 
> +#include 
>
>  typedef struct _filename_node {
> char *filename;
> @@ -165,9 +166,12 @@ static int
>  _entries_resemble_maildir (struct dirent **entries, int count)
>  {
> int i, found = 0;
> +struct stat statbuf;
>
> for (i = 0; i < count; i++) {
> -   if (entries[i]->d_type != DT_DIR && entries[i]->d_type !=
DT_UNKNOWN)
> +   if (stat(entries[i]->d_name, ) == -1)
> +   continue;
> +   if (! S_ISDIR(statbuf.st_mode))

Notmuch new is possibly one of the most performance critical bits for
people with, uh, much mail. The performance impact of the new syscalls
should be measured. (Can't do this myself atm.)

BR,
Jani.

>continue;
>
>if (strcmp(entries[i]->d_name, "new") == 0 ||
> @@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,
> struct stat st;
> notmuch_bool_t is_maildir, new_directory;
> const char **tag;
> +struct stat statbuf;
>
> if (stat (path, )) {
>fprintf (stderr, "Error reading directory %s: %s\n",
> @@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,
>
>entry = fs_entries[i];
>
> +   if (stat(entry->d_name, ) == -1)
> +   continue;
> +
>/* We only want to descend into directories.
> * But symlinks can be to directories too, of course.
> *
> @@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,
> * scandir results, then it might be a directory (and if not,
> * then we'll stat and return immediately in the next level of
> * recursion). */
> -   if (entry->d_type != DT_DIR &&
> -   entry->d_type != DT_LNK &&
> -   entry->d_type != DT_UNKNOWN)
> +   if (!(statbuf.st_mode & S_IFDIR) &&
> +   !(statbuf.st_mode & S_IFLNK))
>{
>continue;
>}
> @@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,
> *
> * In either case, a stat does the trick.
> */
> -   if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
> +   if (stat(entry->d_name, ) == -1 || statbuf.st_mode &
S_IFLNK) {
>int err;
>
>next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
> @@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,
>
>if (! S_ISREG (st.st_mode))
>continue;
> -   } else if (entry->d_type != DT_REG) {
> +   } else if ( statbuf.st_mode & S_IFREG) {
>continue;
>}
>
> --
> 1.7.3.2
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/223c13d0/attachment.html>


[PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-09 Thread Jani Nikula
On Apr 9, 2012 1:18 PM,  wrote:
>
> From: Vladimir Marek 
>
> Posix /bin/sh is not capable of running this configure and fails.

What fails? What would it take to make this work on posix sh instead?

The tests do require bash, but generally I think it would be preferable to
not depend on bash to build.

BR,
Jani.

>
> Signed-off-by: Vladimir Marek 
> ---
>  configure |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/configure b/configure
> index 71981b7..6870341 100755
> --- a/configure
> +++ b/configure
> @@ -1,4 +1,4 @@
> -#! /bin/sh
> +#! /bin/bash
>
>  # Store original IFS value so it can be changed (and restored) in many
places.
>  readonly DEFAULT_IFS=$IFS
> --
> 1.7.3.2
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/39f64c38/attachment-0001.html>


[PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread Jani Nikula
Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
that's supposed to provide type safety (at least with GCC), and I'd be
hesitant about adding the casts. Please look in your talloc.h.

BR,
Jani.

On Apr 9, 2012 1:19 PM,  wrote:
>
> From: Vladimir Marek 
>
>
> Signed-off-by: Vladimir Marek 
> ---
>  lib/database.cc |2 +-
>  lib/message.cc  |2 +-
>  lib/thread.cc   |2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/database.cc b/lib/database.cc
> index 16c4354..3c82632 100644
> --- a/lib/database.cc
> +++ b/lib/database.cc
> @@ -1361,7 +1361,7 @@ _resolve_message_id_to_thread_id
(notmuch_database_t *notmuch,
>return status;
>
> if (message) {
> -   *thread_id_ret = talloc_steal (ctx,
> +   *thread_id_ret = (const char*)talloc_steal (ctx,
>   notmuch_message_get_thread_id
(message));
>
>notmuch_message_destroy (message);
> diff --git a/lib/message.cc b/lib/message.cc
> index 0075425..d56d442 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -220,7 +220,7 @@ _notmuch_message_create_for_message_id
(notmuch_database_t *notmuch,
>
 message_id,
>
 );
> if (message)
> -   return talloc_steal (notmuch, message);
> +   return (notmuch_message_t*) talloc_steal (notmuch, message);
> else if (*status_ret)
>return NULL;
>
> diff --git a/lib/thread.cc b/lib/thread.cc
> index e976d64..d41ff3e 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -225,7 +225,7 @@ _thread_add_message (notmuch_thread_t *thread,
> char *clean_author;
>
> _notmuch_message_list_add_message (thread->message_list,
> -  talloc_steal (thread, message));
> +  (_notmuch_message*)talloc_steal
(thread, message));
> thread->total_messages++;
>
> g_hash_table_insert (thread->message_hash,
> --
> 1.7.3.2
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/31478ded/attachment.html>


[PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread David Bremner
Dmitry Kurochkin  writes:

> I am going to remove needs-review tag from this one since there seems to
> be no one interested in reviewing it.  The patch itself may not be
> trivial, but it is pretty simple and does not make any critical changes.
> So I believe it is safe to push it.  If there are any issues with the
> patch discovered later, I am committed to fix them.

Sorry, but if I can't take in the patch at a glance, it needs some
review before I am willing to push it.

d


[PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread vladimir.ma...@oracle.com
From: Vladimir Marek 


Signed-off-by: Vladimir Marek 
---
 lib/database.cc |2 +-
 lib/message.cc  |2 +-
 lib/thread.cc   |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 16c4354..3c82632 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1361,7 +1361,7 @@ _resolve_message_id_to_thread_id (notmuch_database_t 
*notmuch,
return status;

 if (message) {
-   *thread_id_ret = talloc_steal (ctx,
+   *thread_id_ret = (const char*)talloc_steal (ctx,
   notmuch_message_get_thread_id (message));

notmuch_message_destroy (message);
diff --git a/lib/message.cc b/lib/message.cc
index 0075425..d56d442 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -220,7 +220,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t 
*notmuch,

message_id,

);
 if (message)
-   return talloc_steal (notmuch, message);
+   return (notmuch_message_t*) talloc_steal (notmuch, message);
 else if (*status_ret)
return NULL;

diff --git a/lib/thread.cc b/lib/thread.cc
index e976d64..d41ff3e 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -225,7 +225,7 @@ _thread_add_message (notmuch_thread_t *thread,
 char *clean_author;

 _notmuch_message_list_add_message (thread->message_list,
-  talloc_steal (thread, message));
+  (_notmuch_message*)talloc_steal (thread, 
message));
 thread->total_messages++;

 g_hash_table_insert (thread->message_hash,
-- 
1.7.3.2



[PATCH 3/4] Private strsep implementation

2012-04-09 Thread vladimir.ma...@oracle.com
From: Vladimir Marek 

strsep is not available on Solaris 10, so we stole the one used by mutt.

Signed-off-by: Vladimir Marek 
---
 compat/Makefile.local |4 +++
 compat/compat.h   |4 +++
 compat/have_strsep.c  |   10 +++
 compat/strsep.c   |   65 +
 configure |   21 ++-
 5 files changed, 102 insertions(+), 2 deletions(-)
 create mode 100644 compat/have_strsep.c
 create mode 100644 compat/strsep.c

diff --git a/compat/Makefile.local b/compat/Makefile.local
index 13f16cd..2c4f65f 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)
 notmuch_compat_srcs += $(dir)/strcasestr.c
 endif

+ifneq ($(HAVE_STRSEP),1)
+notmuch_compat_srcs += $(dir)/strsep.c
+endif
+
 SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index b2e2736..cf8d56d 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -46,6 +46,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE 
*fp);
 char* strcasestr(const char *haystack, const char *needle);
 #endif /* !HAVE_STRCASESTR */

+#if !HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif /* !HAVE_STRSEP */
+
 /* Silence gcc warnings about unused results.  These warnings exist
  * for a reason; any use of this needs to be justified. */
 #ifdef __GNUC__
diff --git a/compat/have_strsep.c b/compat/have_strsep.c
new file mode 100644
index 000..5bd396c
--- /dev/null
+++ b/compat/have_strsep.c
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include 
+
+int main()
+{
+char *found;
+char **stringp, const char *delim;
+
+found = strsep(stringp, delim);
+}
diff --git a/compat/strsep.c b/compat/strsep.c
new file mode 100644
index 000..78ab9e7
--- /dev/null
+++ b/compat/strsep.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include 
+
+/* Taken from glibc 2.6.1 */
+
+char *strsep (char **stringp, const char *delim)
+{
+  char *begin, *end;
+
+  begin = *stringp;
+  if (begin == NULL)
+return NULL;
+
+  /* A frequent case is when the delimiter string contains only one
+ character.  Here we don't need to call the expensive `strpbrk'
+ function and instead work using `strchr'.  */
+  if (delim[0] == '\0' || delim[1] == '\0')
+{
+  char ch = delim[0];
+
+  if (ch == '\0')
+   end = NULL;
+  else
+   {
+ if (*begin == ch)
+   end = begin;
+ else if (*begin == '\0')
+   end = NULL;
+ else
+   end = strchr (begin + 1, ch);
+   }
+}
+  else
+/* Find the end of the token.  */
+end = strpbrk (begin, delim);
+
+  if (end)
+{
+  /* Terminate the token and set *STRINGP past NUL character.  */
+  *end++ = '\0';
+  *stringp = end;
+}
+  else
+/* No more delimiters; this is the last token.  */
+*stringp = NULL;
+
+  return begin;
+}
diff --git a/configure b/configure
index 6870341..a06df7c 100755
--- a/configure
+++ b/configure
@@ -486,6 +486,17 @@ else
 fi
 rm -f compat/have_strcasestr

+printf "Checking for strsep... "
+if ${CC} -o compat/have_strsep "$srcdir"/compat/have_strsep > /dev/null 2>&1
+then
+printf "Yes.\n"
+have_strsep=1
+else
+printf "No (will use our own instead).\n"
+have_strsep=0
+fi
+rm -f compat/have_strsep
+
 printf "int main(void){return 0;}\n" > minimal.c

 printf "Checking for rpath support... "
@@ -645,6 +656,10 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}

+# Whether the strsep function is available (if not, then notmuch will
+# build its own version)
+HAVE_STRSEP = ${have_strsep}
+
 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
 PLATFORM = ${platform}

@@ -689,10 +704,12 @@ WITH_ZSH = ${WITH_ZSH}
 # Combined flags for compiling and linking against all of the above
 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)  \\
   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
-  \$(VALGRIND_CFLAGS) -DHAVE_STRCASESTR=\$(HAVE_STRCASESTR)
+

[PATCH 2/4] dirent->d_type not available on Soalris

2012-04-09 Thread vladimir.ma...@oracle.com
From: Vladimir Marek 

The inspiration was taken from similar issue in mutt:
http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html

Signed-off-by: Vladimir Marek 
---
 notmuch-new.c |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 4f13535..20bc580 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -21,6 +21,7 @@
 #include "notmuch-client.h"

 #include 
+#include 

 typedef struct _filename_node {
 char *filename;
@@ -165,9 +166,12 @@ static int
 _entries_resemble_maildir (struct dirent **entries, int count)
 {
 int i, found = 0;
+struct stat statbuf;

 for (i = 0; i < count; i++) {
-   if (entries[i]->d_type != DT_DIR && entries[i]->d_type != DT_UNKNOWN)
+   if (stat(entries[i]->d_name, ) == -1)
+   continue;
+   if (! S_ISDIR(statbuf.st_mode))
continue;

if (strcmp(entries[i]->d_name, "new") == 0 ||
@@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
 const char **tag;
+struct stat statbuf;

 if (stat (path, )) {
fprintf (stderr, "Error reading directory %s: %s\n",
@@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,

entry = fs_entries[i];

+   if (stat(entry->d_name, ) == -1)
+   continue;
+
/* We only want to descend into directories.
 * But symlinks can be to directories too, of course.
 *
@@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
-   if (entry->d_type != DT_DIR &&
-   entry->d_type != DT_LNK &&
-   entry->d_type != DT_UNKNOWN)
+   if (!(statbuf.st_mode & S_IFDIR) &&
+   !(statbuf.st_mode & S_IFLNK))
{
continue;
}
@@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
-   if (entry->d_type == DT_LNK || entry->d_type == DT_UNKNOWN) {
+   if (stat(entry->d_name, ) == -1 || statbuf.st_mode & S_IFLNK) {
int err;

next = talloc_asprintf (notmuch, "%s/%s", path, entry->d_name);
@@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,

if (! S_ISREG (st.st_mode))
continue;
-   } else if (entry->d_type != DT_REG) {
+   } else if ( statbuf.st_mode & S_IFREG) {
continue;
}

-- 
1.7.3.2



notmuch on Solaris

2012-04-09 Thread vladimir.ma...@oracle.com
Hi,

In order to make notmuch compilable on Solaris, I had to make some
changes in the source code. Some changes are not yet ready to be
included to official tree, some I believe are. So I took first few to
see if I'm doing anything which could be accepted and hopefully decrease
number of local patches I have to hold. Comments are mostly welcome.

Thank you
-- 
Vlad


[PATCH 3/3] emacs: have tag-completion return all tags for nil input

2012-04-09 Thread Jameson Graef Rollins
Previously the function would fail if the initial input was nil.  Now
it will return a list of all tags, which obviously makes much more
sense.
---
 emacs/notmuch.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 8b48399..ba833e6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -85,6 +85,8 @@ For example:
 `notmuch-read-tag-changes' function.")

 (defun notmuch-tag-completions ( search-terms)
+  (if (null search-terms)
+  (setq search-terms (list "*")))
   (split-string
(with-output-to-string
  (with-current-buffer standard-output
-- 
1.7.9.1



[PATCH 2/3] emacs: include tags from excluded messages in tag tab completion

2012-04-09 Thread Jameson Graef Rollins
The new message exclude functionality will hide tags that only exist
on excluded messages.  However, one might very well want to manually
modify excluded tags.  This makes sure tags from excluded messages are
always available in tab completion.
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 38ae005..8b48399 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -89,7 +89,7 @@ For example:
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t
- nil "search" "--output=tags" search-terms)))
+ nil "search" "--output=tags" "--exclude=false" search-terms)))
"\n+" t))

 (defun notmuch-select-tag-with-completion (prompt  search-terms)
-- 
1.7.9.1



[PATCH 1/3] emacs: update call in tag-completion function

2012-04-09 Thread Jameson Graef Rollins
"search-tags" is deprecated, so use the more modern and supported
"search --output=tags".
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f0afa07..38ae005 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -89,7 +89,7 @@ For example:
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t
- nil "search-tags" search-terms)))
+ nil "search" "--output=tags" search-terms)))
"\n+" t))

 (defun notmuch-select-tag-with-completion (prompt  search-terms)
-- 
1.7.9.1



bug fixes to emacs notmuch-tag-completion function

2012-04-09 Thread Jameson Graef Rollins
I had originally included this fixes as part of a more involved series
to fix up tagging functions [0].  However, these are actually bug
fixes that stand alone and should not be bogged down in a series
that's likely going to take a while to come to fruition.  The changes
here are pretty trivial, so hopefully they can get pushed quickly and
I'll rework the rest of tagging fix up series on top of them.

jamie.

[0] id:"154853-25729-1-git-send-email-jrollins at finestructure.net"



[PATCH 2/8] emacs: update tag-completion function

2012-04-09 Thread Jameson Graef Rollins
On Mon, Apr 09 2012, Mark Walters  wrote:
>> -  nil "search-tags" search-terms)))
>> +  nil "search" "--output=tags" search-terms)))
>
> Perhaps make this 
>   + nil "search" "--output=tags" "--exclude=false" search-terms)))
>
> to fix the existing bug that if the message is excluded the completion
> can get confused. Or I can submit that separately if you prefer.

Hey, Mark.  Yes, that was included as a separate patch in v1 of the
series, but now that your exclude stuff has been pushed this should be
included as well.  I'll send a patch for this now.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/50a1649a/attachment.pgp>


[PATCH 2/4] dirent->d_type not available on Soalris

2012-04-09 Thread Adam Wolfe Gordon
On Mon, Apr 9, 2012 at 09:12, Vladimir Marek  
wrote:
> Fair enough. Is there some performance test suite? Another way would be
> to make this compile time option set by configure. Used only when the
> system in question does not have dirent->d_type member.

I like the idea of making it configurable. From the Linux readdir(3) man page:

> Under glibc, programs can check  for  the  availability
> of  the  fields  not defined in POSIX.1 by testing whether
> the macros _DIRENT_HAVE_D_NAMLEN,
> _DIRENT_HAVE_D_RECLEN, _DIRENT_HAVE_D_OFF,
> or  _DIRENT_HAVE_D_TYPE  are defined.

I read this as meaning that we can just test for _DIRENT_HAVE_D_TYPE
instead of adding our own define.

I expect the stat system calls will provide some overhead, and there's
no real need to pay that overhead on systems where it isn't necessary.

-- Adam


notmuch-poll and OfflineIMAP

2012-04-09 Thread Sebastian Spaeth
Adam Wolfe Gordon  wrote:
>
>I run offlineimap in autorefresh mode (with IDLE too, actually) and
>use a script based on inotify to update notmuch whenever new mail
>comes in: https://gist.github.com/1952483 . It sounds like some
>variant of this would probably work for you.

I actually plan to add new-message-hooks to offlineimap fairly soon.

Sebastian

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


Message deletion wisdom

2012-04-09 Thread Sebastian Spaeth
Jameson Graef Rollins  wrote:
>So in summary, if you would like to "delete" messages, you can:
>
> * add a key binding to emacs (or your favorite ui) to add a "deleted"
>   tag to messages that you want to delete:
>
>(define-key notmuch-show-mode-map "d"
>  (lambda ()
>(interactive)
>(notmuch-show-tag-message "+deleted")))
>
> * add exclusion for messages with the "deleted" tag:
>
>notmuch config set search.exclude_tags deleted
>
> * and if you really want them purged from disk, delete them manually
>   with:
>
>notmuch search --output=files tag:deleted | xargs -l rm

Thanks Jamie, that ws a very helpful summary.

Sebastian

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


notmuch-poll and OfflineIMAP

2012-04-09 Thread Sebastian Spaeth
Jani Nikula  wrote:

>Jacek Generowicz  writes:
>
>> Hello,
>>
>> Would you have any advice on how to construct a notmuch-poll script
>> that would work well in concert with OfflineIMAP?  In particlular,
>how
>> can you avoid having to re-issue the IMAP account passwords?

>> Any words of wisdom?
>
>Offlineimap supports running hooks after syncing. Check if SIGUSR1 does
>that too. Then you could run notmuch new in the post sync hook.
>
>Also, notmuch new supports pre-new and post-new hooks. You could start
>or SIGUSR1 offlineimap in the pre-new hook. See man notmuch-hooks for

Offlineimap hooks work nicely for running notmuch scripts, i run it this way. 
Sending Sigusr1 will invoke that too, but I don't think that would be needed. 
It's mostly for peole running OfflineMap as a daemon

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


[PATCH 7/8] emacs: modify show tag functions to use new notmuch-tag interface

2012-04-09 Thread Jameson Graef Rollins
On Sat, Apr 07 2012, Mark Walters  wrote:
> I think this is what is making the two tests fail: they count the number
> of invocations of notmuch and in case there is one invocation of notmuch
> show and one of notmuch tag -unread message-id, where before it was just
> the single notmuch show.

Good call, Mark.  After a bit of testing it looks like that is what's
going on.  I was confused, since I had thought that the call to
notmuch-show should have involved two notmuch calls originally as well,
one for retrieving the message and the other removing the unread tag.
However, it appears the messages in those tests don't have unread tags
after all.  Not sure why, but that explains it.

So I guess the upshot is that moving all the common prompting and tag
validation stuff into notmuch-tag means that in certain cases there will
be extra notmuch calls, even if no tags are changed.  Is that a problem?

What I can do, though, is add extra validation to notmuch-tag to not
actually call notmuch tag, or any of the pre- and post- tagging hooks,
if no tags are changing.  This will still require one call to notmuch to
retrieve the current set of tags for the query, but at least it wont tag
or call the hooks if nothing is changing.  That seems reasonable to me,
but please let me know if you think it's not.

I've pasted below a new version of notmuch-tag that addresses these
issues.  Let me know what you think, and I'll resubmit the series.

jamie.


(defun notmuch-tag (query  tag-changes)
  "Add/remove tags in TAG-CHANGES to messages matching QUERY.

QUERY should be a string containing the search-terms.
TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of
strings of the form \"+tag\" or \"-tag\" then those are the tag
changes applied.  If TAG-CHANGES is a string then it is
interpreted as a single tag change.  If TAG-CHANGES is the string
\"-\" or \"+\", or null, then the user is prompted to enter the
tag changes.

Note: Other code should always use this function alter tags of
messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
directly, so that hooks specified in notmuch-before-tag-hook and
notmuch-after-tag-hook will be run."
  ;; Perform some validation
  (if (string-or-null-p tag-changes)
  (if (or (string= tag-changes "-") (string= tag-changes "+") (null 
tag-changes))
  (setq tag-changes (notmuch-read-tag-changes tag-changes query))
(setq tag-changes (list tag-changes
  (mapc (lambda (tag-change)
  (unless (string-match-p "^[-+]\\S-+$" tag-change)
(error "Tag must be of the form `+this_tag' or `-that_tag'")))
tag-changes)
  (let* ((current-tags (notmuch-tag-completions (list query)))
 (new-tags (notmuch-update-tags current-tags tag-changes)))
(if (equal current-tags new-tags)
;; if no tags are changing, return nil
nil
  (run-hooks 'notmuch-before-tag-hook)
  (apply 'notmuch-call-notmuch-process "tag"
 (append tag-changes (list "--" query)))
  (run-hooks 'notmuch-after-tag-hook)
  ;; otherwise, return the list of actual changed tags
  tag-changes)))
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120409/d9120d2c/attachment.pgp>


Why not tags inside messages?

2012-04-09 Thread Sebastian Spaeth

>On Sat, Apr 7, 2012 at 10:46, David Belohrad  wrote:
>> I'd love to use notmuch with offline imap ?to work rather on local
>copy of
>> messages, than using remote notmuch, which is slightly slower due to
>> bandwidth limitation of my vdsl line. There is however fundamental
>problem
>> of syncing flags between two instances of notmuch. So my question is,
>> whether it would be possible, when tagging message, to store the tag
>as well
>> in the message itself. Might this help to sync across multiple
>instances?

My long-term dream is still to enable offlinemap to sync all imap flags and 
sync notmuch flags via offlineimap/imap server. But don` t hold your breath :-) 

Sebastian

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.


Re: [PATCH 7/8] emacs: modify show tag functions to use new notmuch-tag interface

2012-04-09 Thread Jameson Graef Rollins
On Sat, Apr 07 2012, Mark Walters markwalters1...@gmail.com wrote:
 I think this is what is making the two tests fail: they count the number
 of invocations of notmuch and in case there is one invocation of notmuch
 show and one of notmuch tag -unread message-id, where before it was just
 the single notmuch show.

Good call, Mark.  After a bit of testing it looks like that is what's
going on.  I was confused, since I had thought that the call to
notmuch-show should have involved two notmuch calls originally as well,
one for retrieving the message and the other removing the unread tag.
However, it appears the messages in those tests don't have unread tags
after all.  Not sure why, but that explains it.

So I guess the upshot is that moving all the common prompting and tag
validation stuff into notmuch-tag means that in certain cases there will
be extra notmuch calls, even if no tags are changed.  Is that a problem?

What I can do, though, is add extra validation to notmuch-tag to not
actually call notmuch tag, or any of the pre- and post- tagging hooks,
if no tags are changing.  This will still require one call to notmuch to
retrieve the current set of tags for the query, but at least it wont tag
or call the hooks if nothing is changing.  That seems reasonable to me,
but please let me know if you think it's not.

I've pasted below a new version of notmuch-tag that addresses these
issues.  Let me know what you think, and I'll resubmit the series.

jamie.


(defun notmuch-tag (query optional tag-changes)
  Add/remove tags in TAG-CHANGES to messages matching QUERY.

QUERY should be a string containing the search-terms.
TAG-CHANGES can take multiple forms.  If TAG-CHANGES is a list of
strings of the form \+tag\ or \-tag\ then those are the tag
changes applied.  If TAG-CHANGES is a string then it is
interpreted as a single tag change.  If TAG-CHANGES is the string
\-\ or \+\, or null, then the user is prompted to enter the
tag changes.

Note: Other code should always use this function alter tags of
messages instead of running (notmuch-call-notmuch-process \tag\ ..)
directly, so that hooks specified in notmuch-before-tag-hook and
notmuch-after-tag-hook will be run.
  ;; Perform some validation
  (if (string-or-null-p tag-changes)
  (if (or (string= tag-changes -) (string= tag-changes +) (null 
tag-changes))
  (setq tag-changes (notmuch-read-tag-changes tag-changes query))
(setq tag-changes (list tag-changes
  (mapc (lambda (tag-change)
  (unless (string-match-p ^[-+]\\S-+$ tag-change)
(error Tag must be of the form `+this_tag' or `-that_tag')))
tag-changes)
  (let* ((current-tags (notmuch-tag-completions (list query)))
 (new-tags (notmuch-update-tags current-tags tag-changes)))
(if (equal current-tags new-tags)
;; if no tags are changing, return nil
nil
  (run-hooks 'notmuch-before-tag-hook)
  (apply 'notmuch-call-notmuch-process tag
 (append tag-changes (list -- query)))
  (run-hooks 'notmuch-after-tag-hook)
  ;; otherwise, return the list of actual changed tags
  tag-changes)))


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


[PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-09 Thread Vladimir . Marek
From: Vladimir Marek vlma...@volny.cz

Posix /bin/sh is not capable of running this configure and fails.

Signed-off-by: Vladimir Marek vlma...@volny.cz
---
 configure |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/configure b/configure
index 71981b7..6870341 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 
 # Store original IFS value so it can be changed (and restored) in many places.
 readonly DEFAULT_IFS=$IFS
-- 
1.7.3.2

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


[PATCH 2/4] dirent-d_type not available on Soalris

2012-04-09 Thread Vladimir . Marek
From: Vladimir Marek vlma...@volny.cz

The inspiration was taken from similar issue in mutt:
http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html

Signed-off-by: Vladimir Marek vlma...@volny.cz
---
 notmuch-new.c |   19 +--
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 4f13535..20bc580 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -21,6 +21,7 @@
 #include notmuch-client.h
 
 #include unistd.h
+#include sys/types.h
 
 typedef struct _filename_node {
 char *filename;
@@ -165,9 +166,12 @@ static int
 _entries_resemble_maildir (struct dirent **entries, int count)
 {
 int i, found = 0;
+struct stat statbuf;
 
 for (i = 0; i  count; i++) {
-   if (entries[i]-d_type != DT_DIR  entries[i]-d_type != DT_UNKNOWN)
+   if (stat(entries[i]-d_name, statbuf) == -1)
+   continue;
+   if (! S_ISDIR(statbuf.st_mode))
continue;
 
if (strcmp(entries[i]-d_name, new) == 0 ||
@@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
 const char **tag;
+struct stat statbuf;
 
 if (stat (path, st)) {
fprintf (stderr, Error reading directory %s: %s\n,
@@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,
 
entry = fs_entries[i];
 
+   if (stat(entry-d_name, statbuf) == -1)
+   continue;
+
/* We only want to descend into directories.
 * But symlinks can be to directories too, of course.
 *
@@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
-   if (entry-d_type != DT_DIR 
-   entry-d_type != DT_LNK 
-   entry-d_type != DT_UNKNOWN)
+   if (!(statbuf.st_mode  S_IFDIR) 
+   !(statbuf.st_mode  S_IFLNK))
{
continue;
}
@@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
-   if (entry-d_type == DT_LNK || entry-d_type == DT_UNKNOWN) {
+   if (stat(entry-d_name, statbuf) == -1 || statbuf.st_mode  S_IFLNK) {
int err;
 
next = talloc_asprintf (notmuch, %s/%s, path, entry-d_name);
@@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 
if (! S_ISREG (st.st_mode))
continue;
-   } else if (entry-d_type != DT_REG) {
+   } else if ( statbuf.st_mode  S_IFREG) {
continue;
}
 
-- 
1.7.3.2

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


[PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread Vladimir . Marek
From: Vladimir Marek vlma...@volny.cz


Signed-off-by: Vladimir Marek vlma...@volny.cz
---
 lib/database.cc |2 +-
 lib/message.cc  |2 +-
 lib/thread.cc   |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 16c4354..3c82632 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1361,7 +1361,7 @@ _resolve_message_id_to_thread_id (notmuch_database_t 
*notmuch,
return status;
 
 if (message) {
-   *thread_id_ret = talloc_steal (ctx,
+   *thread_id_ret = (const char*)talloc_steal (ctx,
   notmuch_message_get_thread_id (message));
 
notmuch_message_destroy (message);
diff --git a/lib/message.cc b/lib/message.cc
index 0075425..d56d442 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -220,7 +220,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t 
*notmuch,

message_id,

message);
 if (message)
-   return talloc_steal (notmuch, message);
+   return (notmuch_message_t*) talloc_steal (notmuch, message);
 else if (*status_ret)
return NULL;
 
diff --git a/lib/thread.cc b/lib/thread.cc
index e976d64..d41ff3e 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -225,7 +225,7 @@ _thread_add_message (notmuch_thread_t *thread,
 char *clean_author;
 
 _notmuch_message_list_add_message (thread-message_list,
-  talloc_steal (thread, message));
+  (_notmuch_message*)talloc_steal (thread, 
message));
 thread-total_messages++;
 
 g_hash_table_insert (thread-message_hash,
-- 
1.7.3.2

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


notmuch on Solaris

2012-04-09 Thread Vladimir . Marek
Hi,

In order to make notmuch compilable on Solaris, I had to make some
changes in the source code. Some changes are not yet ready to be
included to official tree, some I believe are. So I took first few to
see if I'm doing anything which could be accepted and hopefully decrease
number of local patches I have to hold. Comments are mostly welcome.

Thank you
-- 
Vlad
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/4] Private strsep implementation

2012-04-09 Thread Vladimir . Marek
From: Vladimir Marek vlma...@volny.cz

strsep is not available on Solaris 10, so we stole the one used by mutt.

Signed-off-by: Vladimir Marek vlma...@volny.cz
---
 compat/Makefile.local |4 +++
 compat/compat.h   |4 +++
 compat/have_strsep.c  |   10 +++
 compat/strsep.c   |   65 +
 configure |   21 ++-
 5 files changed, 102 insertions(+), 2 deletions(-)
 create mode 100644 compat/have_strsep.c
 create mode 100644 compat/strsep.c

diff --git a/compat/Makefile.local b/compat/Makefile.local
index 13f16cd..2c4f65f 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -13,4 +13,8 @@ ifneq ($(HAVE_STRCASESTR),1)
 notmuch_compat_srcs += $(dir)/strcasestr.c
 endif
 
+ifneq ($(HAVE_STRSEP),1)
+notmuch_compat_srcs += $(dir)/strsep.c
+endif
+
 SRCS := $(SRCS) $(notmuch_compat_srcs)
diff --git a/compat/compat.h b/compat/compat.h
index b2e2736..cf8d56d 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -46,6 +46,10 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE 
*fp);
 char* strcasestr(const char *haystack, const char *needle);
 #endif /* !HAVE_STRCASESTR */
 
+#if !HAVE_STRSEP
+char *strsep(char **stringp, const char *delim);
+#endif /* !HAVE_STRSEP */
+
 /* Silence gcc warnings about unused results.  These warnings exist
  * for a reason; any use of this needs to be justified. */
 #ifdef __GNUC__
diff --git a/compat/have_strsep.c b/compat/have_strsep.c
new file mode 100644
index 000..5bd396c
--- /dev/null
+++ b/compat/have_strsep.c
@@ -0,0 +1,10 @@
+#define _GNU_SOURCE
+#include string.h
+
+int main()
+{
+char *found;
+char **stringp, const char *delim;
+
+found = strsep(stringp, delim);
+}
diff --git a/compat/strsep.c b/compat/strsep.c
new file mode 100644
index 000..78ab9e7
--- /dev/null
+++ b/compat/strsep.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include string.h
+
+/* Taken from glibc 2.6.1 */
+
+char *strsep (char **stringp, const char *delim)
+{
+  char *begin, *end;
+
+  begin = *stringp;
+  if (begin == NULL)
+return NULL;
+
+  /* A frequent case is when the delimiter string contains only one
+ character.  Here we don't need to call the expensive `strpbrk'
+ function and instead work using `strchr'.  */
+  if (delim[0] == '\0' || delim[1] == '\0')
+{
+  char ch = delim[0];
+
+  if (ch == '\0')
+   end = NULL;
+  else
+   {
+ if (*begin == ch)
+   end = begin;
+ else if (*begin == '\0')
+   end = NULL;
+ else
+   end = strchr (begin + 1, ch);
+   }
+}
+  else
+/* Find the end of the token.  */
+end = strpbrk (begin, delim);
+
+  if (end)
+{
+  /* Terminate the token and set *STRINGP past NUL character.  */
+  *end++ = '\0';
+  *stringp = end;
+}
+  else
+/* No more delimiters; this is the last token.  */
+*stringp = NULL;
+
+  return begin;
+}
diff --git a/configure b/configure
index 6870341..a06df7c 100755
--- a/configure
+++ b/configure
@@ -486,6 +486,17 @@ else
 fi
 rm -f compat/have_strcasestr
 
+printf Checking for strsep... 
+if ${CC} -o compat/have_strsep $srcdir/compat/have_strsep  /dev/null 21
+then
+printf Yes.\n
+have_strsep=1
+else
+printf No (will use our own instead).\n
+have_strsep=0
+fi
+rm -f compat/have_strsep
+
 printf int main(void){return 0;}\n  minimal.c
 
 printf Checking for rpath support... 
@@ -645,6 +656,10 @@ HAVE_GETLINE = ${have_getline}
 # build its own version)
 HAVE_STRCASESTR = ${have_strcasestr}
 
+# Whether the strsep function is available (if not, then notmuch will
+# build its own version)
+HAVE_STRSEP = ${have_strsep}
+
 # Supported platforms (so far) are: LINUX, MACOSX, SOLARIS
 PLATFORM = ${platform}
 
@@ -689,10 +704,12 @@ WITH_ZSH = ${WITH_ZSH}
 # Combined flags for compiling and linking against all of the above
 CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)  \\
   \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND)   \\
-  \$(VALGRIND_CFLAGS) 

Re: [PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-09 Thread Jani Nikula
On Apr 9, 2012 1:18 PM, vladimir.ma...@oracle.com wrote:

 From: Vladimir Marek vlma...@volny.cz

 Posix /bin/sh is not capable of running this configure and fails.

What fails? What would it take to make this work on posix sh instead?

The tests do require bash, but generally I think it would be preferable to
not depend on bash to build.

BR,
Jani.


 Signed-off-by: Vladimir Marek vlma...@volny.cz
 ---
  configure |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/configure b/configure
 index 71981b7..6870341 100755
 --- a/configure
 +++ b/configure
 @@ -1,4 +1,4 @@
 -#! /bin/sh
 +#! /bin/bash

  # Store original IFS value so it can be changed (and restored) in many
places.
  readonly DEFAULT_IFS=$IFS
 --
 1.7.3.2

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


Re: [PATCH 2/4] dirent-d_type not available on Soalris

2012-04-09 Thread Jani Nikula
On Apr 9, 2012 1:18 PM, vladimir.ma...@oracle.com wrote:

 From: Vladimir Marek vlma...@volny.cz

 The inspiration was taken from similar issue in mutt:
 http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html

 Signed-off-by: Vladimir Marek vlma...@volny.cz
 ---
  notmuch-new.c |   19 +--
  1 files changed, 13 insertions(+), 6 deletions(-)

 diff --git a/notmuch-new.c b/notmuch-new.c
 index 4f13535..20bc580 100644
 --- a/notmuch-new.c
 +++ b/notmuch-new.c
 @@ -21,6 +21,7 @@
  #include notmuch-client.h

  #include unistd.h
 +#include sys/types.h

  typedef struct _filename_node {
 char *filename;
 @@ -165,9 +166,12 @@ static int
  _entries_resemble_maildir (struct dirent **entries, int count)
  {
 int i, found = 0;
 +struct stat statbuf;

 for (i = 0; i  count; i++) {
 -   if (entries[i]-d_type != DT_DIR  entries[i]-d_type !=
DT_UNKNOWN)
 +   if (stat(entries[i]-d_name, statbuf) == -1)
 +   continue;
 +   if (! S_ISDIR(statbuf.st_mode))

Notmuch new is possibly one of the most performance critical bits for
people with, uh, much mail. The performance impact of the new syscalls
should be measured. (Can't do this myself atm.)

BR,
Jani.

continue;

if (strcmp(entries[i]-d_name, new) == 0 ||
 @@ -258,6 +262,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
 const char **tag;
 +struct stat statbuf;

 if (stat (path, st)) {
fprintf (stderr, Error reading directory %s: %s\n,
 @@ -321,6 +326,9 @@ add_files_recursive (notmuch_database_t *notmuch,

entry = fs_entries[i];

 +   if (stat(entry-d_name, statbuf) == -1)
 +   continue;
 +
/* We only want to descend into directories.
 * But symlinks can be to directories too, of course.
 *
 @@ -328,9 +336,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
 -   if (entry-d_type != DT_DIR 
 -   entry-d_type != DT_LNK 
 -   entry-d_type != DT_UNKNOWN)
 +   if (!(statbuf.st_mode  S_IFDIR) 
 +   !(statbuf.st_mode  S_IFLNK))
{
continue;
}
 @@ -427,7 +434,7 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
 -   if (entry-d_type == DT_LNK || entry-d_type == DT_UNKNOWN) {
 +   if (stat(entry-d_name, statbuf) == -1 || statbuf.st_mode 
S_IFLNK) {
int err;

next = talloc_asprintf (notmuch, %s/%s, path, entry-d_name);
 @@ -443,7 +450,7 @@ add_files_recursive (notmuch_database_t *notmuch,

if (! S_ISREG (st.st_mode))
continue;
 -   } else if (entry-d_type != DT_REG) {
 +   } else if ( statbuf.st_mode  S_IFREG) {
continue;
}

 --
 1.7.3.2

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


Re: [PATCH 1/4] Make configure use /bin/bash instead of /bin/sh

2012-04-09 Thread Vladimir Marek
  Posix /bin/sh is not capable of running this configure and fails.
 
 What fails? What would it take to make this work on posix sh instead?
 
 The tests do require bash, but generally I think it would be preferable to
 not depend on bash to build.

Well I gave it a quick stab. This is not posix:

BLAH=$( ... )
BLAH=$(( ... ))
${option%=*}
${option%%=*}
${option#=*}
${option##=*}

First two cases are easy to replace by `...` resp `expr ...`. The rest
leads to external utility like sed. The dirtiest part of configure is
parsing the commandline arguments, but that could be replaced by
/usr/bin/getopts.

If it is appealing way of doing that, I can rework my patch and submit
it for consideration.

Thank you
-- 
Vlad
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Dmitry Kurochkin
Hi all.

I am going to remove needs-review tag from this one since there seems to
be no one interested in reviewing it.  The patch itself may not be
trivial, but it is pretty simple and does not make any critical changes.
So I believe it is safe to push it.  If there are any issues with the
patch discovered later, I am committed to fix them.

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


Re: [PATCH 2/4] dirent-d_type not available on Soalris

2012-04-09 Thread Vladimir Marek
 Notmuch new is possibly one of the most performance critical bits for
 people with, uh, much mail. The performance impact of the new syscalls
 should be measured. (Can't do this myself atm.)

Fair enough. Is there some performance test suite? Another way would be
to make this compile time option set by configure. Used only when the
system in question does not have dirent-d_type member.

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


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread David Bremner
Dmitry Kurochkin dmitry.kuroch...@gmail.com writes:

 I am going to remove needs-review tag from this one since there seems to
 be no one interested in reviewing it.  The patch itself may not be
 trivial, but it is pretty simple and does not make any critical changes.
 So I believe it is safe to push it.  If there are any issues with the
 patch discovered later, I am committed to fix them.

Sorry, but if I can't take in the patch at a glance, it needs some
review before I am willing to push it.

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


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Dmitry Kurochkin
David Bremner da...@tethera.net writes:

 Dmitry Kurochkin dmitry.kuroch...@gmail.com writes:

 I am going to remove needs-review tag from this one since there seems to
 be no one interested in reviewing it.  The patch itself may not be
 trivial, but it is pretty simple and does not make any critical changes.
 So I believe it is safe to push it.  If there are any issues with the
 patch discovered later, I am committed to fix them.

 Sorry, but if I can't take in the patch at a glance, it needs some
 review before I am willing to push it.


Ok.  Tagged as needs-review again.  Let's see if I can attract some
attention to the patch on IRC.

Regards,
  Dmitry

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


[PATCH 2/4] dirent-d_type not available on Soalris

2012-04-09 Thread Vladimir . Marek
From: Vladimir Marek vlma...@volny.cz

The inspiration was taken from similar issue in mutt:
http://does-not-exist.org/mail-archives/mutt-dev/msg11290.html

Signed-off-by: Vladimir Marek vlma...@volny.cz
---
 notmuch-new.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 4f13535..3d265bd 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -21,6 +21,9 @@
 #include notmuch-client.h
 
 #include unistd.h
+#ifndef _DIRENT_HAVE_D_TYPE
+#include sys/types.h
+#endif
 
 typedef struct _filename_node {
 char *filename;
@@ -167,7 +170,14 @@ _entries_resemble_maildir (struct dirent **entries, int 
count)
 int i, found = 0;
 
 for (i = 0; i  count; i++) {
+#ifdef _DIRENT_HAVE_D_TYPE
if (entries[i]-d_type != DT_DIR  entries[i]-d_type != DT_UNKNOWN)
+#else
+   struct stat statbuf;
+   if (stat(entries[i]-d_name, statbuf) == -1)
+   continue;
+   if (! S_ISDIR(statbuf.st_mode))
+#endif
continue;
 
if (strcmp(entries[i]-d_name, new) == 0 ||
@@ -258,6 +268,9 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct stat st;
 notmuch_bool_t is_maildir, new_directory;
 const char **tag;
+#ifndef _DIRENT_HAVE_D_TYPE
+struct stat statbuf;
+#endif
 
 if (stat (path, st)) {
fprintf (stderr, Error reading directory %s: %s\n,
@@ -328,9 +341,16 @@ add_files_recursive (notmuch_database_t *notmuch,
 * scandir results, then it might be a directory (and if not,
 * then we'll stat and return immediately in the next level of
 * recursion). */
+#ifdef _DIRENT_HAVE_D_TYPE
if (entry-d_type != DT_DIR 
entry-d_type != DT_LNK 
entry-d_type != DT_UNKNOWN)
+#else
+   if (stat(entry-d_name, statbuf) == -1)
+   continue;
+   if (!(statbuf.st_mode  S_IFDIR) 
+   !(statbuf.st_mode  S_IFLNK))
+#endif
{
continue;
}
@@ -427,7 +447,11 @@ add_files_recursive (notmuch_database_t *notmuch,
 *
 * In either case, a stat does the trick.
 */
+#ifdef _DIRENT_HAVE_D_TYPE
if (entry-d_type == DT_LNK || entry-d_type == DT_UNKNOWN) {
+#else
+   if (stat(entry-d_name, statbuf) == -1 || statbuf.st_mode  S_IFLNK) {
+#endif
int err;
 
next = talloc_asprintf (notmuch, %s/%s, path, entry-d_name);
@@ -443,7 +467,11 @@ add_files_recursive (notmuch_database_t *notmuch,
 
if (! S_ISREG (st.st_mode))
continue;
+#ifdef _DIRENT_HAVE_D_TYPE
} else if (entry-d_type != DT_REG) {
+#else
+   } else if (statbuf.st_mode  S_IFREG) {
+#endif
continue;
}
 
-- 
1.7.3.2

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


Re: [PATCH 2/8] emacs: update tag-completion function

2012-04-09 Thread Mark Walters
On Sun, 08 Apr 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:
 search-tags is deprecated, so we move to the more modern and
 supported search --output=tags.
 ---
  emacs/notmuch-tag.el |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
 index 81b4b00..5240d13 100644
 --- a/emacs/notmuch-tag.el
 +++ b/emacs/notmuch-tag.el
 @@ -59,7 +59,7 @@ the messages that were tagged
 (with-output-to-string
   (with-current-buffer standard-output
 (apply 'call-process notmuch-command nil t
 -   nil search-tags search-terms)))
 +   nil search --output=tags search-terms)))

Perhaps make this 
  + nil search --output=tags --exclude=false search-terms)))

to fix the existing bug that if the message is excluded the completion
can get confused. Or I can submit that separately if you prefer.

Best wishes

Mark

 \n+ t))
  
  (defun notmuch-select-tag-with-completion (prompt rest search-terms)
 -- 
 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


Re: [PATCH 2/8] emacs: update tag-completion function

2012-04-09 Thread Jameson Graef Rollins
On Mon, Apr 09 2012, Mark Walters markwalters1...@gmail.com wrote:
 -  nil search-tags search-terms)))
 +  nil search --output=tags search-terms)))

 Perhaps make this 
   + nil search --output=tags --exclude=false search-terms)))

 to fix the existing bug that if the message is excluded the completion
 can get confused. Or I can submit that separately if you prefer.

Hey, Mark.  Yes, that was included as a separate patch in v1 of the
series, but now that your exclude stuff has been pushed this should be
included as well.  I'll send a patch for this now.

jamie.


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


Re: [PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread Vladimir Marek
Hi,

 Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
 that's supposed to provide type safety (at least with GCC), and I'd be
 hesitant about adding the casts. Please look in your talloc.h.

It does not compile. It might be that I'm using Sun/Oracle CC instead of
gcc. The error looks like this:

lib/database.cc, line 1368: Error: Cannot assign void* to const char*.


When looking into talloc documentation, the definition seems to be:

void* talloc_steal ( const void * new_ctx, const void * ptr )

http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c


When looking into talloc.h, it says:

/* try to make talloc_set_destructor() and talloc_steal() type safe,
   if we have a recent gcc */

So, maybe the way to satisfy everyone would be:

notmuch_message_t *tmp_message = message;
talloc_steal(notmuch, tmp_message);
return(tmp_message);

Or alternatively,

#if (__GNUC__ = 3)
   return talloc_steal (notmuch, message);
#else
   return (notmuch_message_t*) talloc_steal (notmuch, message);
#fi


Of course I'm happy either way :)

Thank you
-- 
Vlad
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/3] emacs: include tags from excluded messages in tag tab completion

2012-04-09 Thread Jameson Graef Rollins
The new message exclude functionality will hide tags that only exist
on excluded messages.  However, one might very well want to manually
modify excluded tags.  This makes sure tags from excluded messages are
always available in tab completion.
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 38ae005..8b48399 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -89,7 +89,7 @@ For example:
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t
- nil search --output=tags search-terms)))
+ nil search --output=tags --exclude=false search-terms)))
\n+ t))
 
 (defun notmuch-select-tag-with-completion (prompt rest search-terms)
-- 
1.7.9.1

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


[PATCH 1/3] emacs: update call in tag-completion function

2012-04-09 Thread Jameson Graef Rollins
search-tags is deprecated, so use the more modern and supported
search --output=tags.
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f0afa07..38ae005 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -89,7 +89,7 @@ For example:
(with-output-to-string
  (with-current-buffer standard-output
(apply 'call-process notmuch-command nil t
- nil search-tags search-terms)))
+ nil search --output=tags search-terms)))
\n+ t))
 
 (defun notmuch-select-tag-with-completion (prompt rest search-terms)
-- 
1.7.9.1

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


[PATCH 3/3] emacs: have tag-completion return all tags for nil input

2012-04-09 Thread Jameson Graef Rollins
Previously the function would fail if the initial input was nil.  Now
it will return a list of all tags, which obviously makes much more
sense.
---
 emacs/notmuch.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 8b48399..ba833e6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -85,6 +85,8 @@ For example:
 `notmuch-read-tag-changes' function.)
 
 (defun notmuch-tag-completions (optional search-terms)
+  (if (null search-terms)
+  (setq search-terms (list *)))
   (split-string
(with-output-to-string
  (with-current-buffer standard-output
-- 
1.7.9.1

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


Re: [PATCH 5/8] emacs: modify search tag functions to use new notmuch-tag interface

2012-04-09 Thread Mark Walters
On Sun, 08 Apr 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:
 The main change here is to modify argument parsing so as to not force
 tag-changes to be a list, and to let notmuch-tag handle prompting the
 user when required.  doc strings are also updated and cleaned up.
 ---
  emacs/notmuch.el |   36 +---
  1 files changed, 13 insertions(+), 23 deletions(-)

 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
 index 9aec96d..a03a526 100644
 --- a/emacs/notmuch.el
 +++ b/emacs/notmuch.el
 @@ -523,13 +523,10 @@ and will also appear in a buffer named \*Notmuch 
 errors*\.
  See `notmuch-search-tag-region' for details.
(apply 'notmuch-search-tag-region (point) (point) tag-changes))
  
 -(defun notmuch-search-tag-region (beg end rest tag-changes)
 -  Change tags for threads in the given region.
 -
 -TAGS is a list of tag operations for `notmuch-tag'.  The tags are
 -added or removed for all threads in the region from BEG to END.
 +(defun notmuch-search-tag-region (beg end optional tag-changes)
 +  Change tags for threads in the given region.
(let ((search-string (notmuch-search-find-thread-id-region-search beg 
 end)))
 -(apply 'notmuch-tag search-string tag-changes)
 +(setq tag-changes (funcall 'notmuch-tag search-string tag-changes))
  (save-excursion
(let ((last-line (line-number-at-pos end))
   (max-line (- (line-number-at-pos (point-max)) 2)))
 @@ -539,14 +536,14 @@ added or removed for all threads in the region from BEG 
 to END.
  (notmuch-update-tags (notmuch-search-get-tags) tag-changes))
 (forward-line))
  
 -(defun notmuch-search-tag (optional initial-input)
 -  Change tags for the currently selected thread or region.
 +(defun notmuch-search-tag (optional tag-changes)
 +  Change tags for the currently selected thread or region.
 +
 +See `notmuch-tag' for information on the format of TAG-CHANGES.
(interactive)
(let* ((beg (if (region-active-p) (region-beginning) (point)))
 -  (end (if (region-active-p) (region-end) (point)))
 -  (search-string (notmuch-search-find-thread-id-region-search beg end))
 -  (tags (notmuch-read-tag-changes initial-input search-string)))
 -(apply 'notmuch-search-tag-region beg end tags)))
 +  (end (if (region-active-p) (region-end) (point
 +(funcall 'notmuch-search-tag-region beg end tag-changes)))
  
  (defun notmuch-search-add-tag ()
Same as `notmuch-search-tag' but sets initial input to '+'.
 @@ -790,18 +787,11 @@ non-authors is found, assume that all of the authors 
 match.
 (goto-char found-target)))
(delete-process proc
  
 -(defun notmuch-search-tag-all (rest tag-changes)
 -  Add/remove tags from all matching messages.
 +(defun notmuch-search-tag-all (optional tag-changes)
 +  Add/remove tags from all messages in current search buffer.
  
 -This command adds or removes tags from all messages matching the
 -current search terms. When called interactively, this command
 -will prompt for tags to be added or removed. Tags prefixed with
 -'+' will be added and tags prefixed with '-' will be removed.
 -
 -Each character of the tag name may consist of alphanumeric
 -characters as well as `_.+-'.
 -
 -  (interactive (notmuch-read-tag-changes))
 +See `notmuch-tag' for information on the format of TAG-CHANGES.
 +  (interactive)
(apply 'notmuch-tag notmuch-search-query-string tag-changes))

My only comment here is that I wonder about the tag-all command. I can
see that this is a performance win over applying tag region to the whole
buffer but is it another place where we have a race with incoming mail
(ie we tag everything that now matches rather than everything in the
buffer).

A second advantage with the tag-region form is that it automatically
does excludes. Currently notmuch-tag does not do excludes as it looked
very hairy to implement correctly: thus the tag-all command could spend
a lot of time tagging excluded messages.

OTOH this seems to be a feature of the existing code so a fix is not
required for this series.

(Note I would not consider this a full review as my lisp is not good
enough; eg I am unsure  why the change from apply to funcall was
needed).

Best wishes

Mark

  
  (defun notmuch-search-buffer-title (query)
 -- 
 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


Re: bug fixes to emacs notmuch-tag-completion function

2012-04-09 Thread Mark Walters

All three of these look good to me and include some genuine bug
fixes. +1

Best wishes

Mark

On Mon, 09 Apr 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:
 I had originally included this fixes as part of a more involved series
 to fix up tagging functions [0].  However, these are actually bug
 fixes that stand alone and should not be bogged down in a series
 that's likely going to take a while to come to fruition.  The changes
 here are pretty trivial, so hopefully they can get pushed quickly and
 I'll rework the rest of tagging fix up series on top of them.

 jamie.

 [0] id:154853-25729-1-git-send-email-jroll...@finestructure.net

 ___
 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] replace gnu xargs usage in notmuch-mutt with perl

2012-04-09 Thread Taylor Carpenter
---
 contrib/notmuch-mutt/notmuch-mutt |   12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/contrib/notmuch-mutt/notmuch-mutt 
b/contrib/notmuch-mutt/notmuch-mutt
index 71206c3..dbe7f2d 100755
--- a/contrib/notmuch-mutt/notmuch-mutt
+++ b/contrib/notmuch-mutt/notmuch-mutt
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl -w
 #
 # notmuch-mutt - notmuch (of a) helper for Mutt
 #
@@ -12,6 +12,7 @@ use strict;
 use warnings;
 
 use File::Path;
+use File::Basename;
 use Getopt::Long qw(:config no_getopt_compat);
 use Mail::Internet;
 use Mail::Box::Maildir;
@@ -41,9 +42,12 @@ sub search($$) {
 $query = shell_quote($query);
 
 empty_maildir($maildir);
-system(notmuch search --output=files $query
-  .  | sed -e 's: : :g'
-  .  | xargs --no-run-if-empty ln -s -t $maildir/cur/);
+my @filelist = `notmuch search --output=files $query`;
+foreach(@filelist) {
+chomp;
+my $target = sprintf($maildir/cur/%s, basename($_));
+symlink($_, $target);
+}
 }
 
 sub prompt($$) {
-- 
1.7.7.4

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


Re: [PATCH 4/4] Explicitly type void* pointers

2012-04-09 Thread Jani Nikula
Vladimir Marek vladimir.ma...@oracle.com writes:

 Hi,

 Hi, does notmuch not compile without this? IIRC talloc_steal is a macro
 that's supposed to provide type safety (at least with GCC), and I'd be
 hesitant about adding the casts. Please look in your talloc.h.

 It does not compile. It might be that I'm using Sun/Oracle CC instead of
 gcc. The error looks like this:

 lib/database.cc, line 1368: Error: Cannot assign void* to const char*.

In general, that's not a difference in the C++ compilers. You can't
assign 'void *' to 'T *' in C++.

 When looking into talloc documentation, the definition seems to be:

 void* talloc_steal ( const void * new_ctx, const void * ptr )

 http://talloc.samba.org/talloc/doc/html/group__talloc.html#gaccc66139273e727183fb5bdda11ef82c


 When looking into talloc.h, it says:

 /* try to make talloc_set_destructor() and talloc_steal() type safe,
if we have a recent gcc */

It just so happens that the trick for type safety fixes the problem for
recent GCC by having an explicit cast.

 So, maybe the way to satisfy everyone would be:

 notmuch_message_t *tmp_message = message;
 talloc_steal(notmuch, tmp_message);
 return(tmp_message);

 Or alternatively,

 #if (__GNUC__ = 3)
return talloc_steal (notmuch, message);
 #else
return (notmuch_message_t*) talloc_steal (notmuch, message);
 #fi


 Of course I'm happy either way :)

I'm throwing in a third alternative below. Does it work for you? I think
it's both prettier and uglier than the above at the same time! ;)

A middle ground would be to change the callers to use
notmuch_talloc_steal, and just #define notmuch_talloc_steal
talloc_steal if __GNUC__ = 3.

One could argue upstream talloc should have this, but OTOH it's a C
library.

BR,
Jani.


diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index ea836f7..83b46e8 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -499,4 +499,22 @@ _notmuch_filenames_create (const void *ctx,
 
 NOTMUCH_END_DECLS
 
+#ifdef __cplusplus
+/* Implicit typecast from 'void *' to 'T *' is okay in C, but not in
+ * C++. In talloc_steal, an explicit cast is provided for type safety
+ * in some GCC versions. Otherwise, a cast is required. Provide a
+ * template function for this to maintain type safety, and redefine
+ * talloc_steal to use it.
+ */
+#if !(__GNUC__ = 3)
+template class T
+T *notmuch_talloc_steal(const void *new_ctx, const T *ptr)
+{
+return static_castT*(talloc_steal(new_ctx, ptr));
+}
+#undef talloc_steal
+#define talloc_steal notmuch_talloc_steal
+#endif
+#endif
+
 #endif
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: Message deletion wisdom

2012-04-09 Thread green
Mark Anderson wrote at 2012-04-06 15:17 -0500:
 On Thu, 5 Apr 2012 12:20:43 -0400, Antoine Beaupré anar...@anarcat.ath.cx 
 wrote:
  Finally, I want to voice that I feel a delete key, even if it doesn't
  delete mails, seems like an important part of a mail user
  agent. Archiving mail is one thing, but for the love and respect of
  sysadmins and the infrastructure they maintain, please consider adding
  at least a way to *tag* those deleted emails.
  
  Having the above keys being defined as standard in notmuch don't seem
  like much to ask.
  
  This may be a dissenting view here, but your mail is not that
  important. :P
 
 Hear! Hear!

I agree also.  I receive lots of mail that I never want to see again, nor do 
I want to see it still existing anywhere in my /home/user or in my backups.  
Someone might argue but what if you decide you want it later but I can use 
an Expires header to mark a message like delete in 2 months, so I still 
have a chance to retrieve it within an amount of time I choose.

Somewhat related is the concept of saving spam messages.  I can understand 
the reasoning behind training bayesian filters, but I have never kept spam.  
I switched to bogofilter recently, and it was correctly filtering mail very 
quickly, perhaps within a few weeks (I did train it using non-spam messages).


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


Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view

2012-04-09 Thread Mark Walters

This looks fine to me (but I am not a lisp expert).

Mark

On Sat, 10 Mar 2012, Dmitry Kurochkin dmitry.kuroch...@gmail.com wrote:
 This patch removes trailing spaces in notmuch-hello view.

 A side effect of this change is that tag/query buttons no longer
 include a space at the end.  This means that pressing RET when the
 point is at the first character after the tag/query button no longer
 works (note that this is the standard behavior for buttons).  We may
 change this behavior in the future (without adding trailing spaces
 back) if people would find this change inconvenient.
 ---
  emacs/notmuch-hello.el |   30 
 
  test/emacs |2 +-
  test/emacs.expected-output/notmuch-hello   |2 +-
  .../emacs.expected-output/notmuch-hello-long-names |6 ++--
  .../notmuch-hello-new-section  |2 +-
  .../notmuch-hello-section-counts   |4 +-
  .../notmuch-hello-section-hidden-tag   |2 +-
  .../notmuch-hello-section-with-empty   |2 +-
  .../emacs.expected-output/notmuch-hello-with-empty |2 +-
  9 files changed, 23 insertions(+), 29 deletions(-)

 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
 index 28f39f1..17f7edd 100644
 --- a/emacs/notmuch-hello.el
 +++ b/emacs/notmuch-hello.el
 @@ -429,7 +429,8 @@ Such a list can be computed with 
 `notmuch-hello-query-counts'.
(let* ((widest (notmuch-hello-longest-label searches))
(tags-and-width (notmuch-hello-tags-per-line widest))
(tags-per-line (car tags-and-width))
 -  (widest (cdr tags-and-width))
 +  (column-width (cdr tags-and-width))
 +  (column-indent 0)
(count 0)
(reordered-list (notmuch-hello-reflect searches tags-per-line))
;; Hack the display of the buttons used.
 @@ -441,32 +442,25 @@ Such a list can be computed with 
 `notmuch-hello-query-counts'.
  (mapc (lambda (elem)
   ;; (not elem) indicates an empty slot in the matrix.
   (when elem
 +   (if ( column-indent 0)
 +   (widget-insert (make-string column-indent ? )))
 (let* ((name (first elem))
(query (second elem))
 -  (msg-count (third elem))
 -  (formatted-name (format %s  name)))
 +  (msg-count (third elem)))
   (widget-insert (format %8s 
  (notmuch-hello-nice-number msg-count)))
 - (if (string= formatted-name notmuch-hello-target)
 + (if (string= name notmuch-hello-target)
   (setq found-target-pos (point-marker)))
   (widget-create 'push-button
  :notify #'notmuch-hello-widget-search
  :notmuch-search-terms query
 -formatted-name)
 - (unless (eq (% count tags-per-line) (1- tags-per-line))
 -   ;; If this is not the last tag on the line, insert
 -   ;; enough space to consume the rest of the column.
 -   ;; Because the button for the name is `(1+ (length
 -   ;; name))' long (due to the trailing space) we can
 -   ;; just insert `(- widest (length name))' spaces - the
 -   ;; column separator is included in the button if
 -   ;; `(equal widest (length name)'.
 -   (widget-insert (make-string (max 0
 -(- widest (length name)))
 -   ? )
 +name)
 + (setq column-indent
 +   (1+ (max 0 (- column-width (length name)))
   (setq count (1+ count))
 - (if (eq (% count tags-per-line) 0)
 - (widget-insert \n)))
 + (when (eq (% count tags-per-line) 0)
 +   (setq column-indent 0)
 +   (widget-insert \n)))
 reordered-list)
  
  ;; If the last line was not full (and hence did not include a
 diff --git a/test/emacs b/test/emacs
 index 29a489c..42780af 100755
 --- a/test/emacs
 +++ b/test/emacs
 @@ -39,7 +39,7 @@ test_begin_subtest Navigation of notmuch-hello to search 
 results
  test_emacs '(notmuch-hello)
   (goto-char (point-min))
   (re-search-forward inbox)
 - (widget-button-press (point))
 + (widget-button-press (1- (point)))
   (notmuch-test-wait)
   (test-output)'
  test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
 diff --git a/test/emacs.expected-output/notmuch-hello 
 b/test/emacs.expected-output/notmuch-hello
 index 1470790..2d69891 100644
 --- a/test/emacs.expected-output/notmuch-hello
 +++ b/test/emacs.expected-output/notmuch-hello
 @@ -2,7 +2,7 @@
  
  Saved searches: [edit]
  
 -   52 inbox   52 unread
 +   52 inbox   52 unread
  
  Search:   

Re: [PATCH] replace gnu xargs usage in notmuch-mutt with perl

2012-04-09 Thread David Bremner

Hi Taylor, and thanks for the patch.

In general for notmuch patches we prefer

- some kind of commit message beyond the one line summary explaining the
rationale for the change.

- not to have unrelated changes (/usr/bin/env perl) in the patch.

d


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