bbdb-mua extensibility [Was: Re: Add basic support for Wanderlust]

2015-11-29 Thread David Maus
On Sun, 22 Nov 2015 23:16:04 +0100,
Roland Winkler wrote:
> 
> > Side note: While implementing the support I noticed that the macro
> > 'bbdb-mua-wrapper' seems to be one important part that prevents
> > one from adding support for additional muas w/o patching bbdb
> > itself. You could rewrite the macro to simply use a dispatch table
> > to select an appropriate function to select buffer based on mua:
> [snip]
> > With this modified macro in place I was able to use BBDB with
> > Wanderlust only be modifying variables and advicing defuns [1]
> > since 2014.
> 
> Just to make sure I understand correctly: your proposed change to
> the macro bbdb-mua-wrapper does not solve all problems immediately.
> It also requires advicing defuns if one wants to add a new MUA.
> -- My point is that advicing defuns can make debugging very painful.
> So for issues of general interest I really would not want to
> advertise it as a strategy.

I agree: Advicing functions is definitely not a good general mechanism
to provide extensibility.

One way to provide a better way to extend bbdb-mua could be something
along this lines:

 - consistently use a lookup-table for all mua-specific stuff
   (functions, hooks, ...)
   
 - provide a function that mua-support-modules call in order to
   register themselves

The role of bbdb-mua-* would be to read the lookup-table and dispatch
to mua-specific functions if neccessary.

Is this a direction bbdb-mua could evolve?

Best,
  -- David

--
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/


Re: Add basic support for Wanderlust

2015-11-29 Thread David Maus
On Sun, 22 Nov 2015 23:16:04 +0100,
Roland Winkler wrote:
> 
> On Sun Nov 22 2015 David Maus wrote:
> > Attached diff against current master adds basic support for
> > Wanderlust, a mail/news management system with IMAP4rev1 support for
> > Emacsen.
> 
> Thank you.  
> 
> I saw that you have already assigned your copyright for Emacs to the
> FSF, that's good.  Could you please also send an informal email to
> the FSF copyright clerk at fsf-reco...@gnu.org saying that your
> previous copyright assignment covers BBDB/Emacs, too?  Thanks.
> (I hope you agree to this.)

I have no problem with this and sent the mail to the copyright clerk.

