[PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-19 Thread David Edmondson
On Sat, Jan 17 2015, David Bremner wrote:
> No attempt is made to optimize anything here, just drop in the
> new command.
> ---
> In a few subjective tests, this seems quite a bit faster than
> the version based on notmuch-show

The changes look fine to me.

> emacs/notmuch-address.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index 9f6711b..de0b991 100644
> --- a/emacs/notmuch-address.el
> +++ b/emacs/notmuch-address.el
> @@ -188,8 +188,8 @@ called when harvesting finishes."
>(query (if filter-query
>   (format "(%s) and (%s)" from-me-query filter-query)
> from-me-query))
> -  (args `("show" "--format=sexp" "--format-version=2"
> -  "--body=false" "--entire-thread=false" ,query)))
> +  (args `("address" "--format=sexp" "--format-version=2"
> +  ,query)))
>  (if synchronous
>   (notmuch-query-map-threads 'notmuch-address-harvest-msg
>  (apply 'notmuch-call-notmuch-sexp args))
> -- 
> 2.1.4


Re: [PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-19 Thread David Edmondson
On Sat, Jan 17 2015, David Bremner wrote:
> No attempt is made to optimize anything here, just drop in the
> new command.
> ---
> In a few subjective tests, this seems quite a bit faster than
> the version based on notmuch-show

The changes look fine to me.

> emacs/notmuch-address.el | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
> index 9f6711b..de0b991 100644
> --- a/emacs/notmuch-address.el
> +++ b/emacs/notmuch-address.el
> @@ -188,8 +188,8 @@ called when harvesting finishes."
>(query (if filter-query
>   (format "(%s) and (%s)" from-me-query filter-query)
> from-me-query))
> -  (args `("show" "--format=sexp" "--format-version=2"
> -  "--body=false" "--entire-thread=false" ,query)))
> +  (args `("address" "--format=sexp" "--format-version=2"
> +  ,query)))
>  (if synchronous
>   (notmuch-query-map-threads 'notmuch-address-harvest-msg
>  (apply 'notmuch-call-notmuch-sexp args))
> -- 
> 2.1.4
___
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-17 Thread David Bremner
No attempt is made to optimize anything here, just drop in the new
command. In particular the use of --output=recipients is known to be
slower than --output=senders, but it fit the existing logic better.
---
Let us never speak of the parent message again.
 emacs/notmuch-address.el | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 9f6711b..d54a8bb 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -20,7 +20,6 @@
 ;; Authors: David Edmondson 

 (require 'message)
-(require 'notmuch-query)
 (require 'notmuch-parser)

 ;;
@@ -148,21 +147,12 @@ external commands."
   (not (file-directory-p bin
  (throw 'found-command bin

-(defun notmuch-address-harvest-msg (msg)
-  (let* ((headers (plist-get msg :headers))
-(to (ignore-errors (mail-extract-address-components (plist-get headers 
:To) t)))
-(cc (ignore-errors (mail-extract-address-components (plist-get headers 
:Cc) t)))
-(bcc (ignore-errors (mail-extract-address-components (plist-get 
headers :Bcc) t
-(mapc (lambda (parts)
-   (let* ((name (car parts))
-  (email (cadr parts))
-  (entry (if name (format "%s <%s>" name email) email)))
- (puthash entry t notmuch-address-completions)))
- (append to cc bcc))
-nil))
+(defun notmuch-address-harvest-addr (result)
+  (let ((name-addr (plist-get result :name-addr)))
+(puthash name-addr t notmuch-address-completions)))

 (defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-query-map-threads 'notmuch-address-harvest-msg (list obj)))
+  (notmuch-address-harvest-addr obj))

 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
@@ -188,10 +178,11 @@ called when harvesting finishes."
 (query (if filter-query
(format "(%s) and (%s)" from-me-query filter-query)
  from-me-query))
-(args `("show" "--format=sexp" "--format-version=2"
-"--body=false" "--entire-thread=false" ,query)))
+(args `("address" "--format=sexp" "--format-version=2"
+"--output=recipients"
+,query)))
 (if synchronous
-   (notmuch-query-map-threads 'notmuch-address-harvest-msg
+   (mapc #'notmuch-address-harvest-addr
   (apply 'notmuch-call-notmuch-sexp args))
   ;; Asynchronous
   (when notmuch-address-harvest-proc
-- 
2.1.4



[PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-17 Thread David Bremner
No attempt is made to optimize anything here, just drop in the
new command.
---
In a few subjective tests, this seems quite a bit faster than
the version based on notmuch-show

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

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 9f6711b..de0b991 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -188,8 +188,8 @@ called when harvesting finishes."
 (query (if filter-query
(format "(%s) and (%s)" from-me-query filter-query)
  from-me-query))
-(args `("show" "--format=sexp" "--format-version=2"
-"--body=false" "--entire-thread=false" ,query)))
+(args `("address" "--format=sexp" "--format-version=2"
+,query)))
 (if synchronous
(notmuch-query-map-threads 'notmuch-address-harvest-msg
   (apply 'notmuch-call-notmuch-sexp args))
-- 
2.1.4



[PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-17 Thread David Bremner
No attempt is made to optimize anything here, just drop in the new
command. In particular the use of --output=recipients is known to be
slower than --output=senders, but it fit the existing logic better.
---
Let us never speak of the parent message again.
 emacs/notmuch-address.el | 25 -
 1 file changed, 8 insertions(+), 17 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 9f6711b..d54a8bb 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -20,7 +20,6 @@
 ;; Authors: David Edmondson 
 
 (require 'message)
-(require 'notmuch-query)
 (require 'notmuch-parser)
 
 ;;
@@ -148,21 +147,12 @@ external commands."
   (not (file-directory-p bin
  (throw 'found-command bin
 
-(defun notmuch-address-harvest-msg (msg)
-  (let* ((headers (plist-get msg :headers))
-(to (ignore-errors (mail-extract-address-components (plist-get headers 
:To) t)))
-(cc (ignore-errors (mail-extract-address-components (plist-get headers 
:Cc) t)))
-(bcc (ignore-errors (mail-extract-address-components (plist-get 
headers :Bcc) t
-(mapc (lambda (parts)
-   (let* ((name (car parts))
-  (email (cadr parts))
-  (entry (if name (format "%s <%s>" name email) email)))
- (puthash entry t notmuch-address-completions)))
- (append to cc bcc))
-nil))
+(defun notmuch-address-harvest-addr (result)
+  (let ((name-addr (plist-get result :name-addr)))
+(puthash name-addr t notmuch-address-completions)))
 
 (defun notmuch-address-harvest-handle-result (obj)
-  (notmuch-query-map-threads 'notmuch-address-harvest-msg (list obj)))
+  (notmuch-address-harvest-addr obj))
 
 (defun notmuch-address-harvest-filter (proc string)
   (when (buffer-live-p (process-buffer proc))
@@ -188,10 +178,11 @@ called when harvesting finishes."
 (query (if filter-query
(format "(%s) and (%s)" from-me-query filter-query)
  from-me-query))
-(args `("show" "--format=sexp" "--format-version=2"
-"--body=false" "--entire-thread=false" ,query)))
+(args `("address" "--format=sexp" "--format-version=2"
+"--output=recipients"
+,query)))
 (if synchronous
-   (notmuch-query-map-threads 'notmuch-address-harvest-msg
+   (mapc #'notmuch-address-harvest-addr
   (apply 'notmuch-call-notmuch-sexp args))
   ;; Asynchronous
   (when notmuch-address-harvest-proc
-- 
2.1.4

___
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] emacs: convert notmuch-address-harvester to use notmuch-address

2015-01-17 Thread David Bremner
No attempt is made to optimize anything here, just drop in the
new command.
---
In a few subjective tests, this seems quite a bit faster than
the version based on notmuch-show

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

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 9f6711b..de0b991 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -188,8 +188,8 @@ called when harvesting finishes."
 (query (if filter-query
(format "(%s) and (%s)" from-me-query filter-query)
  from-me-query))
-(args `("show" "--format=sexp" "--format-version=2"
-"--body=false" "--entire-thread=false" ,query)))
+(args `("address" "--format=sexp" "--format-version=2"
+,query)))
 (if synchronous
(notmuch-query-map-threads 'notmuch-address-harvest-msg
   (apply 'notmuch-call-notmuch-sexp args))
-- 
2.1.4

___
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch