Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2013-04-06 Thread David Bremner
David Bremner da...@tethera.net writes:

 Daniel Bergey ber...@alum.mit.edu writes:

 From a show buffer, notmuch-bbdb/snarf-from imports the sender into
 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
 contacts are reported in the minibuffer / Messages buffer.

 Both functions use the BBDB parser to recognize email address formats.

 Pushed, 

 d

And reverted. It was causing a build failure.

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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2013-03-31 Thread Daniel Bergey
From fbaf5c568876a6f1e3d8c02446bd83331b6325f0 Mon Sep 17 00:00:00 2001
From: Daniel Bergey ber...@alum.mit.edu
Date: Thu, 26 Jul 2012 15:44:01 -0400
Subject: [PATCH] emacs: functions to import sender or recipients into BBDB

From a show buffer, notmuch-bbdb/snarf-from imports the sender into
bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
contacts are reported in the minibuffer / Messages buffer.

Both functions use the BBDB parser to recognize email address formats.
---
This differs from the last version of the patch only in whitespace.  In
 addition to changes pointed out by Tomi Ollila, I fixed a ')' on a line
 alone, and aligned the lines of notmuch-bbdb/header-by-name.

I've been using this code (prior to whitespace changes) for a month and
 a half, as far as testing goes.

I wonder if I can get whitespace-mode to warn me about double-spacing
 emacs/notmuch-address.el |   41 +
 1 file changed, 41 insertions(+)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2bf762b..32c8490 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -96,6 +96,47 @@ line.
 (when (notmuch-address-locate-command notmuch-address-command)
   (notmuch-address-message-insinuate))
 
