[PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements  writes:

> Xapian doesn't consider ":abc" to be a prefixed term.  This makes
> parse_boolean_term similarly reject queries with an empty prefix.
> ---

pushed.

d


notmuch 0.15 release in progress

2013-01-07 Thread David Bremner

We "frozen", although so far there is no divergence between release and
master. I took the liberty of pushing two tiny patches updating the
version(s) and the corresponding debian changelog.

Pragmatically what this means is that if you want something to go into
0.15, you need to push for that, and do it pretty soon.  

We also need need a few NEWS items, not least for the new dump/restore
and batch tagging features.

d
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20130107/d3dfcc7e/attachment.pgp>


[Patch v2 2/9] notmuch-tag.c: convert to use tag-utils

2013-01-07 Thread Tomi Ollila
On Mon, Jan 07 2013, Jani Nikula  wrote:

> On Mon, 07 Jan 2013, david at tethera.net wrote:
>> From: David Bremner 
>>
>> Command line parsing is factored out into a function
>> parse_tag_command_line in tag-utils.c.
>>
>> There is some duplicated code eliminated in tag_query, and a bunch of
>> translation from using the bare tag_op structs to using that tag-utils
>> API.
>> ---
>>  notmuch-tag.c |   99 
>> -
>>  tag-util.c|   51 +++--
>>  tag-util.h|   15 +
>>  3 files changed, 84 insertions(+), 81 deletions(-)
>>
>> diff --git a/notmuch-tag.c b/notmuch-tag.c
>> index fc9d43a..8129912 100644
>> --- a/notmuch-tag.c
>> +++ b/notmuch-tag.c
>> @@ -19,6 +19,7 @@
>>   */
>>  
>>  #include "notmuch-client.h"
>> +#include "tag-util.h"
>>  #include "string-util.h"
>>  
>>  static volatile sig_atomic_t interrupted;
>> @@ -36,14 +37,10 @@ handle_sigint (unused (int sig))
>>  interrupted = 1;
>>  }
>>  
>> -typedef struct {
>> -const char *tag;
>> -notmuch_bool_t remove;
>> -} tag_operation_t;
>>  
>>  static char *
>>  _optimize_tag_query (void *ctx, const char *orig_query_string,
>> - const tag_operation_t *tag_ops)
>> + const tag_op_list_t *list)
>>  {
>>  /* This is subtler than it looks.  Xapian ignores the '-' operator
>>   * at the beginning both queries and parenthesized groups and,
>> @@ -60,7 +57,7 @@ _optimize_tag_query (void *ctx, const char 
>> *orig_query_string,
>>  size_t i;
>>  
>>  /* Don't optimize if there are no tag changes. */
>> -if (tag_ops[0].tag == NULL)
>> +if (tag_op_list_size (list) == 0)
>>  return talloc_strdup (ctx, orig_query_string);
>>  
>>  /* Build the new query string */
>> @@ -69,17 +66,17 @@ _optimize_tag_query (void *ctx, const char 
>> *orig_query_string,
>>  else
>>  query_string = talloc_asprintf (ctx, "( %s ) and (", orig_query_string);
>>  
>> -for (i = 0; tag_ops[i].tag && query_string; i++) {
>> +for (i = 0; i < tag_op_list_size (list) && query_string; i++) {
>>  /* XXX in case of OOM, query_string will be deallocated when
>>   * ctx is, which might be at shutdown */
>>  if (make_boolean_term (ctx,
>> -   "tag", tag_ops[i].tag,
>> +   "tag", tag_op_list_tag (list, i),
>> , _len))
>>  return NULL;
>>  
>>  query_string = talloc_asprintf_append_buffer (
>>  query_string, "%s%s%s", join,
>> -tag_ops[i].remove ? "" : "not ",
>> +tag_op_list_isremove (list, i) ? "" : "not ",
>>  escaped);
>>  join = " or ";
>>  }
>> @@ -91,17 +88,15 @@ _optimize_tag_query (void *ctx, const char 
>> *orig_query_string,
>>  return query_string;
>>  }
>>  
>> -/* Tag messages matching 'query_string' according to 'tag_ops', which
>> - * must be an array of tagging operations terminated with an empty
>> - * element. */
>> +/* Tag messages matching 'query_string' according to 'tag_ops'
>> + */
>>  static int
>>  tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
>> -   tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags)
>> +   tag_op_list_t *tag_ops, tag_op_flag_t flags)
>>  {
>>  notmuch_query_t *query;
>>  notmuch_messages_t *messages;
>>  notmuch_message_t *message;
>> -int i;
>>  
>>  /* Optimize the query so it excludes messages that already have
>>   * the specified set of tags. */
>> @@ -124,21 +119,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, 
>> const char *query_string,
>>   notmuch_messages_valid (messages) && ! interrupted;
>>   notmuch_messages_move_to_next (messages)) {
>>  message = notmuch_messages_get (messages);
>> -
>> -notmuch_message_freeze (message);
>> -
>> -for (i = 0; tag_ops[i].tag; i++) {
>> -if (tag_ops[i].remove)
>> -notmuch_message_remove_tag (message, tag_ops[i].tag);
>> -else
>> -notmuch_message_add_tag (message, tag_ops[i].tag);
>> -}
>> -
>> -notmuch_message_thaw (message);
>> -
>> -if (synchronize_flags)
>> -notmuch_message_tags_to_maildir_flags (message);
>> -
>> +tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);
>
> I think we probably want to check for errors and bail out on them
> here. It's a functional change, so it belongs in a follow-up patch. We
> haven't done it before, but it'll be more important with batch tagging.


I marked this message as notmuch::bug so it doesn't get forgotten.

Now there is this lengthy message shown in nmbug status page with subject
Re: [Patch v2 2/9] notmuch-tag.c: convert to use tag-utils and Jani's 
name on it ;) 

I guess we can expect everyone checking nmbug page regularly for messages
with their name :D

> BR,
> Jani.


Thanks,

Tomi

>
>
>>  notmuch_message_destroy (message);
>>  }
>>  
>> @@ -150,15 +131,13 

[PATCH v2] emacs: show: make buttons select window

2013-01-07 Thread Mark Walters
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
---

This versions fixes most of the comments raised by Austin's review.
The one change I didn't make was changing :supertype to 'supertype. In
principle I agree with Austin but the : form is used for inheritance
for other notmuch buttons in wash and crypto.

Best wishes

Mark




 emacs/notmuch-crypto.el |5 -
 emacs/notmuch-lib.el|   15 +++
 emacs/notmuch-show.el   |4 +++-
 emacs/notmuch-wash.el   |3 ++-
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 83e5d37..5233824 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: Jameson Rollins 

+(require 'notmuch-lib)
+
 (defcustom notmuch-crypto-process-mime nil
   "Should cryptographic MIME parts be processed?

@@ -76,7 +78,8 @@ mode."
 (define-button-type 'notmuch-crypto-status-button-type
   'action (lambda (button) (message (button-get button 'help-echo)))
   'follow-link t
-  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts.")
+  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts."
+  :supertype 'notmuch-button-type)

 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0407f8a..6836192 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -97,6 +97,21 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)

