Re: [PATCH 2/2] test: Add tests for advance/rewind.

2011-12-30 Thread David Edmondson
What's the general feeling about this approach to producing tests for
the emacs UI? (That is, code the test in a .el file and call the
relevant function(s) from the test harness.)

It makes it simpler to develop and maintain the test (because you can do
more work with traditional emacs support for editing elisp), but might
make interpreting failures more difficult (the test harness mostly just
reports 'failed').


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


Segmentation fault at gmime-iconv with python binding

2011-12-30 Thread Kazuo Teramoto
Hi!

When I try to run the attached test.py after adding the attached email
(4EFC743A.3060609_april.org) to notmuch db I got a segmentation fault
(gdb bt attached).

This is what I think a relevant part of the gdb:

(gdb) frame 1
#1  0x75f2759c in g_mime_iconv_open (to=0x761ef0 "UTF-8", from=0x83d590 
"iso-8859-1") at gmime-iconv.c:261
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache, 
key, TRUE))) {
(gdb) list
256 key = g_alloca (strlen (from) + strlen (to) + 2);
257 sprintf (key, "%s:%s", from, to);
258 
259 ICONV_CACHE_LOCK ();
260 
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache, 
key, TRUE))) {
262 if (node->used) {
263 if ((cd = iconv_open (to, from)) == (iconv_t) 
-1)
264 goto exception;
265 } else {
(gdb) print iconv_cache
$1 = (Cache *) 0x0
(gdb) 


iconv_cache is initialized in g_mime_iconv_init() that is called by
g_mime_init().

notmuch CLI show the message correct. I know nothing about gmime or
notmuch code, but can this be the case of the python bindings not
calling g_mime_init() correctly?

Regards,
Kazuo Teramoto
#!/usr/bin/env python2
import notmuch
db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
q_new = notmuch.Query(db, 'id:"4efc743a.3060...@april.org"')
for t in q_new.search_threads():
pass
Message-ID: <4efc743a.3060...@april.org>
Date: Thu, 29 Dec 2011 15:07:54 +0100
From: "=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=" 
User-Agent: Mozilla/5.0 (X11; Linux i686;
 rv:9.0) Gecko/20111224 Thunderbird/9.0.1
MIME-Version: 1.0
To: Allan McRae , 
 "Discussion about the Arch User Repository (AUR)" 
References: <4efc3931.6030...@april.org> <4efc3d62.4030...@archlinux.org>
In-Reply-To: <4efc3d62.4030...@archlinux.org>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Subject: Re: [aur-general] Guidelines: cp, mkdir vs install

Le 29/12/2011 11:13, Allan McRae a écrit :
> On 29/12/11 19:56, François Boulogne wrote:
>> Hi,
>>
>> Looking to improve the quality of my packages, I read again the guidelines.
>> https://wiki.archlinux.org/index.php/Arch_Packaging_Standards
>>
>> However, it don't see anything about the install command like
>> install -d $pkgdir/usr/{bin,share/man/man1,share/locale}
>>
>> Some contributors on AUR use cp or mkdir to install files/dir (when no
>> makefile is provided) and others use install command.
>>
>> What's the opinion of TU on this point?
>>
> 
> Use install with -m specifying the correct permissions
> 

Thank you Allan


-- 
François Boulogne.
https://www.sciunto.org
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /usr/bin/python2...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python2 test.py
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x75f4fd82 in cache_node_lookup (cache=0x0, key=0x7fffaab0 
"iso-8859-1:UTF-8", use=1) at cache.c:110
110 node = g_hash_table_lookup (cache->node_hash, key);
(gdb) bt
#0  0x75f4fd82 in cache_node_lookup (cache=0x0, key=0x7fffaab0 
"iso-8859-1:UTF-8", use=1) at cache.c:110
#1  0x75f2759c in g_mime_iconv_open (to=0x761ef0 "UTF-8", from=0x83d590 
"iso-8859-1") at gmime-iconv.c:261
#2  0x75f4633f in rfc2047_decode_word (in=0x82f350 
"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=", inlen=36) at gmime-utils.c:1839
#3  0x75f46ad1 in g_mime_utils_header_decode_phrase (phrase=0x82f350 
"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=") at gmime-utils.c:2084
#4  0x75f4a759 in _internet_address_decode_name (ia=0x83d630, 
name=0x88fae0) at internet-address.c:1367
#5  0x75f4afab in decode_address (in=0x7fffad60) at 
internet-address.c:1659
#6  0x75f4b003 in internet_address_list_parse_string (str=0x766530 
"\"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=\" ") at 
internet-address.c:1692
#7  0x761915d7 in _thread_add_message (thread=0x6d99d0, 
message=0x6d9330) at lib/thread.cc:236
#8  0x76191dd7 in _notmuch_thread_create (ctx=0x7d54e0, 
notmuch=0x6e01d0, seed_doc_id=213092, match_set=0x83c888, 
sort=NOTMUCH_SORT_NEWEST_FIRST) at lib/thread.cc:470
#9  0x761906b7 in notmuch_threads_get (threads=0x83c870) at 
lib/query.cc:392
#10 0x765a7e34 in ffi_call_unix64 () from /usr/lib/libffi.so.5
#11 0x765a7855 in ffi_call () from /usr/lib/libffi.so.5
#12 0x767bb1f

Re: [PATCH] test: Remove #! line from test-lib.sh

2011-12-30 Thread David Bremner
On Wed, 28 Dec 2011 21:34:56 -0500, Austin Clements  wrote:
> It makes no sense to run test-lib.sh, so it makes no sense to give it
> an interpreter.  This is particularly annoying for Emacs users who
> have executable-insert set, since the presence of the #! line will
> cause Emacs to mark test-lib.sh executable when saving it, which will
> in turn case the 'basic' test to fail.

Pushed.

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


Re: [PATCH] test: Make generated message date a real date

2011-12-30 Thread David Bremner
On Wed, 28 Dec 2011 21:34:43 -0500, Austin Clements  wrote:
> January 5, 2001 was a Tuesday, not a Friday.  Jameson fixed this exact
> problem for the multipart test in ec2b0a98cc, but not for
> generate_message itself.

Pushed, 

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


Segmentation fault at gmime-iconv with python binding

2011-12-30 Thread Kazuo Teramoto
Hi!

When I try to run the attached test.py after adding the attached email
(4EFC743A.3060609_april.org) to notmuch db I got a segmentation fault
(gdb bt attached).

This is what I think a relevant part of it:

(gdb) frame 1
#1  0x75f2759c in g_mime_iconv_open (to=0x761ef0 "UTF-8",
from=0x83d590 "iso-8859-1") at gmime-iconv.c:261
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache,
key, TRUE))) {
(gdb) list
256 key = g_alloca (strlen (from) + strlen (to) + 2);
257 sprintf (key, "%s:%s", from, to);
258 
259 ICONV_CACHE_LOCK ();
260 
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache,
key, TRUE))) {
262 if (node->used) {
263 if ((cd = iconv_open (to, from)) == (iconv_t) 
-1)
264 goto exception;
265 } else {
(gdb) print iconv_cache
$1 = (Cache *) 0x0
(gdb)


iconv_cache is initialized in g_mime_iconv_init() that is called by
g_mime_init().

notmuch CLI show the message correct. I know nothing about gmime or
notmuch code, but can this be the case of the python bindings not
calling g_mime_init() correctly?

Regards,
Kazuo Teramoto
#!/usr/bin/env python2
import notmuch
db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
q_new = notmuch.Query(db, 'id:"4efc743a.3060...@april.org"')
for t in q_new.search_threads():
pass


4EFC743A.3060609_april.org
Description: Lotus Organizer


notmuch_py_gmime.gdb_bt
Description: Binary data
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/3 v2] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2011-12-30 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---

Added removal of backslashes from the mailbox part.

 emacs/notmuch-show.el |   52 
 1 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..01b774d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -230,21 +230,47 @@ indentation."
   "Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails."
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string "\"" "" name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; "User " style.
+   ((string-match "\\(.*\\) <\\(.*\\)>" address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; "" style.
+   ((string-match "<\\(.*\\)>" address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (t
+   (setq p-address address)))
+  
+  ;; Remove elements of the mailbox part that are not relevant for
+  ;; display, even if they are required during transport.
+  (when p-name
+   ;; Outer double quotes.
+   (when (string-match "^\"\\(.*\\)\"$" p-name)
+ (setq p-name (match-string 1 p-name)))
+
+   ;; Backslashes.
+   (setq p-name (replace-regexp-in-string "" "" p-name)))
+   
   ;; If the address is 'f...@bar.com ' then show just
   ;; 'f...@bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name " <" address ">")))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name " <" p-address ">")))
 (error address)))
 
 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3

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


Re: [PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Edmondson
On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin 
 wrote:
> Before the change, there were two ways to do search in Emacs UI:
> search widget in notmuch-hello buffer and `notmuch-search' function
> bound to "s".  Internally, notmuch-hello search widget uses
> `notmuch-search' function.  But it uses widget field input instead of
> minibuffer.
> 
> Such duplication is a major issue for notmuch-hello usability: search
> interface is inconsistent and lacks features that are available in
> minibuffer (e.g. history and auto completion).

Were there actual complaints about the usability of the current
approach?

I much preferred your alternative approach (merging the history while
leaving the UI alone).


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


Re: [notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2011-12-30 Thread David Edmondson
On Fri, 21 Oct 2011 22:50:48 +0200, Daniel Schoepe  wrote:
> On Tue, 23 Feb 2010 11:32:51 -0500, James Vasile  
> wrote:
> > Added notmuch-enqueue-asynch to replace calls to
> > notmuch-call-notmuch-process.  Calls to notmuch are then queued and
> > executed asynchronously.  If the db is busy and we get an error saying
> > it was locked, keep trying until the db is no longer busy.  Errors go
> > in a buffer as per usual.
> 
> I discovered this patch a while ago and it almost applies cleanly (the
> conflicts are easy to fix though) and it has made the emacs UI for
> notmuch _much_ more responsive and enjoyable for me. As discussed on
> IRC, issues such as where to handle retries in case the database is
> locked should probably be handled in the notmuch binary instead of each
> UI.
>
> I am however unaware of any patches to accomplish that and with the pace
> of development / patch reviews the way it is at the moment, this patch
> is a really helpful stop-gap (performing calls to notmuch asynchronously
> is useful independently of where concurrency issues are handled though)
> for me. If someone else agrees, I can fix the conflicts for this patch
> and send the revised version to the list.

It would be good to have an updated version of this patch if it is still
considered useful, though I don't suffer particularly from lag in the
emacs UI.

One concern is the string searching on the output of 'notmuch' to detect
the database locked condition. Perhaps 'notmuch' could be made to
return a specific error code in that case, negating the need to string
match?


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


Re: [PATCH v2] Ignore encrypted parts when indexing.

2011-12-30 Thread David Bremner
On Wed, 28 Dec 2011 12:14:29 -0800, Jameson Graef Rollins 
 wrote:
> It appears to be an oversight that encrypted parts were indexed
> previously.  The terms generated from encrypted parts are meaningless
> and do nothing but add bloat to the database.  It is not worth
> indexing the encrypted content, just as it's not worth indexing the
> signatures in signed parts.

Pushed.

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


Segmentation fault at gmime-iconv with python binding

2011-12-30 Thread Kazuo Teramoto
Hi!

When I try to run the attached test.py after adding the attached email
(4EFC743A.3060609_april.org) to notmuch db I got a segmentation fault
(gdb bt attached).

This is what I think a relevant part of it:

(gdb) frame 1
#1  0x75f2759c in g_mime_iconv_open (to=0x761ef0 "UTF-8", from=0x83d590 
"iso-8859-1") at gmime-iconv.c:261
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache, 
key, TRUE))) {
(gdb) list
256 key = g_alloca (strlen (from) + strlen (to) + 2);
257 sprintf (key, "%s:%s", from, to);
258 
259 ICONV_CACHE_LOCK ();
260 
261 if ((node = (IconvCacheNode *) cache_node_lookup (iconv_cache, 
key, TRUE))) {
262 if (node->used) {
263 if ((cd = iconv_open (to, from)) == (iconv_t) 
-1)
264 goto exception;
265 } else {
(gdb) print iconv_cache
$1 = (Cache *) 0x0
(gdb) 


iconv_cache is initialized in g_mime_iconv_init() that is called by
g_mime_init().

notmuch CLI show the message correct. I know nothing about gmime or
notmuch code, but can this be the case of the python bindings not
calling g_mime_init() correctly?

Regards,
Kazuo Teramoto
#!/usr/bin/env python2
import notmuch
db = notmuch.Database(mode=notmuch.Database.MODE.READ_WRITE)
q_new = notmuch.Query(db, 'id:"4efc743a.3060...@april.org"')
for t in q_new.search_threads():
pass


4EFC743A.3060609_april.org
Description: Lotus Organizer
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from /usr/bin/python2...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python2 test.py
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x75f4fd82 in cache_node_lookup (cache=0x0, key=0x7fffaab0 
"iso-8859-1:UTF-8", use=1) at cache.c:110
110 node = g_hash_table_lookup (cache->node_hash, key);
(gdb) bt
#0  0x75f4fd82 in cache_node_lookup (cache=0x0, key=0x7fffaab0 
"iso-8859-1:UTF-8", use=1) at cache.c:110
#1  0x75f2759c in g_mime_iconv_open (to=0x761ef0 "UTF-8", from=0x83d590 
"iso-8859-1") at gmime-iconv.c:261
#2  0x75f4633f in rfc2047_decode_word (in=0x82f350 
"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=", inlen=36) at gmime-utils.c:1839
#3  0x75f46ad1 in g_mime_utils_header_decode_phrase (phrase=0x82f350 
"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=") at gmime-utils.c:2084
#4  0x75f4a759 in _internet_address_decode_name (ia=0x83d630, 
name=0x88fae0) at internet-address.c:1367
#5  0x75f4afab in decode_address (in=0x7fffad60) at 
internet-address.c:1659
#6  0x75f4b003 in internet_address_list_parse_string (str=0x766530 
"\"=?ISO-8859-1?Q?Fran=E7ois_Boulogne?=\" ") at 
internet-address.c:1692
#7  0x761915d7 in _thread_add_message (thread=0x6d99d0, 
message=0x6d9330) at lib/thread.cc:236
#8  0x76191dd7 in _notmuch_thread_create (ctx=0x7d54e0, 
notmuch=0x6e01d0, seed_doc_id=213092, match_set=0x83c888, 
sort=NOTMUCH_SORT_NEWEST_FIRST) at lib/thread.cc:470
#9  0x761906b7 in notmuch_threads_get (threads=0x83c870) at 
lib/query.cc:392
#10 0x765a7e34 in ffi_call_unix64 () from /usr/lib/libffi.so.5
#11 0x765a7855 in ffi_call () from /usr/lib/libffi.so.5
#12 0x767bb1f7 in _ctypes_callproc () from 
/usr/lib/python2.7/lib-dynload/_ctypes.so
#13 0x767b4a86 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#14 0x77a66683 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#15 0x77afbbda in PyEval_EvalFrameEx () from 
/usr/lib/libpython2.7.so.1.0
#16 0x77afe8ef in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#17 0x77a8b15c in function_call () from /usr/lib/libpython2.7.so.1.0
#18 0x77a66683 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#19 0x77a752bf in instancemethod_call () from 
/usr/lib/libpython2.7.so.1.0
#20 0x77a66683 in PyObject_Call () from /usr/lib/libpython2.7.so.1.0
#21 0x77abc002 in call_method () from /usr/lib/libpython2.7.so.1.0
#22 0x77af8b1f in PyEval_EvalFrameEx () from 
/usr/lib/libpython2.7.so.1.0
#23 0x77afe8ef in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#24 0x77afea22 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#25 0x77b18d8c in run_mod () from /usr/lib/libpython2.7.so.1.0
#26 0x77b19b90 in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1.0
#27 0x00

