[PATCH] replace null terminator in string

2011-03-16 Thread James Vasile
In order to make the prior patch work for trailing whitespace, we also need 
this one.
---
 lib/thread.cc |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 7a816ea..54fde2b 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -291,6 +291,8 @@ rectify_whitespace (char *str)
   *curr = 32; //space
   while (curr++ < last);

+  *(last+1) = 0;
+
   return str;
 }

-- 
1.7.2.3


[PATCH] Remove/replace vertical whitespace in subject header field body.

2011-03-16 Thread James Vasile
RFC 822 specifies that headers are one-liners of ASCII:

> The field-body may be composed of any ASCII characters, except CR or
> LF.  (While CR and/or LF may be present in the actual text, they are
> removed by the action of unfolding the field.)

RFC 5335 allows UTF-8 in header field bodies, but as I read the docs,
the RFC 822 specification that they end up as one-liners still applies.

RFC 5322 describes folding and unfolding as follows:

> Each header field is logically a single line of characters comprising
> the field name, the colon, and the field body. For convenience
> however, and to deal with the 998/78 character limitations per line,
> the field body portion of a header field can be split into a
> multiple-line representation; this is called "folding". The general
> rule is that wherever this specification allows for folding white
> space (not simply WSP characters), a CRLF may be inserted before any
> WSP.
...
> The process of moving from this folded multiple-line representation of
> a header field to its single line representation is called
> "unfolding". Unfolding is accomplished by simply removing any CRLF
> that is immediately followed by WSP.

Again, unfolded subjects should be one-liners.

An email was sent to me from pingg.com (I think it's a pretentious
version of evite) came with a subject of
"=?utf-8?Q?bring_small_items_for_a_pi=C3=B1ata=21=21=21=21=0A?=", which
"notmuch search" displays as "Subject: bring small items for a
pi?ata" with a \n at the end.  This befuddles the emacs UI ("Error:
Unexpected output from notmuch search:").  I've attached an email that
reproduces the error.

I don't think ending the subject with a utf-8-encoded 0x0A followed by
the usual CRLF is RFC-compliant.  Still, notmuch should surely follow
the deplorable "accept liberally/emit conservatively" doctrine.

Here is a patch that trims leading and trailing whitespace from subjects
and replaces internal non-space, non-horizontal-tab whitespace with
spaces.  It fixes the problem described in this message.
---
 lib/thread.cc |   36 
 1 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 5190a66..7a816ea 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -266,6 +266,34 @@ _thread_add_message (notmuch_thread_t *thread,
 }
 }

+/* Remove leading/trailing whitespace and replace internal vertical
+ * whitespace with spaces.
+ */
+static char *
+rectify_whitespace (char *str)
+{
+  char *last;
+  char *curr;
+
+  while (isspace (*str))
+str++;
+
+  if (*str == 0)
+return str;
+
+  last = str + strlen(str) - 1;
+  while (last > str && isspace (*last))
+last--;
+
+  curr = str;
+  do
+if ((*curr >= 10) && (*curr <= 13))
+  *curr = 32; //space
+  while (curr++ < last);
+
+  return str;
+}
+
 static void
 _thread_set_subject_from_message (notmuch_thread_t *thread,
  notmuch_message_t *message)
@@ -282,11 +310,11 @@ _thread_set_subject_from_message (notmuch_thread_t 
*thread,
(strncasecmp (subject, "Vs: ", 4) == 0) ||
(strncasecmp (subject, "Sv: ", 4) == 0)) {

-   cleaned_subject = talloc_strndup (thread,
- subject + 4,
- strlen(subject) - 4);
+  cleaned_subject = rectify_whitespace(talloc_strndup (thread,
+  subject + 4,
+  strlen(subject) - 
4));
 } else {
-   cleaned_subject = talloc_strdup (thread, subject);
+  cleaned_subject = rectify_whitespace(talloc_strdup (thread, subject));
 }

 if (thread->subject)
-- 
1.7.2.3



