bbdb-print.el lexical binding breaks bbdb-print-record

Vincent Belaïche <[email protected]>
Newsgroups gmane.emacs.bbdb.user
Message-ID <AM5PR10MB0676092D97DC0F32FA66AA6784D20@AM5PR10MB0676.EURPRD10.PROD.OUTLOOK.COM>
Hello Roland,

With lexical binding bbdb-print-record makes a void variable error on address variable.

Attached is a fix. I use a lambda expression to make the binding dynmical so that bbdb-print-require can be evalled in the correct context. An alternative fix would have been to use :

(cl-progv '(first-letter name organization mail phone address xfields) (list first-letter name organization mail phone address xfields)).

Well, to avoid any duplication in this case, it would be better to use some macro like this:

(defmacro bbdb-do-cl-progv (&rest l)
   `(cl-progv (quote ,l) (list ,@l)))

and then in bdbd-print-record:

(bbdb-do-cl-progv first-letter name organization mail phone address xfields)(list first-letter name organization mail phone address xfields)

Anyway, I prefer the lambda trick, I don't like cl-progv and eval. Probably lambdas are more portable to old Emacs versions.

  Vincent.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
[email protected]
https://lists.sourceforge.net/lists/listinfo/bbdb-info
BBDB Home Page: http://bbdb.sourceforge.net/
bug.diff (application/octet-stream, 678 B)
diff --git a/lisp/bbdb-print.el b/lisp/bbdb-print.el
index f2efef1..dc72e3d 100644
--- a/lisp/bbdb-print.el
+++ b/lisp/bbdb-print.el
@@ -437,7 +437,8 @@ The return value is the new CURRENT-LETTER."
         (xfields (bbdb-record-xfields record))
         (bbdb-address-format-list bbdb-print-address-format-list))
 
-    (when (eval bbdb-print-require)
+    (when (funcall `(lambda (first-letter name organization mail phone address xfields) ,bbdb-print-require)
+		   first-letter name organization mail phone address xfields)
       ;; Insert section header, if neccessary.
       (if (or (eq current-letter t)
               (not (string-equal first-letter current-letter)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.