[PATCH 2/3 v2] test: Add tests for `notmuch-show-clean-address'.

2011-12-30 Thread David Edmondson
---

Added backslash test. UTF8 round-trip still isn't right.

 test/emacs |   20 
 .../notmuch-address-simplification |   10 ++
 2 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-address-simplification

diff --git a/test/emacs b/test/emacs
index a06c223..69738cd 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,24 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 2
 
+test_begin_subtest "notmuch-show address simplification"
+test_emacs '
+(with-temp-buffer
+  (let ((input (list
+"f...@bar.com"
+""
+"Foo Bar "
+"f...@bar.com "
+"ДБ "
+"foo (at home) "
+"foo [at home] "
+"\"Foo Bar\" "
+"Foo Bar"
+"Fred Dibna \\[extraordinaire\\] "
+   )))
+(mapc (lambda (a) (insert (notmuch-show-clean-address a) "\n")) input))
+  (test-output))
+'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-address-simplification
+
 test_done
diff --git a/test/emacs.expected-output/notmuch-address-simplification 
b/test/emacs.expected-output/notmuch-address-simplification
new file mode 100644
index 000..4747827
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-address-simplification
@@ -0,0 +1,10 @@
+f...@bar.com
+f...@bar.com
+Foo Bar 
+f...@bar.com
+ДБ 
+foo (at home) 
+foo [at home] 
+Foo Bar 
+Foo Bar
+Fred Dibna [extraordinaire] 
-- 
1.7.7.3

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


[PATCH 3/3 v2] test: Fix the 'invalid from' test in light of address cleaning changes.

2011-12-30 Thread David Edmondson
---
 test/emacs |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/emacs b/test/emacs
index 69738cd..32d49ae 100755
--- a/test/emacs
+++ b/test/emacs
@@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads 
subject:message-with-invalid-from)
 test_emacs "(notmuch-show \"$thread\")
(test-output)"
 cat 

rewind and text/plain hooks and visual-line-mode and ...

2011-12-30 Thread David Edmondson
After setting up a new user recently[1] and discussion with j4ni, it
occurred to me that some of my recent patches are interrelated in a way
that I didn't previously realise.

Getting natural feeling `notmuch-show-rewind' behaviour (latest patches
are [2]) is made more difficult if `truncate-lines' is set to `nil',
because the cursor can end up somewhere at the end of a wrapped header
line when the start of the header line is not visible on the screen. The
current code has some tests for 'near the top of the window' that might
address this, but I removed them.

In general I think that having `truncate-lines' set to `t' in
`notmuch-show-mode' is better, as large numbers of tags causes the
header lines to wrap frequently, making a collapsed view of the threads
difficult to read (compare [3] and [4] for a quick example).

`notmuch-show-mode' could set `truncate-lines' to `t', but that would
clash with the use of `visual-line-mode', which turns off line
truncation and performs line wrapping.

`visual-line-mode' is useful because some mailers and/or users send
messages with very long lines. Luckily the patch to enable more cleaning
of text/plain parts[5] by default means that this would be less of a
problem, as most (all?) such messages would have their lines wrapped by
coolj.

There is no patch to remove `visual-line-mode' and set `truncate-lines'
yet, but it's simple for an interested developer to try.

Hence this is really a plea to consider these various patches (and the
resulting behaviour and appearance) together, even though they might not
immediately appear to be related.

Footnotes: 
[1]  "You're never too young to learn to use emacs."
[2]  id:"1325160490-23472-1-git-send-email-...@dme.org"
[3]  http://dme.org/data/images/2011-12-27-114014_958x1179_scrot.png
[4]  http://dme.org/data/images/2011-12-27-114028_958x1179_scrot.png
[5]  id:"1324987225-3067-1-git-send-email-...@dme.org"



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


[PATCH] emacs: Improved printing support.

2011-12-30 Thread David Edmondson
Add various functions to print notmuch messages and tie them together
with a simple frontend. No keybinding is currently made to encourage
paper saving.
---

Resurrecting an old patch.

 emacs/Makefile.local   |3 +-
 emacs/notmuch-print.el |   75 
 emacs/notmuch-show.el  |   51 
 3 files changed, 128 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-print.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 0c58b82..4fee0e8 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -13,7 +13,8 @@ emacs_sources := \
$(dir)/notmuch-maildir-fcc.el \
$(dir)/notmuch-message.el \
$(dir)/notmuch-crypto.el \
-   $(dir)/coolj.el
+   $(dir)/coolj.el \
+   $(dir)/notmuch-print.el
 
 emacs_images := \
