unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* de-dynamicizing some code
@ 2014-11-20  3:42 Eric Abrahamsen
  2014-11-20  3:57 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Abrahamsen @ 2014-11-20  3:42 UTC (permalink / raw)
  To: help-gnu-emacs; +Cc: Stefan Monnier

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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-20  4:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-20  3:42 de-dynamicizing some code Eric Abrahamsen
2014-11-20  3:57 ` Stefan Monnier
2014-11-20  4:13   ` Eric Abrahamsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).