From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: never use `eval' (was: Re: How to mapcar or across a list?) Date: Wed, 15 Jul 2015 16:27:54 -0700 Message-ID: References: <87io9lmb4z.fsf@mbork.pl> <87oajdkqc7.fsf@kuiper.lan.informatimago.com> <87vbdlt4g3.fsf_-_@nl106-137-147.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1437002908 18145 80.91.229.3 (15 Jul 2015 23:28:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jul 2015 23:28:28 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 16 01:28:27 2015 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 1ZFW6F-0006kO-0H for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Jul 2015 01:28:27 +0200 Original-Received: from localhost ([::1]:37805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFW6D-0001q1-Mv for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Jul 2015 19:28:25 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFW63-0001pd-MU for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 19:28:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFW62-00085x-T8 for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 19:28:15 -0400 Original-Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:35639) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFW62-00085l-PD for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 19:28:14 -0400 Original-Received: by obbop1 with SMTP id op1so36618646obb.2 for ; Wed, 15 Jul 2015 16:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Bf1JBeK13jylL0vMBm+Md+UeCHOzuljcFOZ4Gg/QQV0=; b=bdUlf5BK84jVZYy/PmGRcg7JdvXlrLQxYbxzSHCaHeQLRB45duv598Go4aU7M71bl7 g15iWbuqLHaJahljnrMroa7IjrIsHZxh4ZAQkfPzbWMTGopqONx5d0+048InJhyhVgeQ iu8jDxL9y2rmNwUlO5B5LxsZVmBWj2OVcdHPNhhpjliL2VYcsLkAEKMY2iPUjmW3fPti EczbkDqZx+NEdmJy5qlH5pl76UV/UVxGKnsh114av92eih6jvLWsrYw2xbltDK8Dnfsl aJ8wkO6ZHhILUzNuMENQetDavymDIgkXIje/8IkRgP/vaH+cVwrKaaolzRMqc19yK4KR FGbQ== X-Received: by 10.182.186.2 with SMTP id fg2mr6187207obc.35.1437002894141; Wed, 15 Jul 2015 16:28:14 -0700 (PDT) Original-Received: by 10.76.168.70 with HTTP; Wed, 15 Jul 2015 16:27:54 -0700 (PDT) In-Reply-To: <87vbdlt4g3.fsf_-_@nl106-137-147.student.uu.se> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::231 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:105750 Archived-At: > Tho some of this code I wrote several years ago, I'd > be happy to correct it. Any hints - general or > specific - are appreciated. > (defun set-color-face (name front &optional bold back) > (eval `(defvar ,(make-symbol name))) > (eval `(setq ,(intern name) > `((t (:foreground ,front > :background ,back > :bold ,bold) ))))) > > (defvar cf-black) (set-color-face "cf-black" "black") > (defvar cf-red) (set-color-face "cf-red" "red") I would use something like this: (defmacro define-color-face (name front &optional bold back) `(defvar ,name (quote ((t (:foreground ,front :background ,back :bold ,bold)))))) (define-color-face cf-black "black") > (defun book-page-to-bibtex () > (interactive) > (save-excursion > (goto-char (point-min)) > (let ((title (get-title)) > (data (mapcar 'key-value > '("authors?" "publisher" "published" "isbn-10")) )) > (eval `(create-book nil ,title ,@data) )))) ; don't INSERT For this (and others like it) it looks like you could instead simply use e.g. (apply #'create-book nil title data) -- john