I also attached an updated diff against master which adds support for
Wanderlust to `bbdb-mua-auto-update-init'.

Best,
  -- David




20151129-bbdb-wanderlust.diff
Description: Binary data
--
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/

Add basic support for Wanderlust

2015-11-22 Thread David Maus
Hi all,

Attached diff against current master adds basic support for
Wanderlust, a mail/news management system with IMAP4rev1 support for
Emacsen.

Side note: While implementing the support I noticed that the macro
'bbdb-mua-wrapper' seems to be one important part that prevents one
from adding support for additional muas w/o patching bbdb itself. You
could rewrite the macro to simply use a dispatch table to select an
appropriate function to select buffer based on mua:

,
| (defmacro bbdb-mua-wrapper ( body)
|   "Execute BODY in a message buffer."
|   (declare (debug t))
|   (let ((mua (gensym)))
| `(let ((,mua (bbdb-mua)))
|(with-current-buffer (funcall (or (cdr (assq ,mua 
bbdb-mua-select-message-buffer-func-alist)) 'current-buffer))
|  ,@body
`

With this modified macro in place I was able to use BBDB with
Wanderlust only be modifying variables and advicing defuns [1] since
2014.

The diff does *not* modify the macro but integrates Wanderlust using
the current convention.

Best,
  -- David

[1] https://github.com/dmj/bbdbv3/blob/t/wanderlust/lisp/bbdb-wanderlust.el

diff --git a/ChangeLog b/ChangeLog
index 295c48d..9a61d8c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-11-21  David Maus  <dm...@dmaus.name>
+
+   * lisp/bbdb-mua.el (bbdb-mua-mode-alist, bbdb-mua)
+   (bbdb-message-header, bbdb-mua-update-records, bbdb-mua-wrapper):
+   Add support for Wanderlust.
+   * lisp/bbdb.el (bbdb-init-forms): Add support for Wanderlust.
+   * lisp/bbdb-wanderlust.el: New file. Add basic support for
+   Wanderlust.
+
 2015-11-14  Roland Winkler  <wink...@gnu.org>
* lisp/bbdb.el (bbdb-auto-revert, bbdb-dedicated-window)
(bbdb-default-domain, bbdb-mua-pop-up)
diff --git a/lisp/Makefile.am b/lisp/Makefile.am
index 413dbae..8440cd6 100644
--- a/lisp/Makefile.am
+++ b/lisp/Makefile.am
@@ -38,7 +38,8 @@ dist_lisp_LISP =  \
bbdb-rmail.el   \
bbdb-sc.el  \
bbdb-snarf.el   \
-   bbdb-site.el
+   bbdb-site.el\
+   bbdb-wanderlust.el
 
 if VM
 dist_lisp_LISP += bbdb-vm.el
diff --git a/lisp/bbdb-mua.el b/lisp/bbdb-mua.el
index 29cf223..ded1c2a 100644
--- a/lisp/bbdb-mua.el
+++ b/lisp/bbdb-mua.el
@@ -59,7 +59,9 @@
   (defvar mu4e~view-buffer-name)
 
   (autoload 'message-field-value "message")
-  (autoload 'mail-decode-encoded-word-string "mail-parse"))
+  (autoload 'mail-decode-encoded-word-string "mail-parse")
+
+  (autoload 'bbdb/wanderlust-header "bbdb-wanderlust"))
 
 (defconst bbdb-mua-mode-alist
   '((vm vm-mode vm-virtual-mode vm-summary-mode vm-presentation-mode)
@@ -68,20 +70,22 @@
 (mh mhe-mode mhe-summary-mode mh-folder-mode)
 (message message-mode)
 (mail mail-mode)
-(mu4e mu4e-view-mode)) ; Tackle `mu4e-headers-mode' later
+(mu4e mu4e-view-mode)  ; Tackle `mu4e-headers-mode' later
+(wanderlust wl-summary-mode wl-draft-mode))
   "Alist of MUA modes supported by BBDB.
 Each element is of the form (MUA MODE MODE ...), where MODEs are used by MUA.")
 
 (defun bbdb-mua ()
   "For the current message return the MUA.
 Return values include
-  gnus  Newsreader Gnus
-  rmail Reading Mail in Emacs
-  vmViewmail
-  mhEmacs interface to the MH mail system (aka MH-E)
-  message   Mail and News composition mode that goes with Gnus
-  mu4e  Mu4e
-  mail  Emacs Mail Mode."
+  gnus   Newsreader Gnus
+  rmail  Reading Mail in Emacs
+  vm Viewmail
+  mh Emacs interface to the MH mail system (aka MH-E)
+  messageMail and News composition mode that goes with Gnus
+  mu4e   Mu4e
+  wanderlust Wanderlust
+  mail   Emacs Mail Mode."
   (let ((mm-alist bbdb-mua-mode-alist)
 elt mua)
 (while (setq elt (pop mm-alist))
@@ -115,6 +119,7 @@ MIME encoded headers are decoded.  Return nil if HEADER 
does not exist."
 ((eq mua 'rmail) (bbdb/rmail-header header))
 ((eq mua 'mh) (bbdb/mh-header header))
 ((eq mua 'mu4e) (message-field-value header))
+((eq mua 'wanderlust) (bbdb/wanderlust-header header))
 ((memq mua '(message mail)) (message-field-value header))
 (t (error "BBDB/%s: header function undefined" mua)
 (if val (mail-decode-encoded-word-string val
@@ -602,6 +607,10 @@ If SORT is non-nil, sort records according to 
`bbdb-record-lessp'."
 (set-buffer mu4e~view-buffer-name)
 (bbdb-update-records (bbdb-get-address-components header-class)
  update-p sort))
+   ;; Wanderlust
+   ((eq mua 'wanderlust)
+(bbdb-update-records (bbdb-get-address-components header-class)
+ u

Re: Add basic support for Wanderlust

2015-11-22 Thread Roland Winkler
On Sun Nov 22 2015 David Maus wrote:
> Attached diff against current master adds basic support for
> Wanderlust, a mail/news management system with IMAP4rev1 support for
> Emacsen.

Thank you.  

I saw that you have already assigned your copyright for Emacs to the
FSF, that's good.  Could you please also send an informal email to
the FSF copyright clerk at fsf-reco...@gnu.org saying that your
previous copyright assignment covers BBDB/Emacs, too?  Thanks.
(I hope you agree to this.)

I'll add your patch to the repository.

> Side note: While implementing the support I noticed that the macro
> 'bbdb-mua-wrapper' seems to be one important part that prevents
> one from adding support for additional muas w/o patching bbdb
> itself. You could rewrite the macro to simply use a dispatch table
> to select an appropriate function to select buffer based on mua:
[snip]
> With this modified macro in place I was able to use BBDB with
> Wanderlust only be modifying variables and advicing defuns [1]
> since 2014.

Just to make sure I understand correctly: your proposed change to
the macro bbdb-mua-wrapper does not solve all problems immediately.
It also requires advicing defuns if one wants to add a new MUA.
-- My point is that advicing defuns can make debugging very painful.
So for issues of general interest I really would not want to
advertise it as a strategy.

--
___
bbdb-info@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/