$(srcdir)/$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
new file mode 100644
index 000..70fb041
--- /dev/null
+++ b/emacs/notmuch-print.el
@@ -0,0 +1,75 @@
+;; notmuch-print.el --- printing messages from notmuch.
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: David Edmondson 
+
+(defcustom notmuch-print-mechanism 'notmuch-print-lpr
+  "How should printing be done?"
+  :group 'notmuch
+  :type '(choice
+ (function :tag "Use lpr" notmuch-print-lpr)
+ (function :tag "Use ps-print" notmuch-print-ps-print)
+ (function :tag "Use ps-print then evince" 
notmuch-print-ps-print/evince)
+ (function :tag "Use muttprint" notmuch-print-muttprint)
+ (function :tag "Use muttprint then evince" 
notmuch-print-muttprint/evince)
+ (function :tag "Using a custom function")))
+
+(defmacro notmuch-print-with-file (filename &rest body)
+  `(with-temp-buffer
+ (insert-file-contents ,filename)
+ (set-buffer-modified-p nil)
+ ,@body))
+
+(defun notmuch-print-lpr (filename)
+  (notmuch-print-with-file filename
+  (lpr-buffer)))
+
+(defun notmuch-print-ps-print (filename)
+  (notmuch-print-with-file filename
+  (ps-print-buffer)))
+
+(defun notmuch-print-ps-print/evince (filename)
+  (let ((ps-file (make-temp-file "notmuch")))
+(notmuch-print-with-file filename
+(ps-print-buffer ps-file)
+(async-shell-command (concat "evince " ps-file)
+
+(defun notmuch-print-muttprint (filename)
+  (shell-command
+   (concat "muttprint "
+  "--file " (shell-quote-argument filename) " "
+  ;; Show the tags.
+  "--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ ")))
+
+(defun notmuch-print-muttprint/evince (filename)
+  (let ((ps-file (make-temp-file "notmuch")))
+(call-process-shell-command
+ (concat "muttprint "
+"--file " (shell-quote-argument filename) " "
+;; Show the tags.
+"--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ "
+"--printer \"TO_FILE:" (shell-quote-argument ps-file) "\""))
+(async-shell-command (concat "evince " ps-file
+
+(defun notmuch-print-message (filename)
+  (funcall notmuch-print-mechanism filename))
+
+;;
+
+(provide 'notmuch-print)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..5beadbc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -34,6 +34,7 @@
 (require 'notmuch-wash)
 (require 'notmuch-mua)
 (require 'notmuch-crypto)
+(require 'notmuch-print)
 
 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
 (declare-function notmuch-fontify-headers "notmuch" nil)
@@ -186,6 +187,51 @@ indentation."
   mm-handle (> (notmuch-count-attachments mm-handle) 1
   (message "Done"))
 
+(defun notmuch-show-with-message-as-text (fn)
+  "Apply function `fn' to a text representation of the current
+message."
+
+  ;; Remake the header to ensure that all information is available.
+  (let* ((to (notmuch-show-get-to))
+(cc (notmuch-show-get-cc))
+(from (notmuch-show-get-from))
+(subject (notmuch-show-get-subject))
+(date (notmuch-show-get-date))
+(tags (notmuch-show-get-tags))
+(depth (notmuch-show-get-depth))
+
+(header (concat
+ "Subject: " subject "\n"
+  

Re: [PATCH] bound mail-parse-charset, used by some functions on mm-view.el when there is no charset metadata in the html

2011-12-30 Thread David Edmondson
Konrad, can you provide a specific example of when this is useful? I
don't understand what it is for.


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


[PATCH] emacs: Better handling of inherited keymaps for `nomuch-help'.

2011-12-30 Thread David Edmondson
`notmuch-hello-mode' inherits the keymap for widgets, which confused
`notmuch-substitute-command-keys'. Fix the confusion.

Simplify `notmuch-substitute-command-keys' a little to make it easier
to read.
---
 emacs/notmuch.el |   17 -
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..6dd65ff 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -164,16 +164,23 @@ For a mouse binding, return nil."
"\t"
(notmuch-documentation-first-line action))
 
-(defalias 'notmuch-substitute-one-command-key
-  (apply-partially 'notmuch-substitute-one-command-key-with-prefix nil))
+(defun notmuch-substitute-command-keys-one (key)
+  ;; A `keymap' key indicates inheritance from a parent keymap - the
+  ;; inherited mappings follow, so there is nothing to print for
+  ;; `keymap' itself.
+  (when (not (eq key 'keymap))
+(notmuch-substitute-one-command-key-with-prefix nil key)))
 
 (defun notmuch-substitute-command-keys (doc)
   "Like `substitute-command-keys' but with documentation, not function names."
   (let ((beg 0))
 (while (string-match "{\\([^}[:space:]]*\\)}" doc beg)
-  (let ((map (substring doc (match-beginning 1) (match-end 1
-   (setq doc (replace-match (mapconcat 'notmuch-substitute-one-command-key
-   (cdr (symbol-value (intern map))) 
"\n") 1 1 doc)))
+  (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
+(keymap (symbol-value (intern keymap-name
+   (setq doc (replace-match
+  (mapconcat #'notmuch-substitute-command-keys-one
+ (cdr keymap) "\n")
+  1 1 doc)))
   (setq beg (match-end 0)))
 doc))
 
-- 
1.7.7.3

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


Re: 0.11 is frozen, please update NEWS

2011-12-30 Thread David Bremner
On Sun, 25 Dec 2011 15:55:43 -0400, David Bremner  wrote:
> 
> Well, it's -19C outside, so guess that is appropriate.

It's warmed up to -10C, with a brief interlude of +10C, so we must be
getting ready to unfreeze. Well, release, but that doesn't really work
as a pun.

> Speaking of NEWS, please have a look at the commits listed under your
> name, and if they impact user experience, then consider a patch for
> NEWS.

I received NEWS items from Tomi and Jani, and I tidied a few things off
the list that probably don't need NEWS items. Probably some more of the
following are also ignorable, but some of them definitely look like they
need NEWS items to me. Some of the contributions are from people that
might not be reading the list regularly, so NEWS items for other
people's patches are ok too.

As before, if you can push to nmbug you should be able to push 

   git push g...@pivot.cs.unb.ca HEAD:news

Or patches to the list are fine too.

> Aaron Ecay:
>   emacs: fix off-by-one bug in notmuch-show-archive

> Austin Clements:
>   emacs: Don't record undo information for search or show buffers.
>   emacs: Avoid unnecessary markers.
> 
> Dmitry Kurochkin :
>   emacs: do not call notmuch show for non-inlinable parts
> 
> Gregor Zattler:
>   emacs: make message indentation width customisable
> 
> Ivy Foster:
>   emacs: Add notmuch-hello-mode-hook
> 
> Jameson Graef Rollins (2):
>   emacs: breakout notmuch-show-advance functionality from 
> notmuch-show-advance-and-archive
>   emacs: call notmuch-show instead of notmuch-search in buttonised id: 
> links
> 

> Thomas Jost (4):
>   emacs: Add a face for crypto parts headers
>   emacs: add notmuch-hello-refresh-hook
>   emacs: rename notmuch-decimal-separator to 
> notmuch-hello-thousands-separator
>   emacs: Change the default thousands separator to a space
> 
> Thomas Schwinge (1):
>   dump: Don't sort the output by message id.
> 


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


Re: [PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 10:44:28 +, David Edmondson  wrote:
> On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin 
>  
> Were there actual complaints about the usability of the current
> approach?
> 
> I much preferred your alternative approach (merging the history while
> leaving the UI alone).

Personally I would like to be able to customize the hello screen to
remove the search box. I find it confusing that that 's' jumps to the
search box there, and everywhere else brings up the mini-buffer. That
might be just me, and the fact that I bind "C-c s" globally to
notmuch-search.  I could easily believe that for new users having a
search box is nicer.

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


Re: Segmentation fault at gmime-iconv with python binding

2011-12-30 Thread David Bremner
On Thu, 29 Dec 2011 22:57:27 -0200, Kazuo Teramoto  wrote:

> notmuch CLI show the message correct. I know nothing about gmime or
> notmuch code, but can this be the case of the python bindings not
> calling g_mime_init() correctly?

That seems likely. We worked around a similar problem by calling
g_type_init in notmuch_database_open. I'm not sure if it is permissible
to call g_mime_init more than once. The g_mime docs are, uhh, concise.

d


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


Re: [PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Edmondson
On Fri, 30 Dec 2011 10:43:37 -0400, David Bremner  wrote:
> On Fri, 30 Dec 2011 10:44:28 +, David Edmondson  wrote:
> > On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin 
> >  
> > Were there actual complaints about the usability of the current
> > approach?
> > 
> > I much preferred your alternative approach (merging the history while
> > leaving the UI alone).
> 
> Personally I would like to be able to customize the hello screen to
> remove the search box.

id:"1318253982-23588-2-git-send-email-dan...@schoepe.org" ?

> I find it confusing that that 's' jumps to the search box there, and
> everywhere else brings up the mini-buffer. That might be just me, and
> the fact that I bind "C-c s" globally to notmuch-search.  I could
> easily believe that for new users having a search box is nicer.

It was intended for people coming from more traditional clients, to help
get them into the swing of notmuch. Maybe also a bit of a joke in
comparison to the gmail interface. (Carl came up with the original idea
- I just knocked out some code.)


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


[PATCH] test/symbol-hiding: prepend new directory to LD_LIBRARY_PATH

2011-12-30 Thread Tomi Ollila
Tester may have set LD_LIBRARY_PATH to find libraries required
by notmuch. Therefore add $TEST_DIRECTORY/../lib to the beginning
of current list of library paths in $LD_LIBRARY_PATH before running
symbol-test.
---
 test/symbol-hiding |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/symbol-hiding b/test/symbol-hiding
index 68f0d1b..7fa7b2a 100755
--- a/test/symbol-hiding
+++ b/test/symbol-hiding
@@ -12,7 +12,7 @@ test_description='exception symbol hiding'
 . ./test-lib.sh
 
 run_test(){
-result=$(LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib 
$TEST_DIRECTORY/symbol-test 2>&1)
+
result=$(LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
 $TEST_DIRECTORY/symbol-test 2>&1)
 }
 
 output="A Xapian exception occurred opening database: Couldn't stat 
'fakedb/.notmuch/xapian'
-- 
1.7.7.4

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


ANNOUNCE: nottoomuch-addresses.sh version 1.6

2011-12-30 Thread Tomi Ollila

nottoomuch-addresses.sh -- email address substring matcher -- completion
helper version 1.6 is available.

This version fixes some 'encoded-text' (=?encoding?type?text?=)
handling.

Header version was not changed so rebuilding of address cache
is not enforced. However running

/path/to/nottoomuch-addresses.sh --update --rebuild

is recommended.


Location: http://www.iki.fi/too/nottoomuch/nottoomuch-addresses.sh

Sha1sum: 2e8be738baffbad3d1e15dea75106a683d62ecec

Web page: http://www.iki.fi/too/nottoomuch/nottoomuch-addresses/

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


Re: [PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 10:43:37 -0400, David Bremner  wrote:
> Personally I would like to be able to customize the hello screen to
> remove the search box. I find it confusing that that 's' jumps to the
> search box there, and everywhere else brings up the mini-buffer.

+1.  I rarely use notmuch-hello, but when I do, I press `s' then look to
the bottom of the screen and am always confused not to see a minibuffer
prompt.

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


[PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread Aaron Ecay
---
 NEWS |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index eaed960..3688944 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,16 @@ Automatic tag query optimization
   exclude messages whose tags won't change.  In the past, we've
   suggested that people do this by hand; this is no longer necessary.
 
+Emacs interface
+---
+
+Bug fixes
+
+  notmuch-show-advance (bound to the spacebar in notmuch-show-mode) had
+  a bug that caused it to always jump to the next message, even if it
+  should have scrolled down to show more of the current message instead.
+  This is now fixed.
+
 
 Notmuch 0.10.2 (2011-12-04)
 ===
-- 
1.7.8.2

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


Re: [PATCH v3] notmuch: replace built-in help with exec of man

2011-12-30 Thread Austin Clements
The C side looks good to me (with the updated commit message).  I
can't speak for the nroff side.

Quoth David Bremner on Dec 29 at  9:11 am:
> From: David Bremner 
> 
> Since we lose the fancy scanning of the commands for which ones take
> search terms, the search terms page SYNOPSIS should be updated.
> ---
>  notmuch.c |  482 
> +
>  1 files changed, 35 insertions(+), 447 deletions(-)
> 
> diff --git a/notmuch.c b/notmuch.c
> index c0ce026..477a09c 100644
> --- a/notmuch.c
> +++ b/notmuch.c
> @@ -29,7 +29,6 @@ typedef struct command {
>  command_function_t function;
>  const char *arguments;
>  const char *summary;
> -const char *documentation;
>  } command_t;
>  
>  #define MAX_ALIAS_SUBSTITUTIONS 3
> @@ -47,447 +46,40 @@ alias_t aliases[] = {
>  static int
>  notmuch_help_command (void *ctx, int argc, char *argv[]);
>  
> -static const char search_terms_help[] =
> -"\tSeveral notmuch commands accept a common syntax for search\n"
> -"\tterms.\n"
> -"\n"
> -"\tThe search terms can consist of free-form text (and quoted\n"
> -"\tphrases) which will match all messages that contain all of\n"
> -"\tthe given terms/phrases in the body, the subject, or any of\n"
> -"\tthe sender or recipient headers.\n"
> -"\n"
> -"\tAs a special case, a search string consisting of exactly a\n"
> -"\tsingle asterisk (\"*\") will match all messages.\n"
> -"\n"
> -"\tIn addition to free text, the following prefixes can be used\n"
> -"\tto force terms to match against specific portions of an email,\n"
> -"\t(where  indicate user-supplied values):\n"
> -"\n"
> -"\t\tfrom:\n"
> -"\t\tto:\n"
> -"\t\tsubject:\n"
> -"\t\tattachment:\n"
> -"\t\ttag: (or is:)\n"
> -"\t\tid:\n"
> -"\t\tthread:\n"
> -"\t\tfolder:\n"
> -"\n"
> -"\tThe from: prefix is used to match the name or address of\n"
> -"\tthe sender of an email message.\n"
> -"\n"
> -"\tThe to: prefix is used to match the names or addresses of\n"
> -"\tany recipient of an email message, (whether To, Cc, or Bcc).\n"
> -"\n"
> -"\tAny term prefixed with subject: will match only text from\n"
> -"\tthe subject of an email. Quoted phrases are supported when\n"
> -"\tsearching with: subject:\"this is a phrase\".\n"
> -"\n"
> -"\tFor tag: and is:, valid tag values include \"inbox\" and \"unread\"\n"
> -"\tby default for new messages added by \"notmuch new\" as well\n"
> -"\tas any other tag values added manually with \"notmuch tag\".\n"
> -"\n"
> -"\tFor id:, message ID values are the literal contents of the\n"
> -"\tMessage-ID: header of email messages, but without the '<','>'\n"
> -"\tdelimiters.\n"
> -"\n"
> -"\tThe thread: prefix can be used with the thread ID values that\n"
> -"\tare generated internally by notmuch (and do not appear in email\n"
> -"\tmessages). These thread ID values can be seen in the first\n"
> -"\tcolumn of output from \"notmuch search\".\n"
> -"\n"
> -"\tThe folder: prefix can be used to search for email message\n"
> -"\tfiles that are contained within particular directories within\n"
> -"\tthe mail store. Only the directory components below the top-level\n"
> -"\tmail database path are available to be searched.\n"
> -"\n"
> -"\tIn addition to individual terms, multiple terms can be\n"
> -"\tcombined with Boolean operators (\"and\", \"or\", \"not\", etc.).\n"
> -"\tEach term in the query will be implicitly connected by a\n"
> -"\tlogical AND if no explicit operator is provided, (except\n"
> -"\tthat terms with a common prefix will be implicitly combined\n"
> -"\twith OR until we get Xapian defect #402 fixed).\n"
> -"\n"
> -"\tParentheses can also be used to control the combination of\n"
> -"\tthe Boolean operators, but will have to be protected from\n"
> -"\tinterpretation by the shell, (such as by putting quotation\n"
> -"\tmarks around any parenthesized expression).\n"
> -"\n"
> -"\tFinally, results can be restricted to only messages within a\n"
> -"\tparticular time range, (based on the Date: header) with:\n"
> -"\n"
> -"\t\t..\n"
> -"\n"
> -"\tEach timestamp is a number representing the number of seconds\n"
> -"\tsince 1970-01-01 00:00:00 UTC. This is not the most convenient\n"
> -"\tmeans of expressing date ranges, but until notmuch is fixed to\n"
> -"\taccept a more convenient form, one can use the date program to\n"
> -"\tconstruct timestamps. For example, with the bash shell the\n"
> -"\tfollowing syntax would specify a date range to return messages\n"
> -"\tfrom 2009-10-01 until the current time:\n"
> -"\n"
> -"\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n";
> -
> -static const char hooks_help[] =
> -"\tHooks are scripts (or arbitrary executables or symlinks to such)

Re: [PATCH] notmuch-addresses: Match on the full name as well as components.

2011-12-30 Thread Jesse Rosenthal
Pushed.

Thanks,
Jesse

On Wed, 21 Dec 2011 13:49:17 +, David Edmondson  wrote:
> ---
>  notmuch_addresses.py |7 +--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch_addresses.py b/notmuch_addresses.py
> index bf45151..74a743c 100755
> --- a/notmuch_addresses.py
> +++ b/notmuch_addresses.py
> @@ -164,11 +164,14 @@ class NotmuchAddressMatcher(object):
>  addrs.append(v)
>  parsed_addrs = email.utils.getaddresses(addrs)
>  for addr in parsed_addrs:
> -mail = addr[1].lower()
> -split_names = addr[0].split(" ")
> +full_name = addr[0]
> +split_names = full_name.split(" ")
> +mail = addr[1]
>  if (len([name for name in split_names 
>   if self.match_function(name)]) > 0
>  or 
> +self.match_function(full_name)
> +or 
>  self.match_function(mail)):
>  
>  emails.add_email_and_name(mail, addr[0])
> -- 
> 1.7.7.3
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 10:52:17 +, David Edmondson  wrote:
> > I discovered this patch a while ago and it almost applies cleanly (the
> > conflicts are easy to fix though) and it has made the emacs UI for
> > notmuch _much_ more responsive and enjoyable for me.

This is definitely true for me as well.  So much so that I reinvented
this patch from scratch a couple of weeks ago.  (As Picasso said, good
artists copy, great artists steal.)

> > As discussed on IRC, issues such as where to handle retries in case
> > the database is locked should probably be handled in the notmuch
> > binary instead of each UI.

Hmm.  When my implementation detects that it cannot get the DB lock
after trying several times (up to ~2 mins of waiting), it stops
trying but continues to queue up operations.  The user can then
manually restart the queue.  This isn’t a principled solution, but
it avoids losing tagging operations from emacs while a long-running
process has the DB locked.  (My original motivation for writing the
patch was actually that my new-mail script sometimes holds the DB
lock when I am trying to read mail, leading to emacs errors and
dropped tagging operations.  The speedup was a welcome side effect.)

I haven’t had a chance to carefully look at the patch you found, so IDK
what its behavior would be in this case.

(The other thing that I dislike about the patch you found is that it
uses a call to the “sleep” command to wait, rather than using built-in
emacs functionality.)

> It would be good to have an updated version of this patch if it is still
> considered useful, though I don't suffer particularly from lag in the
> emacs UI.

The emacs UI has small delays, which dropped away when I applied my
version of this patch.  After being conditioned to expect them, I was
surprised to find how much faster everything seemed.  My hardware is old
but not ancient (5.5 year old Macbook; I suspect the bottleneck for
notmuch is the 5400rpm HDD).  Depending on your setup, you too might be
pleasantly surprised.

The test suite is borked on OS X and I don’t have access to a linux
machine while traveling.  I was planning on sending my patch in early
Jan. when I had a chance to verify it under the test suite (probably
requiring some changes to the emacs test library to make it async-safe).
I also haven’t tested the patch on Emacs versions older than 24 – but I
don’t think there are any impediments to compatibility with v.23 (not
sure about earlier versions).

Since there is interest, I’ll go ahead and send it now with all the
usual caveats about code under development.  I have been using the patch
for a couple of weeks without problems, though.  Daniel, if you want to
un-conflict (and squash) the patches from James that might be useful, at
least to compare the two approaches.

Aaron

-cut-here-

From f0a0fe04254d9b5e17c873b293c6a5a270cb909a Mon Sep 17 00:00:00 2001
From: Aaron Ecay 
Date: Mon, 19 Dec 2011 12:14:31 -0500
Subject: [PATCH] [emacs] add async tagging support

still a WIP
---
 emacs/notmuch.el |   55 +-
 1 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..ca077c2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -446,6 +446,59 @@ Complete list of currently available key bindings:
   (let ((message-id (notmuch-search-find-thread-id)))
 (notmuch-mua-new-reply message-id prompt-for-sender)))
 
+(defvar notmuch-process-queue nil
+  "Queue of pending notmuch tag operations.
+
+Each entry in the queue is a list of strings, which are arguments
+to be passed to the notmuch command.")
+
+(defvar notmuch-process-current-command nil
+  "The currently executing notmuch command arguments")
+
+(defvar notmuch-process-wait-time 1.0
+  "How long to wait for the db lock, in seconds.")
+
+(defvar notmuch-process-error nil)
+
+(defun notmuch-process-restart-queue ()
+  (interactive)
+  (setq notmuch-process-error nil)
+  (notmuch-process-kick-queue))
+
+(defun notmuch-process-kick-queue ()
+  (when notmuch-process-error
+;; TODO: better error msg, tell how to manually kick
+(error "Notmuch couldn't get the DB lock after trying for more than a 
minute."))
+  (when (and notmuch-process-queue
+(memq (process-status "notmuch") '(exit nil)))
+(let ((args (car notmuch-process-queue))
+ proc)
+  (setq notmuch-process-queue (cdr notmuch-process-queue)
+   notmuch-process-current-command args
+   proc (apply #'start-process "notmuch"
+   (get-buffer-create "*Notmuch output*")
+   notmuch-command args))
+  (set-process-sentinel proc #'notmuch-process-sentinel
+
+(defun notmuch-process-sentinel (proc status)
+  (if (equal status "finished\n")
+  (progn
+   (setq notmuch-process-wait-time 1.0
+ notmuch-process-current-command nil)
+   (notmuch-process-kick-queue))
+(setq notmuch-process-wait-tim

Re: [PATCH] notmuch-addresses: Match on the full name as well as components.

2011-12-30 Thread Jesse Rosenthal
Oh, and I moved the code to

http://commonmeasure.org/~jkr/notmuch_addresses.git

Best,
Jesse

On Fri, 30 Dec 2011 14:04:43 -0500, Jesse Rosenthal  wrote:
> Pushed.
> 
> Thanks,
> Jesse
> 
> On Wed, 21 Dec 2011 13:49:17 +, David Edmondson  wrote:
> > ---
> >  notmuch_addresses.py |7 +--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/notmuch_addresses.py b/notmuch_addresses.py
> > index bf45151..74a743c 100755
> > --- a/notmuch_addresses.py
> > +++ b/notmuch_addresses.py
> > @@ -164,11 +164,14 @@ class NotmuchAddressMatcher(object):
> >  addrs.append(v)
> >  parsed_addrs = email.utils.getaddresses(addrs)
> >  for addr in parsed_addrs:
> > -mail = addr[1].lower()
> > -split_names = addr[0].split(" ")
> > +full_name = addr[0]
> > +split_names = full_name.split(" ")
> > +mail = addr[1]
> >  if (len([name for name in split_names 
> >   if self.match_function(name)]) > 0
> >  or 
> > +self.match_function(full_name)
> > +or 
> >  self.match_function(mail)):
> >  
> >  emails.add_email_and_name(mail, addr[0])
> > -- 
> > 1.7.7.3
> > 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/2] Multiples calls of g_mime_init

2011-12-30 Thread Kazuo Teramoto
The gmime docs don't says if is ok to call g_mime_init multiple times,
but the code have a check for it in a form like this:

static unsigned int initialized = 0;
g_mime_init (guint32 flags)
{
if (initialized++)
return;

so the init code is run only once and notmuch don't need to explicit
check for an already initialized gmime.

This make possible to call g_mime_init again in lib/database.cc and this
call really solve the OP segmentation fault in python bindings.

Kazuo Teramoto (2):
  lib: Remove unnecessary checks when calling g_mime_init
  lib: call g_mime_init from notmuch_database_open

 lib/database.cc|5 +
 lib/index.cc   |4 
 lib/message-file.c |4 
 3 files changed, 5 insertions(+), 8 deletions(-)

-- 
1.7.8.1

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


[PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread Kazuo Teramoto
g_mime_init already check for multiple initializations.
---
 lib/index.cc   |4 
 lib/message-file.c |4 
 2 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index d8f8b2b..6764929 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -419,12 +419,8 @@ _notmuch_message_index_file (notmuch_message_t *message,
 FILE *file = NULL;
 const char *from, *subject;
 notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
-static int initialized = 0;
 
-if (! initialized) {
g_mime_init (0);
-   initialized = 1;
-}
 
 file = fopen (filename, "r");
 if (! file) {
diff --git a/lib/message-file.c b/lib/message-file.c
index 915aba8..78c7820 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -223,14 +223,10 @@ notmuch_message_file_get_header (notmuch_message_file_t 
*message,
 char *header, *decoded_value, *header_sofar, *combined_header;
 const char *s, *colon;
 int match, newhdr, hdrsofar, is_received;
-static int initialized = 0;
 
 is_received = (strcmp(header_desired,"received") == 0);
 
-if (! initialized) {
g_mime_init (0);
-   initialized = 1;
-}
 
 message->parsing_started = 1;
 
-- 
1.7.8.1

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


[PATCH 2/2] lib: call g_mime_init from notmuch_database_open

2011-12-30 Thread Kazuo Teramoto
We need to call g_mime_init to correct initialize the structures needed
by gmime before using it.
---
 lib/database.cc |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index d11dfaf..07ca3fd 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -28,6 +28,8 @@
 #include  /* g_free, GPtrArray, GHashTable */
 #include  /* g_type_init */
 
+#include  /* g_mime_init */
+
 using namespace std;
 
 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@@ -608,6 +610,9 @@ notmuch_database_open (const char *path,
 /* Initialize the GLib type system and threads */
 g_type_init ();
 
+/* Initialize gmime */
+g_mime_init (0);
+
 notmuch = talloc (NULL, notmuch_database_t);
 notmuch->exception_reported = FALSE;
 notmuch->path = talloc_strdup (notmuch, path);
-- 
1.7.8.1

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


Re: [PATCH 0/2] Multiples calls of g_mime_init

2011-12-30 Thread Patrick Totzke
hi!

while I cannot confirm that this patch solves the stated issue (cannot 
reproduce),
It seeminly doesn't break things either and I'm all in favour of doing things 
right™.

On a related note: It also doesn't fix the recent segfaults of the bindings
that occur when you try to write to a locked database.
cf "id:4eddf2b1.4288980a.0b74.5...@mx.google.com"

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


Re: [PATCH 0/2] Multiples calls of g_mime_init

2011-12-30 Thread Kazuo Teramoto
On 2011-12-30T23:16:47, Patrick Totzke wrote:

>It seeminly doesn't break things either and I'm all in favour of doing
>things right™.

And talking about doing things right, we probably need to call
g_mime_shutdown() too, one for every time we call g_mime_init(). I will
send a patch after I do some more tests.

>On a related note: It also doesn't fix the recent segfaults of the bindings
>that occur when you try to write to a locked database.
>cf "id:4eddf2b1.4288980a.0b74.5...@mx.google.com"
>

This still hit me. If I remember right when I did a test what is
happening is that the binding is trying to close the db, so we need a
check if the db is opened before trying to close it.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 13:42:24 -0500, Aaron Ecay  wrote:
> ---
>  NEWS |   10 ++
>  1 files changed, 10 insertions(+), 0 deletions(-)

pushed, although I had to mess with it a fair amount. Maybe it was
against master, rather than release?

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


Re: [PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 19:58:09 -0200, Kazuo Teramoto  wrote:
> g_mime_init already check for multiple initializations.
> ---
>  lib/index.cc   |4 
>  lib/message-file.c |4 
>  2 files changed, 0 insertions(+), 8 deletions(-)

Is this needed to fix the bug? It seems less futureproof to rely on
gmime to check for double initialization if we don't have to.

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


Re: [PATCH 2/2] lib: call g_mime_init from notmuch_database_open

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 19:58:10 -0200, Kazuo Teramoto  wrote:
> We need to call g_mime_init to correct initialize the structures needed
> by gmime before using it.
> ---
>  lib/database.cc |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)

I can confirm this patch (alone) fixes the segfault for me. and doesn't
cause in test failures when applied against the release branch.  I'm
considering pushing it into the 0.11 release. Any comments on that?

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


Re: [PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread Kazuo Teramoto
On 2011-12-31T00:55:59, David Bremner wrote:

>On Fri, 30 Dec 2011 19:58:09 -0200, Kazuo Teramoto  wrote:
>> g_mime_init already check for multiple initializations.
>> ---
>>  lib/index.cc   |4 
>>  lib/message-file.c |4 
>>  2 files changed, 0 insertions(+), 8 deletions(-)
>
>Is this needed to fix the bug? It seems less futureproof to rely on
>gmime to check for double initialization if we don't have to.
>

No its not. But if you decide to push only the other part we probably
need to add the initialization check to it, for consistency. I can send
another patch, would you like it?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] lib: call g_mime_init() from notmuch_database_open()

2011-12-30 Thread Kazuo Teramoto
I'm resending the PATCH 2/2 as a standalone, leaving the matter of
removing the checks for the future. I added a more detailed commit too.

This is the only patch needed to fix the segfault I reported.

Kazuo Teramoto (1):
  lib: call g_mime_init() from notmuch_database_open()

 lib/database.cc |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

-- 
1.7.8.1

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


[PATCH] lib: call g_mime_init() from notmuch_database_open()

2011-12-30 Thread Kazuo Teramoto
As reported in
id:"caebopgyuhnz4bptdutntpuhcp3eycrcrkxhyojr43rumw67...@mail.gmail.com"
sometimes gmime try to access a NULL pointer, e.g. g_mime_iconv_open()
try to access iconv_cache that is NULL if g_mime_init() is not called.
This cause notmuch to segfault when calling gmime functions.

Calling g_mime_init() initialize iconv_cache and others variables needed
by gmime, making sure they are initialized when notmuch calls gmime
functions.
---
 lib/database.cc |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index d11dfaf..8103bd9 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -28,6 +28,8 @@
 #include  /* g_free, GPtrArray, GHashTable */
 #include  /* g_type_init */
 
+#include  /* g_mime_init */
+
 using namespace std;
 
 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@@ -585,6 +587,7 @@ notmuch_database_open (const char *path,
 struct stat st;
 int err;
 unsigned int i, version;
+static int initialized = 0;
 
 if (asprintf (¬much_path, "%s/%s", path, ".notmuch") == -1) {
notmuch_path = NULL;
@@ -608,6 +611,12 @@ notmuch_database_open (const char *path,
 /* Initialize the GLib type system and threads */
 g_type_init ();
 
+/* Initialize gmime */
+if (! initialized) {
+   g_mime_init (0);
+   initialized = 1;
+}
+
 notmuch = talloc (NULL, notmuch_database_t);
 notmuch->exception_reported = FALSE;
 notmuch->path = talloc_strdup (notmuch, path);
-- 
1.7.8.1

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


Re: [PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 22:54:30 -0400, David Bremner  wrote:
> pushed, although I had to mess with it a fair amount. Maybe it was
> against master, rather than release?

It was.  I didn’t realize that the patch should be against the release
branch; sorry about that...  :-|

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


Re: [PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread Austin Clements
Shouldn't we remove the g_mime_init's from this code entirely if we're
going to do it in notmuch_database_open?

Quoth Kazuo Teramoto on Dec 30 at  7:58 pm:
> g_mime_init already check for multiple initializations.
> ---
>  lib/index.cc   |4 
>  lib/message-file.c |4 
>  2 files changed, 0 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index d8f8b2b..6764929 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -419,12 +419,8 @@ _notmuch_message_index_file (notmuch_message_t *message,
>  FILE *file = NULL;
>  const char *from, *subject;
>  notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
> -static int initialized = 0;
>  
> -if (! initialized) {
>   g_mime_init (0);
> - initialized = 1;
> -}
>  
>  file = fopen (filename, "r");
>  if (! file) {
> diff --git a/lib/message-file.c b/lib/message-file.c
> index 915aba8..78c7820 100644
> --- a/lib/message-file.c
> +++ b/lib/message-file.c
> @@ -223,14 +223,10 @@ notmuch_message_file_get_header (notmuch_message_file_t 
> *message,
>  char *header, *decoded_value, *header_sofar, *combined_header;
>  const char *s, *colon;
>  int match, newhdr, hdrsofar, is_received;
> -static int initialized = 0;
>  
>  is_received = (strcmp(header_desired,"received") == 0);
>  
> -if (! initialized) {
>   g_mime_init (0);
> - initialized = 1;
> -}
>  
>  message->parsing_started = 1;
>  
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/3 v2] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address'.

2011-12-30 Thread David Edmondson
`mail-header-parse-address' expects un-decoded mailbox parts, which is
not what we have at this point. Replace it with simple string
deconstruction.
---

Added removal of backslashes from the mailbox part.

 emacs/notmuch-show.el |   52 
 1 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..01b774d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -230,21 +230,47 @@ indentation."
   "Try to clean a single email ADDRESS for display.  Return
 unchanged ADDRESS if parsing fails."
   (condition-case nil
-(let* ((parsed (mail-header-parse-address address))
-  (address (car parsed))
-  (name (cdr parsed)))
-  ;; Remove double quotes. They might be required during transport,
-  ;; but we don't need to see them.
-  (when name
-(setq name (replace-regexp-in-string "\"" "" name)))
+(let (p-name p-address)
+  ;; It would be convenient to use `mail-header-parse-address',
+  ;; but that expects un-decoded mailbox parts, whereas our
+  ;; mailbox parts are already decoded (and hence may contain
+  ;; UTF-8). Given that notmuch should handle most of the awkward
+  ;; cases, some simple string deconstruction should be sufficient
+  ;; here.
+  (cond
+   ;; "User " style.
+   ((string-match "\\(.*\\) <\\(.*\\)>" address)
+   (setq p-name (match-string 1 address)
+ p-address (match-string 2 address)))
+
+   ;; "" style.
+   ((string-match "<\\(.*\\)>" address)
+   (setq p-address (match-string 1 address)))
+
+   ;; Everything else.
+   (t
+   (setq p-address address)))
+  
+  ;; Remove elements of the mailbox part that are not relevant for
+  ;; display, even if they are required during transport.
+  (when p-name
+   ;; Outer double quotes.
+   (when (string-match "^\"\\(.*\\)\"$" p-name)
+ (setq p-name (match-string 1 p-name)))
+
+   ;; Backslashes.
+   (setq p-name (replace-regexp-in-string "" "" p-name)))
+   
   ;; If the address is 'foo at bar.com ' then show just
   ;; 'foo at bar.com'.
-  (when (string= name address)
-(setq name nil))
-
-  (if (not name)
-address
-(concat name " <" address ">")))
+  (when (string= p-name p-address)
+(setq p-name nil))
+
+  ;; If no name results, return just the address.
+  (if (not p-name)
+ p-address
+   ;; Otherwise format the name and address together.
+   (concat p-name " <" p-address ">")))
 (error address)))

 (defun notmuch-show-insert-headerline (headers date tags depth)
-- 
1.7.7.3



[PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Edmondson
On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin  wrote:
> Before the change, there were two ways to do search in Emacs UI:
> search widget in notmuch-hello buffer and `notmuch-search' function
> bound to "s".  Internally, notmuch-hello search widget uses
> `notmuch-search' function.  But it uses widget field input instead of
> minibuffer.
> 
> Such duplication is a major issue for notmuch-hello usability: search
> interface is inconsistent and lacks features that are available in
> minibuffer (e.g. history and auto completion).

Were there actual complaints about the usability of the current
approach?

I much preferred your alternative approach (merging the history while
leaving the UI alone).
-- 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/20111230/c5d8f6f8/attachment.pgp>


[notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2011-12-30 Thread David Edmondson
On Fri, 21 Oct 2011 22:50:48 +0200, Daniel Schoepe  
wrote:
> On Tue, 23 Feb 2010 11:32:51 -0500, James Vasile  
> wrote:
> > Added notmuch-enqueue-asynch to replace calls to
> > notmuch-call-notmuch-process.  Calls to notmuch are then queued and
> > executed asynchronously.  If the db is busy and we get an error saying
> > it was locked, keep trying until the db is no longer busy.  Errors go
> > in a buffer as per usual.
> 
> I discovered this patch a while ago and it almost applies cleanly (the
> conflicts are easy to fix though) and it has made the emacs UI for
> notmuch _much_ more responsive and enjoyable for me. As discussed on
> IRC, issues such as where to handle retries in case the database is
> locked should probably be handled in the notmuch binary instead of each
> UI.
>
> I am however unaware of any patches to accomplish that and with the pace
> of development / patch reviews the way it is at the moment, this patch
> is a really helpful stop-gap (performing calls to notmuch asynchronously
> is useful independently of where concurrency issues are handled though)
> for me. If someone else agrees, I can fix the conflicts for this patch
> and send the revised version to the list.

It would be good to have an updated version of this patch if it is still
considered useful, though I don't suffer particularly from lag in the
emacs UI.

One concern is the string searching on the output of 'notmuch' to detect
the database locked condition. Perhaps 'notmuch' could be made to
return a specific error code in that case, negating the need to string
match?
-- 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/20111230/42d48223/attachment.pgp>


[PATCH 2/3 v2] test: Add tests for `notmuch-show-clean-address'.

2011-12-30 Thread David Edmondson
---

Added backslash test. UTF8 round-trip still isn't right.

 test/emacs |   20 
 .../notmuch-address-simplification |   10 ++
 2 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-address-simplification

diff --git a/test/emacs b/test/emacs
index a06c223..69738cd 100755
--- a/test/emacs
+++ b/test/emacs
@@ -514,4 +514,24 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 2

+test_begin_subtest "notmuch-show address simplification"
+test_emacs '
+(with-temp-buffer
+  (let ((input (list
+"foo at bar.com"
+""
+"Foo Bar "
+"foo at bar.com "
+"?? "
+"foo (at home) "
+"foo [at home] "
+"\"Foo Bar\" "
+"Foo Bar"
+"Fred Dibna \\[extraordinaire\\] "
+   )))
+(mapc (lambda (a) (insert (notmuch-show-clean-address a) "\n")) input))
+  (test-output))
+'
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-address-simplification
+
 test_done
diff --git a/test/emacs.expected-output/notmuch-address-simplification 
b/test/emacs.expected-output/notmuch-address-simplification
new file mode 100644
index 000..4747827
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-address-simplification
@@ -0,0 +1,10 @@
+foo at bar.com
+foo at bar.com
+Foo Bar 
+foo at bar.com
+?? 
+foo (at home) 
+foo [at home] 
+Foo Bar 
+Foo Bar
+Fred Dibna [extraordinaire] 
-- 
1.7.7.3



[PATCH 3/3 v2] test: Fix the 'invalid from' test in light of address cleaning changes.

2011-12-30 Thread David Edmondson
---
 test/emacs |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/emacs b/test/emacs
index 69738cd..32d49ae 100755
--- a/test/emacs
+++ b/test/emacs
@@ -78,7 +78,7 @@ thread=$(notmuch search --output=threads 
subject:message-with-invalid-from)
 test_emacs "(notmuch-show \"$thread\")
(test-output)"
 cat 

rewind and text/plain hooks and visual-line-mode and ...

2011-12-30 Thread David Edmondson
After setting up a new user recently[1] and discussion with j4ni, it
occurred to me that some of my recent patches are interrelated in a way
that I didn't previously realise.

Getting natural feeling `notmuch-show-rewind' behaviour (latest patches
are [2]) is made more difficult if `truncate-lines' is set to `nil',
because the cursor can end up somewhere at the end of a wrapped header
line when the start of the header line is not visible on the screen. The
current code has some tests for 'near the top of the window' that might
address this, but I removed them.

In general I think that having `truncate-lines' set to `t' in
`notmuch-show-mode' is better, as large numbers of tags causes the
header lines to wrap frequently, making a collapsed view of the threads
difficult to read (compare [3] and [4] for a quick example).

`notmuch-show-mode' could set `truncate-lines' to `t', but that would
clash with the use of `visual-line-mode', which turns off line
truncation and performs line wrapping.

`visual-line-mode' is useful because some mailers and/or users send
messages with very long lines. Luckily the patch to enable more cleaning
of text/plain parts[5] by default means that this would be less of a
problem, as most (all?) such messages would have their lines wrapped by
coolj.

There is no patch to remove `visual-line-mode' and set `truncate-lines'
yet, but it's simple for an interested developer to try.

Hence this is really a plea to consider these various patches (and the
resulting behaviour and appearance) together, even though they might not
immediately appear to be related.

Footnotes: 
[1]  "You're never too young to learn to use emacs."
[2]  id:"1325160490-23472-1-git-send-email-dme at dme.org"
[3]  http://dme.org/data/images/2011-12-27-114014_958x1179_scrot.png
[4]  http://dme.org/data/images/2011-12-27-114028_958x1179_scrot.png
[5]  id:"1324987225-3067-1-git-send-email-dme at dme.org"

-- 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/20111230/0aa5d8bd/attachment-0001.pgp>


[PATCH] emacs: Improved printing support.

2011-12-30 Thread David Edmondson
Add various functions to print notmuch messages and tie them together
with a simple frontend. No keybinding is currently made to encourage
paper saving.
---

Resurrecting an old patch.

 emacs/Makefile.local   |3 +-
 emacs/notmuch-print.el |   75 
 emacs/notmuch-show.el  |   51 
 3 files changed, 128 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-print.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 0c58b82..4fee0e8 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -13,7 +13,8 @@ emacs_sources := \
$(dir)/notmuch-maildir-fcc.el \
$(dir)/notmuch-message.el \
$(dir)/notmuch-crypto.el \
-   $(dir)/coolj.el
+   $(dir)/coolj.el \
+   $(dir)/notmuch-print.el

 emacs_images := \
$(srcdir)/$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el
new file mode 100644
index 000..70fb041
--- /dev/null
+++ b/emacs/notmuch-print.el
@@ -0,0 +1,75 @@
+;; notmuch-print.el --- printing messages from notmuch.
+;;
+;; Copyright ? David Edmondson
+;;
+;; This file is part of Notmuch.
+;;
+;; Notmuch is free software: you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; Notmuch is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with Notmuch.  If not, see .
+;;
+;; Authors: David Edmondson 
+
+(defcustom notmuch-print-mechanism 'notmuch-print-lpr
+  "How should printing be done?"
+  :group 'notmuch
+  :type '(choice
+ (function :tag "Use lpr" notmuch-print-lpr)
+ (function :tag "Use ps-print" notmuch-print-ps-print)
+ (function :tag "Use ps-print then evince" 
notmuch-print-ps-print/evince)
+ (function :tag "Use muttprint" notmuch-print-muttprint)
+ (function :tag "Use muttprint then evince" 
notmuch-print-muttprint/evince)
+ (function :tag "Using a custom function")))
+
+(defmacro notmuch-print-with-file (filename &rest body)
+  `(with-temp-buffer
+ (insert-file-contents ,filename)
+ (set-buffer-modified-p nil)
+ , at body))
+
+(defun notmuch-print-lpr (filename)
+  (notmuch-print-with-file filename
+  (lpr-buffer)))
+
+(defun notmuch-print-ps-print (filename)
+  (notmuch-print-with-file filename
+  (ps-print-buffer)))
+
+(defun notmuch-print-ps-print/evince (filename)
+  (let ((ps-file (make-temp-file "notmuch")))
+(notmuch-print-with-file filename
+(ps-print-buffer ps-file)
+(async-shell-command (concat "evince " ps-file)
+
+(defun notmuch-print-muttprint (filename)
+  (shell-command
+   (concat "muttprint "
+  "--file " (shell-quote-argument filename) " "
+  ;; Show the tags.
+  "--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ ")))
+
+(defun notmuch-print-muttprint/evince (filename)
+  (let ((ps-file (make-temp-file "notmuch")))
+(call-process-shell-command
+ (concat "muttprint "
+"--file " (shell-quote-argument filename) " "
+;; Show the tags.
+"--printed-headers Date_To_From_CC_Newsgroups_*Subject*_/Tags/ "
+"--printer \"TO_FILE:" (shell-quote-argument ps-file) "\""))
+(async-shell-command (concat "evince " ps-file
+
+(defun notmuch-print-message (filename)
+  (funcall notmuch-print-mechanism filename))
+
+;;
+
+(provide 'notmuch-print)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..5beadbc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -34,6 +34,7 @@
 (require 'notmuch-wash)
 (require 'notmuch-mua)
 (require 'notmuch-crypto)
+(require 'notmuch-print)

 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
 (declare-function notmuch-fontify-headers "notmuch" nil)
@@ -186,6 +187,51 @@ indentation."
   mm-handle (> (notmuch-count-attachments mm-handle) 1
   (message "Done"))

+(defun notmuch-show-with-message-as-text (fn)
+  "Apply function `fn' to a text representation of the current
+message."
+
+  ;; Remake the header to ensure that all information is available.
+  (let* ((to (notmuch-show-get-to))
+(cc (notmuch-show-get-cc))
+(from (notmuch-show-get-from))
+(subject (notmuch-show-get-subject))
+(date (notmuch-show-get-date))
+(tags (notmuch-show-get-tags))
+(depth (notmuch-show-get-depth))
+
+(header (concat
+ "Subject: " subject "\n"
+  

[PATCH] bound mail-parse-charset, used by some functions on mm-view.el when there is no charset metadata in the html

2011-12-30 Thread David Edmondson
Konrad, can you provide a specific example of when this is useful? I
don't understand what it is for.
-- 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/20111230/a0ed97a3/attachment.pgp>


[PATCH] emacs: Better handling of inherited keymaps for `nomuch-help'.

2011-12-30 Thread David Edmondson
`notmuch-hello-mode' inherits the keymap for widgets, which confused
`notmuch-substitute-command-keys'. Fix the confusion.

Simplify `notmuch-substitute-command-keys' a little to make it easier
to read.
---
 emacs/notmuch.el |   17 -
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..6dd65ff 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -164,16 +164,23 @@ For a mouse binding, return nil."
"\t"
(notmuch-documentation-first-line action))

-(defalias 'notmuch-substitute-one-command-key
-  (apply-partially 'notmuch-substitute-one-command-key-with-prefix nil))
+(defun notmuch-substitute-command-keys-one (key)
+  ;; A `keymap' key indicates inheritance from a parent keymap - the
+  ;; inherited mappings follow, so there is nothing to print for
+  ;; `keymap' itself.
+  (when (not (eq key 'keymap))
+(notmuch-substitute-one-command-key-with-prefix nil key)))

 (defun notmuch-substitute-command-keys (doc)
   "Like `substitute-command-keys' but with documentation, not function names."
   (let ((beg 0))
 (while (string-match "{\\([^}[:space:]]*\\)}" doc beg)
-  (let ((map (substring doc (match-beginning 1) (match-end 1
-   (setq doc (replace-match (mapconcat 'notmuch-substitute-one-command-key
-   (cdr (symbol-value (intern map))) 
"\n") 1 1 doc)))
+  (let* ((keymap-name (substring doc (match-beginning 1) (match-end 1)))
+(keymap (symbol-value (intern keymap-name
+   (setq doc (replace-match
+  (mapconcat #'notmuch-substitute-command-keys-one
+ (cdr keymap) "\n")
+  1 1 doc)))
   (setq beg (match-end 0)))
 doc))

-- 
1.7.7.3



0.11 is frozen, please update NEWS

2011-12-30 Thread David Bremner
On Sun, 25 Dec 2011 15:55:43 -0400, David Bremner  wrote:
> 
> Well, it's -19C outside, so guess that is appropriate.

It's warmed up to -10C, with a brief interlude of +10C, so we must be
getting ready to unfreeze. Well, release, but that doesn't really work
as a pun.

> Speaking of NEWS, please have a look at the commits listed under your
> name, and if they impact user experience, then consider a patch for
> NEWS.

I received NEWS items from Tomi and Jani, and I tidied a few things off
the list that probably don't need NEWS items. Probably some more of the
following are also ignorable, but some of them definitely look like they
need NEWS items to me. Some of the contributions are from people that
might not be reading the list regularly, so NEWS items for other
people's patches are ok too.

As before, if you can push to nmbug you should be able to push 

   git push git at pivot.cs.unb.ca HEAD:news

Or patches to the list are fine too.

> Aaron Ecay:
>   emacs: fix off-by-one bug in notmuch-show-archive

> Austin Clements:
>   emacs: Don't record undo information for search or show buffers.
>   emacs: Avoid unnecessary markers.
> 
> Dmitry Kurochkin :
>   emacs: do not call notmuch show for non-inlinable parts
> 
> Gregor Zattler:
>   emacs: make message indentation width customisable
> 
> Ivy Foster:
>   emacs: Add notmuch-hello-mode-hook
> 
> Jameson Graef Rollins (2):
>   emacs: breakout notmuch-show-advance functionality from 
> notmuch-show-advance-and-archive
>   emacs: call notmuch-show instead of notmuch-search in buttonised id: 
> links
> 

> Thomas Jost (4):
>   emacs: Add a face for crypto parts headers
>   emacs: add notmuch-hello-refresh-hook
>   emacs: rename notmuch-decimal-separator to 
> notmuch-hello-thousands-separator
>   emacs: Change the default thousands separator to a space
> 
> Thomas Schwinge (1):
>   dump: Don't sort the output by message id.
> 
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111230/6c0548e2/attachment.pgp>


[PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 10:44:28 +, David Edmondson  wrote:
> On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin  gmail.com> 
> Were there actual complaints about the usability of the current
> approach?
> 
> I much preferred your alternative approach (merging the history while
> leaving the UI alone).

Personally I would like to be able to customize the hello screen to
remove the search box. I find it confusing that that 's' jumps to the
search box there, and everywhere else brings up the mini-buffer. That
might be just me, and the fact that I bind "C-c s" globally to
notmuch-search.  I could easily believe that for new users having a
search box is nicer.

d


Segmentation fault at gmime-iconv with python binding

2011-12-30 Thread David Bremner
On Thu, 29 Dec 2011 22:57:27 -0200, Kazuo Teramoto  wrote:

> notmuch CLI show the message correct. I know nothing about gmime or
> notmuch code, but can this be the case of the python bindings not
> calling g_mime_init() correctly?

That seems likely. We worked around a similar problem by calling
g_type_init in notmuch_database_open. I'm not sure if it is permissible
to call g_mime_init more than once. The g_mime docs are, uhh, concise.

d




[PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread David Edmondson
On Fri, 30 Dec 2011 10:43:37 -0400, David Bremner  wrote:
> On Fri, 30 Dec 2011 10:44:28 +, David Edmondson  wrote:
> > On Sun, 25 Dec 2011 08:14:52 +0400, Dmitry Kurochkin  > gmail.com> 
> > Were there actual complaints about the usability of the current
> > approach?
> > 
> > I much preferred your alternative approach (merging the history while
> > leaving the UI alone).
> 
> Personally I would like to be able to customize the hello screen to
> remove the search box.

id:"1318253982-23588-2-git-send-email-daniel at schoepe.org" ?

> I find it confusing that that 's' jumps to the search box there, and
> everywhere else brings up the mini-buffer. That might be just me, and
> the fact that I bind "C-c s" globally to notmuch-search.  I could
> easily believe that for new users having a search box is nicer.

It was intended for people coming from more traditional clients, to help
get them into the swing of notmuch. Maybe also a bit of a joke in
comparison to the gmail interface. (Carl came up with the original idea
- I just knocked out some code.)
-- 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/20111230/a69b03dc/attachment.pgp>


[PATCH] test/symbol-hiding: prepend new directory to LD_LIBRARY_PATH

2011-12-30 Thread Tomi Ollila
Tester may have set LD_LIBRARY_PATH to find libraries required
by notmuch. Therefore add $TEST_DIRECTORY/../lib to the beginning
of current list of library paths in $LD_LIBRARY_PATH before running
symbol-test.
---
 test/symbol-hiding |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/test/symbol-hiding b/test/symbol-hiding
index 68f0d1b..7fa7b2a 100755
--- a/test/symbol-hiding
+++ b/test/symbol-hiding
@@ -12,7 +12,7 @@ test_description='exception symbol hiding'
 . ./test-lib.sh

 run_test(){
-result=$(LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib 
$TEST_DIRECTORY/symbol-test 2>&1)
+
result=$(LD_LIBRARY_PATH="$TEST_DIRECTORY/../lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
 $TEST_DIRECTORY/symbol-test 2>&1)
 }

 output="A Xapian exception occurred opening database: Couldn't stat 
'fakedb/.notmuch/xapian'
-- 
1.7.7.4



ANNOUNCE: nottoomuch-addresses.sh version 1.6

2011-12-30 Thread Tomi Ollila

nottoomuch-addresses.sh -- email address substring matcher -- completion
helper version 1.6 is available.

This version fixes some 'encoded-text' (=?encoding?type?text?=)
handling.

Header version was not changed so rebuilding of address cache
is not enforced. However running

/path/to/nottoomuch-addresses.sh --update --rebuild

is recommended.


Location: http://www.iki.fi/too/nottoomuch/nottoomuch-addresses.sh

Sha1sum: 2e8be738baffbad3d1e15dea75106a683d62ecec

Web page: http://www.iki.fi/too/nottoomuch/nottoomuch-addresses/

Enjoy!
Tomi


[PATCH 1/4] emacs: unify search mechanisms

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 10:43:37 -0400, David Bremner  wrote:
> Personally I would like to be able to customize the hello screen to
> remove the search box. I find it confusing that that 's' jumps to the
> search box there, and everywhere else brings up the mini-buffer.

+1.  I rarely use notmuch-hello, but when I do, I press `s' then look to
the bottom of the screen and am always confused not to see a minibuffer
prompt.

-- 
Aaron Ecay


[PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread Aaron Ecay
---
 NEWS |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index eaed960..3688944 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,16 @@ Automatic tag query optimization
   exclude messages whose tags won't change.  In the past, we've
   suggested that people do this by hand; this is no longer necessary.

+Emacs interface
+---
+
+Bug fixes
+
+  notmuch-show-advance (bound to the spacebar in notmuch-show-mode) had
+  a bug that caused it to always jump to the next message, even if it
+  should have scrolled down to show more of the current message instead.
+  This is now fixed.
+

 Notmuch 0.10.2 (2011-12-04)
 ===
-- 
1.7.8.2



[PATCH v3] notmuch: replace built-in help with exec of man

2011-12-30 Thread Austin Clements
The C side looks good to me (with the updated commit message).  I
can't speak for the nroff side.

Quoth David Bremner on Dec 29 at  9:11 am:
> From: David Bremner 
> 
> Since we lose the fancy scanning of the commands for which ones take
> search terms, the search terms page SYNOPSIS should be updated.
> ---
>  notmuch.c |  482 
> +
>  1 files changed, 35 insertions(+), 447 deletions(-)
> 
> diff --git a/notmuch.c b/notmuch.c
> index c0ce026..477a09c 100644
> --- a/notmuch.c
> +++ b/notmuch.c
> @@ -29,7 +29,6 @@ typedef struct command {
>  command_function_t function;
>  const char *arguments;
>  const char *summary;
> -const char *documentation;
>  } command_t;
>  
>  #define MAX_ALIAS_SUBSTITUTIONS 3
> @@ -47,447 +46,40 @@ alias_t aliases[] = {
>  static int
>  notmuch_help_command (void *ctx, int argc, char *argv[]);
>  
> -static const char search_terms_help[] =
> -"\tSeveral notmuch commands accept a common syntax for search\n"
> -"\tterms.\n"
> -"\n"
> -"\tThe search terms can consist of free-form text (and quoted\n"
> -"\tphrases) which will match all messages that contain all of\n"
> -"\tthe given terms/phrases in the body, the subject, or any of\n"
> -"\tthe sender or recipient headers.\n"
> -"\n"
> -"\tAs a special case, a search string consisting of exactly a\n"
> -"\tsingle asterisk (\"*\") will match all messages.\n"
> -"\n"
> -"\tIn addition to free text, the following prefixes can be used\n"
> -"\tto force terms to match against specific portions of an email,\n"
> -"\t(where  indicate user-supplied values):\n"
> -"\n"
> -"\t\tfrom:\n"
> -"\t\tto:\n"
> -"\t\tsubject:\n"
> -"\t\tattachment:\n"
> -"\t\ttag: (or is:)\n"
> -"\t\tid:\n"
> -"\t\tthread:\n"
> -"\t\tfolder:\n"
> -"\n"
> -"\tThe from: prefix is used to match the name or address of\n"
> -"\tthe sender of an email message.\n"
> -"\n"
> -"\tThe to: prefix is used to match the names or addresses of\n"
> -"\tany recipient of an email message, (whether To, Cc, or Bcc).\n"
> -"\n"
> -"\tAny term prefixed with subject: will match only text from\n"
> -"\tthe subject of an email. Quoted phrases are supported when\n"
> -"\tsearching with: subject:\"this is a phrase\".\n"
> -"\n"
> -"\tFor tag: and is:, valid tag values include \"inbox\" and \"unread\"\n"
> -"\tby default for new messages added by \"notmuch new\" as well\n"
> -"\tas any other tag values added manually with \"notmuch tag\".\n"
> -"\n"
> -"\tFor id:, message ID values are the literal contents of the\n"
> -"\tMessage-ID: header of email messages, but without the '<','>'\n"
> -"\tdelimiters.\n"
> -"\n"
> -"\tThe thread: prefix can be used with the thread ID values that\n"
> -"\tare generated internally by notmuch (and do not appear in email\n"
> -"\tmessages). These thread ID values can be seen in the first\n"
> -"\tcolumn of output from \"notmuch search\".\n"
> -"\n"
> -"\tThe folder: prefix can be used to search for email message\n"
> -"\tfiles that are contained within particular directories within\n"
> -"\tthe mail store. Only the directory components below the top-level\n"
> -"\tmail database path are available to be searched.\n"
> -"\n"
> -"\tIn addition to individual terms, multiple terms can be\n"
> -"\tcombined with Boolean operators (\"and\", \"or\", \"not\", etc.).\n"
> -"\tEach term in the query will be implicitly connected by a\n"
> -"\tlogical AND if no explicit operator is provided, (except\n"
> -"\tthat terms with a common prefix will be implicitly combined\n"
> -"\twith OR until we get Xapian defect #402 fixed).\n"
> -"\n"
> -"\tParentheses can also be used to control the combination of\n"
> -"\tthe Boolean operators, but will have to be protected from\n"
> -"\tinterpretation by the shell, (such as by putting quotation\n"
> -"\tmarks around any parenthesized expression).\n"
> -"\n"
> -"\tFinally, results can be restricted to only messages within a\n"
> -"\tparticular time range, (based on the Date: header) with:\n"
> -"\n"
> -"\t\t..\n"
> -"\n"
> -"\tEach timestamp is a number representing the number of seconds\n"
> -"\tsince 1970-01-01 00:00:00 UTC. This is not the most convenient\n"
> -"\tmeans of expressing date ranges, but until notmuch is fixed to\n"
> -"\taccept a more convenient form, one can use the date program to\n"
> -"\tconstruct timestamps. For example, with the bash shell the\n"
> -"\tfollowing syntax would specify a date range to return messages\n"
> -"\tfrom 2009-10-01 until the current time:\n"
> -"\n"
> -"\t\t$(date +%%s -d 2009-10-01)..$(date +%%s)\n\n";
> -
> -static const char hooks_help[] =
> -"\tHooks are scripts (or arbitrary executables or symlinks to such)

[PATCH] notmuch-addresses: Match on the full name as well as components.

2011-12-30 Thread Jesse Rosenthal
Pushed.

Thanks,
Jesse

On Wed, 21 Dec 2011 13:49:17 +, David Edmondson  wrote:
> ---
>  notmuch_addresses.py |7 +--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/notmuch_addresses.py b/notmuch_addresses.py
> index bf45151..74a743c 100755
> --- a/notmuch_addresses.py
> +++ b/notmuch_addresses.py
> @@ -164,11 +164,14 @@ class NotmuchAddressMatcher(object):
>  addrs.append(v)
>  parsed_addrs = email.utils.getaddresses(addrs)
>  for addr in parsed_addrs:
> -mail = addr[1].lower()
> -split_names = addr[0].split(" ")
> +full_name = addr[0]
> +split_names = full_name.split(" ")
> +mail = addr[1]
>  if (len([name for name in split_names 
>   if self.match_function(name)]) > 0
>  or 
> +self.match_function(full_name)
> +or 
>  self.match_function(mail)):
>  
>  emails.add_email_and_name(mail, addr[0])
> -- 
> 1.7.7.3
> 


[notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 10:52:17 +, David Edmondson  wrote:
> > I discovered this patch a while ago and it almost applies cleanly (the
> > conflicts are easy to fix though) and it has made the emacs UI for
> > notmuch _much_ more responsive and enjoyable for me.

This is definitely true for me as well.  So much so that I reinvented
this patch from scratch a couple of weeks ago.  (As Picasso said, good
artists copy, great artists steal.)

> > As discussed on IRC, issues such as where to handle retries in case
> > the database is locked should probably be handled in the notmuch
> > binary instead of each UI.

Hmm.  When my implementation detects that it cannot get the DB lock
after trying several times (up to ~2 mins of waiting), it stops
trying but continues to queue up operations.  The user can then
manually restart the queue.  This isn?t a principled solution, but
it avoids losing tagging operations from emacs while a long-running
process has the DB locked.  (My original motivation for writing the
patch was actually that my new-mail script sometimes holds the DB
lock when I am trying to read mail, leading to emacs errors and
dropped tagging operations.  The speedup was a welcome side effect.)

I haven?t had a chance to carefully look at the patch you found, so IDK
what its behavior would be in this case.

(The other thing that I dislike about the patch you found is that it
uses a call to the ?sleep? command to wait, rather than using built-in
emacs functionality.)

> It would be good to have an updated version of this patch if it is still
> considered useful, though I don't suffer particularly from lag in the
> emacs UI.

The emacs UI has small delays, which dropped away when I applied my
version of this patch.  After being conditioned to expect them, I was
surprised to find how much faster everything seemed.  My hardware is old
but not ancient (5.5 year old Macbook; I suspect the bottleneck for
notmuch is the 5400rpm HDD).  Depending on your setup, you too might be
pleasantly surprised.

The test suite is borked on OS X and I don?t have access to a linux
machine while traveling.  I was planning on sending my patch in early
Jan. when I had a chance to verify it under the test suite (probably
requiring some changes to the emacs test library to make it async-safe).
I also haven?t tested the patch on Emacs versions older than 24 ? but I
don?t think there are any impediments to compatibility with v.23 (not
sure about earlier versions).

Since there is interest, I?ll go ahead and send it now with all the
usual caveats about code under development.  I have been using the patch
for a couple of weeks without problems, though.  Daniel, if you want to
un-conflict (and squash) the patches from James that might be useful, at
least to compare the two approaches.

Aaron

-cut-here-

>From f0a0fe04254d9b5e17c873b293c6a5a270cb909a Mon Sep 17 00:00:00 2001
From: Aaron Ecay 
Date: Mon, 19 Dec 2011 12:14:31 -0500
Subject: [PATCH] [emacs] add async tagging support

still a WIP
---
 emacs/notmuch.el |   55 +-
 1 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..ca077c2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -446,6 +446,59 @@ Complete list of currently available key bindings:
   (let ((message-id (notmuch-search-find-thread-id)))
 (notmuch-mua-new-reply message-id prompt-for-sender)))

+(defvar notmuch-process-queue nil
+  "Queue of pending notmuch tag operations.
+
+Each entry in the queue is a list of strings, which are arguments
+to be passed to the notmuch command.")
+
+(defvar notmuch-process-current-command nil
+  "The currently executing notmuch command arguments")
+
+(defvar notmuch-process-wait-time 1.0
+  "How long to wait for the db lock, in seconds.")
+
+(defvar notmuch-process-error nil)
+
+(defun notmuch-process-restart-queue ()
+  (interactive)
+  (setq notmuch-process-error nil)
+  (notmuch-process-kick-queue))
+
+(defun notmuch-process-kick-queue ()
+  (when notmuch-process-error
+;; TODO: better error msg, tell how to manually kick
+(error "Notmuch couldn't get the DB lock after trying for more than a 
minute."))
+  (when (and notmuch-process-queue
+(memq (process-status "notmuch") '(exit nil)))
+(let ((args (car notmuch-process-queue))
+ proc)
+  (setq notmuch-process-queue (cdr notmuch-process-queue)
+   notmuch-process-current-command args
+   proc (apply #'start-process "notmuch"
+   (get-buffer-create "*Notmuch output*")
+   notmuch-command args))
+  (set-process-sentinel proc #'notmuch-process-sentinel
+
+(defun notmuch-process-sentinel (proc status)
+  (if (equal status "finished\n")
+  (progn
+   (setq notmuch-process-wait-time 1.0
+ notmuch-process-current-command nil)
+   (notmuch-process-kick-queue))
+(setq notmuch-process-wait-tim

[PATCH] notmuch-addresses: Match on the full name as well as components.

2011-12-30 Thread Jesse Rosenthal
Oh, and I moved the code to

http://commonmeasure.org/~jkr/notmuch_addresses.git

Best,
Jesse

On Fri, 30 Dec 2011 14:04:43 -0500, Jesse Rosenthal  
wrote:
> Pushed.
> 
> Thanks,
> Jesse
> 
> On Wed, 21 Dec 2011 13:49:17 +, David Edmondson  wrote:
> > ---
> >  notmuch_addresses.py |7 +--
> >  1 files changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/notmuch_addresses.py b/notmuch_addresses.py
> > index bf45151..74a743c 100755
> > --- a/notmuch_addresses.py
> > +++ b/notmuch_addresses.py
> > @@ -164,11 +164,14 @@ class NotmuchAddressMatcher(object):
> >  addrs.append(v)
> >  parsed_addrs = email.utils.getaddresses(addrs)
> >  for addr in parsed_addrs:
> > -mail = addr[1].lower()
> > -split_names = addr[0].split(" ")
> > +full_name = addr[0]
> > +split_names = full_name.split(" ")
> > +mail = addr[1]
> >  if (len([name for name in split_names 
> >   if self.match_function(name)]) > 0
> >  or 
> > +self.match_function(full_name)
> > +or 
> >  self.match_function(mail)):
> >  
> >  emails.add_email_and_name(mail, addr[0])
> > -- 
> > 1.7.7.3
> > 


[PATCH 0/2] Multiples calls of g_mime_init

2011-12-30 Thread Kazuo Teramoto
The gmime docs don't says if is ok to call g_mime_init multiple times,
but the code have a check for it in a form like this:

static unsigned int initialized = 0;
g_mime_init (guint32 flags)
{
if (initialized++)
return;

so the init code is run only once and notmuch don't need to explicit
check for an already initialized gmime.

This make possible to call g_mime_init again in lib/database.cc and this
call really solve the OP segmentation fault in python bindings.

Kazuo Teramoto (2):
  lib: Remove unnecessary checks when calling g_mime_init
  lib: call g_mime_init from notmuch_database_open

 lib/database.cc|5 +
 lib/index.cc   |4 
 lib/message-file.c |4 
 3 files changed, 5 insertions(+), 8 deletions(-)

-- 
1.7.8.1



[PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread Kazuo Teramoto
g_mime_init already check for multiple initializations.
---
 lib/index.cc   |4 
 lib/message-file.c |4 
 2 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index d8f8b2b..6764929 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -419,12 +419,8 @@ _notmuch_message_index_file (notmuch_message_t *message,
 FILE *file = NULL;
 const char *from, *subject;
 notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
-static int initialized = 0;

-if (! initialized) {
g_mime_init (0);
-   initialized = 1;
-}

 file = fopen (filename, "r");
 if (! file) {
diff --git a/lib/message-file.c b/lib/message-file.c
index 915aba8..78c7820 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -223,14 +223,10 @@ notmuch_message_file_get_header (notmuch_message_file_t 
*message,
 char *header, *decoded_value, *header_sofar, *combined_header;
 const char *s, *colon;
 int match, newhdr, hdrsofar, is_received;
-static int initialized = 0;

 is_received = (strcmp(header_desired,"received") == 0);

-if (! initialized) {
g_mime_init (0);
-   initialized = 1;
-}

 message->parsing_started = 1;

-- 
1.7.8.1



[PATCH 2/2] lib: call g_mime_init from notmuch_database_open

2011-12-30 Thread Kazuo Teramoto
We need to call g_mime_init to correct initialize the structures needed
by gmime before using it.
---
 lib/database.cc |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index d11dfaf..07ca3fd 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -28,6 +28,8 @@
 #include  /* g_free, GPtrArray, GHashTable */
 #include  /* g_type_init */

+#include  /* g_mime_init */
+
 using namespace std;

 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
@@ -608,6 +610,9 @@ notmuch_database_open (const char *path,
 /* Initialize the GLib type system and threads */
 g_type_init ();

+/* Initialize gmime */
+g_mime_init (0);
+
 notmuch = talloc (NULL, notmuch_database_t);
 notmuch->exception_reported = FALSE;
 notmuch->path = talloc_strdup (notmuch, path);
-- 
1.7.8.1



[PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 13:42:24 -0500, Aaron Ecay  wrote:
> ---
>  NEWS |   10 ++
>  1 files changed, 10 insertions(+), 0 deletions(-)

pushed, although I had to mess with it a fair amount. Maybe it was
against master, rather than release?

d


[PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 19:58:09 -0200, Kazuo Teramoto  wrote:
> g_mime_init already check for multiple initializations.
> ---
>  lib/index.cc   |4 
>  lib/message-file.c |4 
>  2 files changed, 0 insertions(+), 8 deletions(-)

Is this needed to fix the bug? It seems less futureproof to rely on
gmime to check for double initialization if we don't have to.

d


[PATCH 2/2] lib: call g_mime_init from notmuch_database_open

2011-12-30 Thread David Bremner
On Fri, 30 Dec 2011 19:58:10 -0200, Kazuo Teramoto  wrote:
> We need to call g_mime_init to correct initialize the structures needed
> by gmime before using it.
> ---
>  lib/database.cc |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)

I can confirm this patch (alone) fixes the segfault for me. and doesn't
cause in test failures when applied against the release branch.  I'm
considering pushing it into the 0.11 release. Any comments on that?

d


[PATCH] Update NEWS for change by Aaron Ecay

2011-12-30 Thread Aaron Ecay
On Fri, 30 Dec 2011 22:54:30 -0400, David Bremner  wrote:
> pushed, although I had to mess with it a fair amount. Maybe it was
> against master, rather than release?

It was.  I didn?t realize that the patch should be against the release
branch; sorry about that...  :-|

-- 
Aaron Ecay


[PATCH 1/2] lib: Remove unnecessary checks when calling g_mime_init

2011-12-30 Thread Austin Clements
Shouldn't we remove the g_mime_init's from this code entirely if we're
going to do it in notmuch_database_open?

Quoth Kazuo Teramoto on Dec 30 at  7:58 pm:
> g_mime_init already check for multiple initializations.
> ---
>  lib/index.cc   |4 
>  lib/message-file.c |4 
>  2 files changed, 0 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index d8f8b2b..6764929 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -419,12 +419,8 @@ _notmuch_message_index_file (notmuch_message_t *message,
>  FILE *file = NULL;
>  const char *from, *subject;
>  notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
> -static int initialized = 0;
>  
> -if (! initialized) {
>   g_mime_init (0);
> - initialized = 1;
> -}
>  
>  file = fopen (filename, "r");
>  if (! file) {
> diff --git a/lib/message-file.c b/lib/message-file.c
> index 915aba8..78c7820 100644
> --- a/lib/message-file.c
> +++ b/lib/message-file.c
> @@ -223,14 +223,10 @@ notmuch_message_file_get_header (notmuch_message_file_t 
> *message,
>  char *header, *decoded_value, *header_sofar, *combined_header;
>  const char *s, *colon;
>  int match, newhdr, hdrsofar, is_received;
> -static int initialized = 0;
>  
>  is_received = (strcmp(header_desired,"received") == 0);
>  
> -if (! initialized) {
>   g_mime_init (0);
> - initialized = 1;
> -}
>  
>  message->parsing_started = 1;
>