From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: de-dynamicizing some code Date: Thu, 20 Nov 2014 11:42:11 +0800 Message-ID: <87h9xuv8q4.fsf@ericabrahamsen.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1416454654 29918 80.91.229.3 (20 Nov 2014 03:37:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Nov 2014 03:37:34 +0000 (UTC) Cc: Stefan Monnier To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 20 04:37:26 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XrIYg-0000sQ-HK for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Nov 2014 04:37:26 +0100 Original-Received: from localhost ([::1]:33381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrIYg-0003E5-5F for geh-help-gnu-emacs@m.gmane.org; Wed, 19 Nov 2014 22:37:26 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36063) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrIYN-0003Dv-LB for help-gnu-emacs@gnu.org; Wed, 19 Nov 2014 22:37:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrIYF-0008G7-QA for help-gnu-emacs@gnu.org; Wed, 19 Nov 2014 22:37:07 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:38551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrIYF-0008Ft-Kg for help-gnu-emacs@gnu.org; Wed, 19 Nov 2014 22:36:59 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XrIYE-0000jX-IL for help-gnu-emacs@gnu.org; Thu, 20 Nov 2014 04:36:58 +0100 Original-Received: from 111.197.160.62 ([111.197.160.62]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Nov 2014 04:36:58 +0100 Original-Received: from eric by 111.197.160.62 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 20 Nov 2014 04:36:58 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 111.197.160.62 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:8HOFRcR/W1aHzOunVke2vauDFhU= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:101066 Archived-At: 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