[notmuch] hello, 'automated' tagging, synchronisation

2010-02-10 Thread David Edmondson
Hello. I've been trying out notmuch for a few days, so far it looks very
useful. Thank you to all those who have participated in implementing
it. I have a couple of questions:

1. How do others add some 'automatic' tagging of new messages? At the
   moment I'm using a script[1] which tags messages after running
   `notmuch new`. This passes over the same data multiple times, which
   seems wasteful but may be inevitable. Combined with a small amount of
   lisp...

   (setq notmuch-folder-list '(mine inbox rss unread
 os-xen os-discuss os-laptop os-network
 xen-changelog xen-devel xen-users
 list/fork list/interesting-people list/sun-alumni 
list/notmuch))
   (setq notmuch-folders (mapcar
 '(lambda (f) (cons f (concat tag: f  AND tag:unread)))
 notmuch-folder-list))

   ...things mostly work out.

2. Sometimes it's useful to use another computer. Having the Maildir
   folders duplicated there is simple (already using offlineimap), as is
   building the search database. Missing are the tags, particularly if
   they were hand applied. So far my (unimplemented) solution for this
   is to dump/restore the tags and store the dump under version
   control. Moving from one computer to another (which I don't do very
   often) would involve:
 a$ notmuch dump tags
 a$ git commit tags
 a$ git push
 b$ git pull
 b$ notmuch restore tags
   With appropriate amounts of conflict resolution should I update the
   tags on both a and b.

   What does everyone else do about this?

Footnotes: 
[1]  http://dme.org/tmp/run-notmuch

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


[notmuch] [PATCH] notmuch.el: Decorate 'Date:' headers with the message-header-other face when visible.

2010-02-10 Thread David Edmondson
---
 notmuch.el |8 +++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index c0bb552..bd721a0 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -816,7 +816,13 @@ before the delimiter marking the beginning of the body.
  (overlay-put (make-overlay (point) (re-search-forward :))
   'face 'message-header-name)
  (overlay-put (make-overlay (point) (re-search-forward .*$))
-  'face 'message-header-other)))
+  'face 'message-header-other))
+ (if (looking-at [Dd]ate:)
+ (progn
+   (overlay-put (make-overlay (point) (re-search-forward :))
+'face 'message-header-name)
+   (overlay-put (make-overlay (point) (re-search-forward .*$))
+'face 'message-header-other
 
 (defun notmuch-show-markup-header (message-begin depth)
   Buttonize and decorate faces in a message header.
-- 
1.6.6.1

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


Re: [notmuch] [PATCH] notmuch.el: Decorate 'Date:' headers with the message-header-other face when visible.

2010-02-10 Thread David Edmondson
On Wed, 10 Feb 2010 12:55:49 +0100, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 On Wed, 10 Feb 2010 11:38:54 +, David Edmondson d...@dme.org wrote:
  [Patch to fontify date]
 
 You do realize that your patch is identical to the one in 
 id:874omet1su@servo.finestructure.net (Jan 22)? :-)

I didn't! My apologies to Jameson.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] emacs: On getting support for inline images

2010-02-11 Thread David Edmondson
 PS. I know that attaching the output of git format-patch to a message
 like this isn't the git way. (That is, you won't get the right result
 by simply piping this message to git am.) But I really wish it
 were. It seems I often write code in response to an email message and I
 often want to reply to that *message* and incidentally provide a
 patch. The git way, with the commit message in the subject and the first
 part of the body seems backwards to me, (as far as the conversation is
 concerned).

How about attaching a message/rfc822 part which contains the patch?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] notmuch.el: 'F' in search mode takes us to a list of folders.

2010-02-11 Thread David Edmondson
---
 notmuch.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 040997e..8f50abe 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1104,6 +1104,7 @@ matching this search term are shown if non-nil. 
 (define-key map - 'notmuch-search-remove-tag)
 (define-key map + 'notmuch-search-add-tag)
 (define-key map (kbd RET) 'notmuch-search-show-thread)
+(define-key map F 'notmuch-folder)
 map)
   Keymap for \notmuch search\ buffers.)
 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
-- 
1.6.6.1

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


[notmuch] [PATCH] notmuch.el: Prefix arg inverts the sort order of notmuch-search.

2010-02-11 Thread David Edmondson
---
 notmuch.el |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 8f50abe..de9ddf8 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1398,7 +1398,8 @@ characters as well as `_.+-'.
 (defun notmuch-search (query optional oldest-first)
   Run \notmuch search\ with the given query string and display results.
   (interactive sNotmuch search: )
-  (let ((buffer (get-buffer-create (concat *notmuch-search- query *
+  (let ((buffer (get-buffer-create (concat *notmuch-search- query *)))
+   (oldest-first (if current-prefix-arg (not oldest-first) oldest-first)))
 (switch-to-buffer buffer)
 (notmuch-search-mode)
 (set 'notmuch-search-query-string query)
-- 
1.6.6.1

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


Re: [notmuch] Backport of Xapian term update optimisation

2010-02-12 Thread David Edmondson
On Thu, 4 Feb 2010 23:23:56 +, Olly Betts o...@survex.com wrote:
 If I get a lot of positive feedback on the snapshot version, that'll encourage
 me to push ahead with it.  I've also announced it on the sup mailing list (as
 they have similar issues with adding tags) and will on the Xapian list later
 today.

I'm using the version from the experimental repository and it's working
well for me so far.

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


[notmuch] [RFC] improved display of message/rfc822 parts

2010-02-12 Thread David Edmondson
I seem to get a lot of forwarded message/rfc822 parts and the default
formatting (which is to inline the contents of the included message) is
very confusing.

Attached is a patch which attempts to improve this. Given that I'm new
to notmuch hacking, any comments would be appreciated.

From 7fd7ad00f4b8f8a2610eb1598a1c0bb4351e Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Fri, 12 Feb 2010 15:01:06 +
Subject: [PATCH] show: Make message/rfc822 parts explicit in show output.
 show: Display header information for message/rfc822 parts.

---
 notmuch-show.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 376aacd..6f12560 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -97,6 +97,34 @@ show_part_content (GMimeObject *part)
 }
 
 static void
+show_message_rfc822 (GMimeObject *part, int *part_count,
+		 void (*show_part) (GMimeObject *part, int *part_count))
+{
+GMimeMessage *message;
+const char *headers[] = {
+	Subject, From, To, Cc, Bcc, Date
+};
+const char *name, *value;
+unsigned int i;
+
+*part_count = *part_count + 1;
+
+message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
+
+printf (\n);
+for (i = 0; i  ARRAY_SIZE (headers); i++) {
+	name = headers[i];
+	value = g_mime_object_get_header (GMIME_OBJECT (message), name);
+	if (value)
+	printf (%s: %s\n, name, value);
+}
+printf (\n);
+
+show_part (g_mime_message_get_mime_part (message),
+	   part_count);
+}
+
+static void
 show_part (GMimeObject *part, int *part_count)
 {
 GMimeContentDisposition *disposition;
@@ -137,6 +165,10 @@ show_part (GMimeObject *part, int *part_count)
 {
 	show_part_content (part);
 }
+else if (g_mime_content_type_is_type (content_type, message, rfc822))
+{
+	show_message_rfc822 (part, part_count, show_part);
+}
 else
 {
 	printf (Non-text part: %s\n,
-- 
1.6.6.1


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


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

2010-02-15 Thread David Edmondson
---
 notmuch.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 8090b2f..3e8e50d 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -703,6 +703,7 @@ is what to put on the button.
   (let* ((cite-start (match-beginning 0))
 (cite-end  (match-end 0))
 (cite-lines (count-lines cite-start cite-end)))
+   (overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
(when ( cite-lines (1+ notmuch-show-citation-lines-prefix))
  (goto-char cite-start)
  (forward-line notmuch-show-citation-lines-prefix)
@@ -718,6 +719,7 @@ is what to put on the button.
(let* ((sig-start (match-beginning 0))
   (sig-end (match-end 0))
   (sig-lines (1- (count-lines sig-start end
+ (overlay-put (make-overlay sig-start end) 'face 
'message-cited-text-face)
  (if (= sig-lines notmuch-show-signature-lines-max)
  (notmuch-show-region-to-button
   sig-start
-- 
1.6.6.1

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


[notmuch] [RFC] labelling parts

2010-02-15 Thread David Edmondson
I've always been quite fond of the way that gnus labelled parts in MIME
messages. Here's a start at doing the same for notmuch.el. Is this
something that might be accepted upstream if I continue?

Obvious next steps are:
- allow the user to choose which parts have buttons (i.e perhaps
  not text/plain by default),
- have the inserted buttons actually do something useful (toggle
  visibility and/or save).

From fcdbb8b3452911ce4c836547fc12519b1881e515 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Mon, 15 Feb 2010 14:13:45 +
Subject: [PATCH] notmuch.el: Label the head of each part.

---
 notmuch.el |   25 ++---
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index b4f8e12..ea74a72 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -128,6 +128,9 @@ remaining lines into a button.)
 (defvar notmuch-show-attachment-end-regexp   \fattachment})
 (defvar notmuch-show-part-begin-regexp   \fpart{)
 (defvar notmuch-show-part-end-regexp \fpart})
+
+(defvar notmuch-show-buttonize-begin-regexp \f\\(part\\|attachment\\){)
+(defvar notmuch-show-buttonize-end-regexp \f\\(part\\|attachment\\)})
 (defvar notmuch-show-marker-regexp \f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$)
 
 (defvar notmuch-show-id-regexp \\(id:[^ ]*\\))
@@ -650,6 +653,9 @@ which this thread was originally shown.
   'help-echo mouse-1, RET: Show message
   'face 'notmuch-message-summary-face
   :supertype 'notmuch-button-invisibility-toggle-type)
+(define-button-type 'notmuch-button-part-toggle-type 'help-echo mouse-1, RET: Show part
+  :supertype 'notmuch-button-invisibility-toggle-type
+  'face 'font-lock-keyword-face)
 
 (defun notmuch-show-citation-regexp (depth)
   Build a regexp for matching citations at a given DEPTH (indent)
@@ -731,7 +737,7 @@ is what to put on the button.
 		 )))
 
 (defun notmuch-show-markup-part (beg end depth)
-  (if (re-search-forward notmuch-show-part-begin-regexp nil t)
+  (if (re-search-forward notmuch-show-buttonize-begin-regexp nil t)
   (progn
 (let (mime-message mime-type)
   (save-excursion
@@ -739,14 +745,19 @@ is what to put on the button.
 (setq mime-type (car (split-string (buffer-substring 
 (match-beginning 1) (match-end 1))
 
+
+  (forward-line)
+	  (insert-button (format (concat % (format %d depth) s[ %s ]\n)  mime-type)
+	  		 :type 'notmuch-button-part-toggle-type)
+
   (if (equal mime-type text/html)
   (let ((filename (notmuch-show-get-filename)))
 (with-temp-buffer
   (insert-file-contents filename nil nil nil t)
   (setq mime-message (mm-dissect-buffer)
-  (forward-line)
+
   (let ((beg (point-marker)))
-(re-search-forward notmuch-show-part-end-regexp)
+(re-search-forward notmuch-show-buttonize-end-regexp)
 (let ((end (copy-marker (match-beginning 0
   (goto-char end)
   (if (not (bolp))
@@ -765,12 +776,12 @@ is what to put on the button.
   (if (equal mime-type text/html)
   (mm-display-part mime-message
 )
-  (notmuch-show-markup-citations-region beg end depth)
+	  (if (equal mime-type text/plain)
+		  (notmuch-show-markup-citations-region beg end depth))
   ; Advance to the next part (if any) (so the outer loop can
   ; determine whether we've left the current message.
-  (if (re-search-forward notmuch-show-part-begin-regexp nil t)
-  (beginning-of-line)
-(goto-char end))
+  (if (re-search-forward notmuch-show-buttonize-begin-regexp nil t)
+  (beginning-of-line))
 (goto-char end)))
 
 (defun notmuch-show-markup-parts-region (beg end depth)
-- 
1.6.6.1


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


[notmuch] [rfc] improved wrapping of long lines

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

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

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

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

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

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

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


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


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

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

Sebastian posted one this morning.

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


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

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

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

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

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

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

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

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

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

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


[notmuch] [PATCH] notmuch.el: Allow citation suffixes to be shown as well as prefixes.

2010-02-17 Thread David Edmondson
In many conversations the last few lines of a citation are more
interesting than the first few lines, hence allow those to be shown if
desired.

Modify the face used for the citation button to distinguish it from
the surrounding citation.
---
 notmuch.el |   37 +
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 20e5144..ab71b5e 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -111,10 +111,20 @@ Can use up to one integer format parameter, i.e. %d)
   Maximum length of signature that will be hidden by default.)
 
 (defvar notmuch-show-citation-lines-prefix 4
-  Always show at least this many lines of a citation.
+  Always show at least this many lines at the start of a citation.
 
-If there is one more line, show that, otherwise collapse
-remaining lines into a button.)
+If there is one more line than the sum of
+`notmuch-show-citation-lines-prefix' and
+`notmuch-show-citation-lines-suffix', show that, otherwise
+collapse remaining lines into a button.)
+
+(defvar notmuch-show-citation-lines-suffix 0
+  Always show at least this many lines at the end of a citation.
+
+If there is one more line than the sum of
+`notmuch-show-citation-lines-prefix' and
+`notmuch-show-citation-lines-suffix', show that, otherwise
+collapse remaining lines into a button.)
 
 (defvar notmuch-command notmuch
   Command to run the notmuch binary.)
@@ -643,7 +653,7 @@ which this thread was originally shown.
 (define-button-type 'notmuch-button-invisibility-toggle-type
   'action 'notmuch-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-delimiter-face)
 (define-button-type 'notmuch-button-citation-toggle-type 'help-echo mouse-1, 
RET: Show citation
   :supertype 'notmuch-button-invisibility-toggle-type)
 (define-button-type 'notmuch-button-signature-toggle-type 'help-echo mouse-1, 
RET: Show signature
@@ -711,16 +721,19 @@ is what to put on the button.
 (cite-end  (match-end 0))
 (cite-lines (count-lines cite-start cite-end)))
(overlay-put (make-overlay cite-start cite-end) 'face 
'message-cited-text-face)
-   (when ( cite-lines (1+ notmuch-show-citation-lines-prefix))
+   (when ( cite-lines (1+ (+ notmuch-show-citation-lines-prefix 
notmuch-show-citation-lines-suffix)))
  (goto-char cite-start)
  (forward-line notmuch-show-citation-lines-prefix)
- (notmuch-show-region-to-button
-  (point) cite-end
-  citation
-  indent
-  (format notmuch-show-citation-button-format
-  (- cite-lines notmuch-show-citation-lines-prefix))
-  
+ (let ((hidden-start (point)))
+   (goto-char cite-end)
+   (forward-line (- notmuch-show-citation-lines-suffix))
+   (notmuch-show-region-to-button
+hidden-start (point)
+citation
+indent
+(format notmuch-show-citation-button-format
+(- cite-lines notmuch-show-citation-lines-prefix 
notmuch-show-citation-lines-suffix))
+)
 (if (and ( (point) end)
 (re-search-forward signature-regexp end t))
(let* ((sig-start (match-beginning 0))
-- 
1.6.6.1

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


[notmuch] [PATCH 1/2] build: Ensure that '.' is in the emacs load-path when compiling files.

2010-02-17 Thread David Edmondson
---
 Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 64b9d4a..9fcb2b9 100644
--- a/Makefile
+++ b/Makefile
@@ -60,7 +60,7 @@ quiet ?= $($1)
$(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $ -o $@
 
 %.elc: %.el
-   $(call quiet,EMACS) -batch -f batch-byte-compile $
+   $(call quiet,EMACS) -batch --directory . -f batch-byte-compile $
 
 .deps/%.d: %.c $(all_deps)
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
-- 
1.6.6.1

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


[notmuch] [PATCH 2/2] notmuch.el: Replace inline function calls for body cleaning with a hook mechanism.

2010-02-17 Thread David Edmondson
In-lining every possible body cleaning function is difficult to
maintain and doesn't allow users any flexibility. Rather, use a hook
mechanism so that users can choose what cleaning takes place.

notmuch-washing.el: Sample cleaning functions.
---
 Makefile.local |6 +++-
 notmuch-washing.el |   65 
 notmuch.el |   12 +
 3 files changed, 76 insertions(+), 7 deletions(-)
 create mode 100644 notmuch-washing.el

diff --git a/Makefile.local b/Makefile.local
index 0a1f203..7124af7 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,6 +1,6 @@
 # -*- mode:makefile -*-
 
-emacs: notmuch.elc coolj.elc
+emacs: notmuch.elc coolj.elc notmuch-washing.elc
 
 notmuch_client_srcs =  \
$(notmuch_compat_srcs)  \
@@ -46,6 +46,8 @@ install-emacs: install emacs
install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)
install -m0644 coolj.el $(DESTDIR)$(emacs_lispdir)
install -m0644 coolj.elc $(DESTDIR)$(emacs_lispdir)
+   install -m0644 notmuch-washing.el $(DESTDIR)$(emacs_lispdir)
+   install -m0644 notmuch-washing.elc $(DESTDIR)$(emacs_lispdir)
 
 install-desktop:
install -d $(DESTDIR)$(desktop_dir)
@@ -62,4 +64,4 @@ install-zsh:
$(DESTDIR)$(zsh_completion_dir)/notmuch
 
 SRCS  := $(SRCS) $(notmuch_client_srcs)
-CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc coolj.elc 
notmuch.1.gz
+CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc coolj.elc 
notmuch-washing.elc notmuch.1.gz
diff --git a/notmuch-washing.el b/notmuch-washing.el
new file mode 100644
index 000..831eb00
--- /dev/null
+++ b/notmuch-washing.el
@@ -0,0 +1,65 @@
+; notmuch-washing.el --- functions to clean body parts
+;
+; Copyright © David Edmondson
+;
+; This file is not (yet) 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 http://www.gnu.org/licenses/.
+;
+; Authors: David Edmondson d...@dme.org
+
+(require 'coolj)
+
+;; Add these functions to `notmuch-show-markup-body-hook' using
+;; `add-hook'. Something like:
+
+;; (eval-after-load notmuch
+;;   '(progn
+;;  (require 'notmuch-washing)
+;;  (add-hook 'notmuch-show-markup-body-hook 'notmuch-show-washing-coolj)
+;;  (add-hook 'notmuch-show-markup-body-hook 
'notmuch-show-washing-compress-blank t)))
+
+;; Note that the ordering of the functions may well be significant.
+
+(defun notmuch-show-washing-coolj (begin end depth)
+  Wrap text in the region whilst maintaining the correct prefix.
+  (coolj-wrap-region beg end))
+
+(defun notmuch-show-washing-compress-blank (begin end depth)
+  Compress successive blank lines into one blank line.
+
+  ;; Algorithm derived from `article-strip-multiple-blank-lines' in
+  ;; `gnus-art.el'.
+  
+  (save-excursion
+;; Make all blank lines empty. **This also removes the prefix!**
+(goto-char begin)
+(while (re-search-forward ^[ \t]+$ end t)
+  (replace-match  nil t))
+;; Replace multiple empty lines with a single empty line.
+(goto-char begin)
+(while (re-search-forward \n\n\\(\n+\\) end t)
+  (delete-region (match-beginning 1) (match-end 1)))
+;; dme - is this really the best way to generate a string of N
+;; spaces?
+(let ((prefix (format (format %%%ds depth) )))
+  (goto-char begin)
+  ;; Insert the relevant prefix.
+  (while (re-search-forward ^$ end t)
+   (insert prefix)
+   (forward-line)
+
+;;
+
+(provide 'notmuch-washing)
diff --git a/notmuch.el b/notmuch.el
index 040fb5e..e64ed25 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -50,7 +50,6 @@
 (require 'cl)
 (require 'mm-view)
 (require 'message)
-(require 'coolj)
 
 (defvar notmuch-show-mode-map
   (let ((map (make-sparse-keymap)))
@@ -157,6 +156,12 @@ collapse remaining lines into a button.)
 (defvar notmuch-show-signatures-visible nil)
 (defvar notmuch-show-headers-visible nil)
 
+(defun notmuch-show-markup-body-hook '(notmuch-show-markup-citations-region)
+  List of functions used to clean up body parts.
+
+Each is passed three arguments: the beginning of the region, the
+end of the region and the indetation depth.)
+
 ; XXX: This should be a generic function in emacs somewhere, not here
 (defun point-invisible-p ()
   Return whether the character at point is invisible.
@@ -703,7 +708,6 @@ is what to put on the button.
 :type button-type)
   )))
 
-
 (defun notmuch-show-markup

Re: [notmuch] [PATCH 2/2] notmuch.el: Replace inline function calls for body cleaning with a hook mechanism.

2010-02-18 Thread David Edmondson
On Wed, 17 Feb 2010 14:04:12 +, David Edmondson d...@dme.org wrote:
 In-lining every possible body cleaning function is difficult to
 maintain and doesn't allow users any flexibility. Rather, use a hook
 mechanism so that users can choose what cleaning takes place.

Improved version attached, including a new washing function to clean up
citation blocks (suggested by Sebastian in #notmuch, though perhaps I
went a bit further than he intended).

From 545e2a0936a19620bf4f91282ca2aca1da0504b7 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Wed, 17 Feb 2010 14:03:24 +
Subject: [PATCH] notmuch.el: Replace inline function calls for body cleaning with a
 hook mechanism.

In-lining every possible body cleaning function is difficult to
maintain and doesn't allow users any flexibility. Rather, use a hook
mechanism so that users can choose what cleaning takes place.

notmuch-washing.el: Sample cleaning functions.
---
 Makefile.local |6 ++-
 notmuch-washing.el |  113 
 notmuch.el |  104 +---
 3 files changed, 171 insertions(+), 52 deletions(-)
 create mode 100644 notmuch-washing.el

diff --git a/Makefile.local b/Makefile.local
index 0a1f203..7124af7 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -1,6 +1,6 @@
 # -*- mode:makefile -*-
 
-emacs: notmuch.elc coolj.elc
+emacs: notmuch.elc coolj.elc notmuch-washing.elc
 
 notmuch_client_srcs =		\
 	$(notmuch_compat_srcs)	\
@@ -46,6 +46,8 @@ install-emacs: install emacs
 	install -m0644 notmuch.elc $(DESTDIR)$(emacs_lispdir)
 	install -m0644 coolj.el $(DESTDIR)$(emacs_lispdir)
 	install -m0644 coolj.elc $(DESTDIR)$(emacs_lispdir)
+	install -m0644 notmuch-washing.el $(DESTDIR)$(emacs_lispdir)
+	install -m0644 notmuch-washing.elc $(DESTDIR)$(emacs_lispdir)
 
 install-desktop:
 	install -d $(DESTDIR)$(desktop_dir)
@@ -62,4 +64,4 @@ install-zsh:
 		$(DESTDIR)$(zsh_completion_dir)/notmuch
 
 SRCS  := $(SRCS) $(notmuch_client_srcs)
-CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc coolj.elc notmuch.1.gz
+CLEAN := $(CLEAN) notmuch $(notmuch_client_modules) notmuch.elc coolj.elc notmuch-washing.elc notmuch.1.gz
diff --git a/notmuch-washing.el b/notmuch-washing.el
new file mode 100644
index 000..fc7b257
--- /dev/null
+++ b/notmuch-washing.el
@@ -0,0 +1,113 @@
+;; notmuch-washing.el --- functions to clean body parts
+;;
+;; Copyright © David Edmondson
+;;
+;; This file is not (yet) 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 http://www.gnu.org/licenses/.
+;;
+;; Authors: David Edmondson d...@dme.org
+
+(require 'coolj)
+
+;; Add these functions to `notmuch-show-markup-body-hook' using
+;; `add-hook'. Something like:
+
+;; (eval-after-load notmuch
+;;   '(progn
+;;  (require 'notmuch-washing)
+;;  (setq notmuch-show-markup-body-hook nil)
+;;  (add-hook 'notmuch-show-markup-body-hook 'notmuch-show-washing-coolj t)
+;;  (add-hook 'notmuch-show-markup-body-hook 'notmuch-show-washing-citations t)
+;;  (add-hook 'notmuch-show-markup-body-hook 'notmuch-show-washing-compress-blanks t)
+;;  (add-hook 'notmuch-show-markup-body-hook 'notmuch-show-markup-citations t)
+;;  ))
+
+;; Note that the ordering of the functions is significant, given that
+;; later functions operate on the results of the earlier functions.
+
+(defun notmuch-show-washing-coolj (depth)
+  Wrap text in the region whilst maintaining the correct prefix.
+  (coolj-wrap-region (point-min) (point-max)))
+
+;; Utility functions.
+(defun remove-prefix (depth)
+  (let ((prefix-regexp (format (format ^%%%ds depth) )))
+(while (and (not (eobp))
+		(re-search-forward prefix-regexp nil t))
+  (replace-match  nil nil)
+  (forward-line
+
+(defun insert-prefix (depth)
+  (let ((prefix (format (format %%%ds depth) )))
+(while (not (eobp))
+  (insert prefix)
+  (forward-line
+
+(defun notmuch-show-washing-compress-blanks (depth)
+  Compress successive blank lines into one blank line.
+
+  ;; Algorithm derived from `article-strip-multiple-blank-lines' in
+  ;; `gnus-art.el'.
+
+  (goto-char (point-min))
+  (remove-prefix depth)
+
+  ;; Make all blank lines empty.
+  (goto-char (point-min))
+  (while (re-search-forward ^[ \t]+$ nil t)
+(replace-match  nil t))
+
+  ;; Replace multiple empty lines with a single empty line.
+  (goto-char (point-min

Re: [notmuch] [PATCH 2/2] notmuch.el: Replace inline function calls for body cleaning with a hook mechanism.

2010-02-18 Thread David Edmondson
This, and any other patches that I'm using, are now in a repository at
  git://gitorious.org/notmuch/notmuch.git

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


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

2010-02-19 Thread David Edmondson
On Thu, 18 Feb 2010 17:29:15 +, James Westby jw+deb...@jameswestby.net 
wrote:
 On Tue, 16 Feb 2010 19:11:24 +, David Edmondson d...@dme.org wrote:
  On Tue, 16 Feb 2010 18:51:00 +, James Westby 
  jw+deb...@jameswestby.net wrote:
   Some people send html parts as text/HTML or similar, so do a
   case-sensitive comparison when checking for html parts.
  
  There are various other places where `equal' is used to compare MIME
  types with strings. Shouldn't they all be fixed? (I see TEXT/PLAIN
  frequently.)
 
 I don't see any others in notmuch.el, but I'm not experienced in elisp,
 so I may be missing some, care to help me out?

How about this:

From e5ae18036ccb1dcaa19d0125976b309c25331892 Mon Sep 17 00:00:00 2001
From: David Edmondson d...@dme.org
Date: Fri, 19 Feb 2010 08:32:05 +
Subject: [PATCH] notmuch.el: Always compare lower-case MIME types.

---
 notmuch.el |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 6fad91e..7731a93 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -757,8 +757,9 @@ is what to put on the button.
 (let (mime-message mime-type)
   (save-excursion
 (re-search-forward notmuch-show-contentype-regexp end t)
-(setq mime-type (car (split-string (buffer-substring 
-(match-beginning 1) (match-end 1))
+(setq mime-type (downcase (car (split-string
+	(buffer-substring 
+	 (match-beginning 1) (match-end 1)))
 
 
   (forward-line)
-- 
1.6.6.1


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


[notmuch] [PATCH] Add the emacs directory to the load-path when byte compiling.

2010-03-12 Thread David Edmondson
---
 Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 46f001c..f0b96e0 100644
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ quiet ?= $($1)
$(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $ -o $@
 
 %.elc: %.el
-   $(call quiet,EMACS) -batch -f batch-byte-compile $
+   $(call quiet,EMACS) -batch -L emacs -f batch-byte-compile $
 
 .deps/%.d: %.c $(global_deps)
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
-- 
1.7.0

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


[notmuch] [PATCH] Add the emacs directory to the load-path when byte compiling

2010-03-12 Thread David Edmondson
When the emacs UI is split into multiple files they are likely to be
interdependent. Adding the emacs directory to the load-path means that
one file will be able to `require' another.

Signed-off-by: David Edmondson d...@dme.org
---
 Makefile |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 46f001c..f0b96e0 100644
--- a/Makefile
+++ b/Makefile
@@ -68,7 +68,7 @@ quiet ?= $($1)
$(call quiet,CC,$(CFLAGS)) -c $(FINAL_CFLAGS) $ -o $@
 
 %.elc: %.el
-   $(call quiet,EMACS) -batch -f batch-byte-compile $
+   $(call quiet,EMACS) -batch -L emacs -f batch-byte-compile $
 
 .deps/%.d: %.c $(global_deps)
@set -e; rm -f $@; mkdir -p $$(dirname $@) ; \
-- 
1.7.0


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


[notmuch] JSON based emacs UI

2010-03-22 Thread David Edmondson
I'm pushed the first stage of a JSON based emacs UI to the repository at
http://github.com/dme/notmuch (it's in the master branch).

This is intended to be functionally equivalent to the current UI, though
HTML display is not present (see below).

This is lightly tested, but if anyone else wants to give it a try I
would be interested in feedback. There were a couple of places in the
current code where I wasn't completely sure of the intention, so I may
have inadvertently diverged (notmuch-show-rewind is a good example).

For HTML display and other improved MIME support my intention is to
enhance notmuch to allow single parts to be output (something like:
notmuch show --part=2 id:k74hf87df@fish.org) and use that from the
UI code. No idea when I'll get to it, though.

Carl - the main changeset is large, but I couldn't see a sensible way to
break it up into smaller pieces. I'm open to suggestions.

Finally, if anyone else is working on something like this, please let me
know - I'd be interested in collaborating.

ps. Thanks to aep in #notmuch for encouraging me to just get on with it.

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


Re: [notmuch] JSON based emacs UI

2010-03-22 Thread David Edmondson
On Mon, 22 Mar 2010 14:47:39 +, David Edmondson d...@dme.org wrote:
 This is lightly tested, but if anyone else wants to give it a try I
 would be interested in feedback. There were a couple of places in the
 current code where I wasn't completely sure of the intention, so I may
 have inadvertently diverged (notmuch-show-rewind is a good example).

Oops, it doesn't remove the unread tag.

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


Re: [notmuch] JSON based emacs UI

2010-03-24 Thread David Edmondson
On Mon, 22 Mar 2010 14:47:39 +, David Edmondson d...@dme.org wrote:
 I've pushed the first stage of a JSON based emacs UI to the repository
 at http://github.com/dme/notmuch (it's in the master branch).
 
 This is intended to be functionally equivalent to the current UI, though
 HTML display is not present (see below).
 
 This is lightly tested, but if anyone else wants to give it a try I
 would be interested in feedback. There were a couple of places in the
 current code where I wasn't completely sure of the intention, so I may
 have inadvertently diverged (notmuch-show-rewind is a good example).
 
 For HTML display and other improved MIME support my intention is to
 enhance notmuch to allow single parts to be output (something like:
 notmuch show --part=2 id:k74hf87df@fish.org) and use that from the
 UI code. No idea when I'll get to it, though.

notmuch part --part=2 id:k74hf87df@fish.org support is pushed now
and notmuch-show.el updated to use it.

An attempt is made to inline all parts, including guessing the type of
application/octet-stream parts using mailcap (so a file called
foo.patch sent as type application/octet-stream will be displayed
using diff-mode formatting).

Image inlining doesn't work, even for simple image/jpeg attachments. I'm
still puzzling over this - the output from 'notmuch part' seems fine,
but the lisp code to generate the image and insert it at the right place
is broken.

Inline images in HTML are also likely problematic - I'm not sure that I
have the framework in place for handling images specified using the cid:
prefix.

Next is to fix images and persuade notmuch to be more verbose about the
detailed MIME structure of messages.

As always, feedback (especially if something breaks) appreciated.

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


Re: [notmuch] JSON based emacs UI

2010-03-26 Thread David Edmondson
On Fri, 26 Mar 2010 10:16:12 +0530, Aneesh Kumar K. V 
aneesh.ku...@linux.vnet.ibm.com wrote:
 That worked. Thanks. BTW is there a way to get '=' to reload the thread
 details. Something similar to notmuch-search-refresh-view. for the show
 window.

I'll look at adding it.

 That would make sure i can get the tag updated tag details by using =
 key. right now it is difficult to find out whether i unread tag is
 removed from a message or not. The best fix would be to show the
 updated tag dynamically

This is now fixed.

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


Re: [notmuch] JSON based emacs UI

2010-03-26 Thread David Edmondson
On Fri, 26 Mar 2010 05:07:49 -0400, Jesse Rosenthal jrosent...@jhu.edu wrote:
 There's a complaint when I open a (multipart?) message:
 
 invalid function: mm-make-handle
 
 Adding (require 'mm-decode) to notmuch-show.el fixes this problem.

Sorry about that. The repository is updated accordingly.

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


Re: [notmuch] JSON based emacs UI

2010-03-26 Thread David Edmondson
On Fri, 26 Mar 2010 20:21:46 +0530, Aneesh Kumar K. V 
aneesh.ku...@linux.vnet.ibm.com wrote:
 On Mon, 22 Mar 2010 14:47:39 +, David Edmondson d...@dme.org wrote:
 
 I found another issue. In the notmuch-show-mode RET key on from and
 subject doesn't seem to work.
 
 For ex: for the last message RET key on from doesn't fold the message.
 For all the message RET key on subject doesn't show the message
 header(from cc and to list)

'RET' anywhere in the message is supposed to toggle visibility of the
message. That was not working perfectly - a little forced redisplay
helped (just pushed).

Toggling the visibility of headers is done with 'h'. There's currently
no way to do that by pressing 'RET' somewhere. (You can also toggle the
body with 'b'.)

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


Re: [notmuch] JSON based emacs UI

2010-03-29 Thread David Edmondson
On Sun, 28 Mar 2010 14:03:44 -0300, Fernando Carrijo fcarr...@yahoo.com.br 
wrote:
 David Edmondson d...@dme.org wrote:
  'RET' anywhere in the message is supposed to toggle visibility of the
  message. That was not working perfectly - a little forced redisplay
  helped (just pushed).
  
  Toggling the visibility of headers is done with 'h'. There's currently
  no way to do that by pressing 'RET' somewhere. (You can also toggle the
  body with 'b'.)
 
 I fear this is not correct. I cloned notmuch from Carl's git repository,
 and whenever I press 'RET' while the point is over the subject line, the
 result is the same as pressing 'h': the subject information gets toggled.

Is this considered a feature that blocks people from switching to the
JSON based UI?

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


Re: [notmuch] pull request

2010-04-02 Thread David Edmondson
On Thu, 01 Apr 2010 14:09:57 -0700, Carl Worth cwo...@cworth.org wrote:
 On Thu, 01 Apr 2010 15:41:03 +0100, David Edmondson d...@dme.org wrote:
  Carl, a couple of patches that I'd like you to consider. They are the
  first two on the `dme' branch of git://github.com/dme/notmuch.git.

The updated changes are on the 'dme-for-cworth' branch now.

  http://github.com/dme/notmuch/commit/f86254e4509ed02731aa3eaa8541df1f2d11e400
   notmuch-show: Add unix and pretty dates to the JSON output
   
   Include a 'date_unix' and 'date_pretty' field in the JSON output for
   each message. 'date_pretty' can be used by a UI implementation,
   whereas 'date_unix' is useful when scripting.
 
 With date_unix it's easy enough to guess what the value is. But
 date_pretty is much more ambiguous. I assumed that this would be an
 RFC 822 date string, (but then found that it's the relative date that
 notmuch show is using currently).
 
 I think I'd rather see that named date_relative, (or dropped with the
 expectation that callers can decide how to format dates on their own).

I renamed it to 'date_relative'.

Keeping the creation of the relative date strings in one place struck me
as a good idea - there will consistency between the two places it is
used (search mode and show mode) and if the `notmuch' command is
localised the Emacs UI will immediately benefit.

   The search terms should match only a single message
   (e.g. id:f...@bar.com). The part number specified refers to the part
   identifiers output by `notmuch show'. The content of the part is written
   the stdout with no formatting or identification marks. It is not JSON
   formatted.
 
 The above documentation isn't quite complete to me. Is MIME decoding
 handled by this or not? Also, the documentation says the search terms
 should match only one message, but what does the implementation do if
 more than one message is matched? It would be good to document that as
 well.
 
 More significantly, this level of documentation needs to be put into the
 notmuch help output (instead of the placeholder that's there in the
 current patch). It also needs to be added to the man page in
 notmuch.1.

The documentation is updated. Sorry for being lazy.

  The second of these (part) has been the topic of some
  discussion. There's a suggestion that a 'cat' subcommand or
  '--format=raw' option to the 'show' subcommand would be better. I'm not
  particular preference - I just wanted the functionality to use in the
  Emacs UI.
 
 One other approach that I imagined with the json output would be to
 simply include all of the MIME parts of all messages directly in the
 json-format output from notmuch show. Does json have any particular
 way of encodign a binary blob? If not, should we just have one single
 encoding here? (Such as BASE64 within a json string?)

I'm sure that JSON could express the blob. There were two reasons that I
decided not to include the full message in the JSON output:

- some of the parts can be very large, causing Emacs to spend
  considerably time loading the part (and consume a bunch of
  memory). This would be particularly noticeable in a thread
  where many of the messages include large parts - the UI will
  load all of the parts, even if you've already seen the
  message.

- there are some parts that the UI will probably never display
  inline usefully (OpenOffice?). For those parts it's quite
  wasteful to have the UI pull them in.

There's obviously a compromise to be had. If we agreed to include
text/html parts in the JSON output it would make sense to me - maybe all
text/* parts should be there. There are probably others that would be
useful.

The later 'display all parts' version of notmuch-show is able to use
either inline or external content to display parts (it uses that
included in the JSON output if present).

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


[notmuch] pull request [was Re: pull request]

2010-04-03 Thread David Edmondson
On Fri, 02 Apr 2010 15:53:34 -0700, Carl Worth cwo...@cworth.org wrote:
 On Fri, 02 Apr 2010 09:53:04 +0100, David Edmondson d...@dme.org wrote:
  The updated changes are on the 'dme-for-cworth' branch now.
 
 Thanks for the quick update, David!
 
 I've pushed this now.

Thanks. Here's another set to consider. They are in the 'dme' branch.

* commit 94893f25d36aaf43487e111fbfba4f7dae808dd2
| Author: David Edmondson d...@dme.org
| Date:   Tue Mar 23 07:04:34 2010 +
| 
| emacs/notmuch.el: Improve tag highlighting in search mode
| 
| Assume that tags never include an opening bracket, and hence improve
| the regular expression used to highlight them. This avoids false
| matches where the 'from' address of a thread participant includes an
| opening bracket.

* commit 4de9f3f09e998d7312be2a1c08526e59bbf135a9
| Author: David Edmondson d...@dme.org
| Date:   Sun Mar 21 09:54:08 2010 +
| 
| emacs/Makefile.local: Use makefile mode

* commit f7ecad654fd8d0274fc75833d92117c8e496bcea
| Author: David Edmondson d...@dme.org
| Date:   Thu Apr 1 18:36:21 2010 +0100
| 
| emacs: Move notmuch-show functionality to notmuch-show.el
| 
| To ease the transition to a JSON based implementation of
| `notmuch-show', move the current implementation into a separate file.

* commit a9590dfb4efc2c05a35948ef4522c362eb788c10
| Author: David Edmondson d...@dme.org
| Date:   Thu Apr 1 11:38:30 2010 +0100
| 
| Makefile: Add the emacs directory to load-path when compiling

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


Re: [notmuch] pull request [was Re: pull request]

2010-04-04 Thread David Edmondson
On Sat, 03 Apr 2010 18:21:57 -0300, David Bremner brem...@unb.ca wrote:
 The warnings about unknown functions can be eliminated by use the
 declare-function macro; if you have emacs lisp reference manual (it
 required the package emacs23-common-non-dfsg on Debian) then you can
 run:
 
 ESC ESC : (info (elisp)Declaring Functions) RETURN
 
 For variables, the obvious approach is to make a file 'notmuch-vars.el'
 and put the variables we need in several files there.

I'll declare common variables and 'exported' functions in
'notmuch-lib.el'. It may take a few days (I'm supposed to be on
holiday).

Carl: is a single changeset that creates notmuch-lib.el and moves the
show implementation into notmuch-show.el okay?

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


Re: [notmuch] pull request [was Re: pull request]

2010-04-04 Thread David Edmondson
On Sun, 04 Apr 2010 08:33:00 +0100, David Edmondson d...@dme.org wrote:
 I'll declare common variables and 'exported' functions in
 'notmuch-lib.el'. It may take a few days (I'm supposed to be on
 holiday).

It was quicker than expected. Using 'declare-function' in a file that is
required didn't have the right effect (it seemed to be ignored), so the
'declare-function' calls are directly in `notmuch-show.el'. I get no
warnings when compiling now.

It's the 'for-cworth' branch of git://github.com/dme/notmuch.git.

There's also a simple update to tell git to ignore notmuch-shared.

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


Re: [notmuch] [PATCH] format_part_json: part_content-data is not null terminated

2010-04-05 Thread David Edmondson
On Thu, 01 Apr 2010 14:05:06 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
 On Thu, 04 Mar 2010, Gregor Hoffleit wrote:
  -   printf (, \content\: %s, json_quote_str (ctx, (char *) 
  part_content-data));
  +   content_data = talloc_size (ctx, part_content-len+1);
  +   memcpy (content_data, (char *)part_content-data, part_content-len+1);
  +   content_data[part_content-len] = 0;
  +   printf (, \content\: %s, json_quote_str (ctx, content_data));
 
 What about modifying json_quote_str() to accept additional parameter
 len? If I have 10MB attachment to the email, this unnecessary copy is
 quite expensive, isn't it?

Agreed. How about this patch:
  http://github.com/dme/notmuch/commit/5f23ae341788d28e455e53488d184d8caaa618c5
?

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


[PATCH] json: Avoid calling strlen(NULL)

2010-04-06 Thread David Edmondson
commit b65817262b3a275ecd0ef1898d92ec5508a9f810
Author: David Edmondson d...@dme.org
Date:   Tue Apr 6 08:24:00 2010 +0100

json: Avoid calling strlen(NULL)

MIME parts may have no filename, which previously resulted in calling
strlen(NULL).

Modified json.c
diff --git a/json.c b/json.c
index f90b0fa..b73f22a 100644
--- a/json.c
+++ b/json.c
@@ -105,5 +105,8 @@ json_quote_chararray(const void *ctx, const char *str, 
const size_t len)
 char *
 json_quote_str(const void *ctx, const char *str)
 {
+if (str == NULL)
+   return (char *)\\;
+
 return (json_quote_chararray (ctx, str, strlen (str)));
 }


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


finding the emacs lisp after install

2010-04-07 Thread David Edmondson
After this change...

 commit dfbec15b2388158693ab0dce0c7d348c4c5a98a5
 Author: Carl Worth cwo...@cworth.org
 Date:   Tue Apr 6 15:05:13 2010 -0700
 
 Install emacs lisp files into a notmuch sub-directory of site-lisp.
 
 Now that we have multiple emacs-lisp source files, it's just more
 polite this way.

...how is emacs supposed to find these files? .../site-lisp/notmuch is
not in my load-path by default (Debian GNU Emacs 23.1.1).

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


Re: Plans for the 0.2 release (this week)

2010-04-08 Thread David Edmondson
On Wed, 07 Apr 2010 15:12:44 -0700, Carl Worth cwo...@cworth.org wrote:
   * The big batch of emacs-client improvements from David E.'s
 repository. David, do you have particular things to recommend here?

It's necessary for me to merge with your latest batch of changes. That
won't happen until next week, when I can set aside a few hours. (The
merge is somewhat painful, as I have modified versions of some of the
recently applied patches in my tree.)

I worry about committing the JSON based Emacs UI and then immediately
producing a release - it would be useful to have more people test it
from git HEAD before dropping it on an unsuspecting public.

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


Re: [PATCH] notmuch.el: 'F' in search mode takes us to a list of folders.

2010-04-08 Thread David Edmondson
On Wed, 07 Apr 2010 16:12:36 -0700, Carl Worth cwo...@cworth.org wrote:
 I'm actually currently using super-n (a personal customization I have)
 to get to notmuch-folder view from *any* buffer in emacs.

This is also my current approach, though I don't use it very much (or
'F').

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


pull request

2010-04-11 Thread David Edmondson
Carl, please consider the following (from the 'for-cworth' branch of
git://github.com/dme/notmuch.git) for 0.2. I hope to have some more UI
changes merged next week.

commit 651f8ca16beadd658c412075a585e4ec90e31456
Author: David Edmondson d...@dme.org
Date:   Mon Mar 22 14:50:20 2010 +

emacs/notmuch-show.el: Avoid passing unintended format strings to `message'

If the text being stashed included %, `message' was unhappy and
complained.

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

commit 744c8274e56e38940644d31cc6a1588f989daa43
Author: David Edmondson d...@dme.org
Date:   Wed Mar 24 15:50:11 2010 +

emacs/notmuch.el: Enable `hl-line-mode' in `notmuch-search-mode'

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

commit 42949084a6dae6997f5872ee9d74da4fc0a89369
Author: David Edmondson d...@dme.org
Date:   Tue Apr 6 08:24:00 2010 +0100

json: Avoid calling strlen(NULL)

MIME parts may have no filename, which previously resulted in calling
strlen(NULL).

 json.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

commit 94ba1fa0de79902c94612dad84e32fdcdc8a34dc
Author: David Edmondson d...@dme.org
Date:   Sun Apr 11 08:58:43 2010 +0100

emacs: JSON based implementation

Re-implement notmuch-show.el using the JSON output format of the
notmuch command. Most functionality is retained - HTML display is
noticeably missing.

 emacs/notmuch-lib.el  |   11 -
 emacs/notmuch-show.el | 1620 +
 emacs/notmuch.el  |   69 +--
 3 files changed, 837 insertions(+), 863 deletions(-)

commit a586736deaf934ac348125499601b00e71d7c841
Author: David Edmondson d...@dme.org
Date:   Mon Mar 22 16:49:16 2010 +

emacs: Move body markup to a separate file

Move the citation and signature markup for text/plain parts to a new
file (notmuch-wash.el) and call it using a hook mechanism rather than
directly.

 emacs/Makefile.local  |3 +-
 emacs/notmuch-show.el |  131 ++-
 emacs/notmuch-wash.el |  150 +
 3 files changed, 157 insertions(+), 127 deletions(-)

commit e4fe7e4274f9669aa8040d34b2df5f6571ff9b61
Author: David Edmondson d...@dme.org
Date:   Thu Apr 1 16:25:20 2010 +0100

emacs: Add more functions to clean up text/plain parts

Add:
- notmuch-wash-wrap-long-lines: Wrap lines longer than the width of
  the current window whilst maintaining any citation prefix.
- notmuch-wash-tidy-citations: Tidy up citations by:
  - compress repeated otherwise blank citation lines,
  - remove otherwise blank citation lines at the head and tail of a
citation and remove blank lines between attribution statements and
the citation,
- notmuch-wash-compress-blanks: Compress repeated blank lines and
  remove leading and trailing blank lines.

Enable all of the functions by default by adding them to
`notmuch-show-insert-text/plain-hook'.

With the wrapping features for text/plain parts enabled, word wrapping
of the buffer leads to an unappealing display of text, so disable it.

 emacs/Makefile.local  |3 +-
 emacs/coolj.el|  145 +
 emacs/notmuch-show.el |   14 -
 emacs/notmuch-wash.el |   72 -
 4 files changed, 230 insertions(+), 4 deletions(-)

commit 53544b7907b3945b06c10113e7900b59113e405f
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 10:06:00 2010 +

emacs/notmuch-show.el: Improved part labelling

If a text/plain part is not the first part in a message, add a label
in order that a user can see that multiple parts are present.

If a part has a 'filename' attribute, include it in any label
describing the part.

 emacs/notmuch-show.el |   26 +-
 1 files changed, 17 insertions(+), 9 deletions(-)

commit 8144f6553b443a916c599d7fbb347c557923e71f
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 11:54:05 2010 +

emacs: Use `mm-display-part' when possible

For parts that the mm-decode/mm-view functions can inline and we have
the content, use `mm-display-part' to insert the part in the
buffer.

 emacs/notmuch-show.el |   30 ++
 1 files changed, 22 insertions(+), 8 deletions(-)

commit bf3da2f2422539f9c099158457b84482b22fbd41
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 11:54:05 2010 +

emacs: Use mailcap.el to guess the type of application/octet-stream parts

Use the mailcap functionality to guess a MIME type for attachments of
type application/octet-stream and, presuming successful, feed the
attachment back into the display code with the determine type.

This is mostly useless at the moment, as the JSON output from notmuch
does

Re: RFC: User-Agent header

2010-04-11 Thread David Edmondson
On Mon, 12 Apr 2010 00:12:15 +0200, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 After some research, this is what I found/propose:
 ...

Please make the insertion of User-Agent optional. Some might not want
it.

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


Re: sup-like label listings (elisp)

2010-04-12 Thread David Edmondson
Oops. That one wasn't complete. Try:

commit 0c55967141e7685b0ba23b45a74c1e48a5964f6c
Author: David Edmondson d...@dme.org
Date:   Mon Apr 12 09:24:44 2010 +0100

emacs: More flexible folder mode construction

Allow callers to `notmuch-folder' to optionally specify the alist of
folders to be shown and a title for the buffer.

Add `notmuch-folder-all-tags' and `notmuch-folder-all-tags-unread'
based on the above.

Modified emacs/notmuch.el
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6d44249..b6a5e5f 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -888,16 +888,43 @@ Currently available key bindings:
 (if search
(notmuch-search (cdr search) notmuch-search-oldest-first
 
+(defun notmuch-folder-all-tags-unread ()
+  Show the notmuch folder view for messages tagged `unread' for
+all tags.
+  (interactive)
+  (notmuch-folder-all-tags tag:unread))
+
+(defun notmuch-folder-all-tags (optional search-restriction)
+  Show the notmuch folder view for all tags. The optional
+parameter `search-restriction' allows the tag based search to be
+refined.
+  (interactive)
+  (notmuch-folder
+   (mapcar '(lambda (tag)
+ (cons tag (concat tag: tag
+   (if search-restriction
+   (concat  AND (  search-restriction  ))
+ 
+  (process-lines notmuch-command search-tags))
+   search-restriction))
+
 ;;;###autoload
-(defun notmuch-folder ()
+(defun notmuch-folder (optional folders title)
   Show the notmuch folder view and update the displayed counts.
   (interactive)
-  (let ((buffer (get-buffer-create *notmuch-folders*)))
+  (let ((buffer (get-buffer-create
+(concat *notmuch-folders
+(if title (concat - title) )
+*)))
+   (folders (or folders notmuch-folders)))
 (switch-to-buffer buffer)
 (let ((inhibit-read-only t)
  (n (line-number-at-pos)))
   (erase-buffer)
   (notmuch-folder-mode)
+  ;; Must come after `notmuch-folder-mode', as that kills all
+  ;; local variables.
+  (set (make-local-variable 'notmuch-folders) folders)
   (notmuch-folder-add notmuch-folders)
   (goto-char (point-min))
   (goto-line n


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


Re: [PATCH] emacs: Add notmuch-hello.el, a friendly frontend to notmuch

2010-04-13 Thread David Edmondson
On Tue, 13 Apr 2010 12:25:43 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
 For next time, could you plese use 'git format-patch' for generating
 patches for sending in email? If I pipe your message to 'git am', all
 the above text becomes a part of commit message.

Will do.

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


Re: [PATCH 13/13] notmuch.el: Add a function to insert a notmuch user-agent header

2010-04-14 Thread David Edmondson
On Wed, 14 Apr 2010 09:38:05 +0200, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 This adds a function (and a hook) to have notmuch insert a User-Agent header
 into composed mails (even if invoked from not-notmuch ways, such as with
 ctrl-x m. This is invariably added for now without the possibility to
 turn it off, a task left as a homework for others.

This really should be done with `define-mail-user-agent' and associated
paraphernalia.

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


[PATCH] emacs: Re-arrange message sending code

2010-04-15 Thread David Edmondson
Define a new `mail-user-agent' (`notmuch-user-agent') and use it by
default. Re-arrange various routines that send mail to use this
(compose, reply, forward). Insert a `User-Agent:' header by default.
---
 emacs/notmuch-hello.el |2 +
 emacs/notmuch-mua.el   |   94 
 emacs/notmuch-show.el  |5 ++-
 emacs/notmuch.el   |   43 --
 4 files changed, 130 insertions(+), 14 deletions(-)
 create mode 100644 emacs/notmuch-mua.el

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index c49a35f..83586f2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -25,6 +25,7 @@
 
 (require 'notmuch-lib)
 (require 'notmuch)
+(require 'notmuch-mua)
 
 (declare-function notmuch-search notmuch (query optional oldest-first 
target-thread target-line))
 (declare-function notmuch-folder-count notmuch (search))
@@ -314,6 +315,7 @@ diagonal.
 
   (use-local-map widget-keymap)
   (local-set-key = 'notmuch-hello-update)
+  (local-set-key m 'notmuch-mua-mail)
   (local-set-key q '(lambda () (interactive) (kill-buffer (current-buffer
   (local-set-key s 'notmuch-hello-goto-search)
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
new file mode 100644
index 000..c8a8743
--- /dev/null
+++ b/emacs/notmuch-mua.el
@@ -0,0 +1,94 @@
+;; notmuch-mua.el --- emacs style mail-user-agent
+;;
+;; 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 http://www.gnu.org/licenses/.
+;;
+;; Authors: David Edmondson d...@dme.org
+
+(require 'message)
+
+;;
+
+(defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)
+  Hook run before sending messages.
+  :group 'notmuch
+  :type 'hook)
+
+(defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent
+  Function used to generate a `User-Agent:' string. If this is
+`nil' then no `User-Agent:' will be generated.
+  :group 'notmuch
+  :type 'function)
+
+;;
+
+(defun notmuch-mua-user-agent ()
+  Generate a `User-Agent:' string suitable for notmuch.
+  (concat
+   ;; Trim off the trailing newline.
+   (substring (shell-command-to-string
+  (concat notmuch-command  --version))
+ 0 -1)
+(Emacs  emacs-version /
+   system-configuration )))
+
+(defun notmuch-mua-forward-message ()
+  (message-forward)
+  (save-excursion
+(when notmuch-mua-user-agent-function
+  (let ((user-agent (funcall notmuch-mua-user-agent-function)))
+   (when (not (string=  user-agent))
+ (message-add-header (format User-Agent: %s user-agent)
+(message-sort-headers)
+(message-hide-headers))
+  (set-buffer-modified-p nil))
+
+(defun notmuch-mua-mail (optional to subject other-headers continue
+  switch-function yank-action send-actions)
+  (interactive)
+
+  (when notmuch-mua-user-agent-function
+(let ((user-agent (funcall notmuch-mua-user-agent-function)))
+  (when (not (string=  user-agent))
+   (push (cons User-Agent user-agent) other-headers
+
+  (message-mail to subject other-headers continue
+   switch-function yank-action send-actions)
+  (message-hide-headers))
+
+(defun notmuch-mua-send-and-exit (optional arg)
+  (interactive P)
+  (message-send-and-exit arg))
+
+(defun notmuch-mua-kill-buffer ()
+  (interactive)
+  (message-kill-buffer))
+
+(defun notmuch-mua-message-send-hook ()
+  The default function used for `notmuch-mua-send-hook', this
+simply runs the corresponding `message-mode' hook functions.
+  (run-hooks 'message-send-hook))
+
+;;
+
+(define-mail-user-agent 'notmuch-user-agent
+  'notmuch-mua-mail 'notmuch-mua-send-and-exit
+  'notmuch-mua-kill-buffer 'notmuch-mua-send-hook)
+
+;;
+
+(provide 'notmuch-mua)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 54d1c48..d1b0f1a 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -30,6 +30,7 @@
 (require 'notmuch-lib)
 (require 'notmuch-query)
 (require 'notmuch-wash)
+(require 'notmuch-mua)
 
 (declare-function notmuch-call-notmuch-process notmuch (rest args))
 (declare-function notmuch-reply notmuch (query-string))
@@ -519,7 +520,7 @@ function is used. 
(define-key map (kbd M-TAB) 'notmuch-show-previous-button)
(define-key map (kbd TAB) 'notmuch-show-next-button)
(define-key map s 'notmuch-search)
-   (define-key map m 'message-mail)
+   (define-key

Re: [PATCH] emacs: Re-arrange message sending code

2010-04-15 Thread David Edmondson
On Thu, 15 Apr 2010 16:50:27 +0100, David Edmondson d...@dme.org wrote:
 Define a new `mail-user-agent' (`notmuch-user-agent') and use it by
 default. Re-arrange various routines that send mail to use this
 (compose, reply, forward). Insert a `User-Agent:' header by default.

I meant to add that this was a proposal in response to Sebastian's
User-Agent related patch (id:87y6gtnkch@sspaeth.de).

Setting `mail-user-agent' in notmuch.el is a bit aggressive, but without
requiring some configuration on the part of the user (which Carl
appeared to want to avoid) it's not obvious how to make things as
simple as the existing approach.

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


Re: pull request

2010-04-19 Thread David Edmondson
On Sun, 11 Apr 2010 11:29:29 +0100, David Edmondson d...@dme.org wrote:
 Carl, please consider the following (from the 'for-cworth' branch of
 git://github.com/dme/notmuch.git) for 0.2. I hope to have some more UI
 changes merged next week.

This is the same set rebased onto 0.2.

commit 8586a86b9dd4ed2406a2fbda6c08bdc6a598cfd8
Author: David Edmondson d...@dme.org
Date:   Sat Apr 10 09:02:32 2010 +0100

debian: git should ignore packaging intermediate files

commit f5de1bb5b4216a1950f6aa5f471c9964e4d0e521
Author: David Edmondson d...@dme.org
Date:   Mon Mar 22 14:50:20 2010 +

emacs/notmuch-show.el: Avoid passing unintended format strings to `message'

If the text being stashed included %, `message' was unhappy and
complained.

commit 4159baa2166a3410663adc200f91145edf8e0e13
Author: David Edmondson d...@dme.org
Date:   Wed Mar 24 15:50:11 2010 +

emacs/notmuch.el: Enable `hl-line-mode' in `notmuch-search-mode'

commit 53c4e64943d09b07e75c9258fc9f954c87a490d6
Author: David Edmondson d...@dme.org
Date:   Tue Apr 6 08:24:00 2010 +0100

json: Avoid calling strlen(NULL)

MIME parts may have no filename, which previously resulted in calling
strlen(NULL).

commit 7dedc95af671173a57bafd973604614c03121ce6
Author: David Edmondson d...@dme.org
Date:   Sun Apr 11 08:58:43 2010 +0100

emacs: JSON based implementation

Re-implement notmuch-show.el using the JSON output format of the
notmuch command. Most functionality is retained - HTML display is
noticeably missing.

commit 514e14c42e214718768a1ec94cb869cd3eb47114
Author: David Edmondson d...@dme.org
Date:   Mon Mar 22 16:49:16 2010 +

emacs: Move body markup to a separate file

Move the citation and signature markup for text/plain parts to a new
file (notmuch-wash.el) and call it using a hook mechanism rather than
directly.

commit 2b6201fbf9209a875f216d48c30b95a6f583c575
Author: David Edmondson d...@dme.org
Date:   Thu Apr 1 16:25:20 2010 +0100

emacs: Add more functions to clean up text/plain parts

Add:
- notmuch-wash-wrap-long-lines: Wrap lines longer than the width of
  the current window whilst maintaining any citation prefix.
- notmuch-wash-tidy-citations: Tidy up citations by:
  - compress repeated otherwise blank citation lines,
  - remove otherwise blank citation lines at the head and tail of a
citation and remove blank lines between attribution statements and
the citation,
- notmuch-wash-compress-blanks: Compress repeated blank lines and
  remove leading and trailing blank lines.

Enable all of the functions by default by adding them to
`notmuch-show-insert-text/plain-hook'.

With the wrapping features for text/plain parts enabled, word wrapping
of the buffer leads to an unappealing display of text, so disable it.

commit c7872f5e1f11cfa10d93cb818c5f6f6c0835b918
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 10:06:00 2010 +

emacs/notmuch-show.el: Improved part labelling

If a text/plain part is not the first part in a message, add a label
in order that a user can see that multiple parts are present.

If a part has a 'filename' attribute, include it in any label
describing the part.

commit 951db85a55a1893e766b26de1377dda5b4573366
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 11:54:05 2010 +

emacs: Use `mm-display-part' when possible

For parts that the mm-decode/mm-view functions can inline and we have
the content, use `mm-display-part' to insert the part in the
buffer.

commit 5c060ded87ec4dc479625348708ef73852d60b36
Author: David Edmondson d...@dme.org
Date:   Tue Mar 23 11:54:05 2010 +

emacs: Use mailcap.el to guess the type of application/octet-stream parts

Use the mailcap functionality to guess a MIME type for attachments of
type application/octet-stream and, presuming successful, feed the
attachment back into the display code with the determine type.

This is mostly useless at the moment, as the JSON output from notmuch
does not include the content of application/octet-stream parts, so
they cannot be displayed even if the guess is a good one.

commit 5fcbb528384b7bda838f7c77434def15f85c7382
Author: David Edmondson d...@dme.org
Date:   Thu Apr 1 18:33:46 2010 +0100

emacs: Display all body parts using `notmuch part --part=n'

Use the `notmuch part' command to access body parts not currently
included in the JSON output and display those body parts
appropriately.

commit 9e193a3998b7503e35d21013c71cc4ecaf6c9d50
Author: David Edmondson d...@dme.org
Date:   Thu Mar 25 12:26:49 2010 +

emacs/notmuch-wash.el: Add `notmuch-wash-inline-patch'

`notmuch-wash-inline-patch' attempts to convert inline patches to fake
attachments, in order that diff-mode highlighting can be applied to
the patch. It should be added to
`notmuch-show

Re: [notmuch] Bulk message tagging

2010-04-19 Thread David Edmondson
On Sat, 17 Apr 2010 08:43:19 -0700, Carl Worth cwo...@cworth.org wrote:
 In fact, until we have some sort of daemon that we can feed
 arbitrarily-long lists to, that's what we should do.

Thinking about loud... What if the sub-commands which accept potentially
long argument lists (most of them?) sprouted a '--stdin' option, which
caused them to read the (remaining) argument list from stdin rather than
looking at argv? It seems that this would be simpler change than full
daemon support.

So:
notmuch show id:f...@bar.baz
could become:
echo id:f...@bar.baz | notmuch show --stdin

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


Re: [PATCH 1/2] Add 'cat' subcommand

2010-04-20 Thread David Edmondson
On Tue, 20 Apr 2010 12:14:56 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
   I'm puzzled why you chose to pass a filename as the argument to 'cat'
   rather than a message id (id:f...@bar.com)?
 
 The reason is that I want be able to distinguish between several
 messages with the same id.

It strikes me that notmuch is not well suited to this in general. For
example, how would you find the filenames for the two messages with the
same message id?

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


Re: [PATCH 1/2] Add 'cat' subcommand

2010-04-20 Thread David Edmondson
On Tue, 20 Apr 2010 13:13:36 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
 On Tue, 20 Apr 2010, David Edmondson wrote:
  On Tue, 20 Apr 2010 12:14:56 +0200, Michal Sojka sojk...@fel.cvut.cz 
  wrote:
 I'm puzzled why you chose to pass a filename as the argument to 'cat'
 rather than a message id (id:f...@bar.com)?
   
   The reason is that I want be able to distinguish between several
   messages with the same id.
  
  It strikes me that notmuch is not well suited to this in general. For
  example, how would you find the filenames for the two messages with the
  same message id?
 
 Currently, it is probably not possible but I can imagine that notmuch
 show will output all file names associated with the message id and user
 could select between them if he needs.

If the filenames are really 'unique message identifiers' and may not
work when passed to open(2), then I don't have a problem.

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


Re: pull request

2010-04-21 Thread David Edmondson
On Tue, 20 Apr 2010 09:25:36 -0700, Carl Worth cwo...@cworth.org wrote:
 I'm currently working on the make-emacs-use-JSON patch, (it's got some
 confusion about body visible vs. message visible that I want to
 fix before pushing).

Could you describe the confusion?

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


Re: pull request

2010-04-22 Thread David Edmondson
On Wed, 21 Apr 2010 12:15:48 -0700, Carl Worth cwo...@cworth.org wrote:
 Sure. Hiding a message with 'b' is visually identical to hiding it with
 RET.

That's not quite true. `b' will (would) hide only the body. If the
header is visible `b' will not hide it.

 Except that the internal mechanism is distinct, so that afterwards one
 can't make it visible again with RET.

The internal mechanism is distinct because it does a different
thing. The original code drew a distinction between header visibility,
body visibility and message-as-a-whole visibility. I agree that visually
there is no difference between 'header and body hidden' and 'message
hidden'. It's possible to have only the header visible, which I've yet
to find a use for. The code works as I intended, though I'd agree that
may not be the desired behaviour :-)

Given that I've never used `b' other than in testing, I'm not worried
about it going away.

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


Re: pull request

2010-04-22 Thread David Edmondson
 missing. The
 link URLs at least appear in the text/plain rendering, (which is
 pretty ugly, but at least not impossible to use).

The HTML formatting depends somewhat on the tools available on your
system. Do you have w3m and w3m-el[1] installed? I'd be curious to see a
screenshot of a message that you think is poorly displayed.

 If we could get one version or the other working completely, then it
 would be nice to display only one.

See above - multipart/alternative support is required.

  commit e9d737feb5a49fd59e1f27bccd24cac2fd1ef749
  
  emacs/notmuch-show.el: Add `notmuch-show-toggle-all' bound to M-RET
  
  `notmuch-show-toggle-all' changes the visibility all of the messages
  in the current thread. By default it makes all of the messages not
  visible. With a prefix argument, it makes them all visible.
 
 I didn't push this one yet.
 
 The feature is *almost* what I want. It's just that I often want to open
 all messages in a thread, (and I've never found myself wanting to close
 all messages). So I'd like to switch which behavior requires the prefix
 argument here.

Should I just re-submit with the sense reversed? After using it for a
few days the opposite approach seems more useful.

 Anyone, if you haven't tried that mode yet for customizing notmuch, you
 should give it a try. (And we should add some hint somewhere to make it
 easier to find. Perhaps a keybinding to get to the customization
 buffer.)

A button in `notmuch-hello' ?

Footnotes: 
[1]  Debian names - presumably similar on other systems.


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


Re: problem with notmuch-search-authors-width in JSON emacs implementation

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 00:37:25 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
 On Wed, 21 Apr 2010 19:09:35 -0400, Jameson Rollins 
 jroll...@finestructure.net wrote:
  Hey, folks.  I just build from Carl's HEAD which includes the new emacs
  JSON interface and I'm noticing a problem with the
  notmuch-search-authors-width variable.  If I set the variable as
  follows:
  
  (setq notmuch-search-authors-width 40)
  
  author lists that overrun the specified width start spitting out into
  the subject field.  I think bremner just confirmed this on irc.  I'll
  try to look into this when I get a chance, but I don't have time right
  now.  Maybe someone with more intimate knowledge of this piece of code
  could figure it out more quickly.

I thought that I had this fixed up properly. Sorry for the breakage.

Can you show any explicit settings you have for
`notmuch-search-authors-width' and `notmuch-search-result-format'? Where
do you set them?

The intention was that if you just want a wider display of authors you
set `notmuch-search-authors-width' (which has existed for some time) and
`notmuch-search-result-format' adapts accordingly.

Admittedly, this doesn't cope well if you modify
`notmuch-search-result-format' without also updating
`notmuch-search-authors-width'. Some more thought required...

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


[PATCH] emacs/notmuch-show.el: Add `notmuch-show-toggle-all' bound to M-RET

2010-04-22 Thread David Edmondson
`notmuch-show-toggle-all' changes the visibility all of the messages
in the current thread. By default it makes all of the messages
visible. With a prefix argument, it makes them all not visible.
---
 emacs/notmuch-show.el |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 916b39e..9775fb4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -526,6 +526,7 @@ function is used. 
(define-key map p 'notmuch-show-previous-open-message)
(define-key map (kbd DEL) 'notmuch-show-rewind)
(define-key map   'notmuch-show-advance-and-archive)
+   (define-key map (kbd M-RET) 'notmuch-show-toggle-all)
(define-key map (kbd RET) 'notmuch-show-toggle-message)
map)
   Keymap for \notmuch show\ buffers.)
@@ -900,6 +901,18 @@ to stdout or stderr will appear in the *Messages* buffer.
  (not (plist-get props :message-visible
   (force-window-update))
 
+(defun notmuch-show-toggle-all ()
+  Change the visibility all of the messages in the current
+thread. By default make all of the messages visible. With a
+prefix argument, make them all not visible.
+  (interactive)
+  (save-excursion
+(goto-char (point-min))
+(loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
+  (not current-prefix-arg))
+ until (not (notmuch-show-goto-message-next
+  (force-window-update))
+
 (defun notmuch-show-next-button ()
   Advance point to the next button in the buffer.
   (interactive)
-- 
1.7.0

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


[PATCH] emacs: Re-arrange message sending code

2010-04-22 Thread David Edmondson
Define a new `mail-user-agent' (`notmuch-user-agent') and use it by
default. Re-arrange various routines that send mail to use this
(compose, reply, forward). Insert a `User-Agent:' header by default.
---
 emacs/Makefile.local   |5 +-
 emacs/notmuch-hello.el |2 +
 emacs/notmuch-lib.el   |   16 ++
 emacs/notmuch-mua.el   |  133 
 emacs/notmuch-show.el  |8 ++--
 emacs/notmuch.el   |   20 ++-
 6 files changed, 163 insertions(+), 21 deletions(-)
 create mode 100644 emacs/notmuch-mua.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 6486d90..e5013b3 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -6,8 +6,9 @@ emacs_sources := \
$(dir)/notmuch.el \
$(dir)/notmuch-query.el \
$(dir)/notmuch-show.el \
-   $(dir)/notmuch-wash.el
-   $(dir)/notmuch-hello.el
+   $(dir)/notmuch-wash.el \
+   $(dir)/notmuch-hello.el \
+   $(dir)/notmuch-mua.el
 
 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 13de6f8..fa6433e 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -25,6 +25,7 @@
 
 (require 'notmuch-lib)
 (require 'notmuch)
+(require 'notmuch-mua)
 
 (declare-function notmuch-search notmuch (query optional oldest-first 
target-thread target-line))
 (declare-function notmuch-folder-count notmuch (search))
@@ -335,6 +336,7 @@ diagonal.
 
   (use-local-map widget-keymap)
   (local-set-key = 'notmuch-hello-update)
+  (local-set-key m 'notmuch-mua-mail)
   (local-set-key q '(lambda () (interactive) (kill-buffer (current-buffer
   (local-set-key s 'notmuch-hello-goto-search)
   (local-set-key v '(lambda () (interactive)
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 274d7ec..47c74b9 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -33,6 +33,22 @@
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch)
 
+;;
+
+(defun notmuch-version ()
+  Return a string with the notmuch version number.
+  (let ((long-string
+;; Trim off the trailing newline.
+(substring (shell-command-to-string
+(concat notmuch-command  --version))
+   0 -1)))
+(if (string-match ^notmuch\\( version\\)? \\(.*\\)$
+ long-string)
+   (match-string 2 long-string)
+  unknown)))
+
+;;
+
 ;; XXX: This should be a generic function in emacs somewhere, not
 ;; here.
 (defun point-invisible-p ()
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
new file mode 100644
index 000..acb7dbf
--- /dev/null
+++ b/emacs/notmuch-mua.el
@@ -0,0 +1,133 @@
+;; notmuch-mua.el --- emacs style mail-user-agent
+;;
+;; 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 http://www.gnu.org/licenses/.
+;;
+;; Authors: David Edmondson d...@dme.org
+
+(require 'cl)
+(require 'message)
+
+(require 'notmuch-lib)
+
+;;
+
+(defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)
+  Hook run before sending messages.
+  :group 'notmuch
+  :type 'hook)
+
+(defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full
+  Function used to generate a `User-Agent:' string. If this is
+`nil' then no `User-Agent:' will be generated.
+  :group 'notmuch
+  :type 'function
+  :options '(notmuch-mua-user-agent-full
+notmuch-mua-user-agent-notmuch
+notmuch-mua-user-agent-emacs))
+
+;;
+
+(defun notmuch-mua-user-agent-full ()
+  Generate a `User-Agent:' string suitable for notmuch.
+  (concat (notmuch-mua-user-agent-notmuch)
+  
+ (notmuch-mua-user-agent-emacs)))
+
+(defun notmuch-mua-user-agent-notmuch ()
+  Generate a `User-Agent:' string suitable for notmuch.
+  (concat Notmuch/ (notmuch-version)  (http://notmuchmail.org)))
+
+(defun notmuch-mua-user-agent-emacs ()
+  Generate a `User-Agent:' string suitable for notmuch.
+  (concat Emacs/ emacs-version  ( system-configuration )))
+
+(defun notmuch-mua-reply (query-string)
+  (let (headers body)
+;; This make assumptions about the output of `notmuch reply', but
+;; really only that the headers come first followed by a blank
+;; line and then the body.
+(with-temp-buffer
+  (call-process notmuch-command nil t nil reply query-string)
+  (goto-char (point-min))
+  (if (re-search

[PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-22 Thread David Edmondson
A tool `notmuch-addresses' is required to produce addresses which
match a query string. An example of a suitable script can be found in
the git repository at
http://jkr.acm.jhu.edu/git/notmuch_addresses.git
There are no doubt others.
---
 emacs/Makefile.local |3 +-
 emacs/notmuch-address.el |   91 ++
 2 files changed, 93 insertions(+), 1 deletions(-)
 create mode 100644 emacs/notmuch-address.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index e5013b3..7537c3d 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -8,7 +8,8 @@ emacs_sources := \
$(dir)/notmuch-show.el \
$(dir)/notmuch-wash.el \
$(dir)/notmuch-hello.el \
-   $(dir)/notmuch-mua.el
+   $(dir)/notmuch-mua.el \
+   $(dir)/notmuch-address.el
 
 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
new file mode 100644
index 000..69a52a2
--- /dev/null
+++ b/emacs/notmuch-address.el
@@ -0,0 +1,91 @@
+;; notmuch-address.el --- address completion with 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 http://www.gnu.org/licenses/.
+;;
+;; Authors: David Edmondson d...@dme.org
+
+(require 'message)
+
+;;
+
+(defcustom notmuch-address-command notmuch-addresses
+  The command which generates possible addresses. It must take a
+single argument and output a list of possible matches, one per
+line.
+  :type 'string
+  :group 'notmuch)
+
+(defvar notmuch-address-message-alist-member
+  
'(^\\(Resent-\\)?\\(To\\|B?Cc\\|Reply-To\\|From\\|Mail-Followup-To\\|Mail-Copies-To\\):
+ . notmuch-address-expand-name))
+
+(defvar notmuch-address-history nil)
+
+(defun notmuch-address-message-insinuate ()
+  (if (not (memq notmuch-address-message-alist-member 
message-completion-alist))
+  (setq message-completion-alist
+   (push notmuch-address-message-alist-member 
message-completion-alist
+
+(defun notmuch-address-options (original)
+  (process-lines notmuch-address-command original))
+
+(defun notmuch-address-expand-name ()
+  (let* ((end (point))
+(beg (save-excursion
+   (re-search-backward \\(\\`\\|[\n:,]\\)[ \t]*)
+   (goto-char (match-end 0))
+   (point)))
+(orig (buffer-substring-no-properties beg end))
+(completion-ignore-case t)
+(options (notmuch-address-options orig))
+(chosen (if (eq (length options) 1)
+(car options)
+  (completing-read Address:  (cdr options) nil nil (car 
options)
+   'notmuch-address-history
+(when chosen
+  (push chosen notmuch-address-history)
+  (delete-region beg end)
+  (insert chosen
+
+;; Copied from `w3m-which-command'.
+(defun notmuch-address-locate-command (command)
+  Return non-nil if `command' is an executable either on
+`exec-path' or an absolute pathname.
+  (when (stringp command)
+(if (and (file-name-absolute-p command)
+(file-executable-p command))
+   command
+  (setq command (file-name-nondirectory command))
+  (catch 'found-command
+   (let (bin)
+ (dolist (dir exec-path)
+   (setq bin (expand-file-name command dir))
+   (when (or (and (file-executable-p bin)
+  (not (file-directory-p bin)))
+ (and (file-executable-p (setq bin (concat bin .exe)))
+  (not (file-directory-p bin
+ (throw 'found-command bin
+
+;; If we can find the program specified by `notmuch-address-command',
+;; insinuate ourselves into `message-mode'.
+(when (notmuch-address-locate-command notmuch-address-command)
+  (notmuch-address-message-insinuate))
+
+;;
+
+(provide 'notmuch-address)
-- 
1.7.0

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


[PATCH] emacs: Add more functions to clean up text/plain parts

2010-04-22 Thread David Edmondson
Add:
- notmuch-wash-wrap-long-lines: Wrap lines longer than the width of
  the current window whilst maintaining any citation prefix.
- notmuch-wash-tidy-citations: Tidy up citations by:
  - compress repeated otherwise blank citation lines,
  - remove otherwise blank citation lines at the head and tail of a
citation and remove blank lines between attribution statements and
the citation,
- notmuch-wash-compress-blanks: Compress repeated blank lines and
  remove leading and trailing blank lines.

Enable `notmuch-wash-tidy-citations' and
`notmuch-wash-compress-blanks' by default by adding them to
`notmuch-show-insert-text/plain-hook'. `notmuch-wash-wrap-long-lines'
is not enabled by default.

If `notmuch-wash-wrap-long-lines' is enabled, word wrapping of the
buffer leads to an unappealing display of text, so provide a function
to disable it and add it to the list of `notmuch-show-mode' hook
functions.
---

This is a small variant on the previous version of the patch. The
wrapping of long lines is not enabled by default - it's simply an
option in the customise interface.

 emacs/Makefile.local  |3 +-
 emacs/coolj.el|  145 +
 emacs/notmuch-show.el |   25 +++--
 emacs/notmuch-wash.el |   72 -
 4 files changed, 239 insertions(+), 6 deletions(-)
 create mode 100644 emacs/coolj.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 7537c3d..ce37ca2 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -9,7 +9,8 @@ emacs_sources := \
$(dir)/notmuch-wash.el \
$(dir)/notmuch-hello.el \
$(dir)/notmuch-mua.el \
-   $(dir)/notmuch-address.el
+   $(dir)/notmuch-address.el \
+   $(dir)/coolj.el
 
 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/coolj.el b/emacs/coolj.el
new file mode 100644
index 000..60af60a
--- /dev/null
+++ b/emacs/coolj.el
@@ -0,0 +1,145 @@
+;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
+
+;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+
+;; Authors:Kai Grossjohann kai.grossjoh...@cs.uni-dortmund.de
+;; Alex Schroeder a...@gnu.org
+;; Chong Yidong c...@stupidchicken.com
+;; Maintainer: David Edmondson d...@dme.org
+;; Keywords: convenience, wp
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;;; This is a simple derivative of some functionality from
+;;; `longlines.el'. The key difference is that this version will
+;;; insert a prefix at the head of each wrapped line. The prefix is
+;;; calculated from the originating long line.
+
+;;; No minor-mode is provided, the caller is expected to call
+;;; `coolj-wrap-region' to wrap the region of interest.
+
+;;; Code:
+
+(defgroup coolj nil
+  Wrapping of long lines with prefix.
+  :group 'fill)
+
+(defcustom coolj-wrap-follows-window-size t
+  Non-nil means wrap text to the window size.
+Otherwise respect `fill-column'.
+  :group 'coolj
+  :type 'boolean)
+
+(defcustom coolj-line-prefix-regexp ^\\(+ \\)*
+  Regular expression that matches line prefixes.
+  :group 'coolj
+  :type 'regexp)
+
+(defvar coolj-wrap-point nil)
+
+(make-variable-buffer-local 'coolj-wrap-point)
+
+(defun coolj-determine-prefix ()
+  Determine the prefix for the current line.
+  (save-excursion
+(beginning-of-line)
+(if (re-search-forward coolj-line-prefix-regexp nil t)
+   (buffer-substring (match-beginning 0) (match-end 0))
+  )))
+
+(defun coolj-wrap-buffer ()
+  Wrap the current buffer.
+  (coolj-wrap-region (point-min) (point-max)))
+
+(defun coolj-wrap-region (beg end)
+  Wrap each successive line, starting with the line before BEG.
+Stop when we reach lines after END that don't need wrapping, or the
+end of the buffer.
+  (setq fill-column (if coolj-wrap-follows-window-size
+   (window-width)
+ fill-column))
+  (let ((mod (buffer-modified-p)))
+(setq coolj-wrap-point (point))
+(goto-char beg)
+(forward-line -1)
+;; Two successful coolj-wrap-line's in a row mean successive
+;; lines don't need wrapping.
+(while (null (and (coolj-wrap-line)
+ (or (eobp)
+ (and (= (point) end)
+  (coolj-wrap-line

Re: pull request

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 04:58:16 -0400, Servilio Afre Puentes servi...@gmail.com 
wrote:
 On 21 April 2010 17:03, Carl Worth cwo...@cworth.org wrote:
  On Mon, 19 Apr 2010 09:27:39 +0100, David Edmondson d...@dme.org wrote:
 [...]
  Meanwhile, another issue with the result of this series is that I now
  seem to get rendering for both the text/plain and the text/html
  alternatives when a message has both. For now, the paragraphs are
  wrapped much more nicely in the rendering of the html portion, but links
  are apparently entirely missing. The link URLs at least appear in the
  text/plain rendering, (which is pretty ugly, but at least not impossible
  to use).
 
  If we could get one version or the other working completely, then it
  would be nice to display only one.
 
 I think that a better approach here would be to list them as parts if
 they are present, then have a [configurable] way to show only one by
 default, and the other would be available to show in-line.

Showing only one (with a variable allowing you to express preference) is
my intention. Any non-shown parts will appear as attachments - you can
save them using the button (and perhaps later view them).

This can make quite a big difference in a 200 message thread with lots
of 'text/plain or text/html ?' choices - using the text/plain part will
improve the performance of building the show buffer significantly.

 What I miss in this view sometimes is the possibility of being able to
 see the structure of the thread. A way to toggle the expanded state of
 the messages originally expanded when I first opened the view would do
 this very nicely.

Ah, so you want a go back to how it was initially command?

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


Re: problem with notmuch-search-authors-width in JSON emacs implementation

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 09:22:32 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
  Can you show any explicit settings you have for
  `notmuch-search-authors-width' and `notmuch-search-result-format'? Where
  do you set them?
 
 Changing notmuch-search-authors-width to anything longer than 20 (which
 is the default set internally) causes the problem (I had it set to 40
 when I first noticed).  It's very easy to test.  You can
 notmuch-search-authors-width on the fly from the configuration manager
 and see the result.  I have not modified notmuch-search-result-format.
 See my previous email on tracking down the issue.

Ah, when you set `notmuch-search-authors-width' the expression which
creates `notmuch-search-result-format' is not re-evaluated.

Do things get better if you restart emacs (sorry for suggesting that)?

If so then I have an idea how to fix it.

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


Re: problem with notmuch-search-authors-width in JSON emacs implementation

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 10:12:59 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
 On Thu, 22 Apr 2010 15:04:45 +0100, David Edmondson d...@dme.org wrote:
  Ah, when you set `notmuch-search-authors-width' the expression which
  creates `notmuch-search-result-format' is not re-evaluated.
  
  Do things get better if you restart emacs (sorry for suggesting that)?
 
 I can't see how that would help, because notmuch-search-result-format is
 always going to be evaluated with the default value of
 notmuch-search-authors-width, which is defined immediately previous to
 it.

The `defcustom' does nothing if the variable already has a value.

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


Re: pull request

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 10:10:15 -0400, Servilio Afre Puentes servi...@gmail.com 
wrote:
  Showing only one (with a variable allowing you to express preference) is
  my intention. Any non-shown parts will appear as attachments - you can
  save them using the button (and perhaps later view them).
 
 Why not see them in-line if possible?

This will probably come later, sure. At the moment the entire buffer is
built in one pass before you see it. If we want to support the insertion
of parts 'on demand' then a little more work is required.

  What I miss in this view sometimes is the possibility of being able to
  see the structure of the thread. A way to toggle the expanded state of
  the messages originally expanded when I first opened the view would do
  this very nicely.
 
  Ah, so you want a go back to how it was initially command?
 
 Yep, then bind it to a key that would alternate between collapsing all
 messages and expanding the ones that were originally expanded.

I'll give this some thought.

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


Re: problem with notmuch-search-authors-width in JSON emacs implementation

2010-04-22 Thread David Edmondson
On Thu, 22 Apr 2010 11:20:33 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
 On Thu, 22 Apr 2010 15:38:55 +0100, David Edmondson d...@dme.org wrote:
  The `defcustom' does nothing if the variable already has a value.
 
 But the defcustom is always going to be called before any customization
 value, since my personal customizations are always loaded last, so I'm
 don't see how this would ever apply.

I see. The original solution assumed that `notmuch.el' would be loaded
on demand rather than ahead of the call to `custom-set-variables'. I'll
find another solution.

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


[PATCH] emacs: Remove `notmuch-search-authors-width' and fix the use of `notmuch-search-result-format' accordingly

2010-04-23 Thread David Edmondson
The width of the authors field in search output was previously
specified in two places:
 - `notmuch-search-authors-width': the limit beyond which the authors
   names are truncated,
 - `notmuch-search-result-format': the layout of the search results.

Changing the configuration of one of these may have required the user
to know about and adapt the other accordingly. This led to confusion.

Instead, remove `notmuch-search-authors-width' and perform truncation
based on the relevant field in `notmuch-search-result-format'.
---

Jamie, could you test this patch please? My main concern is that it
makes a small assumption about the value of
`notmuch-search-result-format' - namely that the `authors' field ends
with a space.

 emacs/notmuch.el |   16 ++--
 1 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f96394a..d40c36e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -55,15 +55,10 @@
 (require 'notmuch-show)
 (require 'notmuch-mua)
 
-(defcustom notmuch-search-authors-width 20
-  Number of columns to use to display authors in a notmuch-search buffer.
-  :type 'integer
-  :group 'notmuch)
-
 (defcustom notmuch-search-result-format
   `((date . %s )
 (count . %-7s )
-(authors . ,(format %%-%ds  notmuch-search-authors-width))
+(authors . %-20s )
 (subject . %s )
 (tags . (%s)))
   Search result formating. Supported fields are:
@@ -585,7 +580,11 @@ matching will be applied.
((string-equal field count)
 (insert (format (cdr (assoc field notmuch-search-result-format)) count)))
((string-equal field authors)
-(insert (format (cdr (assoc field notmuch-search-result-format)) authors)))
+(insert (let ((sample (format (cdr (assoc field 
notmuch-search-result-format)) )))
+ (if ( (length authors)
+(length sample))
+ (concat (substring authors 0 (- (length sample) 4)) ... )
+   (format (cdr (assoc field notmuch-search-result-format)) 
authors)
((string-equal field subject)
 (insert (format (cdr (assoc field notmuch-search-result-format)) subject)))
((string-equal field tags)
@@ -614,12 +613,9 @@ matching will be applied.
   (date (match-string 2 string))
   (count (match-string 3 string))
   (authors (match-string 4 string))
-  (authors-length (length authors))
   (subject (match-string 5 string))
   (tags (match-string 6 string))
   (tag-list (if tags (save-match-data (split-string 
tags)
- (if ( authors-length notmuch-search-authors-width)
- (set 'authors (concat (substring authors 0 (- 
notmuch-search-authors-width 3)) ...)))
  (goto-char (point-max))
  (let ((beg (point-marker)))
(notmuch-search-show-result date count authors subject 
tags)
-- 
1.7.0

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


Re: pull request

2010-04-23 Thread David Edmondson
On Wed, 21 Apr 2010 15:47:12 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
 On Wed, 21 Apr 2010 12:15:48 -0700, Carl Worth cwo...@cworth.org wrote:
  [*] Even more simplification is possible if we stop trying to hide
  header components. Several people have requested that To and Cc be
  visible all the time.
 
 Hey, Carl.  I had actually been meaning to bring this up.  I actually
 don't like having the headers collapsed at all, so I am definitely in
 favor of the idea of doing away with this feature.  At the very least,
 I would like to see header hiding/collapsing be an option, so that I
 could turn it off.  As is, I'm having to hit 'h' for every message I
 view, so I can just see who the message was sent to (not to mention to
 recover the unfortunately missing blank line between the header and the
 body, which is visually useful).

See id:1272023661-14038-1-git-send-email-...@dme.org.

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


Re: [PATCH] emacs: Allow headers to be shown by default in show mode

2010-04-23 Thread David Edmondson
I like the current behaviour, but changing the default would be fine.

On Friday, April 23, 2010, Carl Worth cwo...@cworth.org wrote:
 On Fri, 23 Apr 2010 12:54:21 +0100, David Edmondson d...@dme.org wrote:
 Add `notmuch-show-headers-visible' which, when set `t', causes headers
 to be shown by default.

 A nice improvement, definitely. But I don't hear anyone actually wanting
 a configuration value here.

 Would anyone complain if I just made these all visible by default?

 Would anyone complain if I removed the code to allow for th hiding of
 the header?

 That's what I'm inclined to do.

 Let me know.

 -Carl

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


Re: [PATCH] emacs: Re-arrange message sending code

2010-04-24 Thread David Edmondson
On Fri, 23 Apr 2010 13:25:22 -0700, Carl Worth cwo...@cworth.org wrote:
 And I'm hoping that this new support makes it easier for people to hook
 in the Fcc code. Does this mean there's now a single place to add that
 that will make it work for messages composed from 'm', 'f', or 'r'?

Yes.

 The one unpleasantry I've noticed is that in the case of 'm' the headers
 are being put into the buffer in the following order:
 
   User-Agent:
   To:
   Subject:
   From:
 
 where I would prefer them in the following order:
 
   From:
   To:
   Subject:
   User-Agent:

I have:

(setq message-hidden-headers
  '(^References: ^Face: ^X-Face: ^X-Draft-From: ^User-Agent:))

so the User-Agent is not even visible.

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


Re: Wrapping up the 0.3 release

2010-04-24 Thread David Edmondson
On Sat, 24 Apr 2010 09:53:17 -0700, Dirk Hohndel hohn...@infradead.org wrote:
* Reply is now splitting the window
  
  We're copying the original message into the new reply buffer, so
  what's the advantage of splitting here?
 
 I'll voice my don't like of this feature as well, I guess.

This depends at least somewhat on the setting of `pop-up-windows'. Maybe
we should:

 (let ((pop-up-windows nil))
  ...)

in the reply code?

I think that notmuch window handling generally needs some consideration
and improvement.

  Finally, any of the tweaks I suggested to notmuch-hello mode would be
  quite welcome. I might take a whack at some of these.

Hopefully early next week for me.

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


[PATCH 1/3] emacs: Adapt the logo background colour to that of the frame

2010-04-26 Thread David Edmondson
The notmuch logo uses transparency. That can display poorly when
inserting the image into an emacs buffer (black logo on a black
background), so force the background colour of the image. We use a
face (`notmuch-hello-logo-background') to represent the colour so that
`defface' can be used to declare the different possible colours, which
depend on whether the frame has a light or dark background.
---
 emacs/notmuch-hello.el |   25 +
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 482ef68..3a74ebd 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -55,9 +55,14 @@
   :type 'boolean
   :group 'notmuch)
 
-(defcustom notmuch-hello-logo-background #5f5f5f
+(defface notmuch-hello-logo-background
+  'class color)
+  (background dark))
+ (:background #5f5f5f))
+(((class color)
+  (background light))
+ (:background white)))
   Background colour for the notmuch logo.
-  :type 'color
   :group 'notmuch)
 
 (defcustom notmuch-hello-jump-to-search t
@@ -209,12 +214,16 @@ diagonal.
 
   (when notmuch-hello-show-logo
 (let ((image notmuch-hello-logo))
-  ;; dme: Sorry, I don't know any other way to achieve this :-( The
-  ;; notmuch logo uses transparency. That works out badly when
-  ;; inserting the image into an emacs buffer, so force the
-  ;; background colour of the image.
-  (setq image (cons 'image (append (cdr image)
-  `(:background 
,notmuch-hello-logo-background
+  ;; The notmuch logo uses transparency. That can display poorly
+  ;; when inserting the image into an emacs buffer (black logo on
+  ;; a black background), so force the background colour of the
+  ;; image. We use a face to represent the colour so that
+  ;; `defface' can be used to declare the different possible
+  ;; colours, which depend on whether the frame has a light or
+  ;; dark background.
+  (setq image (cons 'image
+   (append (cdr image)
+   (list :background (face-background 
'notmuch-hello-logo-background)
   (insert-image image))
 (widget-insert   ))
 
-- 
1.7.0

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


[PATCH 3/3] emacs: Add a search to the 'recent searches' list once only

2010-04-26 Thread David Edmondson
Avoiding adding the same search string to the 'recent searches' list
more than once by testing whether the string was already used with
`member' rather than `memq'.
---
 emacs/notmuch-hello.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 52f162a..30b3a5e 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -77,7 +77,7 @@ field.
 (defvar notmuch-hello-recent-searches nil)
 
 (defun notmuch-hello-remember-search (search)
-  (if (not (memq search notmuch-hello-recent-searches))
+  (if (not (member search notmuch-hello-recent-searches))
   (push search notmuch-hello-recent-searches))
   (if ( (length notmuch-hello-recent-searches)
 notmuch-hello-recent-searches-max)
-- 
1.7.0

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


[PATCH 2/3] emacs: Remove the accelerator keys from the hello buffer

2010-04-26 Thread David Edmondson
Carl though that the recent search accelerator keys are not useful, so
remove them.
---
 emacs/notmuch-hello.el |   44 ++--
 1 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 3a74ebd..52f162a 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -266,20 +266,26 @@ diagonal.
   clear)
 (widget-insert \n\n)
 (let ((start (point))
- (key 0))
+ (nth 0))
   (mapc '(lambda (search)
-  (widget-insert (format %2d:  key))
-  (let ((widget-symbol (intern (format notmuch-hello-search-%d 
key
+  (let ((widget-symbol (intern (format notmuch-hello-search-%d 
nth
 (set widget-symbol
  (widget-create 'editable-field
-;; Leave some space at the start
-;; and end of the search boxes. 4
-;; for the accelerator key. 1 for
-;; the space before the `save'
-;; button. 6 for the `save'
-;; button.
-:size (max 8 (- (window-width) (* 2 
notmuch-hello-indent)
-4 1 6))
+;; Don't let the search boxes be
+;; less than 8 characters wide.
+:size (max 8
+   (- (window-width)
+  ;; Leave some space
+  ;; at the start and
+  ;; end of the
+  ;; boxes.
+  (* 2 notmuch-hello-indent)
+  ;; 1 for the space
+  ;; before the
+  ;; `[save]' button. 6
+  ;; for the `[save]'
+  ;; button.
+  1 6))
 :action (lambda (widget rest ignore)
   (notmuch-hello-search 
(widget-value widget)))
 search))
@@ -290,7 +296,7 @@ diagonal.
:notmuch-saved-search-widget widget-symbol
save))
   (widget-insert \n)
-  (setq key (1+ key)))
+  (setq nth (1+ nth)))
notmuch-hello-recent-searches)
   (indent-rigidly start (point) notmuch-hello-indent)))
 
@@ -329,12 +335,6 @@ diagonal.
 (widget-insert Type a search query and hit RET to view matching 
threads.\n)
 (when notmuch-hello-recent-searches
   (widget-insert Hit RET to re-submit a previous search. Edit it first if 
you like.\n)
-  (let ((searches (length notmuch-hello-recent-searches)))
-   (widget-insert
-(if (eq 1 searches)
-Key 0 acts as an accelerator for the previous query.\n
-  (format Keys 0-%d act as accelerators for the previous queries.\n
-  (- searches 1)
   (widget-insert Save recent searches with the `save' button.\n))
 (when notmuch-hello-saved-searches
   (widget-insert Edit saved searches with the `edit' button.\n))
@@ -351,14 +351,6 @@ diagonal.
   (local-set-key v '(lambda () (interactive)
(message notmuch version %s (notmuch-version
 
-  (loop for key from 0 to (- (length notmuch-hello-recent-searches) 1)
-   do (let ((widget-symbol (intern (format notmuch-hello-search-%d 
key
-(local-set-key (number-to-string key)
-   `(lambda ()
-  (interactive)
-  (notmuch-search (widget-value ,widget-symbol)
-  notmuch-search-oldest-first
-  nil nil 
#'notmuch-hello-search-continuation)
   (widget-setup)
 
   (if notmuch-hello-jump-to-search
-- 
1.7.0

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


Re: [PATCH] emacs: Add notmuch-hello.el, a friendly frontend to notmuch

2010-04-26 Thread David Edmondson
On Fri, 23 Apr 2010 13:13:01 -0700, Carl Worth cwo...@cworth.org wrote:
   * This should be integrated such that (require 'notmuch) provides the
 notmuch-hello functionality. That's our documented access point for
 getting at notmuch functionality.

I'll do this, but I wonder if it is actually good advice. It causes
notmuch.el (and anything that requires) to be loaded immediately. This
will typically happen before any of a users' customisation settings are
loaded (as `custom-set-variables', etc. generally happens right at the
bottom of .emacs).

A result of this is that notmuch can't use any of the customisation
settings to adapt its' behaviour at load time. A example is (about which
more lower down):

   * I would *love* a simple way to import my existing notmuch-folder
 configuration into notmuch-hello. Bonus points if this happens
 automatically.

notmuch-hello.el has:

(defcustom notmuch-hello-saved-searches notmuch-folders
  A list of saved searches to display.
  :type '(alist :key-type string :value-type string)
  :group 'notmuch)

So if `notmuch-folders' is set before notmuch-hello.el is loaded, you
get some saved-searches copied from your folders (but this won't
override any specific settings you made for
`notmuch-hello-saved-searches').

Relying on the order in general is bad
(cf. `notmuch-search-authors-width'), but it can allow us to provide
some useful functionality.

If we don't want users to (require 'notmuch) we'd probably have to
suggest one or more autoloads - perhaps even provide a file with a bunch
of autoloads in it. Oh, or (require 'notmuch) should just load
something that has the autoloads (d'oh!) and some
`define-mail-user-agent' goop so that `compose-mail' does the right
thing.

I'll try to produce a patch for this last thing.

   * The logo background is gray on my white-background emacs. That
 looks odd.

Patch sent.

   * It would be great if point were in the search bar right when this
 mode started.

This is customisable, and I see that you changed the default ;-)

   * I'd like the saved searches to appear before the recent searches I
 think.

Did you come to any conclusion about this?

   * I'm not sure how useful the numbered shortcuts are for the recent
 searches. We want to encourage people to move to saved searches
 instead, (and the recent searches are quite transient anyway). So do
 we really need these? [I mistook them for message counts at
 first.]

Patch sent which removes them.

   * Repeating a recent search by pressing RET on it creates a new
 identical search which doesn't seem all that useful.

Patch sent.

   * I would *love* a simple way to import my existing notmuch-folder
 configuration into notmuch-hello. Bonus points if this happens
 automatically.

We could have `notmuch-hello' use `notmuch-folders' if
`notmuch-hello-saved-searches' is `nil'. Would that help?

 Finally, I'm quite inclined to make `notmuch' invoke this mode, so
 think about that.

It seems straightforward, I'll produce a patch.

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


[PATCH] emacs: Correct message/header/citation/signature hiding

2010-04-26 Thread David Edmondson
Set `buffer-invisibility-spec' to `nil' (a list) if it is just `t'
before inserting any body parts, otherwise removing items from
`buffer-invisibility-spec' (which is what
`notmuch-show-headers-visible' and `notmuch-show-message-visible' do)
is a no-op and has no effect. This caused threads with only matching
messages to have those messages hidden initially because
`buffer-invisibility-spec' stayed `t'.
---

Carl, we need this fix before 0.3 is released. The bug has always
existed in the JSON based UI and is now exposed because previously
there was always a call to `add-to-invisibility-spec' (for the
headers), which transformed `buffer-invisiliblty-spec' from `t' to a
list. That doesn't always happen now (only calls to
`remove-from-invisibility-spec'), so the variable could get left as
`t'.

 emacs/notmuch-show.el |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f958a30..f9d6c93 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -382,6 +382,22 @@ current buffer, if possible.
(headers-invis-spec (notmuch-show-make-symbol header))
(message-invis-spec (notmuch-show-make-symbol message)))
 
+;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise
+;; removing items from `buffer-invisibility-spec' (which is what
+;; `notmuch-show-headers-visible' and
+;; `notmuch-show-message-visible' do) is a no-op and has no
+;; effect. This caused threads with only matching messages to have
+;; those messages hidden initially because
+;; `buffer-invisibility-spec' stayed `t'.
+;;
+;; This needs to be set here (rather than just above the call to
+;; `notmuch-show-headers-visible') because some of the part
+;; rendering or body washing functions
+;; (e.g. `notmuch-wash-text/plain-citations') manipulate
+;; `buffer-invisibility-spec').
+(when (eq buffer-invisibility-spec t)
+  (setq buffer-invisibility-spec nil))
+
 (setq message-start (point-marker))
 
 (notmuch-show-insert-headerline headers
-- 
1.7.0

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


Re: [PATCH] RFC: Add From guessing when forwarding email

2010-04-26 Thread David Edmondson
On Fri, 23 Apr 2010 15:52:15 -0700, Dirk Hohndel hohn...@infradead.org wrote:
 Given how little elisp I know I'm quite interested in feedback
 and better implementations

I think that:

(defun notmuch-show-forward-message ()
  Forward the current message.
  (interactive)
  (let ((user-mail-address
 (shell-command-to-string (concat notmuch-command
  guess-from
  (notmuch-show-get-message-id)
(with-current-notmuch-show-message
 (notmuch-mua-forward-message

is more idiomatic.

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


[PATCH] emacs: Automatically load notmuch-address

2010-04-26 Thread David Edmondson
notmuch-address.el tries to be careful to insinuate itself into
message mode only if it will do something useful, so it's safe to load
it all of the time.
---
 emacs/notmuch-mua.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index acb7dbf..305275e 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -23,6 +23,7 @@
 (require 'message)
 
 (require 'notmuch-lib)
+(require 'notmuch-address)
 
 ;;
 
-- 
1.7.0

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


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson
On Fri, 23 Apr 2010 17:49:38 -0700, Carl Worth cwo...@cworth.org wrote:
 I finally hit on doing (require 'notmuch-address) in .emacs. As noted
 previously, can we please make (require 'notmuch) pull in all notmuch
 functionality rather than having it separated like this?

Patch sent.

 Finally, though, I haven't figured out how to get more than a single
 match from this. If the first match isn't what I want, how do I see and
 choose later matches?

M-n to move forward in the list, M-p to move backwards (including into
any history you have accrued).

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


Re: [PATCH] emacs: Allow headers to be shown by default in show mode

2010-04-26 Thread David Edmondson
On Sat, 24 Apr 2010 05:42:54 -0700, Carl Worth cwo...@cworth.org wrote:
 On Fri, 23 Apr 2010 21:08:48 +0100, David Edmondson d...@dme.org wrote:
  I like the current behaviour, but changing the default would be fine.
 
 Which parts of it do you like? Being able to toggle the header back and
 forth? Or just that the hidden headers take up so little vertical
 space?

Both, particularly that the headers can be hidden by default. Mostly I
care about what you have to say and who you are, not who you said it to.

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


Re: [PATCH] notmuch.pod: pod version of documentation, converted by rman, massaged by hand.

2010-04-26 Thread David Edmondson
On Sat, 24 Apr 2010 11:04:49 -0300, David Bremner da...@tethera.net wrote:
 As I'm faced with writing docs for output selection, I'd like to revisit
 this idea. I didn't get any feedback, positive or negative about the
 idea of keeping the docs in pod.  I don't care much about the format,
 but I think it would be nice to avoid maintaining two copies of the
 documentation.
 
 Should I rebase/rebuild this against the current docs, or not bother?

I like the idea, but I have no experience with pod.

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


Re: Unhandled Xapian exception

2010-04-26 Thread David Edmondson
On Sat, 24 Apr 2010 07:38:03 -0700, Carl Worth cwo...@cworth.org wrote:
 Otherwise, we might want to start supporting more clever handling of the
 exception. For example, the high-level application might want to retry
 an operation if it fails due to a DatabaseModified exception.

This is what I would like to do (and thought that I was!) in notsync.

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


[PATCH] emacs: Suppress window creation when replying

2010-04-26 Thread David Edmondson
The buffer used to edit a reply should overlay the original
message. Encourage this by setting `same-window-regexps' locally.
---
 emacs/notmuch-mua.el |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 305275e..b69e31c 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -73,12 +73,16 @@
  (setq headers (mail-header-extract)
   (forward-line 1)
   (setq body (buffer-substring (point) (point-max
-(notmuch-mua-mail (mail-header 'to headers)
- (mail-header 'subject headers)
- (loop for header in headers
-   if (not (or (eq 'to (car header))
-   (eq 'subject (car header
-   collect header))
+(let
+   ;; Overlay the composition window on that being used to read
+   ;; the original message.
+   ((same-window-regexps '(\\*mail .*)))
+  (notmuch-mua-mail (mail-header 'to headers)
+   (mail-header 'subject headers)
+   (loop for header in headers
+ if (not (or (eq 'to (car header))
+ (eq 'subject (car header
+ collect header)))
 (message-sort-headers)
 (message-hide-headers)
 (save-excursion
-- 
1.7.0

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


[PATCH] emacs: Sort headers when composing

2010-04-26 Thread David Edmondson
Always sort the headers in the message composition window.
---
 emacs/notmuch-mua.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index b69e31c..004b50a 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -112,6 +112,7 @@
 
   (message-mail to subject other-headers continue
switch-function yank-action send-actions)
+  (message-sort-headers)
   (message-hide-headers))
 
 (defun notmuch-mua-send-and-exit (optional arg)
-- 
1.7.0

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


Re: Wrapping up the 0.3 release

2010-04-26 Thread David Edmondson
On Sat, 24 Apr 2010 08:37:11 -0700, Carl Worth cwo...@cworth.org wrote:
 Meanwhile, I'm aware of two regressions I'd like to see fixed before
 0.3:
 
   * Reply is now splitting the window
 
 We're copying the original message into the new reply buffer, so
 what's the advantage of splitting here?

Patch sent.

   * Composing a new message with 'm' brings up headers in a scrambled
 order.
 
 A minor point, but it would be nice to fix this.

Patch sent.

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


[PATCH] emacs: Hide the User-Agent: when composing messages

2010-04-26 Thread David Edmondson
Add a list of headers to those hidden by `message-mode' when
composing. By default the list includes only User-Agent:.
---
 emacs/notmuch-mua.el |   17 +
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 004b50a..bca20db 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -41,6 +41,12 @@
 notmuch-mua-user-agent-notmuch
 notmuch-mua-user-agent-emacs))
 
+(defcustom notmuch-mua-hidden-headers '(^User-Agent:)
+  Headers that are added to the `message-mode' hidden headers
+list.
+  :group 'notmuch
+  :type '(repeat string))
+
 ;;
 
 (defun notmuch-mua-user-agent-full ()
@@ -57,6 +63,13 @@
   Generate a `User-Agent:' string suitable for notmuch.
   (concat Emacs/ emacs-version  ( system-configuration )))
 
+(defun notmuch-mua-add-more-hidden-headers ()
+  Add some headers to the list that are hidden by default.
+  (mapc (lambda (header)
+ (when (not (member header 'message-hidden-headers))
+   (push header message-hidden-headers)))
+   notmuch-mua-hidden-headers))
+
 (defun notmuch-mua-reply (query-string)
   (let (headers body)
 ;; This make assumptions about the output of `notmuch reply', but
@@ -134,6 +147,10 @@ simply runs the corresponding `message-mode' hook 
functions.
   'notmuch-mua-mail 'notmuch-mua-send-and-exit
   'notmuch-mua-kill-buffer 'notmuch-mua-send-hook)
 
+;; Add some more headers to the list that `message-mode' hides when
+;; composing a message.
+(notmuch-mua-add-more-hidden-headers)
+
 ;;
 
 (provide 'notmuch-mua)
-- 
1.7.0

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


[PATCH] emacs: Add more functions to clean up text/plain parts

2010-04-26 Thread David Edmondson
Add:
- notmuch-wash-wrap-long-lines: Wrap lines longer than the width of
  the current window whilst maintaining any citation prefix.
- notmuch-wash-tidy-citations: Tidy up citations by:
  - compress repeated otherwise blank citation lines,
  - remove otherwise blank citation lines at the head and tail of a
citation,
- notmuch-wash-elide-blank-lines: Compress repeated blank lines and
  remove leading and trailing blank lines.

None of these is enabled by default - add them to
`notmuch-show-insert-text/plain-hook' to use.
---

Another attempt :-)

- Functions renamed to be clearer about what they do,
- Function documentation both more concise (for display in customisation
  buffers) and more complete,
- Interaction of long line wrapping and `word-wrap' improved,
- Push `notmuch-show-pretty-hook' functions that everyone will use
  directly into the code, thus avoiding the naming dilemma.

 emacs/Makefile.local  |3 +-
 emacs/coolj.el|  145 +
 emacs/notmuch-show.el |   28 +++---
 emacs/notmuch-wash.el |   84 -
 4 files changed, 248 insertions(+), 12 deletions(-)
 create mode 100644 emacs/coolj.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 7537c3d..ce37ca2 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -9,7 +9,8 @@ emacs_sources := \
$(dir)/notmuch-wash.el \
$(dir)/notmuch-hello.el \
$(dir)/notmuch-mua.el \
-   $(dir)/notmuch-address.el
+   $(dir)/notmuch-address.el \
+   $(dir)/coolj.el
 
 emacs_images := \
$(dir)/notmuch-logo.png
diff --git a/emacs/coolj.el b/emacs/coolj.el
new file mode 100644
index 000..60af60a
--- /dev/null
+++ b/emacs/coolj.el
@@ -0,0 +1,145 @@
+;;; coolj.el --- automatically wrap long lines  -*- coding:utf-8 -*-
+
+;; Copyright (C) 2000, 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software 
Foundation, Inc.
+
+;; Authors:Kai Grossjohann kai.grossjoh...@cs.uni-dortmund.de
+;; Alex Schroeder a...@gnu.org
+;; Chong Yidong c...@stupidchicken.com
+;; Maintainer: David Edmondson d...@dme.org
+;; Keywords: convenience, wp
+
+;; This file is not part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see http://www.gnu.org/licenses/.
+
+;;; Commentary:
+
+;;; This is a simple derivative of some functionality from
+;;; `longlines.el'. The key difference is that this version will
+;;; insert a prefix at the head of each wrapped line. The prefix is
+;;; calculated from the originating long line.
+
+;;; No minor-mode is provided, the caller is expected to call
+;;; `coolj-wrap-region' to wrap the region of interest.
+
+;;; Code:
+
+(defgroup coolj nil
+  Wrapping of long lines with prefix.
+  :group 'fill)
+
+(defcustom coolj-wrap-follows-window-size t
+  Non-nil means wrap text to the window size.
+Otherwise respect `fill-column'.
+  :group 'coolj
+  :type 'boolean)
+
+(defcustom coolj-line-prefix-regexp ^\\(+ \\)*
+  Regular expression that matches line prefixes.
+  :group 'coolj
+  :type 'regexp)
+
+(defvar coolj-wrap-point nil)
+
+(make-variable-buffer-local 'coolj-wrap-point)
+
+(defun coolj-determine-prefix ()
+  Determine the prefix for the current line.
+  (save-excursion
+(beginning-of-line)
+(if (re-search-forward coolj-line-prefix-regexp nil t)
+   (buffer-substring (match-beginning 0) (match-end 0))
+  )))
+
+(defun coolj-wrap-buffer ()
+  Wrap the current buffer.
+  (coolj-wrap-region (point-min) (point-max)))
+
+(defun coolj-wrap-region (beg end)
+  Wrap each successive line, starting with the line before BEG.
+Stop when we reach lines after END that don't need wrapping, or the
+end of the buffer.
+  (setq fill-column (if coolj-wrap-follows-window-size
+   (window-width)
+ fill-column))
+  (let ((mod (buffer-modified-p)))
+(setq coolj-wrap-point (point))
+(goto-char beg)
+(forward-line -1)
+;; Two successful coolj-wrap-line's in a row mean successive
+;; lines don't need wrapping.
+(while (null (and (coolj-wrap-line)
+ (or (eobp)
+ (and (= (point) end)
+  (coolj-wrap-line))
+(goto-char coolj-wrap-point)
+(set-buffer-modified-p mod)))
+
+(defun coolj-wrap-line ()
+  If the current line needs to be wrapped, wrap it and return nil.
+If wrapping

[PATCH] emacs: More DWIM when editing messages

2010-04-26 Thread David Edmondson
For composing new messages and forwarding, leave the cursor on the
'To:' field. For replies, leave the cursor at the start of the
body. In all cases, mark the buffer as not modified so that the user
is not prompted if she decides to immediately kill the buffer.
---
 emacs/notmuch-mua.el |   32 +++-
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index bca20db..c7a9aee 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -98,21 +98,24 @@ list.
  collect header)))
 (message-sort-headers)
 (message-hide-headers)
-(save-excursion
-  (goto-char (point-max))
-  (insert body))
-(set-buffer-modified-p nil)))
+(goto-char (point-max))
+(insert body))
+(set-buffer-modified-p nil)
+
+(message-goto-body))
 
 (defun notmuch-mua-forward-message ()
   (message-forward)
-  (save-excursion
-(when notmuch-mua-user-agent-function
-  (let ((user-agent (funcall notmuch-mua-user-agent-function)))
-   (when (not (string=  user-agent))
- (message-add-header (format User-Agent: %s user-agent)
-(message-sort-headers)
-(message-hide-headers))
-  (set-buffer-modified-p nil))
+
+  (when notmuch-mua-user-agent-function
+(let ((user-agent (funcall notmuch-mua-user-agent-function)))
+  (when (not (string=  user-agent))
+   (message-add-header (format User-Agent: %s user-agent)
+  (message-sort-headers)
+  (message-hide-headers)
+  (set-buffer-modified-p nil)
+
+  (message-goto-to))
 
 (defun notmuch-mua-mail (optional to subject other-headers continue
   switch-function yank-action send-actions)
@@ -126,7 +129,10 @@ list.
   (message-mail to subject other-headers continue
switch-function yank-action send-actions)
   (message-sort-headers)
-  (message-hide-headers))
+  (message-hide-headers)
+  (set-buffer-modified-p nil)
+
+  (message-goto-to))
 
 (defun notmuch-mua-send-and-exit (optional arg)
   (interactive P)
-- 
1.7.0

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


Re: Kudos! Also: +1 PGP!

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 15:52:37 +0200, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 We were discussing on IRC whether decryption should be handled in
 notmuch show --decrypt or in emacs and I had a quick look at what it
 would take for emacs. Here is a snippet of code that outputs
 Good signature from 5585F58CC827A062 Sebastian Spaeth (Private
 Communication) sebast...@sspaeth.de (trust ultimate) created at
 2010-04-26T14:27:07+0200 using DSA in the minibuffer. I guess something
 based on this could be used to parse the email and try to decrypt via gpg
 and mark the signature status in the summary line:

Inline PGP could be handled by the text/plain washing functions. I had a
quick go at this and bremner tested, but there were some wrinkles and I
didn't finish it.

multipart/signed really needs the re-worked JSON output so that the UI
can know what is going on. It might be possible to kludge something
together with the current output, but it will be awkward.

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


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


Re: [SCM] notmuch - thread-based email index, search and tagging. branch, master, updated. 0.2-191-g38c35f8

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 07:17:47 -0700 (PDT), 
notmuch-commits-sen...@notmuchmail.org (Carl Worth) wrote:
 commit 97570954cb583cacac35b0235cbe449a07630ae3
 Author: David Edmondson d...@dme.org
 Date:   Thu Apr 22 13:26:06 2010 +0100
 
 emacs: Add more functions to clean up text/plain parts
 
 Add:
 - notmuch-wash-wrap-long-lines: Wrap lines longer than the width of
   the current window whilst maintaining any citation prefix.
 - notmuch-wash-tidy-citations: Tidy up citations by:
   - compress repeated otherwise blank citation lines,
   - remove otherwise blank citation lines at the head and tail of a
 citation and remove blank lines between attribution statements and
 the citation,
 - notmuch-wash-compress-blanks: Compress repeated blank lines and
   remove leading and trailing blank lines.
 
 Enable `notmuch-wash-tidy-citations' and
 `notmuch-wash-compress-blanks' by default by adding them to
 `notmuch-show-insert-text/plain-hook'. `notmuch-wash-wrap-long-lines'
 is not enabled by default.
 
 If `notmuch-wash-wrap-long-lines' is enabled, word wrapping of the
 buffer leads to an unappealing display of text, so provide a function
 to disable it and add it to the list of `notmuch-show-mode' hook
 functions.

This looks as though you took the earlier patch rather than one that I
sent today (id:1272289530-12593-1-git-send-email-...@dme.org is the most
recent).

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


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


Re: [PATCH] emacs: Add notmuch-address.el for address completion using notmuch

2010-04-26 Thread David Edmondson

   To: David Edmondson d...@dme.org, notmuch@notmuchmail.org, 
d...@yoom.home.cworth.org
   Cc: c...@ut.hh.sledj.net
   Date: Mon, 26 Apr 2010 08:21:51 -0700

Something interesting is happening here :-)

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


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


Re: [PATCH] emacs: `notmuch' should display the `notmuch-hello' interface

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 09:11:07 -0700, Dirk Hohndel hohn...@infradead.org wrote:
 This is lacking a committ message...

I wasn't sure what else to say.

 On Mon, 26 Apr 2010 16:07:04 +0100, d...@dme.org wrote:
  From: David Edmondson d...@dme.org
  --- a/emacs/notmuch-lib.el
  +++ b/emacs/notmuch-lib.el
  @@ -33,6 +33,11 @@
 :type '(alist :key-type (string) :value-type (string))
 :group 'notmuch)
   
  +(defcustom notmuch-search-oldest-first t
  +  Show the oldest mail first when searching.
  +  :type 'boolean
  +  :group 'notmuch)
  +
 
 And this doesn't seem related to the subject...
 
  @@ -221,8 +222,6 @@ For a mouse binding, return nil.
   (defvar notmuch-search-query-string)
   (defvar notmuch-search-target-thread)
   (defvar notmuch-search-target-line)
  -(defvar notmuch-search-oldest-first t
  -  Show the oldest mail first in the search-mode)
   (defvar notmuch-search-continuation)
   
   (defvar notmuch-search-disjunctive-regexp  \\[oO][rR]\\)
 
 ditto...

They are both due to re-arranging the relationship between notmuch.el
and notmuch-hello.el.

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


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


Re: Kudos! Also: +1 PGP!

2010-04-26 Thread David Edmondson
On Mon, 26 Apr 2010 12:19:26 -0400, Jameson Rollins 
jroll...@finestructure.net wrote:
 On Mon, 26 Apr 2010 17:11:33 +0100, David Edmondson d...@dme.org wrote:
  multipart/signed really needs the re-worked JSON output so that the UI
  can know what is going on. It might be possible to kludge something
  together with the current output, but it will be awkward.
 
 Actually the emacs UI is current using the JSON output, since the
 bremner's reworking got merged a couple weeks ago.

Unfortunately we still need more. notmuch doesn't include the details of
how parts are related in a multipart/* message.

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


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


[PATCH] emacs: Usability improvements for `notmuch-hello'.

2010-04-28 Thread David Edmondson
- If no saved searches exist or are displayed, don't signal an error,
- If no saved searches exist or are displayed, leave the cursor in the
  search bar,
- Minor layout improvements.
---
 emacs/notmuch-hello.el |   36 +++-
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 6a1c56e..1358387 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -273,7 +273,7 @@ diagonal.
   (notmuch-hello-update))
 :help-echo Refresh
 (car (process-lines notmuch-command count)))
-  (widget-insert  messages (that's not much mail).\n\n))
+  (widget-insert  messages (that's not much mail).\n))
 
 (let ((found-target-pos nil)
  (final-target-pos nil))
@@ -292,7 +292,7 @@ diagonal.
 (widest (max saved-widest alltags-widest)))
 
(when saved-alist
- (widget-insert Saved searches: )
+ (widget-insert \nSaved searches: )
  (widget-create 'push-button
 :notify (lambda (rest ignore)
   (customize-variable 'notmuch-saved-searches))
@@ -305,18 +305,16 @@ diagonal.
(setq final-target-pos found-target-pos))
(indent-rigidly start (point) notmuch-hello-indent)))
 
-   (let ((start (point)))
- (widget-insert \nSearch: )
- (setq notmuch-hello-search-bar-marker (point-marker))
- (widget-create 'editable-field
-;; Leave some space at the start and end of the
-;; search boxes.
-:size (max 8 (- (window-width) (* 2 
notmuch-hello-indent)
-(length Search: )))
-:action (lambda (widget rest ignore)
-  (notmuch-hello-search (widget-value 
widget
- (widget-insert \n)
- (indent-rigidly start (point) notmuch-hello-indent))
+   (widget-insert \nSearch: )
+   (setq notmuch-hello-search-bar-marker (point-marker))
+   (widget-create 'editable-field
+  ;; Leave some space at the start and end of the
+  ;; search boxes.
+  :size (max 8 (- (window-width) notmuch-hello-indent
+  (length Search: )))
+  :action (lambda (widget rest ignore)
+(notmuch-hello-search (widget-value widget
+   (widget-insert \n)
 
(when notmuch-hello-recent-searches
  (widget-insert \nRecent searches: )
@@ -408,9 +406,13 @@ diagonal.
 
   (widget-setup)
 
-  (goto-char final-target-pos)
-  (if (not (widget-at))
- (widget-forward 1)
+  (when final-target-pos
+   (goto-char final-target-pos)
+   (unless (widget-at)
+ (widget-forward 1)))
+
+  (unless (widget-at)
+   (notmuch-hello-goto-search)
 
 ;;;###autoload
 (defun notmuch-folder ()
-- 
1.7.0

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


Re: [PATCH] emacs: Display non-matching authors in italic.

2010-04-28 Thread David Edmondson
On Wed, 28 Apr 2010 11:55:06 -0700, Dirk Hohndel hohn...@infradead.org wrote:
 I'm not a fan of it either (and I implemented this feature). Yet it was
 the only character that I could think of that somehow create the visual
 separation and that is rare in Author Names and at the same time not
 already used (like ';') in notmuch output

We could change that - replace ; with | as the separator in the output
(and vice-versa).

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


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


[PATCH 2/2] emacs: Set the `face' property rather than `font-lock-face'.

2010-04-29 Thread David Edmondson
Avoid using face properties reserved for the font-lock package.
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 60c0ee5..d36a92d 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -438,7 +438,7 @@ and will also appear in a buffer named \*Notmuch 
errors*\.
   (let ((end (point)))
(delete-region beg end)
(insert (propertize (mapconcat  'identity tags  )
-   'font-lock-face 'notmuch-tag-face))
+   'face 'notmuch-tag-face))
 
 (defun notmuch-search-get-tags ()
   (save-excursion
-- 
1.7.0

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


[PATCH] emacs: Allow control over faces for search mode columns.

2010-04-29 Thread David Edmondson
Add face declarations for the date, count, matching author and subject
columns in search mode and apply those faces when building the search
mode display.
---

This is intended to support 'fruit salad' mode: 
   http://dme.org/images/2010-04-29-081213_1590x1197_scrot.png

 emacs/notmuch.el |   59 +++--
 1 files changed, 43 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index d36a92d..7c9c028 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -285,27 +285,48 @@ For a mouse binding, return nil.
  Face for the single-line message summary in notmuch-show-mode.
  :group 'notmuch)
 
-(defface notmuch-tag-face
+(defface notmuch-search-date
+  '((t :inherit default))
+  Face used in search mode for dates.
+  :group 'notmuch)
+
+(defface notmuch-search-count
+  '((t :inherit default))
+  Face used in search mode for the count matching the query.
+  :group 'notmuch)
+
+(defface notmuch-search-subject
+  '((t :inherit default))
+  Face used in search mode for subjects.
+  :group 'notmuch)
+
+(defface notmuch-search-matching-authors
+  '((t :inherit default))
+  Face used in search mode for authors matching the query.
+  :group 'notmuch)
+
+(defface notmuch-search-non-matching-authors
   'class color)
   (background dark))
- (:foreground OliveDrab1))
+ (:foreground grey30))
 (((class color)
   (background light))
- (:foreground navy blue :bold t))
+ (:foreground grey60))
 (t
- (:bold t)))
-  Notmuch search mode face used to highligh tags.
+ (:italic t)))
+  Face used in search mode for authors not matching the query.
   :group 'notmuch)
 
-(defface notmuch-search-non-matching-authors
+(defface notmuch-tag-face
   'class color)
   (background dark))
- (:foreground grey30))
+ (:foreground OliveDrab1))
 (((class color)
   (background light))
- (:foreground grey60))
-(t (:italic t)))
-  Face used in search mode for authors not matching the query.
+ (:foreground navy blue :bold t))
+(t
+ (:bold t)))
+  Face used in search mode face for tags.
   :group 'notmuch)
 
 ;;;###autoload
@@ -599,21 +620,27 @@ matching will be applied.
;; `notmuch-search-process-filter'.
(save-match-data
  (if (string-match \\(.*\\)|\\(..*\\) truncated-string)
- (concat (match-string 1 truncated-string) ,
+ (concat (propertize (concat (match-string 1 truncated-string) 
,)
+ 'face 'notmuch-search-matching-authors)
  (propertize (match-string 2 truncated-string)
  'face 
'notmuch-search-non-matching-authors))
-   truncated-string)
+   (propertize truncated-string 'face 
'notmuch-search-matching-authors))
 
 (defun notmuch-search-insert-field (field date count authors subject tags)
   (cond
((string-equal field date)
-(insert (format (cdr (assoc field notmuch-search-result-format)) date)))
+(insert (propertize (format (cdr (assoc field 
notmuch-search-result-format)) date)
+   'face 'notmuch-search-date)))
((string-equal field count)
-(insert (format (cdr (assoc field notmuch-search-result-format)) count)))
+(insert (propertize (format (cdr (assoc field 
notmuch-search-result-format)) count)
+   'face 'notmuch-search-count)))
+   ((string-equal field subject)
+(insert (propertize (format (cdr (assoc field 
notmuch-search-result-format)) subject)
+   'face 'notmuch-search-subject)))
+
((string-equal field authors)
 (notmuch-search-insert-authors (cdr (assoc field 
notmuch-search-result-format)) authors))
-   ((string-equal field subject)
-(insert (format (cdr (assoc field notmuch-search-result-format)) subject)))
+
((string-equal field tags)
 (insert (concat ( (propertize tags 'font-lock-face 'notmuch-tag-face) 
))
 
-- 
1.7.0

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


[PATCH] emacs: Allow tuning of the tag/saved search layout.

2010-04-29 Thread David Edmondson
Add `notmuch-column-control', which has three potential sets of
values:

- t: automatically calculate the number of columns per line based on
  the tags to be shown and the window width,
- an integer: a lower bound on the number of characters that will be
  used to display each column,
- a float: a fraction of the window width that is the lower bound on
  the number of characters that should be used for each column.

So:
- if you would like two columns of tags, set this to 0.5.
- if you would like a single column of tags, set this to 1.0.
- if you would like tags to be 30 characters wide, set this to
  30.
- if you don't want to worry about all of this nonsense, leave
  this set to `t'.
---

`notmuch-hello-tag-width' is now `notmuch-column-control', given that
your proposed first sentence is a better explanation of the purpose.

 emacs/notmuch-hello.el |   63 +++
 1 files changed, 57 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 1358387..acf40bc 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -65,6 +65,32 @@
   Background colour for the notmuch logo.
   :group 'notmuch)
 
+(defcustom notmuch-column-control t
+  Controls the number of columns for saved searches/tags in notmuch view.
+
+This variable has three potential sets of values:
+
+- t: automatically calculate the number of columns possible based
+  on the tags to be shown and the window width,
+- an integer: a lower bound on the number of characters that will
+  be used to display each column,
+- a float: a fraction of the window width that is the lower bound
+  on the number of characters that should be used for each
+  column.
+
+So:
+- if you would like two columns of tags, set this to 0.5.
+- if you would like a single column of tags, set this to 1.0.
+- if you would like tags to be 30 characters wide, set this to
+  30.
+- if you don't want to worry about all of this nonsense, leave
+  this set to `t'.
+  :group 'notmuch
+  :type '(choice
+ (const :tag Automatically calculated t)
+ (integer :tag Number of characters)
+ (float :tag Fraction of window)))
+
 (defvar notmuch-hello-url http://notmuchmail.org;
   The `notmuch' web site.)
 
@@ -146,13 +172,38 @@ diagonal.
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command count search)))
 
+(defun notmuch-hello-tags-per-line (widest)
+  Determine how many tags to show per line and how wide they
+should be. Returns a cons cell `(tags-per-line width)'.
+  (let ((tags-per-line
+(cond
+ ((integerp notmuch-column-control)
+  (max 1
+   (/ (- (window-width) notmuch-hello-indent)
+  ;; Count is 7 wide (6 digits plus space), 1 for the space
+  ;; after the name.
+  (+ 7 1 (max notmuch-column-control widest)
+
+ ((floatp notmuch-column-control)
+  (let* ((available-width (- (window-width) notmuch-hello-indent))
+ (proposed-width (max (* available-width 
notmuch-column-control) widest)))
+(floor available-width proposed-width)))
+
+ (t
+  (max 1
+   (/ (- (window-width) notmuch-hello-indent)
+  ;; Count is 7 wide (6 digits plus space), 1 for the space
+  ;; after the name.
+  (+ 7 1 widest)))
+
+(cons tags-per-line (/ (- (window-width) notmuch-hello-indent
+ (* tags-per-line (+ 7 1)))
+  tags-per-line
+
 (defun notmuch-hello-insert-tags (tag-alist widest target)
-  (let* ((tags-per-line (max 1
-(/ (- (window-width) notmuch-hello-indent)
-   ;; Count is 7 wide (6 digits plus
-   ;; space), 1 for the space after the
-   ;; name.
-   (+ 7 1 widest
+  (let* ((tags-and-width (notmuch-hello-tags-per-line widest))
+(tags-per-line (car tags-and-width))
+(widest (cdr tags-and-width))
 (count 0)
 (reordered-list (notmuch-hello-reflect tag-alist tags-per-line))
 ;; Hack the display of the buttons used.
-- 
1.7.0

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


Re: all authors and subjects in the search buffer [was: Re: [PATCH] emacs: Fix i-search to open up invisible citations as necessary]

2010-05-04 Thread David Edmondson
On Mon, 03 May 2010 13:27:35 -0700, Carl Worth cwo...@cworth.org wrote:
 On Fri, 30 Apr 2010 17:00:08 +0100, David Edmondson d...@dme.org wrote:
  All of the authors appear in the output already, but that doesn't seem
  to be the case of the subjects. Would you envisage doing something
  similar to the changes Dirk made for authors?
 
 Right. We do have a similar approach already for picking out the first
 matching subject. So it would be an easy extension to have it print a
 sorted list of all the subjects.
 
 But let's start by making the emacs interface allow for searching of the
 authors. Then we can think about whether it makes sense to list all the
 subjects as well.

Patch sent to allow searching of the hidden authors.

Given that the tags are displayed after the subject, I suspect that we
would choose to hide _all_ of the 'non-matching' subject(s), displaying
it only as necessary during isearch.

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


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


[PATCH] emacs: Pretty print the numbers of matching messages.

2010-05-04 Thread David Edmondson
Insert a separator every three digits when outputting numbers. Allow
the user to choose the separator by customizing
`notmuch-decimal-separator'. Widen the space allocated for message
counts accordingly.
---
 emacs/notmuch-hello.el |   38 +++---
 1 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index bf49bb1..a6e8a47 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -91,6 +91,13 @@ So:
  (integer :tag Number of characters)
  (float :tag Fraction of window)))
 
+(defcustom notmuch-decimal-separator ,
+  The string used as a decimal separator.
+
+Typically \,\ in the US and UK and \.\ in Europe.
+  :group 'notmuch
+  :type 'string)
+
 (defvar notmuch-hello-url http://notmuchmail.org;
   The `notmuch' web site.)
 
@@ -103,6 +110,17 @@ So:
 notmuch-recent-searches-max)
   (setq notmuch-hello-recent-searches (butlast 
notmuch-hello-recent-searches
 
+(defun notmuch-hello-nice-number (n)
+  (let (result)
+(while ( n 0)
+  (push (% n 1000) result)
+  (setq n (/ n 1000)))
+(apply #'concat
+ (number-to-string (car result))
+ (mapcar (lambda (elem)
+ (format %s%03d notmuch-decimal-separator elem))
+(cdr result)
+
 (defun notmuch-hello-trim (search)
   Trim whitespace.
   (if (string-match ^[[:space:]]*\\(.*[^[:space:]]\\)[[:space:]]*$ search)
@@ -180,9 +198,9 @@ should be. Returns a cons cell `(tags-per-line width)'.
  ((integerp notmuch-column-control)
   (max 1
(/ (- (window-width) notmuch-hello-indent)
-  ;; Count is 7 wide (6 digits plus space), 1 for the space
+  ;; Count is 9 wide (8 digits plus space), 1 for the space
   ;; after the name.
-  (+ 7 1 (max notmuch-column-control widest)
+  (+ 9 1 (max notmuch-column-control widest)
 
  ((floatp notmuch-column-control)
   (let* ((available-width (- (window-width) notmuch-hello-indent))
@@ -192,12 +210,15 @@ should be. Returns a cons cell `(tags-per-line width)'.
  (t
   (max 1
(/ (- (window-width) notmuch-hello-indent)
-  ;; Count is 7 wide (6 digits plus space), 1 for the space
+  ;; Count is 9 wide (8 digits plus space), 1 for the space
   ;; after the name.
-  (+ 7 1 widest)))
+  (+ 9 1 widest)))
 
 (cons tags-per-line (/ (- (window-width) notmuch-hello-indent
- (* tags-per-line (+ 7 1)))
+ ;; Count is 9 wide (8 digits plus
+ ;; space), 1 for the space after the
+ ;; name.
+ (* tags-per-line (+ 9 1)))
   tags-per-line
 
 (defun notmuch-hello-insert-tags (tag-alist widest target)
@@ -218,7 +239,9 @@ should be. Returns a cons cell `(tags-per-line width)'.
  (let* ((name (car elem))
 (query (cdr elem))
 (formatted-name (format %s  name)))
-   (widget-insert (format %6s  (notmuch-saved-search-count 
query)))
+   (widget-insert (format %8s 
+  (notmuch-hello-nice-number
+   (string-to-number 
(notmuch-saved-search-count query)
(if (string= formatted-name target)
(setq found-target-pos (point-marker)))
(widget-create 'push-button
@@ -323,7 +346,8 @@ should be. Returns a cons cell `(tags-per-line width)'.
 :notify (lambda (rest ignore)
   (notmuch-hello-update))
 :help-echo Refresh
-(car (process-lines notmuch-command count)))
+(notmuch-hello-nice-number
+ (string-to-number (car (process-lines notmuch-command 
count)
   (widget-insert  messages (that's not much mail).\n))
 
 (let ((found-target-pos nil)
-- 
1.7.0

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


Re: [PATCH] emacs: More functionality for `notmuch-wash-tidy-citations'.

2010-05-04 Thread David Edmondson
On Tue,  4 May 2010 14:45:14 +0100, David Edmondson d...@dme.org wrote:
 Add:
 - Insert a blank line before a citation if there isn't one,
 - Insert a blank line after a citation if there isn't one.

Don't use this, it matches too often.

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


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


[PATCH] emacs: More functionality for `notmuch-wash-tidy-citations'.

2010-05-04 Thread David Edmondson
Add:
- Insert a blank line before a citation if there isn't one,
- Insert a blank line after a citation if there isn't one.
---

Better than the last version.

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

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 46e1824..26a3f88 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -214,7 +214,17 @@ Perform four transformations on the message body:
   ;; text.
   (goto-char (point-min))
   (while (re-search-forward \\(^[ ]*\n\\)\\(^$\\|^[^].*\\) nil t)
-(replace-match \\2)))
+(replace-match \\2))
+
+  ;; Insert a blank line before a citation if there isn't one.
+  (goto-char (point-min))
+  (while (re-search-forward \\(^[^]+\\)\n nil t)
+(replace-match \\1\n\n))
+
+  ;; Insert a blank line after a citation if there isn't one.
+  (goto-char (point-min))
+  (while (re-search-forward \\(^.+\\)\n\\([^]\\) nil t)
+(replace-match \\1\n\n\\2)))
 
 ;;
 
-- 
1.7.0

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


rfc: improved MIME handling (multipart)

2010-05-10 Thread David Edmondson
A (third) attempt at improved MIME handling, specifically for multipart,
is at:
   http://github.com/dme/notmuch/tree/mp3
   git://github.com/dme/notmuch.git (branch 'mp3')

I wouldn't describe this as finished, but it's usable for my own
day-to-day work, so I'd like to see if some others could try it out and
provide feedback. Particularly interesting would be to know about
messages where it behaves badly.

The JSON format output from `notmuch show' is where most of the change
is apparent. The text output should be similar to before, with the only
change being to output a header{} block for in-lined message/rfc822
parts. This could be easily removed if it breaks something (the vim
plugin?).

This doesn't yet have the changes necessary to support multipart/related
text/html parts with associated graphics or useful multipart/signed
(there's no checking of signatures, etc.). Those should be `a simple
matter' of writing some more emacs lisp. If someone else wants to have a
go at that I'd be thrilled.

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


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


Re: sample message that misdisplays in HTML

2010-05-17 Thread David Edmondson
On Sun, 16 May 2010 08:57:51 -0700, Dirk Hohndel hohn...@infradead.org wrote:
 Apologize for the commercial message - but this one shows a weird effect
 in the html display for me. This is with GNU Emacs 23.1.94.1
 (x86_64-redhat-linux-gnu, GTK+ Version 2.19.7) under X running the
 latest notmuch.

Do you have w3m and emacs-w3m installed? (They are `w3m' and `w3m-el' in
Debian/Ubuntu.)

I think that we should at least recommend them, if not require.

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


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


  1   2   3   4   5   6   7   8   9   10   >