help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

de-dynamicizing some code


From: Eric Abrahamsen
Subject: de-dynamicizing some code
Date: Thu, 20 Nov 2014 11:42:11 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux)

I'm addressing this to Stefan, because of some comments he made
previously, but posting this here because it's probably of general
interest.

I'm working around some BBDB code that looks like this:

  (let* ((indent (or (bbdb-layout-get-option layout 'indentation) 21))
         (fmt (format " %%%ds: " (- indent 3)))
         start field formatfun)
    (dolist (field field-list)
      (setq start (point))
      (cond (;; customized formatting
             (setq formatfun (intern-soft (format "bbdb-display-%s-multi-line" 
field)))
             (funcall formatfun record))

What's happening is, you can provide a custom formatting function for a
field on a BBDB record, and BBDB will call the format function if it
exists.

The local vars `indent' and `fmt' are necessary for formatting the
field, and you access them dynamically from within the `formatfun'. This
makes compiler warnings, and is presumably bad for our lexical future.

I assume the proper solution is to replace this:

(funcall formatfun record)

with:

(funcall formatfun record indent fmt)

Is that correct?

Thanks,
Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]