+;; By default clicking on a button does not select the window
+;; containing the button (as opposed to clicking on a widget which
+;; does). This means that the button action is then executed in the
+;; current selected window which can cause problems if the button
+;; changes the buffer (e.g., id: links) or moves point.
+;;
+;; This provides a button type which overrides mouse-action so that
+;; the button's window is selected before the action is run. Other
+;; notmuch buttons can get the same behaviour by inheriting from this
+;; button type.
+(define-button-type 'notmuch-button-type
+  'mouse-action (lambda (button)
+ (select-window (posn-window (event-start last-input-event)))
+ (button-activate button)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..059194d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -469,7 +469,8 @@ message at DEPTH in the current thread."
   'action 'notmuch-show-part-button-default
   'keymap 'notmuch-show-part-button-map
   'follow-link t
-  'face 'message-mml)
+  'face 'message-mml
+  :supertype 'notmuch-button-type)

 (defvar notmuch-show-part-button-map
   (let ((map (make-sparse-keymap)))
@@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."
;; Remove the overlay created by goto-address-mode
(remove-overlays (first link) (second link) 'goto-address t)
(make-text-button (first link) (second link)
+ :type 'notmuch-button-type
  'action `(lambda (arg)
 (notmuch-show ,(third link)))
  'follow-link t
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d6db4fa..826b6f4 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -115,7 +115,8 @@ lower).")
 (define-button-type 'notmuch-wash-button-invisibility-toggle-type
   'action 'notmuch-wash-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-face
+  :supertype 'notmuch-button-type)

 (define-button-type 'notmuch-wash-button-citation-toggle-type
   'help-echo "mouse-1, RET: Show citation"
-- 
1.7.9.1



[PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements  writes:

> Xapian doesn't consider ":abc" to be a prefixed term.  This makes
> parse_boolean_term similarly reject queries with an empty prefix.
> ---

pushed.

d


Xapian-quoting based batch tagging.

2013-01-07 Thread David Bremner
david at tethera.net writes:

> This is essentially just a rebase of 
>
>  id:1356464567-21779-1-git-send-email-david at tethera.net
>
> with some commit-message fixups for 
>
> [Patch v2 3/9] cli: add support for batch tagging operations to

pushed, with one blank line deleted, and one plural corrected, per Tomi
on IRC.

d


Xapian-quoting based batch tagging.

2013-01-07 Thread Jani Nikula
On Mon, 07 Jan 2013, david at tethera.net wrote:
> This is essentially just a rebase of 
>
>  id:1356464567-21779-1-git-send-email-david at tethera.net
>
> with some commit-message fixups for 
>
> [Patch v2 3/9] cli: add support for batch tagging operations to
>
> as suggested by Jani

The series LGTM,
Jani.


[Patch v2 2/9] notmuch-tag.c: convert to use tag-utils

2013-01-07 Thread Jani Nikula
On Mon, 07 Jan 2013, david at tethera.net wrote:
> From: David Bremner 
>
> Command line parsing is factored out into a function
> parse_tag_command_line in tag-utils.c.
>
> There is some duplicated code eliminated in tag_query, and a bunch of
> translation from using the bare tag_op structs to using that tag-utils
> API.
> ---
>  notmuch-tag.c |   99 
> -
>  tag-util.c|   51 +++--
>  tag-util.h|   15 +
>  3 files changed, 84 insertions(+), 81 deletions(-)
>
> diff --git a/notmuch-tag.c b/notmuch-tag.c
> index fc9d43a..8129912 100644
> --- a/notmuch-tag.c
> +++ b/notmuch-tag.c
> @@ -19,6 +19,7 @@
>   */
>  
>  #include "notmuch-client.h"
> +#include "tag-util.h"
>  #include "string-util.h"
>  
>  static volatile sig_atomic_t interrupted;
> @@ -36,14 +37,10 @@ handle_sigint (unused (int sig))
>  interrupted = 1;
>  }
>  
> -typedef struct {
> -const char *tag;
> -notmuch_bool_t remove;
> -} tag_operation_t;
>  
>  static char *
>  _optimize_tag_query (void *ctx, const char *orig_query_string,
> -  const tag_operation_t *tag_ops)
> +  const tag_op_list_t *list)
>  {
>  /* This is subtler than it looks.  Xapian ignores the '-' operator
>   * at the beginning both queries and parenthesized groups and,
> @@ -60,7 +57,7 @@ _optimize_tag_query (void *ctx, const char 
> *orig_query_string,
>  size_t i;
>  
>  /* Don't optimize if there are no tag changes. */
> -if (tag_ops[0].tag == NULL)
> +if (tag_op_list_size (list) == 0)
>   return talloc_strdup (ctx, orig_query_string);
>  
>  /* Build the new query string */
> @@ -69,17 +66,17 @@ _optimize_tag_query (void *ctx, const char 
> *orig_query_string,
>  else
>   query_string = talloc_asprintf (ctx, "( %s ) and (", orig_query_string);
>  
> -for (i = 0; tag_ops[i].tag && query_string; i++) {
> +for (i = 0; i < tag_op_list_size (list) && query_string; i++) {
>   /* XXX in case of OOM, query_string will be deallocated when
>* ctx is, which might be at shutdown */
>   if (make_boolean_term (ctx,
> -"tag", tag_ops[i].tag,
> +"tag", tag_op_list_tag (list, i),
>  , _len))
>   return NULL;
>  
>   query_string = talloc_asprintf_append_buffer (
>   query_string, "%s%s%s", join,
> - tag_ops[i].remove ? "" : "not ",
> + tag_op_list_isremove (list, i) ? "" : "not ",
>   escaped);
>   join = " or ";
>  }
> @@ -91,17 +88,15 @@ _optimize_tag_query (void *ctx, const char 
> *orig_query_string,
>  return query_string;
>  }
>  
> -/* Tag messages matching 'query_string' according to 'tag_ops', which
> - * must be an array of tagging operations terminated with an empty
> - * element. */
> +/* Tag messages matching 'query_string' according to 'tag_ops'
> + */
>  static int
>  tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
> -tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags)
> +tag_op_list_t *tag_ops, tag_op_flag_t flags)
>  {
>  notmuch_query_t *query;
>  notmuch_messages_t *messages;
>  notmuch_message_t *message;
> -int i;
>  
>  /* Optimize the query so it excludes messages that already have
>   * the specified set of tags. */
> @@ -124,21 +119,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const 
> char *query_string,
>notmuch_messages_valid (messages) && ! interrupted;
>notmuch_messages_move_to_next (messages)) {
>   message = notmuch_messages_get (messages);
> -
> - notmuch_message_freeze (message);
> -
> - for (i = 0; tag_ops[i].tag; i++) {
> - if (tag_ops[i].remove)
> - notmuch_message_remove_tag (message, tag_ops[i].tag);
> - else
> - notmuch_message_add_tag (message, tag_ops[i].tag);
> - }
> -
> - notmuch_message_thaw (message);
> -
> - if (synchronize_flags)
> - notmuch_message_tags_to_maildir_flags (message);
> -
> + tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);

I think we probably want to check for errors and bail out on them
here. It's a functional change, so it belongs in a follow-up patch. We
haven't done it before, but it'll be more important with batch tagging.

BR,
Jani.


>   notmuch_message_destroy (message);
>  }
>  
> @@ -150,15 +131,13 @@ tag_query (void *ctx, notmuch_database_t *notmuch, 
> const char *query_string,
>  int
>  notmuch_tag_command (void *ctx, int argc, char *argv[])
>  {
> -tag_operation_t *tag_ops;
> -int tag_ops_count = 0;
> -char *query_string;
> +tag_op_list_t *tag_ops = NULL;
> +char *query_string = NULL;
>  notmuch_config_t *config;
>  notmuch_database_t *notmuch;
>  struct sigaction action;
> -notmuch_bool_t synchronize_flags;
> -int i;
> -int 

[PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements  writes:

> Xapian doesn't consider ":abc" to be a prefixed term.  This makes
> parse_boolean_term similarly reject queries with an empty prefix.

Looks OK to me.

d


[PATCH] emacs: show: make buttons select window

2013-01-07 Thread Mark Walters
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
---

This is a new patch attempting to do the same as
id:1355958602-16752-1-git-send-email-markwalters1009 at gmail.com

This version changes all notmuch buttons to select the appropriate
window before applying the action. This brings the buttons in line
with widgets (as used in notmuch hello) and whatever is used for
http:// links.

I think that buttons should at least run the action in the clicked
window: whether point should remain there is less clear. This version
does leave point there as this is what widgets and links do (but this
would be easy to change).

I don't know whether we want to do this for 0.15: the change for id
links would be nice, the other cases are less important. If preferred
I can provide a patch fixing that single instance.

Finally, if anyone who uses the crypto stuff could check that it works
for crypto buttons that would be nice as I do not have crypto setup.

Best wishes

Mark




 emacs/notmuch-crypto.el |3 ++-
 emacs/notmuch-lib.el|5 +
 emacs/notmuch-show.el   |4 +++-
 emacs/notmuch-wash.el   |3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 83e5d37..173a3e7 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -76,7 +76,8 @@ mode."
 (define-button-type 'notmuch-crypto-status-button-type
   'action (lambda (button) (message (button-get button 'help-echo)))
   'follow-link t
-  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts.")
+  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
parts."
+  :supertype 'notmuch-button-type)

 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0407f8a..1573e32 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -97,6 +97,11 @@ For example, if you wanted to remove an \"inbox\" tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)

+(define-button-type 'notmuch-button-type
+  'mouse-action (lambda (button)
+ (select-window (posn-window (event-start last-input-event)))
+ (button-activate button)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..059194d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -469,7 +469,8 @@ message at DEPTH in the current thread."
   'action 'notmuch-show-part-button-default
   'keymap 'notmuch-show-part-button-map
   'follow-link t
-  'face 'message-mml)
+  'face 'message-mml
+  :supertype 'notmuch-button-type)

 (defvar notmuch-show-part-button-map
   (let ((map (make-sparse-keymap)))
@@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."
;; Remove the overlay created by goto-address-mode
(remove-overlays (first link) (second link) 'goto-address t)
(make-text-button (first link) (second link)
+ :type 'notmuch-button-type
  'action `(lambda (arg)
 (notmuch-show ,(third link)))
  'follow-link t
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d6db4fa..826b6f4 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -115,7 +115,8 @@ lower).")
 (define-button-type 'notmuch-wash-button-invisibility-toggle-type
   'action 'notmuch-wash-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-face
+  :supertype 'notmuch-button-type)

 (define-button-type 'notmuch-wash-button-citation-toggle-type
   'help-echo "mouse-1, RET: Show citation"
-- 
1.7.9.1



[PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread Austin Clements
Xapian doesn't consider ":abc" to be a prefixed term.  This makes
parse_boolean_term similarly reject queries with an empty prefix.
---
 util/string-util.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/string-util.c b/util/string-util.c
index aba9aa8..a5622d7 100644
--- a/util/string-util.c
+++ b/util/string-util.c
@@ -127,7 +127,7 @@ parse_boolean_term (void *ctx, const char *str,
 /* Parse prefix */
 str = skip_space (str);
 const char *pos = strchr (str, ':');
-if (! pos)
+if (! pos || pos == str)
goto FAIL;
 *prefix_out = talloc_strndup (ctx, str, pos - str);
 if (! *prefix_out) {
-- 
1.7.10.4



[PATCH v2] emacs: show: make buttons select window

2013-01-07 Thread Austin Clements
LGTM.

Quoth Mark Walters on Jan 07 at  9:07 pm:
> Emacs has two button type objects: widgets (as used for saved searches
> in notmuch-hello) and buttons as used by parts/citations and id links
> in notmuch-show. These two behave subtly differently when clicked with
> the mouse: widgets select the window clicked before running the
> action, buttons do not.
> 
> This patch makes all of these behave the same: clicking always selects
> the clicked window. It does this by defining a notmuch-button-type
> supertype that the other notmuch buttons can inherit from. This
> supertype binds the mouse-action to select the window and then
> activate the button.
> ---
> 
> This versions fixes most of the comments raised by Austin's review.
> The one change I didn't make was changing :supertype to 'supertype. In
> principle I agree with Austin but the : form is used for inheritance
> for other notmuch buttons in wash and crypto.
> 
> Best wishes
> 
> Mark
> 
> 
> 
> 
>  emacs/notmuch-crypto.el |5 -
>  emacs/notmuch-lib.el|   15 +++
>  emacs/notmuch-show.el   |4 +++-
>  emacs/notmuch-wash.el   |3 ++-
>  4 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
> index 83e5d37..5233824 100644
> --- a/emacs/notmuch-crypto.el
> +++ b/emacs/notmuch-crypto.el
> @@ -19,6 +19,8 @@
>  ;;
>  ;; Authors: Jameson Rollins 
>  
> +(require 'notmuch-lib)
> +
>  (defcustom notmuch-crypto-process-mime nil
>"Should cryptographic MIME parts be processed?
>  
> @@ -76,7 +78,8 @@ mode."
>  (define-button-type 'notmuch-crypto-status-button-type
>'action (lambda (button) (message (button-get button 'help-echo)))
>'follow-link t
> -  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
> parts.")
> +  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
> parts."
> +  :supertype 'notmuch-button-type)
>  
>  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
>(let* ((status (plist-get sigstatus :status))
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 0407f8a..6836192 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -97,6 +97,21 @@ For example, if you wanted to remove an \"inbox\" tag and 
> add an
>:group 'notmuch-search
>:group 'notmuch-show)
>  
> +;; By default clicking on a button does not select the window
> +;; containing the button (as opposed to clicking on a widget which
> +;; does). This means that the button action is then executed in the
> +;; current selected window which can cause problems if the button
> +;; changes the buffer (e.g., id: links) or moves point.
> +;;
> +;; This provides a button type which overrides mouse-action so that
> +;; the button's window is selected before the action is run. Other
> +;; notmuch buttons can get the same behaviour by inheriting from this
> +;; button type.
> +(define-button-type 'notmuch-button-type
> +  'mouse-action (lambda (button)
> +   (select-window (posn-window (event-start last-input-event)))
> +   (button-activate button)))
> +
>  (defun notmuch-version ()
>"Return a string with the notmuch version number."
>(let ((long-string
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5751d98..059194d 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -469,7 +469,8 @@ message at DEPTH in the current thread."
>'action 'notmuch-show-part-button-default
>'keymap 'notmuch-show-part-button-map
>'follow-link t
> -  'face 'message-mml)
> +  'face 'message-mml
> +  :supertype 'notmuch-button-type)
>  
>  (defvar notmuch-show-part-button-map
>(let ((map (make-sparse-keymap)))
> @@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."
>   ;; Remove the overlay created by goto-address-mode
>   (remove-overlays (first link) (second link) 'goto-address t)
>   (make-text-button (first link) (second link)
> +   :type 'notmuch-button-type
> 'action `(lambda (arg)
>(notmuch-show ,(third link)))
> 'follow-link t
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index d6db4fa..826b6f4 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -115,7 +115,8 @@ lower).")
>  (define-button-type 'notmuch-wash-button-invisibility-toggle-type
>'action 'notmuch-wash-toggle-invisible-action
>'follow-link t
> -  'face 'font-lock-comment-face)
> +  'face 'font-lock-comment-face
> +  :supertype 'notmuch-button-type)
>  
>  (define-button-type 'notmuch-wash-button-citation-toggle-type
>'help-echo "mouse-1, RET: Show citation"


[PATCH] emacs: Disambiguate point placement after hiding message

2013-01-07 Thread Austin Clements
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.
---
 emacs/notmuch-show.el |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..94b4178 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1363,7 +1363,23 @@ effects."
 ;; components.

 (defun notmuch-show-message-visible (props visible-p)
-  (overlay-put (plist-get props :message-overlay) 'invisible (not visible-p))
+  (let ((ov (plist-get props :message-overlay)))
+(overlay-put ov 'invisible (not visible-p))
+(when (not visible-p)
+  ;; 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)))
   (notmuch-show-set-prop :message-visible visible-p props))

 (defun notmuch-show-headers-visible (props visible-p)
-- 
1.7.10.4



[PATCH] emacs: show: make buttons select window

2013-01-07 Thread Austin Clements
Quoth Mark Walters on Jan 07 at  6:24 pm:
> Emacs has two button type objects: widgets (as used for saved searches
> in notmuch-hello) and buttons as used by parts/citations and id links
> in notmuch-show. These two behave subtly differently when clicked with
> the mouse: widgets select the window clicked before running the
> action, buttons do not.
> 
> This patch makes all of these behave the same: clicking always selects
> the clicked window. It does this by defining a notmuch-button-type
> supertype that the other notmuch buttons can inherit from. This
> supertype binds the mouse-action to select the window and then
> activate the button.
> ---
> 
> This is a new patch attempting to do the same as
> id:1355958602-16752-1-git-send-email-markwalters1009 at gmail.com
> 
> This version changes all notmuch buttons to select the appropriate
> window before applying the action. This brings the buttons in line
> with widgets (as used in notmuch hello) and whatever is used for
> http:// links.
> 
> I think that buttons should at least run the action in the clicked
> window: whether point should remain there is less clear. This version
> does leave point there as this is what widgets and links do (but this
> would be easy to change).
> 
> I don't know whether we want to do this for 0.15: the change for id
> links would be nice, the other cases are less important. If preferred
> I can provide a patch fixing that single instance.
> 
> Finally, if anyone who uses the crypto stuff could check that it works
> for crypto buttons that would be nice as I do not have crypto setup.
> 
> Best wishes
> 
> Mark
> 
> 
> 
> 
>  emacs/notmuch-crypto.el |3 ++-
>  emacs/notmuch-lib.el|5 +
>  emacs/notmuch-show.el   |4 +++-
>  emacs/notmuch-wash.el   |3 ++-
>  4 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
> index 83e5d37..173a3e7 100644
> --- a/emacs/notmuch-crypto.el
> +++ b/emacs/notmuch-crypto.el
> @@ -76,7 +76,8 @@ mode."
>  (define-button-type 'notmuch-crypto-status-button-type
>'action (lambda (button) (message (button-get button 'help-echo)))
>'follow-link t
> -  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
> parts.")
> +  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime 
> parts."
> +  :supertype 'notmuch-button-type)

This should be 'supertype for consistency.

Also, notmuch-crypto.el should have a (require 'notmuch-lib) at the
top now.

>  
>  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
>(let* ((status (plist-get sigstatus :status))
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 0407f8a..1573e32 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -97,6 +97,11 @@ For example, if you wanted to remove an \"inbox\" tag and 
> add an
>:group 'notmuch-search
>:group 'notmuch-show)
>  
> +(define-button-type 'notmuch-button-type
> +  'mouse-action (lambda (button)
> +   (select-window (posn-window (event-start last-input-event)))
> +   (button-activate button)))
> +

I think this deserves a comment explaining how buttons behave by
default and the problems this causes both for code (funny results of
buffer changes and point placement) and user experience (not moving
point to the clicked window).

>  (defun notmuch-version ()
>"Return a string with the notmuch version number."
>(let ((long-string
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5751d98..059194d 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -469,7 +469,8 @@ message at DEPTH in the current thread."
>'action 'notmuch-show-part-button-default
>'keymap 'notmuch-show-part-button-map
>'follow-link t
> -  'face 'message-mml)
> +  'face 'message-mml
> +  :supertype 'notmuch-button-type)

'supertype

>  
>  (defvar notmuch-show-part-button-map
>(let ((map (make-sparse-keymap)))
> @@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."
>   ;; Remove the overlay created by goto-address-mode
>   (remove-overlays (first link) (second link) 'goto-address t)
>   (make-text-button (first link) (second link)
> +   :type 'notmuch-button-type

'type

> 'action `(lambda (arg)
>(notmuch-show ,(third link)))
> 'follow-link t
> diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
> index d6db4fa..826b6f4 100644
> --- a/emacs/notmuch-wash.el
> +++ b/emacs/notmuch-wash.el
> @@ -115,7 +115,8 @@ lower).")
>  (define-button-type 'notmuch-wash-button-invisibility-toggle-type
>'action 'notmuch-wash-toggle-invisible-action
>'follow-link t
> -  'face 'font-lock-comment-face)
> +  'face 'font-lock-comment-face
> +  :supertype 'notmuch-button-type)

'supertype

>  
>  (define-button-type 'notmuch-wash-button-citation-toggle-type
>

[PATCH 1/1] fix line breaks in one comment paragraph in generated .notmuch-config file

2013-01-07 Thread Tomi Ollila
On Mon, Jan 07 2013, David Bremner  wrote:

> Tomi Ollila  writes:
>
>> While one comment in generated .notmuch-config file looked good in the
>> source file notmuch-config.c, the generated output was inconsistently
>> wide -- even breaking the 80-column boundary.
>
> pushed, after deleting one character.

Thank you... brown paper bags anyone ?

> d

Tomi


Unicode characters are incorrectly reproduced when forwarding mail

2013-01-07 Thread Albin Stjerna
Tomi Ollila wrote:

> On Sat, Jan 05 2013, Albin Stjerna  wrote:

> > Hi!
> >
> > When forwarding an email containing (what I think is) unicode characters
> > (primarily umlauts), these are incorrectly re-entered as strange escaped
> > characters (? becomes \344, ? becomes \345 and so on). Then, when I try
> > to send the email, I get an error about the message containing
> > unprintable characters.
> >
> > Interestingly enough, this problem does not occur in the headers
> > (Subject, From etc), and the problem does not occur at all when quoting
> > messages via notmuch-reply. Also, it doesn't happen for all email
> > messages, so it might be an issue with the encoding. I think a common
> > denominator for the un-forwardable messages is that they contain no
> > charset= declaration, though they still render just fine.
> >
> > Any help debugging would be greatly appreciated!


> What version of notmuch are you using? There has been some fixes
> in this front done since 0.14 (i.e. currently only available from git)

You were right in your suggestion, the problem is apparently fixed in git 
notmuch. Thanks!


[PATCH] emacs: show: make id links respect window

2013-01-07 Thread Austin Clements
On Wed, 19 Dec 2012, Mark Walters  wrote:
> There is a bug in current notmuch: if you have multiple windows in one
> frame and click an id button link in a show buffer that does not
> contain point then the link is opened in the window containing point.
>
> This reads the mouse event to make sure that the correct window is
> used for the link.

Personally I prefer that point move to the clicked window, as this patch
does.  The fact that it's even possible for point not to move to the
clicked window I find strange.

> ---
>
> I think this is a bug but that could be debated. It is particularly
> easy to trigger with notmuch pick because that uses the split pane
> while focus usually remains in the `pick' pane rather than the `show'
> pane.
>
> The lisp is not pretty but seems to work.
>
> Best wishes
>
> Mark
>
>
>
>
>  emacs/notmuch-show.el |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5751d98..5664ea3 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1077,6 +1077,11 @@ buttons for a corresponding notmuch search."
>   (make-text-button (first link) (second link)
> 'action `(lambda (arg)
>(notmuch-show ,(third link)))
> +   'mouse-action `(lambda (arg)
> +(let* ((event last-input-event)
> +   (window (car (cadr event

Better would be (posn-window (event-start event)).  If you use the
accessors, I don't think the let bindings are really necessary since the
code becomes self-documenting.

> +  (select-window window)
> +  (notmuch-show ,(third link

Would it be better to (button-activate arg) so you don't have to
duplicate the action code?  (Then you also wouldn't need the
quasiquoting and unquoting.)

> 'follow-link t
> 'help-echo "Mouse-1, RET: search for this message"
> 'face goto-address-mail-face)
> -- 
> 1.7.9.1
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v5 0/6] Use Xapian query syntax for batch-tag dump/restore

2013-01-07 Thread Jani Nikula
On Sun, 06 Jan 2013, Austin Clements  wrote:
> This obsoletes
>
>   id:1356936162-2589-1-git-send-email-amdragon at mit.edu
>
> v5 should address all of the comments on v4 except those I
> specifically replied to (via the ML or IRC).  It also adds a new patch
> at the beginning that makes missing message IDs non-fatal in restore,
> like they were in 0.14.  This patch can be pushed separately; it's in
> this series because later tests rely on it.

The series LGMT,
Jani.

>
> The diff from v4 follows.
>
> diff --git a/notmuch-dump.c b/notmuch-dump.c
> index bf01a39..a3244e0 100644
> --- a/notmuch-dump.c
> +++ b/notmuch-dump.c
> @@ -103,6 +103,18 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
> *argv[])
>   message = notmuch_messages_get (messages);
>   message_id = notmuch_message_get_message_id (message);
>  
> + if (output_format == DUMP_FORMAT_BATCH_TAG &&
> + strchr (message_id, '\n')) {
> + /* This will produce a line break in the output, which
> +  * would be difficult to handle in tools.  However, it's
> +  * also impossible to produce an email containing a line
> +  * break in a message ID because of unfolding, so we can
> +  * safely disallow it. */
> + fprintf (stderr, "Warning: skipping message id containing line 
> break: \"%s\"\n", message_id);
> + notmuch_message_destroy (message);
> + continue;
> + }
> +
>   if (output_format == DUMP_FORMAT_SUP) {
>   fprintf (output, "%s (", message_id);
>   }
> @@ -133,19 +145,10 @@ notmuch_dump_command (unused (void *ctx), int argc, 
> char *argv[])
>   if (output_format == DUMP_FORMAT_SUP) {
>   fputs (")\n", output);
>   } else {
> - if (strchr (message_id, '\n')) {
> - /* This will produce a line break in the output, which
> -  * would be difficult to handle in tools.  However,
> -  * it's also impossible to produce an email containing
> -  * a line break in a message ID because of unfolding,
> -  * so we can safely disallow it. */
> - fprintf (stderr, "Error: cannot dump message id containing line 
> break: %s\n", message_id);
> - return 1;
> - }
>   if (make_boolean_term (notmuch, "id", message_id,
>  , _size)) {
> - fprintf (stderr, "Error: failed to quote message id %s\n",
> -  message_id);
> + fprintf (stderr, "Error quoting message id %s: %s\n",
> +  message_id, strerror (errno));
>   return 1;
>   }
>   fprintf (output, " -- %s\n", buffer);
> diff --git a/notmuch-restore.c b/notmuch-restore.c
> index 77a4c27..81d4d98 100644
> --- a/notmuch-restore.c
> +++ b/notmuch-restore.c
> @@ -26,7 +26,8 @@
>  static regex_t regex;
>  
>  /* Non-zero return indicates an error in retrieving the message,
> - * or in applying the tags.
> + * or in applying the tags.  Missing messages are reported, but not
> + * considered errors.
>   */
>  static int
>  tag_message (unused (void *ctx),
> @@ -40,13 +41,17 @@ tag_message (unused (void *ctx),
>  int ret = 0;
>  
>  status = notmuch_database_find_message (notmuch, message_id, );
> -if (status || message == NULL) {
> - fprintf (stderr, "Warning: cannot apply tags to %smessage: %s\n",
> -  message ? "" : "missing ", message_id);
> - if (status)
> - fprintf (stderr, "%s\n", notmuch_status_to_string (status));
> +if (status) {
> + fprintf (stderr, "Error applying tags to message %s: %s\n",
> +  message_id, notmuch_status_to_string (status));
>   return 1;
>  }
> +if (message == NULL) {
> + fprintf (stderr, "Warning: cannot apply tags to missing message: %s\n",
> +  message_id);
> + /* We consider this a non-fatal error. */
> + return 0;
> +}
>  
>  /* In order to detect missing messages, this check/optimization is
>   * intentionally done *after* first finding the message. */
> @@ -222,12 +227,17 @@ notmuch_restore_command (unused (void *ctx), int argc, 
> char *argv[])
>   if (ret == 0) {
>   ret = parse_boolean_term (line_ctx, query_string,
> , );
> - if (ret) {
> - fprintf (stderr, "Warning: cannot parse query: %s\n",
> -  query_string);
> + if (ret && errno == EINVAL) {
> + fprintf (stderr, "Warning: cannot parse query: %s 
> (skipping)\n", query_string);
>   continue;
> + } else if (ret) {
> + /* This is more fatal (e.g., out of memory) */
> + fprintf (stderr, "Error parsing query: %s\n",
> +  strerror (errno));
> + ret = 1;
> + break;
>   } else if (strcmp ("id", 

Re: Unicode characters are incorrectly reproduced when forwarding mail

2013-01-07 Thread Albin Stjerna
Tomi Ollila wrote:

 On Sat, Jan 05 2013, Albin Stjerna albin.stje...@gmail.com wrote:

  Hi!
 
  When forwarding an email containing (what I think is) unicode characters
  (primarily umlauts), these are incorrectly re-entered as strange escaped
  characters (ä becomes \344, å becomes \345 and so on). Then, when I try
  to send the email, I get an error about the message containing
  unprintable characters.
 
  Interestingly enough, this problem does not occur in the headers
  (Subject, From etc), and the problem does not occur at all when quoting
  messages via notmuch-reply. Also, it doesn't happen for all email
  messages, so it might be an issue with the encoding. I think a common
  denominator for the un-forwardable messages is that they contain no
  charset= declaration, though they still render just fine.
 
  Any help debugging would be greatly appreciated!


 What version of notmuch are you using? There has been some fixes
 in this front done since 0.14 (i.e. currently only available from git)

You were right in your suggestion, the problem is apparently fixed in git 
notmuch. Thanks!
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/1] fix line breaks in one comment paragraph in generated .notmuch-config file

2013-01-07 Thread Tomi Ollila
On Mon, Jan 07 2013, David Bremner da...@tethera.net wrote:

 Tomi Ollila tomi.oll...@iki.fi writes:

 While one comment in generated .notmuch-config file looked good in the
 source file notmuch-config.c, the generated output was inconsistently
 wide -- even breaking the 80-column boundary.

 pushed, after deleting one character.

Thank you... brown paper bags anyone ?

 d

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


[PATCH] emacs: show: make buttons select window

2013-01-07 Thread Mark Walters
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
---

This is a new patch attempting to do the same as
id:1355958602-16752-1-git-send-email-markwalters1...@gmail.com

This version changes all notmuch buttons to select the appropriate
window before applying the action. This brings the buttons in line
with widgets (as used in notmuch hello) and whatever is used for
http:// links.

I think that buttons should at least run the action in the clicked
window: whether point should remain there is less clear. This version
does leave point there as this is what widgets and links do (but this
would be easy to change).

I don't know whether we want to do this for 0.15: the change for id
links would be nice, the other cases are less important. If preferred
I can provide a patch fixing that single instance.

Finally, if anyone who uses the crypto stuff could check that it works
for crypto buttons that would be nice as I do not have crypto setup.

Best wishes

Mark




 emacs/notmuch-crypto.el |3 ++-
 emacs/notmuch-lib.el|5 +
 emacs/notmuch-show.el   |4 +++-
 emacs/notmuch-wash.el   |3 ++-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 83e5d37..173a3e7 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -76,7 +76,8 @@ mode.
 (define-button-type 'notmuch-crypto-status-button-type
   'action (lambda (button) (message (button-get button 'help-echo)))
   'follow-link t
-  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
parts.)
+  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
parts.
+  :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0407f8a..1573e32 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -97,6 +97,11 @@ For example, if you wanted to remove an \inbox\ tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)
 
+(define-button-type 'notmuch-button-type
+  'mouse-action (lambda (button)
+ (select-window (posn-window (event-start last-input-event)))
+ (button-activate button)))
+
 (defun notmuch-version ()
   Return a string with the notmuch version number.
   (let ((long-string
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..059194d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -469,7 +469,8 @@ message at DEPTH in the current thread.
   'action 'notmuch-show-part-button-default
   'keymap 'notmuch-show-part-button-map
   'follow-link t
-  'face 'message-mml)
+  'face 'message-mml
+  :supertype 'notmuch-button-type)
 
 (defvar notmuch-show-part-button-map
   (let ((map (make-sparse-keymap)))
@@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search.
;; Remove the overlay created by goto-address-mode
(remove-overlays (first link) (second link) 'goto-address t)
(make-text-button (first link) (second link)
+ :type 'notmuch-button-type
  'action `(lambda (arg)
 (notmuch-show ,(third link)))
  'follow-link t
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d6db4fa..826b6f4 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -115,7 +115,8 @@ lower).)
 (define-button-type 'notmuch-wash-button-invisibility-toggle-type
   'action 'notmuch-wash-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-face
+  :supertype 'notmuch-button-type)
 
 (define-button-type 'notmuch-wash-button-citation-toggle-type
   'help-echo mouse-1, RET: Show citation
-- 
1.7.9.1

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


Re: [Patch v2 2/9] notmuch-tag.c: convert to use tag-utils

2013-01-07 Thread Jani Nikula
On Mon, 07 Jan 2013, da...@tethera.net wrote:
 From: David Bremner brem...@debian.org

 Command line parsing is factored out into a function
 parse_tag_command_line in tag-utils.c.

 There is some duplicated code eliminated in tag_query, and a bunch of
 translation from using the bare tag_op structs to using that tag-utils
 API.
 ---
  notmuch-tag.c |   99 
 -
  tag-util.c|   51 +++--
  tag-util.h|   15 +
  3 files changed, 84 insertions(+), 81 deletions(-)

 diff --git a/notmuch-tag.c b/notmuch-tag.c
 index fc9d43a..8129912 100644
 --- a/notmuch-tag.c
 +++ b/notmuch-tag.c
 @@ -19,6 +19,7 @@
   */
  
  #include notmuch-client.h
 +#include tag-util.h
  #include string-util.h
  
  static volatile sig_atomic_t interrupted;
 @@ -36,14 +37,10 @@ handle_sigint (unused (int sig))
  interrupted = 1;
  }
  
 -typedef struct {
 -const char *tag;
 -notmuch_bool_t remove;
 -} tag_operation_t;
  
  static char *
  _optimize_tag_query (void *ctx, const char *orig_query_string,
 -  const tag_operation_t *tag_ops)
 +  const tag_op_list_t *list)
  {
  /* This is subtler than it looks.  Xapian ignores the '-' operator
   * at the beginning both queries and parenthesized groups and,
 @@ -60,7 +57,7 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  size_t i;
  
  /* Don't optimize if there are no tag changes. */
 -if (tag_ops[0].tag == NULL)
 +if (tag_op_list_size (list) == 0)
   return talloc_strdup (ctx, orig_query_string);
  
  /* Build the new query string */
 @@ -69,17 +66,17 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  else
   query_string = talloc_asprintf (ctx, ( %s ) and (, orig_query_string);
  
 -for (i = 0; tag_ops[i].tag  query_string; i++) {
 +for (i = 0; i  tag_op_list_size (list)  query_string; i++) {
   /* XXX in case of OOM, query_string will be deallocated when
* ctx is, which might be at shutdown */
   if (make_boolean_term (ctx,
 -tag, tag_ops[i].tag,
 +tag, tag_op_list_tag (list, i),
  escaped, escaped_len))
   return NULL;
  
   query_string = talloc_asprintf_append_buffer (
   query_string, %s%s%s, join,
 - tag_ops[i].remove ?  : not ,
 + tag_op_list_isremove (list, i) ?  : not ,
   escaped);
   join =  or ;
  }
 @@ -91,17 +88,15 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  return query_string;
  }
  
 -/* Tag messages matching 'query_string' according to 'tag_ops', which
 - * must be an array of tagging operations terminated with an empty
 - * element. */
 +/* Tag messages matching 'query_string' according to 'tag_ops'
 + */
  static int
  tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
 -tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags)
 +tag_op_list_t *tag_ops, tag_op_flag_t flags)
  {
  notmuch_query_t *query;
  notmuch_messages_t *messages;
  notmuch_message_t *message;
 -int i;
  
  /* Optimize the query so it excludes messages that already have
   * the specified set of tags. */
 @@ -124,21 +119,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, const 
 char *query_string,
notmuch_messages_valid (messages)  ! interrupted;
notmuch_messages_move_to_next (messages)) {
   message = notmuch_messages_get (messages);
 -
 - notmuch_message_freeze (message);
 -
 - for (i = 0; tag_ops[i].tag; i++) {
 - if (tag_ops[i].remove)
 - notmuch_message_remove_tag (message, tag_ops[i].tag);
 - else
 - notmuch_message_add_tag (message, tag_ops[i].tag);
 - }
 -
 - notmuch_message_thaw (message);
 -
 - if (synchronize_flags)
 - notmuch_message_tags_to_maildir_flags (message);
 -
 + tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);

I think we probably want to check for errors and bail out on them
here. It's a functional change, so it belongs in a follow-up patch. We
haven't done it before, but it'll be more important with batch tagging.

BR,
Jani.


   notmuch_message_destroy (message);
  }
  
 @@ -150,15 +131,13 @@ tag_query (void *ctx, notmuch_database_t *notmuch, 
 const char *query_string,
  int
  notmuch_tag_command (void *ctx, int argc, char *argv[])
  {
 -tag_operation_t *tag_ops;
 -int tag_ops_count = 0;
 -char *query_string;
 +tag_op_list_t *tag_ops = NULL;
 +char *query_string = NULL;
  notmuch_config_t *config;
  notmuch_database_t *notmuch;
  struct sigaction action;
 -notmuch_bool_t synchronize_flags;
 -int i;
 -int ret;
 +tag_op_flag_t tag_flags = TAG_FLAG_NONE;
 +int ret = 0;
  
  /* Setup our handler for SIGINT */
  memset (action, 0, 

Re: Xapian-quoting based batch tagging.

2013-01-07 Thread Jani Nikula
On Mon, 07 Jan 2013, da...@tethera.net wrote:
 This is essentially just a rebase of 

  id:1356464567-21779-1-git-send-email-da...@tethera.net

 with some commit-message fixups for 

 [Patch v2 3/9] cli: add support for batch tagging operations to

 as suggested by Jani

The series LGTM,
Jani.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: show: make buttons select window

2013-01-07 Thread Austin Clements
Quoth Mark Walters on Jan 07 at  6:24 pm:
 Emacs has two button type objects: widgets (as used for saved searches
 in notmuch-hello) and buttons as used by parts/citations and id links
 in notmuch-show. These two behave subtly differently when clicked with
 the mouse: widgets select the window clicked before running the
 action, buttons do not.
 
 This patch makes all of these behave the same: clicking always selects
 the clicked window. It does this by defining a notmuch-button-type
 supertype that the other notmuch buttons can inherit from. This
 supertype binds the mouse-action to select the window and then
 activate the button.
 ---
 
 This is a new patch attempting to do the same as
 id:1355958602-16752-1-git-send-email-markwalters1...@gmail.com
 
 This version changes all notmuch buttons to select the appropriate
 window before applying the action. This brings the buttons in line
 with widgets (as used in notmuch hello) and whatever is used for
 http:// links.
 
 I think that buttons should at least run the action in the clicked
 window: whether point should remain there is less clear. This version
 does leave point there as this is what widgets and links do (but this
 would be easy to change).
 
 I don't know whether we want to do this for 0.15: the change for id
 links would be nice, the other cases are less important. If preferred
 I can provide a patch fixing that single instance.
 
 Finally, if anyone who uses the crypto stuff could check that it works
 for crypto buttons that would be nice as I do not have crypto setup.
 
 Best wishes
 
 Mark
 
 
 
 
  emacs/notmuch-crypto.el |3 ++-
  emacs/notmuch-lib.el|5 +
  emacs/notmuch-show.el   |4 +++-
  emacs/notmuch-wash.el   |3 ++-
  4 files changed, 12 insertions(+), 3 deletions(-)
 
 diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
 index 83e5d37..173a3e7 100644
 --- a/emacs/notmuch-crypto.el
 +++ b/emacs/notmuch-crypto.el
 @@ -76,7 +76,8 @@ mode.
  (define-button-type 'notmuch-crypto-status-button-type
'action (lambda (button) (message (button-get button 'help-echo)))
'follow-link t
 -  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
 parts.)
 +  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
 parts.
 +  :supertype 'notmuch-button-type)

This should be 'supertype for consistency.

Also, notmuch-crypto.el should have a (require 'notmuch-lib) at the
top now.

  
  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
(let* ((status (plist-get sigstatus :status))
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index 0407f8a..1573e32 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -97,6 +97,11 @@ For example, if you wanted to remove an \inbox\ tag and 
 add an
:group 'notmuch-search
:group 'notmuch-show)
  
 +(define-button-type 'notmuch-button-type
 +  'mouse-action (lambda (button)
 +   (select-window (posn-window (event-start last-input-event)))
 +   (button-activate button)))
 +

I think this deserves a comment explaining how buttons behave by
default and the problems this causes both for code (funny results of
buffer changes and point placement) and user experience (not moving
point to the clicked window).

  (defun notmuch-version ()
Return a string with the notmuch version number.
(let ((long-string
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 5751d98..059194d 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -469,7 +469,8 @@ message at DEPTH in the current thread.
'action 'notmuch-show-part-button-default
'keymap 'notmuch-show-part-button-map
'follow-link t
 -  'face 'message-mml)
 +  'face 'message-mml
 +  :supertype 'notmuch-button-type)

'supertype

  
  (defvar notmuch-show-part-button-map
(let ((map (make-sparse-keymap)))
 @@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search.
   ;; Remove the overlay created by goto-address-mode
   (remove-overlays (first link) (second link) 'goto-address t)
   (make-text-button (first link) (second link)
 +   :type 'notmuch-button-type

'type

 'action `(lambda (arg)
(notmuch-show ,(third link)))
 'follow-link t
 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
 index d6db4fa..826b6f4 100644
 --- a/emacs/notmuch-wash.el
 +++ b/emacs/notmuch-wash.el
 @@ -115,7 +115,8 @@ lower).)
  (define-button-type 'notmuch-wash-button-invisibility-toggle-type
'action 'notmuch-wash-toggle-invisible-action
'follow-link t
 -  'face 'font-lock-comment-face)
 +  'face 'font-lock-comment-face
 +  :supertype 'notmuch-button-type)

'supertype

  
  (define-button-type 'notmuch-wash-button-citation-toggle-type
'help-echo mouse-1, RET: Show citation
___
notmuch mailing list
notmuch@notmuchmail.org

Re: [Patch v2 2/9] notmuch-tag.c: convert to use tag-utils

2013-01-07 Thread Tomi Ollila
On Mon, Jan 07 2013, Jani Nikula j...@nikula.org wrote:

 On Mon, 07 Jan 2013, da...@tethera.net wrote:
 From: David Bremner brem...@debian.org

 Command line parsing is factored out into a function
 parse_tag_command_line in tag-utils.c.

 There is some duplicated code eliminated in tag_query, and a bunch of
 translation from using the bare tag_op structs to using that tag-utils
 API.
 ---
  notmuch-tag.c |   99 
 -
  tag-util.c|   51 +++--
  tag-util.h|   15 +
  3 files changed, 84 insertions(+), 81 deletions(-)

 diff --git a/notmuch-tag.c b/notmuch-tag.c
 index fc9d43a..8129912 100644
 --- a/notmuch-tag.c
 +++ b/notmuch-tag.c
 @@ -19,6 +19,7 @@
   */
  
  #include notmuch-client.h
 +#include tag-util.h
  #include string-util.h
  
  static volatile sig_atomic_t interrupted;
 @@ -36,14 +37,10 @@ handle_sigint (unused (int sig))
  interrupted = 1;
  }
  
 -typedef struct {
 -const char *tag;
 -notmuch_bool_t remove;
 -} tag_operation_t;
  
  static char *
  _optimize_tag_query (void *ctx, const char *orig_query_string,
 - const tag_operation_t *tag_ops)
 + const tag_op_list_t *list)
  {
  /* This is subtler than it looks.  Xapian ignores the '-' operator
   * at the beginning both queries and parenthesized groups and,
 @@ -60,7 +57,7 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  size_t i;
  
  /* Don't optimize if there are no tag changes. */
 -if (tag_ops[0].tag == NULL)
 +if (tag_op_list_size (list) == 0)
  return talloc_strdup (ctx, orig_query_string);
  
  /* Build the new query string */
 @@ -69,17 +66,17 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  else
  query_string = talloc_asprintf (ctx, ( %s ) and (, orig_query_string);
  
 -for (i = 0; tag_ops[i].tag  query_string; i++) {
 +for (i = 0; i  tag_op_list_size (list)  query_string; i++) {
  /* XXX in case of OOM, query_string will be deallocated when
   * ctx is, which might be at shutdown */
  if (make_boolean_term (ctx,
 -   tag, tag_ops[i].tag,
 +   tag, tag_op_list_tag (list, i),
 escaped, escaped_len))
  return NULL;
  
  query_string = talloc_asprintf_append_buffer (
  query_string, %s%s%s, join,
 -tag_ops[i].remove ?  : not ,
 +tag_op_list_isremove (list, i) ?  : not ,
  escaped);
  join =  or ;
  }
 @@ -91,17 +88,15 @@ _optimize_tag_query (void *ctx, const char 
 *orig_query_string,
  return query_string;
  }
  
 -/* Tag messages matching 'query_string' according to 'tag_ops', which
 - * must be an array of tagging operations terminated with an empty
 - * element. */
 +/* Tag messages matching 'query_string' according to 'tag_ops'
 + */
  static int
  tag_query (void *ctx, notmuch_database_t *notmuch, const char *query_string,
 -   tag_operation_t *tag_ops, notmuch_bool_t synchronize_flags)
 +   tag_op_list_t *tag_ops, tag_op_flag_t flags)
  {
  notmuch_query_t *query;
  notmuch_messages_t *messages;
  notmuch_message_t *message;
 -int i;
  
  /* Optimize the query so it excludes messages that already have
   * the specified set of tags. */
 @@ -124,21 +119,7 @@ tag_query (void *ctx, notmuch_database_t *notmuch, 
 const char *query_string,
   notmuch_messages_valid (messages)  ! interrupted;
   notmuch_messages_move_to_next (messages)) {
  message = notmuch_messages_get (messages);
 -
 -notmuch_message_freeze (message);
 -
 -for (i = 0; tag_ops[i].tag; i++) {
 -if (tag_ops[i].remove)
 -notmuch_message_remove_tag (message, tag_ops[i].tag);
 -else
 -notmuch_message_add_tag (message, tag_ops[i].tag);
 -}
 -
 -notmuch_message_thaw (message);
 -
 -if (synchronize_flags)
 -notmuch_message_tags_to_maildir_flags (message);
 -
 +tag_op_list_apply (message, tag_ops, flags | TAG_FLAG_PRE_OPTIMIZED);

 I think we probably want to check for errors and bail out on them
 here. It's a functional change, so it belongs in a follow-up patch. We
 haven't done it before, but it'll be more important with batch tagging.


I marked this message as notmuch::bug so it doesn't get forgotten.

Now there is this lengthy message shown in nmbug status page with subject
Re: [Patch v2 2/9] notmuch-tag.c: convert to use tag-utils and Jani's 
name on it ;) 

I guess we can expect everyone checking nmbug page regularly for messages
with their name :D

 BR,
 Jani.


Thanks,

Tomi



  notmuch_message_destroy (message);
  }
  
 @@ -150,15 +131,13 @@ tag_query (void *ctx, notmuch_database_t *notmuch, 
 const char *query_string,
  int
  notmuch_tag_command (void *ctx, int argc, char *argv[])
  {
 -tag_operation_t *tag_ops;
 -int tag_ops_count = 0;
 -char *query_string;
 + 

[PATCH] emacs: Disambiguate point placement after hiding message

2013-01-07 Thread Austin Clements
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.
---
 emacs/notmuch-show.el |   18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..94b4178 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1363,7 +1363,23 @@ effects.
 ;; components.
 
 (defun notmuch-show-message-visible (props visible-p)
-  (overlay-put (plist-get props :message-overlay) 'invisible (not visible-p))
+  (let ((ov (plist-get props :message-overlay)))
+(overlay-put ov 'invisible (not visible-p))
+(when (not visible-p)
+  ;; 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)))
   (notmuch-show-set-prop :message-visible visible-p props))
 
 (defun notmuch-show-headers-visible (props visible-p)
-- 
1.7.10.4

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


[PATCH v2] emacs: show: make buttons select window

2013-01-07 Thread Mark Walters
Emacs has two button type objects: widgets (as used for saved searches
in notmuch-hello) and buttons as used by parts/citations and id links
in notmuch-show. These two behave subtly differently when clicked with
the mouse: widgets select the window clicked before running the
action, buttons do not.

This patch makes all of these behave the same: clicking always selects
the clicked window. It does this by defining a notmuch-button-type
supertype that the other notmuch buttons can inherit from. This
supertype binds the mouse-action to select the window and then
activate the button.
---

This versions fixes most of the comments raised by Austin's review.
The one change I didn't make was changing :supertype to 'supertype. In
principle I agree with Austin but the : form is used for inheritance
for other notmuch buttons in wash and crypto.

Best wishes

Mark




 emacs/notmuch-crypto.el |5 -
 emacs/notmuch-lib.el|   15 +++
 emacs/notmuch-show.el   |4 +++-
 emacs/notmuch-wash.el   |3 ++-
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 83e5d37..5233824 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -19,6 +19,8 @@
 ;;
 ;; Authors: Jameson Rollins jroll...@finestructure.net
 
+(require 'notmuch-lib)
+
 (defcustom notmuch-crypto-process-mime nil
   Should cryptographic MIME parts be processed?
 
@@ -76,7 +78,8 @@ mode.
 (define-button-type 'notmuch-crypto-status-button-type
   'action (lambda (button) (message (button-get button 'help-echo)))
   'follow-link t
-  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
parts.)
+  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
parts.
+  :supertype 'notmuch-button-type)
 
 (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
   (let* ((status (plist-get sigstatus :status))
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 0407f8a..6836192 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -97,6 +97,21 @@ For example, if you wanted to remove an \inbox\ tag and 
add an
   :group 'notmuch-search
   :group 'notmuch-show)
 
+;; By default clicking on a button does not select the window
+;; containing the button (as opposed to clicking on a widget which
+;; does). This means that the button action is then executed in the
+;; current selected window which can cause problems if the button
+;; changes the buffer (e.g., id: links) or moves point.
+;;
+;; This provides a button type which overrides mouse-action so that
+;; the button's window is selected before the action is run. Other
+;; notmuch buttons can get the same behaviour by inheriting from this
+;; button type.
+(define-button-type 'notmuch-button-type
+  'mouse-action (lambda (button)
+ (select-window (posn-window (event-start last-input-event)))
+ (button-activate button)))
+
 (defun notmuch-version ()
   Return a string with the notmuch version number.
   (let ((long-string
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..059194d 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -469,7 +469,8 @@ message at DEPTH in the current thread.
   'action 'notmuch-show-part-button-default
   'keymap 'notmuch-show-part-button-map
   'follow-link t
-  'face 'message-mml)
+  'face 'message-mml
+  :supertype 'notmuch-button-type)
 
 (defvar notmuch-show-part-button-map
   (let ((map (make-sparse-keymap)))
@@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search.
;; Remove the overlay created by goto-address-mode
(remove-overlays (first link) (second link) 'goto-address t)
(make-text-button (first link) (second link)
+ :type 'notmuch-button-type
  'action `(lambda (arg)
 (notmuch-show ,(third link)))
  'follow-link t
diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index d6db4fa..826b6f4 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -115,7 +115,8 @@ lower).)
 (define-button-type 'notmuch-wash-button-invisibility-toggle-type
   'action 'notmuch-wash-toggle-invisible-action
   'follow-link t
-  'face 'font-lock-comment-face)
+  'face 'font-lock-comment-face
+  :supertype 'notmuch-button-type)
 
 (define-button-type 'notmuch-wash-button-citation-toggle-type
   'help-echo mouse-1, RET: Show citation
-- 
1.7.9.1

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


Re: [PATCH v2] emacs: show: make buttons select window

2013-01-07 Thread Austin Clements
LGTM.

Quoth Mark Walters on Jan 07 at  9:07 pm:
 Emacs has two button type objects: widgets (as used for saved searches
 in notmuch-hello) and buttons as used by parts/citations and id links
 in notmuch-show. These two behave subtly differently when clicked with
 the mouse: widgets select the window clicked before running the
 action, buttons do not.
 
 This patch makes all of these behave the same: clicking always selects
 the clicked window. It does this by defining a notmuch-button-type
 supertype that the other notmuch buttons can inherit from. This
 supertype binds the mouse-action to select the window and then
 activate the button.
 ---
 
 This versions fixes most of the comments raised by Austin's review.
 The one change I didn't make was changing :supertype to 'supertype. In
 principle I agree with Austin but the : form is used for inheritance
 for other notmuch buttons in wash and crypto.
 
 Best wishes
 
 Mark
 
 
 
 
  emacs/notmuch-crypto.el |5 -
  emacs/notmuch-lib.el|   15 +++
  emacs/notmuch-show.el   |4 +++-
  emacs/notmuch-wash.el   |3 ++-
  4 files changed, 24 insertions(+), 3 deletions(-)
 
 diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
 index 83e5d37..5233824 100644
 --- a/emacs/notmuch-crypto.el
 +++ b/emacs/notmuch-crypto.el
 @@ -19,6 +19,8 @@
  ;;
  ;; Authors: Jameson Rollins jroll...@finestructure.net
  
 +(require 'notmuch-lib)
 +
  (defcustom notmuch-crypto-process-mime nil
Should cryptographic MIME parts be processed?
  
 @@ -76,7 +78,8 @@ mode.
  (define-button-type 'notmuch-crypto-status-button-type
'action (lambda (button) (message (button-get button 'help-echo)))
'follow-link t
 -  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
 parts.)
 +  'help-echo Set notmuch-crypto-process-mime to process cryptographic mime 
 parts.
 +  :supertype 'notmuch-button-type)
  
  (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)
(let* ((status (plist-get sigstatus :status))
 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
 index 0407f8a..6836192 100644
 --- a/emacs/notmuch-lib.el
 +++ b/emacs/notmuch-lib.el
 @@ -97,6 +97,21 @@ For example, if you wanted to remove an \inbox\ tag and 
 add an
:group 'notmuch-search
:group 'notmuch-show)
  
 +;; By default clicking on a button does not select the window
 +;; containing the button (as opposed to clicking on a widget which
 +;; does). This means that the button action is then executed in the
 +;; current selected window which can cause problems if the button
 +;; changes the buffer (e.g., id: links) or moves point.
 +;;
 +;; This provides a button type which overrides mouse-action so that
 +;; the button's window is selected before the action is run. Other
 +;; notmuch buttons can get the same behaviour by inheriting from this
 +;; button type.
 +(define-button-type 'notmuch-button-type
 +  'mouse-action (lambda (button)
 +   (select-window (posn-window (event-start last-input-event)))
 +   (button-activate button)))
 +
  (defun notmuch-version ()
Return a string with the notmuch version number.
(let ((long-string
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 5751d98..059194d 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -469,7 +469,8 @@ message at DEPTH in the current thread.
'action 'notmuch-show-part-button-default
'keymap 'notmuch-show-part-button-map
'follow-link t
 -  'face 'message-mml)
 +  'face 'message-mml
 +  :supertype 'notmuch-button-type)
  
  (defvar notmuch-show-part-button-map
(let ((map (make-sparse-keymap)))
 @@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search.
   ;; Remove the overlay created by goto-address-mode
   (remove-overlays (first link) (second link) 'goto-address t)
   (make-text-button (first link) (second link)
 +   :type 'notmuch-button-type
 'action `(lambda (arg)
(notmuch-show ,(third link)))
 'follow-link t
 diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
 index d6db4fa..826b6f4 100644
 --- a/emacs/notmuch-wash.el
 +++ b/emacs/notmuch-wash.el
 @@ -115,7 +115,8 @@ lower).)
  (define-button-type 'notmuch-wash-button-invisibility-toggle-type
'action 'notmuch-wash-toggle-invisible-action
'follow-link t
 -  'face 'font-lock-comment-face)
 +  'face 'font-lock-comment-face
 +  :supertype 'notmuch-button-type)
  
  (define-button-type 'notmuch-wash-button-citation-toggle-type
'help-echo mouse-1, RET: Show citation
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread Austin Clements
Xapian doesn't consider :abc to be a prefixed term.  This makes
parse_boolean_term similarly reject queries with an empty prefix.
---
 util/string-util.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/string-util.c b/util/string-util.c
index aba9aa8..a5622d7 100644
--- a/util/string-util.c
+++ b/util/string-util.c
@@ -127,7 +127,7 @@ parse_boolean_term (void *ctx, const char *str,
 /* Parse prefix */
 str = skip_space (str);
 const char *pos = strchr (str, ':');
-if (! pos)
+if (! pos || pos == str)
goto FAIL;
 *prefix_out = talloc_strndup (ctx, str, pos - str);
 if (! *prefix_out) {
-- 
1.7.10.4

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


Re: [PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread Jani Nikula
On Mon, 07 Jan 2013, Austin Clements amdra...@mit.edu wrote:
 Xapian doesn't consider :abc to be a prefixed term.  This makes
 parse_boolean_term similarly reject queries with an empty prefix.

LGTM,
Jani.

 ---
  util/string-util.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/util/string-util.c b/util/string-util.c
 index aba9aa8..a5622d7 100644
 --- a/util/string-util.c
 +++ b/util/string-util.c
 @@ -127,7 +127,7 @@ parse_boolean_term (void *ctx, const char *str,
  /* Parse prefix */
  str = skip_space (str);
  const char *pos = strchr (str, ':');
 -if (! pos)
 +if (! pos || pos == str)
   goto FAIL;
  *prefix_out = talloc_strndup (ctx, str, pos - str);
  if (! *prefix_out) {
 -- 
 1.7.10.4
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements amdra...@mit.edu writes:

 Xapian doesn't consider :abc to be a prefixed term.  This makes
 parse_boolean_term similarly reject queries with an empty prefix.

Looks OK to me.

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


Re: Xapian-quoting based batch tagging.

2013-01-07 Thread David Bremner
da...@tethera.net writes:

 This is essentially just a rebase of 

  id:1356464567-21779-1-git-send-email-da...@tethera.net

 with some commit-message fixups for 

 [Patch v2 3/9] cli: add support for batch tagging operations to

pushed, with one blank line deleted, and one plural corrected, per Tomi
on IRC.

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


Re: [PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements amdra...@mit.edu writes:

 Xapian doesn't consider :abc to be a prefixed term.  This makes
 parse_boolean_term similarly reject queries with an empty prefix.
 ---

pushed.

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


notmuch 0.15 release in progress

2013-01-07 Thread David Bremner

We frozen, although so far there is no divergence between release and
master. I took the liberty of pushing two tiny patches updating the
version(s) and the corresponding debian changelog.

Pragmatically what this means is that if you want something to go into
0.15, you need to push for that, and do it pretty soon.  

We also need need a few NEWS items, not least for the new dump/restore
and batch tagging features.

d


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


Re: [PATCH] string-util: Disallow empty prefixes in parse_boolean_term

2013-01-07 Thread David Bremner
Austin Clements amdra...@mit.edu writes:

 Xapian doesn't consider :abc to be a prefixed term.  This makes
 parse_boolean_term similarly reject queries with an empty prefix.
 ---

pushed.

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