+;; functions to add sender / recipients to BBDB
+
+(defun notmuch-bbdb/snarf-headers (headers)
+  ;; Helper function to avoid code duplication in the two below
+  ;; headers should have the same format as bbdb-get-addresses-headers
+
+  ;; bbdb-get-addresses reads these
+  ;; Ugh, pass-by-global
+  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))
+   (bbdb-get-addresses-headers headers) ; headers to read
+   (bbdb-gag-messages t)) ; suppress m/n processed message)
+(bbdb-update-records addrs t t))
+
+  (defun notmuch-bbdb/snarf-from ()
+Import the sender of the current message into BBDB
+(interactive)
+(notmuch-bbdb/snarf-headers
+ (list (assoc 'authors bbdb-get-addresses-headers
+
+(defun notmuch-bbdb/snarf-to ()
+  Import all recipients of the current message into BBDB
+  (interactive)
+  (notmuch-bbdb/snarf-headers
+   (list (assoc 'recipients bbdb-get-addresses-headers
+
+(defvar notmuch-bbdb/header-by-name
+  ;; both are case sensitive
+  '( (From . :From)
+ (To . :To)
+ (CC . :Cc)
+ (BCC . :Bcc)
+ (Resent-From . nil)
+ (Reply-To . nil)
+ (Resent-To . nil)
+ (Resent-CC . nil))
+  Alist for dispatching header symbols as used by notmuch-show-get-header
+from strings as used by bbdb-get-addresses)
+
+(defun notmuch-bbdb/get-header-content (name)
+  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name
+
 ;;
 
 (provide 'notmuch-address)
-- 
1.7.10.4

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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2013-03-31 Thread Tomi Ollila
On Sun, Mar 31 2013, Daniel Bergey wrote:

From fbaf5c568876a6f1e3d8c02446bd83331b6325f0 Mon Sep 17 00:00:00 2001
 From: Daniel Bergey ber...@alum.mit.edu
 Date: Thu, 26 Jul 2012 15:44:01 -0400
 Subject: [PATCH] emacs: functions to import sender or recipients into BBDB

From a show buffer, notmuch-bbdb/snarf-from imports the sender into
 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
 contacts are reported in the minibuffer / Messages buffer.

 Both functions use the BBDB parser to recognize email address formats.
 ---

LGTM, although git commit --amend is needed after git am to clean 
the junk in commit message (just deleting content).

Tomi

 This differs from the last version of the patch only in whitespace.  In
  addition to changes pointed out by Tomi Ollila, I fixed a ')' on a line
  alone, and aligned the lines of notmuch-bbdb/header-by-name.

 I've been using this code (prior to whitespace changes) for a month and
  a half, as far as testing goes.

 I wonder if I can get whitespace-mode to warn me about double-spacing
  emacs/notmuch-address.el |   41 +
  1 file changed, 41 insertions(+)

 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
 index 2bf762b..32c8490 100644
 --- a/emacs/notmuch-address.el
 +++ b/emacs/notmuch-address.el
 @@ -96,6 +96,47 @@ line.
  (when (notmuch-address-locate-command notmuch-address-command)
(notmuch-address-message-insinuate))
  
 +;; functions to add sender / recipients to BBDB
 +
 +(defun notmuch-bbdb/snarf-headers (headers)
 +  ;; Helper function to avoid code duplication in the two below
 +  ;; headers should have the same format as bbdb-get-addresses-headers
 +
 +  ;; bbdb-get-addresses reads these
 +  ;; Ugh, pass-by-global
 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))
 + (bbdb-get-addresses-headers headers) ; headers to read
 + (bbdb-gag-messages t)) ; suppress m/n processed message)
 +(bbdb-update-records addrs t t))
 +
 +  (defun notmuch-bbdb/snarf-from ()
 +Import the sender of the current message into BBDB
 +(interactive)
 +(notmuch-bbdb/snarf-headers
 + (list (assoc 'authors bbdb-get-addresses-headers
 +
 +(defun notmuch-bbdb/snarf-to ()
 +  Import all recipients of the current message into BBDB
 +  (interactive)
 +  (notmuch-bbdb/snarf-headers
 +   (list (assoc 'recipients bbdb-get-addresses-headers
 +
 +(defvar notmuch-bbdb/header-by-name
 +  ;; both are case sensitive
 +  '( (From . :From)
 + (To . :To)
 + (CC . :Cc)
 + (BCC . :Bcc)
 + (Resent-From . nil)
 + (Reply-To . nil)
 + (Resent-To . nil)
 + (Resent-CC . nil))
 +  Alist for dispatching header symbols as used by notmuch-show-get-header
 +from strings as used by bbdb-get-addresses)
 +
 +(defun notmuch-bbdb/get-header-content (name)
 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name
 +
  ;;
  
  (provide 'notmuch-address)
 -- 
 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: functions to import sender or recipient into BBDB

2013-02-18 Thread Tomi Ollila
On Thu, Feb 07 2013, Daniel Bergey wrote:

From a show buffer, notmuch-bbdb/snarf-from imports the sender into
 bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
 concacts are reported in the minibuffer / Messages buffer.

 Both functions use the BBDB parser to recognize email address formats.
 ---
 Following discussion upthread, I put everything in notmuch-address.  I
 renamed the functions to put notmuch before bbdb.  And I replaced the
 horrid comma-splitting from my first version with the functions BBDB
 provides for parsing email headers.

 It looks as though Reply-To is not exposed in the :headers plist.  I
 assume the Resent-* headers are not, either.  Therefore none of these
 are imported (nil entries in notmuch-bbdb/header-by-name).  They would be
 easy to add if the plist is expanded.

 Thanks, and sorry it's taken me so long to get back to this patch.

From my understanding the code looks pretty good; I have only some
whitespace consistency things that jist briefly passes the threshold
to mention -- comments inline.

But before doing a potential cleanup patch the users of notmuch-bbdb
please test and comment

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

 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
 index 2bf762b..8d5f727 100644
 --- a/emacs/notmuch-address.el
 +++ b/emacs/notmuch-address.el
 @@ -98,4 +98,47 @@ line.
  
  ;;

This ';;' used to be 3rd last line in notmuch-address.el. 
Running 'tail -n 5 emacs/*.el' reveals that it is (somewhat) consistent
to use it as separator between code above and (provide 'notmuch-...)
that follows. 

 +;; functions to add sender / recipients to BBDB
 +
 +(defun notmuch-bbdb/snarf-headers (headers)
 +  ;; Helper function to avoid code duplication in the two below
 +  ;; headers should have the same format as bbdb-get-addresses-headers
 +
 +  ;; bbdb-get-addresses reads these
 +  ;; Ugh, pass-by-global
 +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))
 +(bbdb-get-addresses-headers headers) ; headers to read
 +(bbdb-gag-messages t) ; suppress m/n processed message
 +)
 +(bbdb-update-records addrs t t)))
 +
 +(defun notmuch-bbdb/snarf-from ()
 +  Import the sender of the current message into BBDB
 +  (interactive)
 +  (notmuch-bbdb/snarf-headers
 +   (list  (assoc 'authors bbdb-get-addresses-headers

Two spaces above.

 +
 +(defun notmuch-bbdb/snarf-to ()
 +  Import all recipients of the current message into BBDB
 +  (interactive)
 +  (notmuch-bbdb/snarf-headers
 +   (list  (assoc 'recipients bbdb-get-addresses-headers

Ditto.

 +
 +(defvar notmuch-bbdb/header-by-name
 +  ;; both are case sensitive
 +  '( (From . :From)
 + (To . :To)
 + (CC . :Cc)
 + (BCC . :Bcc)
 + (Resent-From . nil)
 + (Reply-To . nil)
 + (Resent-To . nil)
 + (Resent-CC . nil))
 +  Alist for dispatching header symbols as used by notmuch-show-get-header
 +from strings as used by bbdb-get-addresses)
 +
 +(defun notmuch-bbdb/get-header-content (name)
 +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name
 +
 +

2 empty lines --- somewhat consistent with notmuch-lib.el ... but
not with anything else ;D

  (provide 'notmuch-address)
 -- 
 1.7.10.4
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2013-02-07 Thread Daniel Bergey
From a show buffer, notmuch-bbdb/snarf-from imports the sender into
bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported
concacts are reported in the minibuffer / Messages buffer.

Both functions use the BBDB parser to recognize email address formats.
---
Following discussion upthread, I put everything in notmuch-address.  I
renamed the functions to put notmuch before bbdb.  And I replaced the
horrid comma-splitting from my first version with the functions BBDB
provides for parsing email headers.

It looks as though Reply-To is not exposed in the :headers plist.  I
assume the Resent-* headers are not, either.  Therefore none of these
are imported (nil entries in notmuch-bbdb/header-by-name).  They would be
easy to add if the plist is expanded.

Thanks, and sorry it's taken me so long to get back to this patch.

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

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index 2bf762b..8d5f727 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -98,4 +98,47 @@ line.
 
 ;;
 
+;; functions to add sender / recipients to BBDB
+
+(defun notmuch-bbdb/snarf-headers (headers)
+  ;; Helper function to avoid code duplication in the two below
+  ;; headers should have the same format as bbdb-get-addresses-headers
+
+  ;; bbdb-get-addresses reads these
+  ;; Ugh, pass-by-global
+  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))
+(bbdb-get-addresses-headers headers) ; headers to read
+(bbdb-gag-messages t) ; suppress m/n processed message
+)
+(bbdb-update-records addrs t t)))
+
+(defun notmuch-bbdb/snarf-from ()
+  Import the sender of the current message into BBDB
+  (interactive)
+  (notmuch-bbdb/snarf-headers
+   (list  (assoc 'authors bbdb-get-addresses-headers
+
+(defun notmuch-bbdb/snarf-to ()
+  Import all recipients of the current message into BBDB
+  (interactive)
+  (notmuch-bbdb/snarf-headers
+   (list  (assoc 'recipients bbdb-get-addresses-headers
+
+(defvar notmuch-bbdb/header-by-name
+  ;; both are case sensitive
+  '( (From . :From)
+   (To . :To)
+   (CC . :Cc)
+   (BCC . :Bcc)
+   (Resent-From . nil)
+   (Reply-To . nil)
+   (Resent-To . nil)
+   (Resent-CC . nil))
+  Alist for dispatching header symbols as used by notmuch-show-get-header
+from strings as used by bbdb-get-addresses)
+
+(defun notmuch-bbdb/get-header-content (name)
+  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name
+
+
 (provide 'notmuch-address)
-- 
1.7.10.4

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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2012-10-21 Thread Tomi Ollila
On Sun, Oct 21 2012, Jani Nikula wrote:

 On Oct 20, 2012 10:35 PM, Tomi Ollila tomi.oll...@iki.fi wrote:

 Fine by me. I suggest:

 file emacs/notmuch-bbdb.el

 Bikeshedding, but how about the existing notmuch-address.el? Surely bbdb
 isn't the only address db, and there's bound to be code to share.

Good point -- this is the most consistent suggestion.

-- and customized insinuation (or something) for enable (??!!)


 J.

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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2012-10-20 Thread Tomi Ollila
On Sat, Oct 20 2012, Ethan Glasser-Camp wrote:

 Daniel Bergey ber...@alum.mit.edu writes:

 From a show buffer, bbdb/notmuch-snarf-from imports the sender into
 bbdb.  bbdb/notmuch-snarf-to attempts to import all recipients.  BBDB
 displays a buffer with each contact; C-g displays the next contact, or
 returns to the notmuch-show buffer.

 This is my first notmuch patch.  Comments very welcome.

 Hi!

  emacs/notmuch-show.el |   28 

 I don't think this belongs in notmuch-show. My first inclination is that
 this should go into a new file contrib/notmuch-bbdb.el (assuming there's
 no other notmuch-bbdb integration stuff floating around).

  1 file changed, 28 insertions(+)

 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 6335d45..3bc1da0 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1895,6 +1895,34 @@ the user (see 
 `notmuch-show-stash-mlarchive-link-alist').
  (button-get button :notmuch-filename)
  (button-get button :notmuch-content-type)))

 +;; bbdb interaction functions, awaiting user keybindings
 +
 +(defun bbdb/snarf-between-commas ()
 +  ; What about names written Surname, First M u...@server.tld?

 Most comments in emacslisp start with two semicolons.

3 quick comments.

I was thinking notmuch-bbdb.el but contrib/notmuch-bbdb.el could be
good start.

then functions like notmuch-bbdb/snarf-between-commas etc...

and yes, ;; comments -- that also keeps indent-region happy.

Tomi

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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2012-10-20 Thread Jameson Graef Rollins
On Sat, Oct 20 2012, Tomi Ollila tomi.oll...@iki.fi wrote:
 I was thinking notmuch-bbdb.el but contrib/notmuch-bbdb.el could be
 good start.

I find this functionality to be really useful.  I don't know if we have
a method of distributing/packaging stuff in contrib, and since I would
prefer to see this actually integrated, lets just put it in
emacs/notmuch-bbdb.el.

jamie.


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


Re: [PATCH] emacs: functions to import sender or recipient into BBDB

2012-10-20 Thread Tomi Ollila
On Sat, Oct 20 2012, Jameson Graef Rollins jroll...@finestructure.net wrote:

 On Sat, Oct 20 2012, Tomi Ollila tomi.oll...@iki.fi wrote:
 I was thinking notmuch-bbdb.el but contrib/notmuch-bbdb.el could be
 good start.

 I find this functionality to be really useful.  I don't know if we have
 a method of distributing/packaging stuff in contrib, and since I would
 prefer to see this actually integrated, lets just put it in
 emacs/notmuch-bbdb.el.

Fine by me. I suggest:

file emacs/notmuch-bbdb.el

functions

 notmuch-bbdb/snarf-between-commas
 notmuch-bbdb/snarf-header

 notmuch-bbdb/snarf-from
 notmuch-bbdb/snarf-to

(or if the format in origina patch is in line what has been done elsewhere, 
then:)

 bbdb/notmuch-snarf-header

 bbdb/notmuch-snarf-from
 bbdb/notmuch-snarf-to

(and, with Ethan's comments addressed)

And then, to notmuch.el or notmuch-show.el:

(autoload 'notmuch-bbdb/snarf-from notmuch-bbdb 
  Import the sender of the current message into BBDB t)
(autoload 'notmuch-bbdb/snarf-to notmuch-bbdb 
  Import all recipients of the current message into BBDB t)







 jamie.
 ___
 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: functions to import sender or recipient into BBDB

2012-10-19 Thread Ethan Glasser-Camp
Daniel Bergey ber...@alum.mit.edu writes:

 From a show buffer, bbdb/notmuch-snarf-from imports the sender into
 bbdb.  bbdb/notmuch-snarf-to attempts to import all recipients.  BBDB
 displays a buffer with each contact; C-g displays the next contact, or
 returns to the notmuch-show buffer.

 This is my first notmuch patch.  Comments very welcome.

Hi!

  emacs/notmuch-show.el |   28 

I don't think this belongs in notmuch-show. My first inclination is that
this should go into a new file contrib/notmuch-bbdb.el (assuming there's
no other notmuch-bbdb integration stuff floating around).

  1 file changed, 28 insertions(+)

 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index 6335d45..3bc1da0 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1895,6 +1895,34 @@ the user (see 
 `notmuch-show-stash-mlarchive-link-alist').
  (button-get button :notmuch-filename)
  (button-get button :notmuch-content-type)))

 +;; bbdb interaction functions, awaiting user keybindings
 +
 +(defun bbdb/snarf-between-commas ()
 +  ; What about names written Surname, First M u...@server.tld?

Most comments in emacslisp start with two semicolons.

I do think more sophisticated parsing is necessary. If you're lucky,
somebody else already has a library to parse email addresses in this
form.

 +  (goto-char (point-min))

I'm not crazy about this. It's probably fine for something limited to
bbdb users (especially since bbdb-snarf uses a very similar technique),
but I think the better approach here is to just take a region and go
from region-beginning and region-end.

 +  (let ((comma (point)))
 +(while (search-forward , nil end)

The third argument of search-forward is NOERROR. I don't understand what
the value end means. The help says Optional third argument, if t...

 +  (bbdb-snarf-region comma (point))
 +  (setq comma (point)))
 +(bbdb-snarf-region comma (point)) ; last entry
 +   ))

Doesn't this cause snarf the comma into any of those entries? It seems
like point starts before the first entry but then goes before each
comma. Obviously this wouldn't be here if it didn't work. I thought
bbdb-snarf handled this kind of thing, but it doesn't. Could you explain
this?

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