-- next part --
A non-text attachment was scrubbed...
Name: malformed_subject
Type: application/octet-stream
Size: 351 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110316/d51114bb/attachment.obj>


problem with folder: search in python bindings

2011-03-16 Thread Sebastian Spaeth
On Tue, 15 Mar 2011 11:30:30 -0700, Jameson Rollins  wrote:
> Hey, folks.  I'm seeing something peculiar with the python bindings.
> It seems that I am not able to get any results when doing "folder:"
> searches with the python bindings.  I'm using a version of notmuch that
> includes the folder index patch.

Interesting, this is not at all what I am seeing in the current
bindings:

cd ~/src/notmuch/bindings/python;./notmuch.py count 'folder:sent'
1957
/usr/local/bin/notmuch count  'folder:sent'
1957

> Anyone have any idea what could be going on here?  I'm not familiar with
> how the python bindings work, unfortunately.

The folder: stuff came after my latest work on the bindings, so I
haven't really tested things with that. But I don't see why it should
work any other than other queries too.

Some quotation issues at work perhaps?

Sebastian
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110316/79e1cb67/attachment.pgp>


python documentation

2011-03-16 Thread Sebastian Spaeth
On Tue, 15 Mar 2011 15:01:15 -0400, James Vasile  
wrote:
> Yep, just a completed TODO.  Patch below.

Fixed and pushed. Thanks.

Sebastian
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20110316/3c1564ae/attachment.pgp>


[PATCH] emacs: "message-cited-text-face" is obsolete since Emacs 22.1. Use "message-cited-text" instead.

2011-03-16 Thread David Bremner


Hi Pieter;

Thanks a lot for the the patch.  I notice there is no commit message in
the body, so I suspect the chances of Carl applying it as-is are pretty
remote. Of course I could be off-base, but we've had many patches in the
past go back for improved commit messages.

All the best,

David


[PATCH] emacs: "message-cited-text-face" is obsolete since Emacs 22.1. Use "message-cited-text" instead.

2011-03-16 Thread Pieter Praet

---
 emacs/notmuch-wash.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index c4a7a41..0e64eb2 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -125,7 +125,7 @@ is what to put on the button."
 (let* ((cite-start (match-beginning 0))
   (cite-end (match-end 0))
   (cite-lines (count-lines cite-start cite-end)))
-  (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
+  (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text)
   (when (> cite-lines (+ notmuch-wash-citation-lines-prefix
 notmuch-wash-citation-lines-suffix
 1))
@@ -151,7 +151,7 @@ is what to put on the button."
  (sig-end-marker (make-marker)))
  (set-marker sig-start-marker sig-start)
  (set-marker sig-end-marker (point-max))
- (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 
'message-cited-text-face)
+ (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 
'message-cited-text)
  (notmuch-wash-region-to-button
   sig-start-marker sig-end-marker
   "signature" "\n"
---


Org-mode support

2011-03-16 Thread micah anderson

Hi Matthieu!

On Mon, 07 Feb 2011 22:22:17 +0100, Matthieu Lemerre  wrote:
> I have written the org-mode support for notmuch a while ago. It allows
> to open links to notmuch from org-mode and create org-mode link from
> notmuch buffers.
> 
> The current maintainer of the package is looking for feedback for
> inclusion of the package in the org-mode trunk, so if anyone is using
> org-mode, I think it would be a good idea to say so on the orgmode
> mailing list!

Thanks so much for sending this, its very interesting! I've just started
trying it and have managed to use M-x org-store-link on your email to
add an org-mode todo item to try out org-mode support for notmuch :)

I have one question, how do you add multiple query arguments? For
example, in my org file I tried 'notmuch-search:tag:notmuch' - this
worked great, but if I did 'notmuch-search:tag:notmuch and subject:Org'
the link only works up until the first space.

I also noticed that David Bremner has done something similar[0] and I
wonder if you have looked at his code[1], or if David has looked at
yours. Perhaps the start of a collaboration?

Micah

0. id:1259979997-31544-1-git-send-email-david at tethera.net
1. 
http://pivot.cs.unb.ca/git/?p=org-mode.git;a=shortlog;h=refs/heads/notmuch-link
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



[PATCH] emacs: message-cited-text-face is obsolete since Emacs 22.1. Use message-cited-text instead.

2011-03-16 Thread Pieter Praet

---
 emacs/notmuch-wash.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index c4a7a41..0e64eb2 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -125,7 +125,7 @@ is what to put on the button.
 (let* ((cite-start (match-beginning 0))
   (cite-end (match-end 0))
   (cite-lines (count-lines cite-start cite-end)))
-  (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
+  (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text)
   (when ( cite-lines (+ notmuch-wash-citation-lines-prefix
 notmuch-wash-citation-lines-suffix
 1))
@@ -151,7 +151,7 @@ is what to put on the button.
  (sig-end-marker (make-marker)))
  (set-marker sig-start-marker sig-start)
  (set-marker sig-end-marker (point-max))
- (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 
'message-cited-text-face)
+ (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 
'message-cited-text)
  (notmuch-wash-region-to-button
   sig-start-marker sig-end-marker
   signature \n
---
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: python documentation

2011-03-16 Thread Sebastian Spaeth
On Tue, 15 Mar 2011 15:01:15 -0400, James Vasile ja...@hackervisions.org 
wrote:
 Yep, just a completed TODO.  Patch below.

Fixed and pushed. Thanks.

Sebastian


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


Re: problem with folder: search in python bindings

2011-03-16 Thread Sebastian Spaeth
On Tue, 15 Mar 2011 11:30:30 -0700, Jameson Rollins 
jroll...@finestructure.net wrote:
 Hey, folks.  I'm seeing something peculiar with the python bindings.
 It seems that I am not able to get any results when doing folder:
 searches with the python bindings.  I'm using a version of notmuch that
 includes the folder index patch.

Interesting, this is not at all what I am seeing in the current
bindings:

cd ~/src/notmuch/bindings/python;./notmuch.py count 'folder:sent'
1957
/usr/local/bin/notmuch count  'folder:sent'
1957

 Anyone have any idea what could be going on here?  I'm not familiar with
 how the python bindings work, unfortunately.

The folder: stuff came after my latest work on the bindings, so I
haven't really tested things with that. But I don't see why it should
work any other than other queries too.

Some quotation issues at work perhaps?

Sebastian


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


Re: Org-mode support

2011-03-16 Thread Matthieu Lemerre

Hi Micah,

 Thanks so much for sending this, its very interesting! I've just started
 trying it and have managed to use M-x org-store-link on your email to
 add an org-mode todo item to try out org-mode support for notmuch :)

Great, that's how it is supposed to be used! :)

 I have one question, how do you add multiple query arguments? For
 example, in my org file I tried 'notmuch-search:tag:notmuch' - this
 worked great, but if I did 'notmuch-search:tag:notmuch and subject:Org'
 the link only works up until the first space.

This is because org-mode links must be url encoded (this is a org-mode
limitation, could do nothing about it). So in links that contain spaces,
such as yours, spaces must be replaced by %20, like this:

[[notmuch-search:toto%20and%20tata][Notmuch search: toto and tata]]

 I also noticed that David Bremner has done something similar[0] and I
 wonder if you have looked at his code[1], or if David has looked at
 yours. Perhaps the start of a collaboration?

If I remember correctly, I specifically forbid myself to look into this
code because David had copyright issues with its employer. But I believe
that both codes are doing essentially the same thing.

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


[PATCH] replace null terminator in string

2011-03-16 Thread James Vasile
In order to make the prior patch work for trailing whitespace, we also need 
this one.
---
 lib/thread.cc |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 7a816ea..54fde2b 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -291,6 +291,8 @@ rectify_whitespace (char *str)
   *curr = 32; //space
   while (curr++  last);
 
+  *(last+1) = 0;
+
   return str;
 }
 
-- 
1.7.2.3
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch