Linking to emails via notmuch

2013-01-23 Thread Suvayu Ali
On Wed, Jan 23, 2013 at 01:32:42PM +0100, Rainer M Krug wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> Hi
> 
> I would like to cross-reference emails via notmuch, i.e. I would like to 
> include a link to an
> email in a git commit message (this is a private gip repo and I am the only 
> developer and
> committer, so no problem from that side). Is it possible to get a link to an 
> email which, when
> clicked in emacs, opens the corresponding email using notmuch? Or should I 
> use a different approach?
> 

You can take a look at how org-notmuch handles this and try something
similar.

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.


[PATCH 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM nonexistent or dumb

2013-01-23 Thread Jani Nikula
On Wed, 23 Jan 2013, Tomi Ollila  wrote:
> The TERM environment variable is set to 'dumb' when running tests, but
> the original value of it is stored for echoing colors and running (emacs

Extra ( there?

> (somewhat interactively) in detached session. Emacs requires some
> terminal control sequences to be available for interactive operation.
> In case original TERM is (also) 'dumb' (or nonexistent) emacs cannot run
> interactively. To fix this problem dtach (and emacs as it's child
> process) is run with TERM=vt100 in case original TERM was nonexistent or
> dumb. This way there is a chance to run emacs tests with different user
> terminals and potentially find problems there.
> ---
>  test/test-lib.sh | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 6ce3b31..3bc67f7 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -41,6 +41,10 @@ esac
>  # Keep the original TERM for say_color and test_emacs
>  ORIGINAL_TERM=$TERM
>  
> +# dtach(1) provides more capable terminal environment to anything
> +# that requires more than dumb terminal...
> +[ x"${TERM:-dumb}" = xdumb ] && DTACH_TERM=vt100 || DTACH_TERM=$TERM

That's just a tiny bit more trickery than I usually like... but then
it's shell after all... :)

> +
>  # For repeatability, reset the environment to known value.
>  LANG=C
>  LC_ALL=C
> @@ -996,9 +1000,10 @@ test_emacs () {
>   fi
>   server_name="notmuch-test-suite-$$"
>   # start a detached session with an emacs server
> - # user's TERM is given to dtach which assumes a minimally
> + # user's TERM (or 'vt100' om case user's term is nonexistent
> + # or 'dumb') is given to dtach which assumes a minimally

Nitpick, s/om/in/

Otherwise LGTM, and works as advertised.


Jani.

>   # VT100-compatible terminal -- and emacs inherits that
> - TERM=$ORIGINAL_TERM dtach -n 
> "$TEST_TMPDIR/emacs-dtach-socket.$$" \
> + TERM=$DTACH_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \
>   sh -c "stty rows 24 cols 80; exec 
> '$TMP_DIRECTORY/run_emacs' \
>   --no-window-system \
>   $load_emacs_tests \
> -- 
> 1.8.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 01/20] cli: add stub for insert command

2013-01-23 Thread Peter Wang
On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula  wrote:
> > Though it could be used as an alternative to notmuch new, the reason
> > I want this is to allow my notmuch frontend to add postponed or sent
> > messages to the mail store and notmuch database, without resorting to
> > another tool (e.g. notmuch-deliver) nor directly modifying the maildir.
> 
> This review is based on the following patches squashed together:
> 
>   cli: add stub for insert command
>   insert: open Maildir tmp file
>   insert: copy stdin to Maildir tmp file
>   insert: move file from Maildir tmp to new
>   insert: add new message to database
>   insert: apply default tags to new message
>   insert: parse and apply command-line tag operations
>   insert: fsync after writing tmp file
>   insert: trap SIGINT and clean up
>   insert: add copyright line from notmuch-deliver
> 
> It's much easier for me to grasp the big picture this way.
> 

So there *is* a limit to how fine-grained notmuchers want their patches ;-)

> > +static notmuch_bool_t
> > +maildir_move_tmp_to_new (const char *tmppath, const char *newpath)
> > +{
> > +if (rename (tmppath, newpath) != 0) {
> > +   fprintf (stderr, "Error: rename() failed: %s\n", strerror (errno));
> > +   return FALSE;
> > +}
> > +
> > +return TRUE;
> > +}
> 
> IMO you could just use rename() inline in the caller, without a wrapper.

A subsequent patch fsyncs the directory here.

> > +/* Copy the contents of standard input (fdin) into fdout. */
> > +static notmuch_bool_t
> > +copy_stdin (int fdin, int fdout)
> 
> The comment and the function name imply the function has something to do
> with stdin, while it only cares about file descriptors.

Tomi pointed out that the error message refers to standard input.

> > +/* Add the specified message file to the notmuch database, applying tags.
> > + * The file is renamed to encode notmuch tags as maildir flags. */
> > +static notmuch_bool_t
> > +add_file_to_database (notmuch_database_t *notmuch, const char *path,
> > + tag_op_list_t *tag_ops)
> > +{
> > +notmuch_message_t *message;
> > +notmuch_status_t status;
> > +
> > +status = notmuch_database_add_message (notmuch, path, );
> > +switch (status) {
> > +case NOTMUCH_STATUS_SUCCESS:
> > +   break;
> > +case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
> > +   fprintf (stderr, "Warning: duplicate message.\n");
> 
> This is not uncommon. Why the warning?
> 

I put in the warning because I wasn't sure, then forgot to revisit it.

> Also, notmuch new does not apply new.tags in this case. Are you sure we
> want to do that here? (You get mail, you read and archive it, you get
> the dupe, it pops up unread in your inbox again.)

Should command-line tags to be applied to duplicate messages?
I'm thinking not.

I'll fix the other problems you found.

Peter


[PATCH v2] emacs: Disambiguate point placement after hiding message

2013-01-23 Thread Tomi Ollila
On Wed, Jan 09 2013, Austin Clements  wrote:

> Currently, if point is in the middle of a message when the user
> collapses it, Emacs then displays the cursor on the header line of the
> next message, even though point is still on the collapsed message and
> even though, if you explicitly move point to the same visual location,
> it will be on the next message.  As a result, following actions like
> re-expanding the message or modifying tags apply to the collapsed
> message, even though, visually, it looks like they will apply to the
> message following the collapsed message.
>
> This patch addresses this by explicitly moving point when a message is
> collapsed so it is visually unambiguous that the point is still on the
> collapsed message.
> ---
>
> v2 should fix the strange behavior observed in v1.  The added code is
> essentially identical to v1, but v2 adds it to
> notmuch-show-toggle-message---which is only used
> interactively---rather than the core notmuch-show-message-visible
> function.
>
>  emacs/notmuch-show.el |   28 +++-
>  1 file changed, 23 insertions(+), 5 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5751d98..6ab926c 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1789,12 +1789,30 @@ See `notmuch-tag' for information on the format of 
> TAG-CHANGES."
>(force-window-update))
>  
>  (defun notmuch-show-toggle-message ()
> -  "Toggle the visibility of the current message."
> +  "Toggle the visibility of the current message.
> +
> +If this hides the current message, it will also move point to
> +make it obvious it's still on the current message."
>(interactive)
> -  (let ((props (notmuch-show-get-message-properties)))
> -(notmuch-show-message-visible
> - props
> - (not (plist-get props :message-visible
> +  (let* ((props (notmuch-show-get-message-properties))
> +  (visible-p (not (plist-get props :message-visible
> +(notmuch-show-message-visible props visible-p)
> +(when (not visible-p)
> +  (let ((ov (plist-get props :message-overlay)))
> + ;; If point was contained in the overlay, move it to a
> + ;; sensible spot that is visible and still on the same
> + ;; message.  Strangely, the Emacs event loop doesn't move the
> + ;; point out of the invisible region for us like it normally
> + ;; does (perhaps because it doesn't know which way to go), so
> + ;; if we don't do this, it's visually ambiguous which message
> + ;; an action will apply to.
> + (let ((start (overlay-start ov))
> +   (end (overlay-end ov)))
> +   (dolist (win (get-buffer-window-list nil nil t))
> + (with-selected-window win
> +   (when (and (<= start (point)) (< (point) end))
> + (goto-char (1- start))
> + (beginning-of-visual-line

Soo. the problem with this is still the behaviour of 
(beginning-of-visual-line), which "leaks" to previous message
if (point) is in the first header line. Interestingly 
(beginning-of-line) does not -- and this is supposed to move more
than beginning-of-visual-line...

But this and the defadvice in
id:1357855176-31653-1-git-send-email-amdragon at mit.edu
could fix this problem -- if the "sketchy" approach were used...

Austin: have you got further with the "alternate" approach
you mentioned in the other mail ?

In the meanwhile I played a bit how those overlays are 
positioned -- basically moved those to one character position
closer to the beginning of buffer -- so that overlays start
with "\n" and end just before "\n". My naive attempts just
to move brought some interesting side effects (line counts
in button change, header line coloring doesn't go to the
end of file and cursor is sometimes positioned interesting
-- but the cursor no longer leak to previous (or next)
message.

For reference, The changes I made attached. I don't bother
to make proper patch until/unless we know this is definite
way to proceed (and this definitely have some implementation
issues, too)...

>From bd3571c578aa45a23a120fc82b89f7e1649617fd Mon Sep 17 00:00:00 2001
From: Tomi Ollila 
Date: Wed, 23 Jan 2013 11:34:20 +0300
Subject: [PATCH] these email headers copied just to make git am happy

---
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1864dd1..7ee6d1d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -870,7 +870,7 @@ message at DEPTH in the current thread."
 (defun notmuch-show-create-part-overlays (msg beg end hide)
   "Add an overlay to the part between BEG and END"
   (let* ((button (button-at beg))
-(part-beg (and button (1+ (button-end button)
+(part-beg (and button (button-end button

 ;; If the part contains no text we do not make it toggleable. We
 ;; also need to check that the button is a genuine part button not
@@ -898,7 +898,7 @@ If HIDE is non-nil then initially hide this part."
 ;; Ensure 

[PATCH] emacs: hello: use batch count

2013-01-23 Thread Tomi Ollila
On Wed, Jan 16 2013, Mark Walters  wrote:

> This modifies notmuch hello to use the new count --batch
> functionality. It should give exactly the same results as before but
> under many conditions it should be much faster. In particular it is
> much faster for remote use.
>
> The code is a little ugly as it has to do some working out of the
> query when asking the query and some when dealing with the result.
> However, the code path is exactly the same in both local and remote
> use.
> ---

Well, the code Looks Good To Me (not Bad or Ugly). Pretty straightforward
conversion.

Can we have newlines in query string^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H

Tomi

>
> It's a little ugly but seems to work and does give a useful speedup.
>
> Best wishes
>
> Mark
>
>  emacs/notmuch-hello.el |   52 +--
>  1 files changed, 32 insertions(+), 20 deletions(-)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index 6db62a0..2244892 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -381,26 +381,38 @@ The result is the list of elements of the form (NAME 
> QUERY COUNT).
>  The values :show-empty-searches, :filter and :filter-count from
>  options will be handled as specified for
>  `notmuch-hello-insert-searches'."
> -  (notmuch-remove-if-not
> -   #'identity
> -   (mapcar
> -(lambda (elem)
> -  (let* ((name (car elem))
> -  (query-and-count (if (consp (cdr elem))
> -   ;; do we have a different query for the 
> message count?
> -   (cons (second elem) (third elem))
> - (cons (cdr elem) (cdr elem
> -  (message-count
> -   (string-to-number
> -(notmuch-saved-search-count
> - (notmuch-hello-filtered-query (cdr query-and-count)
> -   (or (plist-get options 
> :filter-count)
> -  (plist-get options 
> :filter)))
> - (and (or (plist-get options :show-empty-searches) (> message-count 0))
> -  (list name (notmuch-hello-filtered-query
> -  (car query-and-count) (plist-get options :filter))
> -message-count
> -query-alist)))
> +  (with-temp-buffer
> +(dolist (elem query-alist nil)
> +  (let ((count-query (if (consp (cdr elem))
> +  ;; do we have a different query for the message 
> count?
> +  (third elem)
> +(cdr elem
> + (insert
> +  (notmuch-hello-filtered-query count-query
> +(or (plist-get options :filter-count)
> +(plist-get options :filter)))
> +  "\n")))
> +
> +(call-process-region (point-min) (point-max) notmuch-command
> +  t t nil "count" "--batch")
> +(goto-char (point-min))
> +
> +(notmuch-remove-if-not
> + #'identity
> + (mapcar
> +  (lambda (elem)
> + (let ((name (car elem))
> +   (search-query (if (consp (cdr elem))
> +  ;; do we have a different query for the 
> message count?
> +  (second elem)
> +   (cdr elem)))
> +   (message-count (prog1 (read (current-buffer))
> + (forward-line 1
> +   (and (or (plist-get options :show-empty-searches) (> message-count 0))
> +(list name (notmuch-hello-filtered-query
> +search-query (plist-get options :filter))
> +  message-count
> +  query-alist
>  
>  (defun notmuch-hello-insert-buttons (searches)
>"Insert buttons for SEARCHES.
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 3/5] cli: add --batch option to notmuch count

2013-01-23 Thread Tomi Ollila
On Tue, Jan 15 2013, Jani Nikula  wrote:

> Add support for reading queries from stdin, one per line, and writing
> results to stdin, one per line.

Jani's parts LGTM, except one IMPORTANT part -- results are written
to STDOUT! (hopefully...yes) instead of STDIN! ;)

I don't see a reason why this particular way to get counts could
not be supported in notmuch into foreseeable future; the implementation
is simple and clean.

Next to look Mark's changes...

Tomi

>
> This will bring considerable performance improvements when utilized in
> Emacs notmuch-hello, especially so when running remote notmuch.
> ---
>  notmuch-count.c |   52 ++--
>  1 file changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/notmuch-count.c b/notmuch-count.c
> index 0e14b48..4bc4215 100644
> --- a/notmuch-count.c
> +++ b/notmuch-count.c
> @@ -62,6 +62,27 @@ print_count (notmuch_database_t *notmuch, const char 
> *query_str,
>  return 0;
>  }
>  
> +static int
> +count_file (notmuch_database_t *notmuch, FILE *input, const char 
> **exclude_tags,
> + size_t exclude_tags_length, int output)
> +{
> +char *line = NULL;
> +ssize_t line_len;
> +size_t line_size;
> +int ret = 0;
> +
> +while (!ret && (line_len = getline (, _size, input)) != -1) {
> + chomp_newline (line);
> + ret = print_count (notmuch, line, exclude_tags, exclude_tags_length,
> +output);
> +}
> +
> +if (line)
> + free (line);
> +
> +return ret;
> +}
> +
>  int
>  notmuch_count_command (void *ctx, int argc, char *argv[])
>  {
> @@ -73,6 +94,9 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>  int exclude = EXCLUDE_TRUE;
>  const char **search_exclude_tags = NULL;
>  size_t search_exclude_tags_length = 0;
> +notmuch_bool_t batch = FALSE;
> +FILE *input = stdin;
> +char *input_file_name = NULL;
>  int ret;
>  
>  notmuch_opt_desc_t options[] = {
> @@ -84,6 +108,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
> (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
> { "false", EXCLUDE_FALSE },
> { 0, 0 } } },
> + { NOTMUCH_OPT_BOOLEAN, , "batch", 0, 0 },
> + { NOTMUCH_OPT_STRING, _file_name, "input", 'i', 0 },
>   { 0, 0, 0, 0, 0 }
>  };
>  
> @@ -93,6 +119,21 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>   return 1;
>  }
>  
> +if (input_file_name) {
> + batch = TRUE;
> + input = fopen (input_file_name, "r");
> + if (input == NULL) {
> + fprintf (stderr, "Error opening %s for reading: %s\n",
> +  input_file_name, strerror (errno));
> + return 1;
> + }
> +}
> +
> +if (batch && opt_index != argc) {
> + fprintf (stderr, "--batch and query string are not compatible\n");
> + return 1;
> +}
> +
>  config = notmuch_config_open (ctx, NULL, NULL);
>  if (config == NULL)
>   return 1;
> @@ -112,10 +153,17 @@ notmuch_count_command (void *ctx, int argc, char 
> *argv[])
>   (config, _exclude_tags_length);
>  }
>  
> -ret = print_count (notmuch, query_str, search_exclude_tags,
> -search_exclude_tags_length, output);
> +if (batch)
> + ret = count_file (notmuch, input, search_exclude_tags,
> +   search_exclude_tags_length, output);
> +else
> + ret = print_count (notmuch, query_str, search_exclude_tags,
> +search_exclude_tags_length, output);
>  
>  notmuch_database_destroy (notmuch);
>  
> +if (input != stdin)
> + fclose (input);
> +
>  return ret;
>  }
> -- 
> 1.7.10.4
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Linking to emails via notmuch

2013-01-23 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi

I would like to cross-reference emails via notmuch, i.e. I would like to 
include a link to an
email in a git commit message (this is a private gip repo and I am the only 
developer and
committer, so no problem from that side). Is it possible to get a link to an 
email which, when
clicked in emacs, opens the corresponding email using notmuch? Or should I use 
a different approach?

Thanks,

Rainer
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ/9hqAAoJENvXNx4PUvmCaqMH/AgrPLWZSU6hsdwaz54GLOBA
h8jvLMq6rtCaAEceMDsFMepYGOmK+3Z1OuzIILbHPS2PDp3c9ExesMS2qAzsOL2D
dhDQsKxYkssSMzWCZBRiLrGeyF7w01Pu7n4VIlKl+KeE3vrItPNV2LHgaeTnClIz
jIHdAfQEwMRbXpZAQiTMXX+ed7Upfu50cgWyf3EydcZ4RcJvCuzvr8iQ/jzcrONM
fSDHdZ7QqMlsvbzIYy9nNIlj0yT+Fs3xwA5hWRPczQvEurNP2UKtHMfZNw+Rn2KG
Po4PEAp9rzzXKqM0JocqWKi9BDBLKpSV/8VseNKlllDM+89IONhEtXQOYTeclKk=
=uTH8
-END PGP SIGNATURE-



[PATCH 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM nonexistent or dumb

2013-01-23 Thread Tomi Ollila
The TERM environment variable is set to 'dumb' when running tests, but
the original value of it is stored for echoing colors and running (emacs
(somewhat interactively) in detached session. Emacs requires some
terminal control sequences to be available for interactive operation.
In case original TERM is (also) 'dumb' (or nonexistent) emacs cannot run
interactively. To fix this problem dtach (and emacs as it's child
process) is run with TERM=vt100 in case original TERM was nonexistent or
dumb. This way there is a chance to run emacs tests with different user
terminals and potentially find problems there.
---
 test/test-lib.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6ce3b31..3bc67f7 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -41,6 +41,10 @@ esac
 # Keep the original TERM for say_color and test_emacs
 ORIGINAL_TERM=$TERM

+# dtach(1) provides more capable terminal environment to anything
+# that requires more than dumb terminal...
+[ x"${TERM:-dumb}" = xdumb ] && DTACH_TERM=vt100 || DTACH_TERM=$TERM
+
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
@@ -996,9 +1000,10 @@ test_emacs () {
fi
server_name="notmuch-test-suite-$$"
# start a detached session with an emacs server
-   # user's TERM is given to dtach which assumes a minimally
+   # user's TERM (or 'vt100' om case user's term is nonexistent
+   # or 'dumb') is given to dtach which assumes a minimally
# VT100-compatible terminal -- and emacs inherits that
-   TERM=$ORIGINAL_TERM dtach -n 
"$TEST_TMPDIR/emacs-dtach-socket.$$" \
+   TERM=$DTACH_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \
sh -c "stty rows 24 cols 80; exec 
'$TMP_DIRECTORY/run_emacs' \
--no-window-system \
$load_emacs_tests \
-- 
1.8.1



[PATCH v3 01/20] cli: add stub for insert command

2013-01-23 Thread Tomi Ollila
On Wed, Jan 23 2013, Peter Wang  wrote:

> On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula  wrote:
>
>> > +/* Copy the contents of standard input (fdin) into fdout. */
>> > +static notmuch_bool_t
>> > +copy_stdin (int fdin, int fdout)
>> 
>> The comment and the function name imply the function has something to do
>> with stdin, while it only cares about file descriptors.
>
> Tomi pointed out that the error message refers to standard input.

Was that me or some other Tomi ;)... Nevertheless the function here called
'copy_stdin' copies fdin to fdout, whatever the file descriptors are,
it doesn't enforce fdin to be fd 0 (default stdin).
I.e. the function name should be more generic (or then drop fdin argument --
should better name then be 'copy_from_stdin' or copy_stdin_to.. or
copy_[from_]stdin_to_some_magic_fd -- ok, no more bikeshedding now >;)).


> Peter

Tomi


[PATCH v3 01/20] cli: add stub for insert command

2013-01-23 Thread Jani Nikula
On Wed, 23 Jan 2013, Peter Wang  wrote:
> On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula  wrote:
>> > Though it could be used as an alternative to notmuch new, the reason
>> > I want this is to allow my notmuch frontend to add postponed or sent
>> > messages to the mail store and notmuch database, without resorting to
>> > another tool (e.g. notmuch-deliver) nor directly modifying the maildir.
>> 
>> This review is based on the following patches squashed together:
>> 
>>  cli: add stub for insert command
>>  insert: open Maildir tmp file
>>  insert: copy stdin to Maildir tmp file
>>  insert: move file from Maildir tmp to new
>>  insert: add new message to database
>>  insert: apply default tags to new message
>>  insert: parse and apply command-line tag operations
>>  insert: fsync after writing tmp file
>>  insert: trap SIGINT and clean up
>>  insert: add copyright line from notmuch-deliver
>> 
>> It's much easier for me to grasp the big picture this way.
>> 
>
> So there *is* a limit to how fine-grained notmuchers want their patches ;-)

:)

>
>> > +static notmuch_bool_t
>> > +maildir_move_tmp_to_new (const char *tmppath, const char *newpath)
>> > +{
>> > +if (rename (tmppath, newpath) != 0) {
>> > +  fprintf (stderr, "Error: rename() failed: %s\n", strerror (errno));
>> > +  return FALSE;
>> > +}
>> > +
>> > +return TRUE;
>> > +}
>> 
>> IMO you could just use rename() inline in the caller, without a wrapper.
>
> A subsequent patch fsyncs the directory here.

Ah, right.

You'll probably need to rework the patch a bit to apply here (if you
take my advice of postponing the --folder etc. options). While at it,
please try to see if you can reduce the amount of paths allocated and
passed around. Given the filename, one can figure out the rest. See
lib/message.cc for examples. In the end, go for clarity if this
suggestion seems messy.

>
>> > +/* Copy the contents of standard input (fdin) into fdout. */
>> > +static notmuch_bool_t
>> > +copy_stdin (int fdin, int fdout)
>> 
>> The comment and the function name imply the function has something to do
>> with stdin, while it only cares about file descriptors.
>
> Tomi pointed out that the error message refers to standard input.
>
>> > +/* Add the specified message file to the notmuch database, applying tags.
>> > + * The file is renamed to encode notmuch tags as maildir flags. */
>> > +static notmuch_bool_t
>> > +add_file_to_database (notmuch_database_t *notmuch, const char *path,
>> > +tag_op_list_t *tag_ops)
>> > +{
>> > +notmuch_message_t *message;
>> > +notmuch_status_t status;
>> > +
>> > +status = notmuch_database_add_message (notmuch, path, );
>> > +switch (status) {
>> > +case NOTMUCH_STATUS_SUCCESS:
>> > +  break;
>> > +case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
>> > +  fprintf (stderr, "Warning: duplicate message.\n");
>> 
>> This is not uncommon. Why the warning?
>> 
>
> I put in the warning because I wasn't sure, then forgot to revisit it.
>
>> Also, notmuch new does not apply new.tags in this case. Are you sure we
>> want to do that here? (You get mail, you read and archive it, you get
>> the dupe, it pops up unread in your inbox again.)
>
> Should command-line tags to be applied to duplicate messages?
> I'm thinking not.

Agreed; a future patch might add an option to choose.

I've thought about having a config option to have notmuch new add a
separate set of tags to duplicates (defaulting to no tags added). That
could be reused here too (but is different from the command-line
tags). But again, future work.

> I'll fix the other problems you found.
>
> Peter


BR,
Jani.


[PATCH 3/4] emacs: possibility to customize the rendering of tags

2013-01-23 Thread Tomi Ollila
On Wed, Jan 23 2013, Austin Clements  wrote:

> On Fri, 18 Jan 2013, Damien Cassou  wrote:
>
>> +  `(("unread"
>> + (:propertize "unread" face
>> +  (:Foreground "red")))
>> +("flagged"
>> + (:propertize "flagged" display
>> +  (image :type svg :file
>> + ,(expand-file-name
>> +   "resources/star.svg"
>> +   (file-name-directory
>> +(or
>> + (locate-library "notmuch-tagger")
>> + (buffer-file-name
>
> Interesting.  Is this a standard way to locate resources?  (I've never
> had need to.)
>
> Since there are other icons here as well, perhaps the resources
> directory should be bound to a global variable so it's easy to construct
> other standard notmuch icon names?  You capture this in a function in
> patch 4, but that function doesn't obviously accomplish anything a
> simple variable wouldn't.

I was thinking this too. M-x apropos RET -path RET (apropos "-path")
outputs (at least) 2 symbols that are relevant here:

image-load-path
  Variable: List of locations in which to search for image files.
  Properties: standard-value custom-type custom-requests
  variable-documentation
and

image-load-path-for-library
  Function: Return a suitable search path for images used by LIBRARY.

(if the second were used I'd suggest to use 'notmuch' instead of
'notmuch-tagger' -- just to support me who just installs notmuch.elc
which is done by concatenating all notmuch .el files together to one
notmuch.el file which is then byte-compiled :D)

> Another possibility is that these icons could be included directly in
> the Elisp source, probably as simplified SVGs (your SVGs look like they
> could be cut down to 3 or 4 lines of XML easily) or as XPMs.  Besides
> skirting issues with resource location, this would make it trivial to
> alter their colors based on user preferences.

I also had the same 2 things in mind, simplify SVGs and possibly include
that directly in the source...


Tomi


update top level argument handling

2013-01-23 Thread Tomi Ollila
On Wed, Jan 23 2013, David Bremner  wrote:

> Jani Nikula  writes:
>
>>
>> Patches 1-4 look good, and IMO should be used regardless of the
>> bikeshedding result on patches 5-7.
>
> I pushed the first 4. 6 and 7 will need rebasing if 5 is omitted, which
> seems to be the plan.

At least it maintains status quo -- and in this particular case
it doesn't seem to jam progress ;)

> d

Tomi


Re: [PATCH v3 01/20] cli: add stub for insert command

2013-01-23 Thread Peter Wang
On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula j...@nikula.org wrote:
  Though it could be used as an alternative to notmuch new, the reason
  I want this is to allow my notmuch frontend to add postponed or sent
  messages to the mail store and notmuch database, without resorting to
  another tool (e.g. notmuch-deliver) nor directly modifying the maildir.
 
 This review is based on the following patches squashed together:
 
   cli: add stub for insert command
   insert: open Maildir tmp file
   insert: copy stdin to Maildir tmp file
   insert: move file from Maildir tmp to new
   insert: add new message to database
   insert: apply default tags to new message
   insert: parse and apply command-line tag operations
   insert: fsync after writing tmp file
   insert: trap SIGINT and clean up
   insert: add copyright line from notmuch-deliver
 
 It's much easier for me to grasp the big picture this way.
 

So there *is* a limit to how fine-grained notmuchers want their patches ;-)

  +static notmuch_bool_t
  +maildir_move_tmp_to_new (const char *tmppath, const char *newpath)
  +{
  +if (rename (tmppath, newpath) != 0) {
  +   fprintf (stderr, Error: rename() failed: %s\n, strerror (errno));
  +   return FALSE;
  +}
  +
  +return TRUE;
  +}
 
 IMO you could just use rename() inline in the caller, without a wrapper.

A subsequent patch fsyncs the directory here.

  +/* Copy the contents of standard input (fdin) into fdout. */
  +static notmuch_bool_t
  +copy_stdin (int fdin, int fdout)
 
 The comment and the function name imply the function has something to do
 with stdin, while it only cares about file descriptors.

Tomi pointed out that the error message refers to standard input.

  +/* Add the specified message file to the notmuch database, applying tags.
  + * The file is renamed to encode notmuch tags as maildir flags. */
  +static notmuch_bool_t
  +add_file_to_database (notmuch_database_t *notmuch, const char *path,
  + tag_op_list_t *tag_ops)
  +{
  +notmuch_message_t *message;
  +notmuch_status_t status;
  +
  +status = notmuch_database_add_message (notmuch, path, message);
  +switch (status) {
  +case NOTMUCH_STATUS_SUCCESS:
  +   break;
  +case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
  +   fprintf (stderr, Warning: duplicate message.\n);
 
 This is not uncommon. Why the warning?
 

I put in the warning because I wasn't sure, then forgot to revisit it.

 Also, notmuch new does not apply new.tags in this case. Are you sure we
 want to do that here? (You get mail, you read and archive it, you get
 the dupe, it pops up unread in your inbox again.)

Should command-line tags to be applied to duplicate messages?
I'm thinking not.

I'll fix the other problems you found.

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


Re: [PATCH v3 01/20] cli: add stub for insert command

2013-01-23 Thread Tomi Ollila
On Wed, Jan 23 2013, Peter Wang noval...@gmail.com wrote:

 On Tue, 22 Jan 2013 23:45:43 +0200, Jani Nikula j...@nikula.org wrote:

  +/* Copy the contents of standard input (fdin) into fdout. */
  +static notmuch_bool_t
  +copy_stdin (int fdin, int fdout)
 
 The comment and the function name imply the function has something to do
 with stdin, while it only cares about file descriptors.

 Tomi pointed out that the error message refers to standard input.

Was that me or some other Tomi ;)... Nevertheless the function here called
'copy_stdin' copies fdin to fdout, whatever the file descriptors are,
it doesn't enforce fdin to be fd 0 (default stdin).
I.e. the function name should be more generic (or then drop fdin argument --
should better name then be 'copy_from_stdin' or copy_stdin_to.. or
copy_[from_]stdin_to_some_magic_fd -- ok, no more bikeshedding now ;)).


 Peter

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


[PATCH 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM nonexistent or dumb

2013-01-23 Thread Tomi Ollila
The TERM environment variable is set to 'dumb' when running tests, but
the original value of it is stored for echoing colors and running (emacs
(somewhat interactively) in detached session. Emacs requires some
terminal control sequences to be available for interactive operation.
In case original TERM is (also) 'dumb' (or nonexistent) emacs cannot run
interactively. To fix this problem dtach (and emacs as it's child
process) is run with TERM=vt100 in case original TERM was nonexistent or
dumb. This way there is a chance to run emacs tests with different user
terminals and potentially find problems there.
---
 test/test-lib.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6ce3b31..3bc67f7 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -41,6 +41,10 @@ esac
 # Keep the original TERM for say_color and test_emacs
 ORIGINAL_TERM=$TERM
 
+# dtach(1) provides more capable terminal environment to anything
+# that requires more than dumb terminal...
+[ x${TERM:-dumb} = xdumb ]  DTACH_TERM=vt100 || DTACH_TERM=$TERM
+
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
@@ -996,9 +1000,10 @@ test_emacs () {
fi
server_name=notmuch-test-suite-$$
# start a detached session with an emacs server
-   # user's TERM is given to dtach which assumes a minimally
+   # user's TERM (or 'vt100' om case user's term is nonexistent
+   # or 'dumb') is given to dtach which assumes a minimally
# VT100-compatible terminal -- and emacs inherits that
-   TERM=$ORIGINAL_TERM dtach -n 
$TEST_TMPDIR/emacs-dtach-socket.$$ \
+   TERM=$DTACH_TERM dtach -n $TEST_TMPDIR/emacs-dtach-socket.$$ \
sh -c stty rows 24 cols 80; exec 
'$TMP_DIRECTORY/run_emacs' \
--no-window-system \
$load_emacs_tests \
-- 
1.8.1

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


Linking to emails via notmuch

2013-01-23 Thread Rainer M Krug
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi

I would like to cross-reference emails via notmuch, i.e. I would like to 
include a link to an
email in a git commit message (this is a private gip repo and I am the only 
developer and
committer, so no problem from that side). Is it possible to get a link to an 
email which, when
clicked in emacs, opens the corresponding email using notmuch? Or should I use 
a different approach?

Thanks,

Rainer
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ/9hqAAoJENvXNx4PUvmCaqMH/AgrPLWZSU6hsdwaz54GLOBA
h8jvLMq6rtCaAEceMDsFMepYGOmK+3Z1OuzIILbHPS2PDp3c9ExesMS2qAzsOL2D
dhDQsKxYkssSMzWCZBRiLrGeyF7w01Pu7n4VIlKl+KeE3vrItPNV2LHgaeTnClIz
jIHdAfQEwMRbXpZAQiTMXX+ed7Upfu50cgWyf3EydcZ4RcJvCuzvr8iQ/jzcrONM
fSDHdZ7QqMlsvbzIYy9nNIlj0yT+Fs3xwA5hWRPczQvEurNP2UKtHMfZNw+Rn2KG
Po4PEAp9rzzXKqM0JocqWKi9BDBLKpSV/8VseNKlllDM+89IONhEtXQOYTeclKk=
=uTH8
-END PGP SIGNATURE-

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


Re: [PATCH 3/5] cli: add --batch option to notmuch count

2013-01-23 Thread Tomi Ollila
On Tue, Jan 15 2013, Jani Nikula j...@nikula.org wrote:

 Add support for reading queries from stdin, one per line, and writing
 results to stdin, one per line.

Jani's parts LGTM, except one IMPORTANT part -- results are written
to STDOUT! (hopefully...yes) instead of STDIN! ;)

I don't see a reason why this particular way to get counts could
not be supported in notmuch into foreseeable future; the implementation
is simple and clean.

Next to look Mark's changes...

Tomi


 This will bring considerable performance improvements when utilized in
 Emacs notmuch-hello, especially so when running remote notmuch.
 ---
  notmuch-count.c |   52 ++--
  1 file changed, 50 insertions(+), 2 deletions(-)

 diff --git a/notmuch-count.c b/notmuch-count.c
 index 0e14b48..4bc4215 100644
 --- a/notmuch-count.c
 +++ b/notmuch-count.c
 @@ -62,6 +62,27 @@ print_count (notmuch_database_t *notmuch, const char 
 *query_str,
  return 0;
  }
  
 +static int
 +count_file (notmuch_database_t *notmuch, FILE *input, const char 
 **exclude_tags,
 + size_t exclude_tags_length, int output)
 +{
 +char *line = NULL;
 +ssize_t line_len;
 +size_t line_size;
 +int ret = 0;
 +
 +while (!ret  (line_len = getline (line, line_size, input)) != -1) {
 + chomp_newline (line);
 + ret = print_count (notmuch, line, exclude_tags, exclude_tags_length,
 +output);
 +}
 +
 +if (line)
 + free (line);
 +
 +return ret;
 +}
 +
  int
  notmuch_count_command (void *ctx, int argc, char *argv[])
  {
 @@ -73,6 +94,9 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
  int exclude = EXCLUDE_TRUE;
  const char **search_exclude_tags = NULL;
  size_t search_exclude_tags_length = 0;
 +notmuch_bool_t batch = FALSE;
 +FILE *input = stdin;
 +char *input_file_name = NULL;
  int ret;
  
  notmuch_opt_desc_t options[] = {
 @@ -84,6 +108,8 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
 (notmuch_keyword_t []){ { true, EXCLUDE_TRUE },
 { false, EXCLUDE_FALSE },
 { 0, 0 } } },
 + { NOTMUCH_OPT_BOOLEAN, batch, batch, 0, 0 },
 + { NOTMUCH_OPT_STRING, input_file_name, input, 'i', 0 },
   { 0, 0, 0, 0, 0 }
  };
  
 @@ -93,6 +119,21 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
   return 1;
  }
  
 +if (input_file_name) {
 + batch = TRUE;
 + input = fopen (input_file_name, r);
 + if (input == NULL) {
 + fprintf (stderr, Error opening %s for reading: %s\n,
 +  input_file_name, strerror (errno));
 + return 1;
 + }
 +}
 +
 +if (batch  opt_index != argc) {
 + fprintf (stderr, --batch and query string are not compatible\n);
 + return 1;
 +}
 +
  config = notmuch_config_open (ctx, NULL, NULL);
  if (config == NULL)
   return 1;
 @@ -112,10 +153,17 @@ notmuch_count_command (void *ctx, int argc, char 
 *argv[])
   (config, search_exclude_tags_length);
  }
  
 -ret = print_count (notmuch, query_str, search_exclude_tags,
 -search_exclude_tags_length, output);
 +if (batch)
 + ret = count_file (notmuch, input, search_exclude_tags,
 +   search_exclude_tags_length, output);
 +else
 + ret = print_count (notmuch, query_str, search_exclude_tags,
 +search_exclude_tags_length, output);
  
  notmuch_database_destroy (notmuch);
  
 +if (input != stdin)
 + fclose (input);
 +
  return ret;
  }
 -- 
 1.7.10.4

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


Re: [PATCH] emacs: hello: use batch count

2013-01-23 Thread Tomi Ollila
On Wed, Jan 16 2013, Mark Walters markwalters1...@gmail.com wrote:

 This modifies notmuch hello to use the new count --batch
 functionality. It should give exactly the same results as before but
 under many conditions it should be much faster. In particular it is
 much faster for remote use.

 The code is a little ugly as it has to do some working out of the
 query when asking the query and some when dealing with the result.
 However, the code path is exactly the same in both local and remote
 use.
 ---

Well, the code Looks Good To Me (not Bad or Ugly). Pretty straightforward
conversion.

Can we have newlines in query string^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H

Tomi


 It's a little ugly but seems to work and does give a useful speedup.

 Best wishes

 Mark

  emacs/notmuch-hello.el |   52 +--
  1 files changed, 32 insertions(+), 20 deletions(-)

 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
 index 6db62a0..2244892 100644
 --- a/emacs/notmuch-hello.el
 +++ b/emacs/notmuch-hello.el
 @@ -381,26 +381,38 @@ The result is the list of elements of the form (NAME 
 QUERY COUNT).
  The values :show-empty-searches, :filter and :filter-count from
  options will be handled as specified for
  `notmuch-hello-insert-searches'.
 -  (notmuch-remove-if-not
 -   #'identity
 -   (mapcar
 -(lambda (elem)
 -  (let* ((name (car elem))
 -  (query-and-count (if (consp (cdr elem))
 -   ;; do we have a different query for the 
 message count?
 -   (cons (second elem) (third elem))
 - (cons (cdr elem) (cdr elem
 -  (message-count
 -   (string-to-number
 -(notmuch-saved-search-count
 - (notmuch-hello-filtered-query (cdr query-and-count)
 -   (or (plist-get options 
 :filter-count)
 -  (plist-get options 
 :filter)))
 - (and (or (plist-get options :show-empty-searches) ( message-count 0))
 -  (list name (notmuch-hello-filtered-query
 -  (car query-and-count) (plist-get options :filter))
 -message-count
 -query-alist)))
 +  (with-temp-buffer
 +(dolist (elem query-alist nil)
 +  (let ((count-query (if (consp (cdr elem))
 +  ;; do we have a different query for the message 
 count?
 +  (third elem)
 +(cdr elem
 + (insert
 +  (notmuch-hello-filtered-query count-query
 +(or (plist-get options :filter-count)
 +(plist-get options :filter)))
 +  \n)))
 +
 +(call-process-region (point-min) (point-max) notmuch-command
 +  t t nil count --batch)
 +(goto-char (point-min))
 +
 +(notmuch-remove-if-not
 + #'identity
 + (mapcar
 +  (lambda (elem)
 + (let ((name (car elem))
 +   (search-query (if (consp (cdr elem))
 +  ;; do we have a different query for the 
 message count?
 +  (second elem)
 +   (cdr elem)))
 +   (message-count (prog1 (read (current-buffer))
 + (forward-line 1
 +   (and (or (plist-get options :show-empty-searches) ( message-count 0))
 +(list name (notmuch-hello-filtered-query
 +search-query (plist-get options :filter))
 +  message-count
 +  query-alist
  
  (defun notmuch-hello-insert-buttons (searches)
Insert buttons for SEARCHES.
 -- 
 1.7.9.1

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


Re: [PATCH v2] emacs: Disambiguate point placement after hiding message

2013-01-23 Thread Tomi Ollila
On Wed, Jan 09 2013, Austin Clements amdra...@mit.edu wrote:

 Currently, if point is in the middle of a message when the user
 collapses it, Emacs then displays the cursor on the header line of the
 next message, even though point is still on the collapsed message and
 even though, if you explicitly move point to the same visual location,
 it will be on the next message.  As a result, following actions like
 re-expanding the message or modifying tags apply to the collapsed
 message, even though, visually, it looks like they will apply to the
 message following the collapsed message.

 This patch addresses this by explicitly moving point when a message is
 collapsed so it is visually unambiguous that the point is still on the
 collapsed message.
 ---

 v2 should fix the strange behavior observed in v1.  The added code is
 essentially identical to v1, but v2 adds it to
 notmuch-show-toggle-message---which is only used
 interactively---rather than the core notmuch-show-message-visible
 function.

  emacs/notmuch-show.el |   28 +++-
  1 file changed, 23 insertions(+), 5 deletions(-)

 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 5751d98..6ab926c 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1789,12 +1789,30 @@ See `notmuch-tag' for information on the format of 
 TAG-CHANGES.
(force-window-update))
  
  (defun notmuch-show-toggle-message ()
 -  Toggle the visibility of the current message.
 +  Toggle the visibility of the current message.
 +
 +If this hides the current message, it will also move point to
 +make it obvious it's still on the current message.
(interactive)
 -  (let ((props (notmuch-show-get-message-properties)))
 -(notmuch-show-message-visible
 - props
 - (not (plist-get props :message-visible
 +  (let* ((props (notmuch-show-get-message-properties))
 +  (visible-p (not (plist-get props :message-visible
 +(notmuch-show-message-visible props visible-p)
 +(when (not visible-p)
 +  (let ((ov (plist-get props :message-overlay)))
 + ;; If point was contained in the overlay, move it to a
 + ;; sensible spot that is visible and still on the same
 + ;; message.  Strangely, the Emacs event loop doesn't move the
 + ;; point out of the invisible region for us like it normally
 + ;; does (perhaps because it doesn't know which way to go), so
 + ;; if we don't do this, it's visually ambiguous which message
 + ;; an action will apply to.
 + (let ((start (overlay-start ov))
 +   (end (overlay-end ov)))
 +   (dolist (win (get-buffer-window-list nil nil t))
 + (with-selected-window win
 +   (when (and (= start (point)) ( (point) end))
 + (goto-char (1- start))
 + (beginning-of-visual-line

Soo. the problem with this is still the behaviour of 
(beginning-of-visual-line), which leaks to previous message
if (point) is in the first header line. Interestingly 
(beginning-of-line) does not -- and this is supposed to move more
than beginning-of-visual-line...

But this and the defadvice in
id:1357855176-31653-1-git-send-email-amdra...@mit.edu
could fix this problem -- if the sketchy approach were used...

Austin: have you got further with the alternate approach
you mentioned in the other mail ?

In the meanwhile I played a bit how those overlays are 
positioned -- basically moved those to one character position
closer to the beginning of buffer -- so that overlays start
with \n and end just before \n. My naive attempts just
to move brought some interesting side effects (line counts
in button change, header line coloring doesn't go to the
end of file and cursor is sometimes positioned interesting
-- but the cursor no longer leak to previous (or next)
message.

For reference, The changes I made attached. I don't bother
to make proper patch until/unless we know this is definite
way to proceed (and this definitely have some implementation
issues, too)...

From bd3571c578aa45a23a120fc82b89f7e1649617fd Mon Sep 17 00:00:00 2001
From: Tomi Ollila tomi.oll...@iki.fi
Date: Wed, 23 Jan 2013 11:34:20 +0300
Subject: [PATCH] these email headers copied just to make git am happy

---
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1864dd1..7ee6d1d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -870,7 +870,7 @@ message at DEPTH in the current thread.
 (defun notmuch-show-create-part-overlays (msg beg end hide)
   Add an overlay to the part between BEG and END
   (let* ((button (button-at beg))
-(part-beg (and button (1+ (button-end button)
+(part-beg (and button (button-end button
 
 ;; If the part contains no text we do not make it toggleable. We
 ;; also need to check that the button is a genuine part button not
@@ -898,7 +898,7 @@ If HIDE is non-nil then initially hide this part.
 ;; Ensure that the part ends with a carriage return.
 (unless (bolp)
   

Re: [PATCH 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM nonexistent or dumb

2013-01-23 Thread Jani Nikula
On Wed, 23 Jan 2013, Tomi Ollila tomi.oll...@iki.fi wrote:
 The TERM environment variable is set to 'dumb' when running tests, but
 the original value of it is stored for echoing colors and running (emacs

Extra ( there?

 (somewhat interactively) in detached session. Emacs requires some
 terminal control sequences to be available for interactive operation.
 In case original TERM is (also) 'dumb' (or nonexistent) emacs cannot run
 interactively. To fix this problem dtach (and emacs as it's child
 process) is run with TERM=vt100 in case original TERM was nonexistent or
 dumb. This way there is a chance to run emacs tests with different user
 terminals and potentially find problems there.
 ---
  test/test-lib.sh | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)

 diff --git a/test/test-lib.sh b/test/test-lib.sh
 index 6ce3b31..3bc67f7 100644
 --- a/test/test-lib.sh
 +++ b/test/test-lib.sh
 @@ -41,6 +41,10 @@ esac
  # Keep the original TERM for say_color and test_emacs
  ORIGINAL_TERM=$TERM
  
 +# dtach(1) provides more capable terminal environment to anything
 +# that requires more than dumb terminal...
 +[ x${TERM:-dumb} = xdumb ]  DTACH_TERM=vt100 || DTACH_TERM=$TERM

That's just a tiny bit more trickery than I usually like... but then
it's shell after all... :)

 +
  # For repeatability, reset the environment to known value.
  LANG=C
  LC_ALL=C
 @@ -996,9 +1000,10 @@ test_emacs () {
   fi
   server_name=notmuch-test-suite-$$
   # start a detached session with an emacs server
 - # user's TERM is given to dtach which assumes a minimally
 + # user's TERM (or 'vt100' om case user's term is nonexistent
 + # or 'dumb') is given to dtach which assumes a minimally

Nitpick, s/om/in/

Otherwise LGTM, and works as advertised.


Jani.

   # VT100-compatible terminal -- and emacs inherits that
 - TERM=$ORIGINAL_TERM dtach -n 
 $TEST_TMPDIR/emacs-dtach-socket.$$ \
 + TERM=$DTACH_TERM dtach -n $TEST_TMPDIR/emacs-dtach-socket.$$ \
   sh -c stty rows 24 cols 80; exec 
 '$TMP_DIRECTORY/run_emacs' \
   --no-window-system \
   $load_emacs_tests \
 -- 
 1.8.1

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


Re: Linking to emails via notmuch

2013-01-23 Thread Suvayu Ali
On Wed, Jan 23, 2013 at 01:32:42PM +0100, Rainer M Krug wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Hi
 
 I would like to cross-reference emails via notmuch, i.e. I would like to 
 include a link to an
 email in a git commit message (this is a private gip repo and I am the only 
 developer and
 committer, so no problem from that side). Is it possible to get a link to an 
 email which, when
 clicked in emacs, opens the corresponding email using notmuch? Or should I 
 use a different approach?
 

You can take a look at how org-notmuch handles this and try something
similar.

Hope this helps,

-- 
Suvayu

Open source is the future. It sets us free.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM nonexistent or dumb

2013-01-23 Thread Tomi Ollila
The TERM environment variable is set to 'dumb' when running tests, but
the original value of it is stored for echoing colors and running emacs
(somewhat interactively) in detached session. Emacs requires some
terminal control sequences to be available for interactive operation.
In case original TERM is (also) 'dumb' (or nonexistent) emacs cannot run
interactively. To fix this problem dtach (and emacs as it's child
process) is run with TERM=vt100 in case original TERM was nonexistent or
dumb. This way there is a chance to run emacs tests with different user
terminals and potentially find problems there.
---

Obsoletes id:1358933736-300-1-git-send-email-tomi.oll...@iki.fi

The 2 typos Jani mentioned fixed (Thanks; I noticed the former but
not the latter)

Diffdiff of the content changes (in git format-patch generated files):

: @@ -8 +8 @@
: -the original value of it is stored for echoing colors and running (emacs
: +the original value of it is stored for echoing colors and running emacs
: @@ -40 +40 @@
: -+# user's TERM (or 'vt100' om case user's term is nonexistent
: ++# user's TERM (or 'vt100' in case user's term is nonexistent

 test/test-lib.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6ce3b31..1567178 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -41,6 +41,10 @@ esac
 # Keep the original TERM for say_color and test_emacs
 ORIGINAL_TERM=$TERM
 
+# dtach(1) provides more capable terminal environment to anything
+# that requires more than dumb terminal...
+[ x${TERM:-dumb} = xdumb ]  DTACH_TERM=vt100 || DTACH_TERM=$TERM
+
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
@@ -996,9 +1000,10 @@ test_emacs () {
fi
server_name=notmuch-test-suite-$$
# start a detached session with an emacs server
-   # user's TERM is given to dtach which assumes a minimally
+   # user's TERM (or 'vt100' in case user's term is nonexistent
+   # or 'dumb') is given to dtach which assumes a minimally
# VT100-compatible terminal -- and emacs inherits that
-   TERM=$ORIGINAL_TERM dtach -n 
$TEST_TMPDIR/emacs-dtach-socket.$$ \
+   TERM=$DTACH_TERM dtach -n $TEST_TMPDIR/emacs-dtach-socket.$$ \
sh -c stty rows 24 cols 80; exec 
'$TMP_DIRECTORY/run_emacs' \
--no-window-system \
$load_emacs_tests \
-- 
1.8.0

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


[PATCH V3 1/1] test/test-lib.sh: use vt100 as dtach terminal if TERM dumb or unset/empty

2013-01-23 Thread Tomi Ollila
The TERM environment variable is set to 'dumb' when running tests, but
the original value of it is stored for echoing colors and running emacs
(somewhat interactively) in detached session. Emacs requires some
terminal control sequences to be available for interactive operation.
In case original TERM is (also) 'dumb' (or unset/empty) emacs cannot
run interactively. To fix this problem dtach (and emacs as it's child
process) is run with TERM=vt100 in case original TERM was unset, empty
or 'dumb'. This way there is a chance to run emacs tests with different
user terminals and potentially find problems there.
---

Obsoletes id:1359011360-15591-1-git-send-email-tomi.oll...@iki.fi

To be accurate (instead of potentially confusing), the commit
message and comments have been edited to mention 'unset or empty'
instead of 'nonexistent'. No functional changes (to neither v1 or v2
of this patch).

 test/test-lib.sh | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 6ce3b31..1567178 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -41,6 +41,10 @@ esac
 # Keep the original TERM for say_color and test_emacs
 ORIGINAL_TERM=$TERM
 
+# dtach(1) provides more capable terminal environment to anything
+# that requires more than dumb terminal...
+[ x${TERM:-dumb} = xdumb ]  DTACH_TERM=vt100 || DTACH_TERM=$TERM
+
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
@@ -996,9 +1000,10 @@ test_emacs () {
fi
server_name=notmuch-test-suite-$$
# start a detached session with an emacs server
-   # user's TERM is given to dtach which assumes a minimally
+   # user's TERM (or 'vt100' in case user's TERM is unset, empty
+   # or 'dumb') is given to dtach which assumes a minimally
# VT100-compatible terminal -- and emacs inherits that
-   TERM=$ORIGINAL_TERM dtach -n 
$TEST_TMPDIR/emacs-dtach-socket.$$ \
+   TERM=$DTACH_TERM dtach -n $TEST_TMPDIR/emacs-dtach-socket.$$ \
sh -c stty rows 24 cols 80; exec 
'$TMP_DIRECTORY/run_emacs' \
--no-window-system \
$load_emacs_tests \
-- 
1.8.0

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