From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: never use `eval' (was: Re: How to mapcar or across a list?) Date: Thu, 16 Jul 2015 00:57:00 +0200 Message-ID: <87vbdlt4g3.fsf_-_@nl106-137-147.student.uu.se> References: <87io9lmb4z.fsf@mbork.pl> <87oajdkqc7.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1437001138 24807 80.91.229.3 (15 Jul 2015 22:58:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 15 Jul 2015 22:58:58 +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 00:58:48 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 1ZFVdW-0005DT-Ta for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Jul 2015 00:58:47 +0200 Original-Received: from localhost ([::1]:37773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFVdW-0006e5-5A for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Jul 2015 18:58:46 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFVdM-0006dw-0o for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 18:58:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFVdG-0008Au-ED for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 18:58:35 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:41981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFVdG-0008AU-6w for help-gnu-emacs@gnu.org; Wed, 15 Jul 2015 18:58:30 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZFVdE-00057i-Ql for help-gnu-emacs@gnu.org; Thu, 16 Jul 2015 00:58:28 +0200 Original-Received: from nl106-137-156.student.uu.se ([130.243.137.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jul 2015 00:58:28 +0200 Original-Received: from embe8573 by nl106-137-156.student.uu.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jul 2015 00:58:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 75 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-156.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:EKNb0uLQJpT4eIsZ4geJt64itRA= 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:105749 Archived-At: "Pascal J. Bourguignon" writes: > It's always a bad idea to use eval, because eval > evalutes in the nil environment, not in the local > lexical envrionment. I have used `eval' eight times in my current setup of 75 files. Tho some of this code I wrote several years ago, I'd be happy to correct it. Any hints - general or specific - are appreciated. ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/faces.el (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") ;; ... ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/ide/lisp.el (defun do-repeat-complex-command () (interactive) (eval (car command-history) )) ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/isbn.el (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 ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/match-data-format.el (defun match-data-format (data match format-str) (save-match-data (string-match match data) (eval `(message format-str ,@(make-match-list 1 data) )))) ;; From: http://user.it.uu.se/~embe8573/conf/emacs-init/wrap-search.el (defun wrap-search-again (prefix) "Search again for the most recent search string of `wrap-search'. Use \\[universal-argument] \(to set the PREFIX\) to toggle case sensitiveness." (interactive "p") (let ((cmd (cl-dolist (cmd command-history) (if (and (eq (car cmd) 'wrap-search) (not (string= (cl-caddr cmd) "")) ) (cl-return cmd) )))) (if cmd (if (eq prefix 4) (let*((old-prefix (cadr cmd)) (search-str (cl-caddr cmd)) (new-prefix (if (eq old-prefix 4) 1 4)) (final-cmd `(wrap-search ,new-prefix ,search-str)) ) (setq command-history (cons final-cmd command-history)) (eval final-cmd) ) (eval cmd) ) (message " No previous search.") ))) -- underground experts united http://user.it.uu.se/~embe8573