From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Macro Problem Date: Tue, 03 Apr 2007 10:11:13 +0200 Organization: Informatimago Message-ID: <87hcrxswri.fsf@voyager.informatimago.com> References: <1175548506.345646.47790@l77g2000hsb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1175589478 4683 80.91.229.12 (3 Apr 2007 08:37:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 3 Apr 2007 08:37: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 Tue Apr 03 10:37:53 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HYeWW-0000qJ-Rl for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Apr 2007 10:37:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HYeZd-00032X-4A for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Apr 2007 04:41:05 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 111 Original-X-Trace: individual.net fo/ii2iX6mFO5mKhH7B/wwZbB6GHH6FOM5ratiK90B8QfABBnk Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux) Cancel-Lock: sha1:skYMK+Lh655KuY8GvvjQ7mkvgbo= Original-Xref: shelby.stanford.edu gnu.emacs.help:146785 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42390 Archived-At: "vy" writes: > Hi, > > I'm trying to fix a macro for a simple task but still couldn't figure > out the solution to the problem emacs complains about. Here's the > related macro: > > (defun adhoc-make-font-face (face spec) > `(,face ((((class color) > (min-colors 8)) > ,spec)))) > > (defmacro adhoc-custom-set-faces (faces) > `(custom-set-faces > ,@(loop for face in faces > collect (adhoc-make-font-face (first face) (second > face))))) This will try to _execute_ the value returned by adhoc-make-font-face. But a face is not a function, so adhoc-make-font-face should not return a function call with face as a function, but a quoted list: (defun adhoc-make-font-face (face spec) `(quote (,face ((((class color) (min-colors 8)) ,spec))))) Of course you can write it as: (defun adhoc-make-font-face (face spec) `'(,face ((((class color) (min-colors 8)) ,spec)))) Also, since adhoc-custom-set-face is a macro that doesn't evaluate its argument, you shouldn't quote it. (macroexpand ' (adhoc-custom-set-faces ((font-lock-builtin-face (:foreground "yellow")) (font-lock-comment-face (:foreground "red")) (font-lock-function-name-face (:foreground "cyan" :underline "cyan")))) ) --> (custom-set-faces (quote (font-lock-builtin-face ((#1=((class color) (min-colors 8)) (:foreground "yellow"))))) (quote (font-lock-comment-face ((#1# (:foreground "red"))))) (quote (font-lock-function-name-face ((#1# (:foreground "cyan" :underline "cyan")))))) And if you used (&rest faces) instead of (faces) for adhoc-custom-set-faces, you could lose one parenthesis: (defmacro adhoc-custom-set-faces (&rest faces) `(custom-set-faces ,@(loop for face in faces collect (adhoc-make-font-face (first face) (second face))))) (macroexpand ' (adhoc-custom-set-faces (font-lock-builtin-face (:foreground "yellow")) (font-lock-comment-face (:foreground "red")) (font-lock-function-name-face (:foreground "cyan" :underline "cyan"))) ) --> (custom-set-faces (quote (font-lock-builtin-face ((#1=((class color) (min-colors 8)) (:foreground "yellow"))))) (quote (font-lock-comment-face ((#1# (:foreground "red"))))) (quote (font-lock-function-name-face ((#1# (:foreground "cyan" :underline "cyan")))))) But since custom-set-faces is a function, perhaps you don't want macros at all! In that case you don't need to return a quoted list from adhoc-make-font-face, since you won't be trying to execute it: (defun adhoc-make-font-face (face spec) `(,face ((((class color) (min-colors 8)) ,spec)))) (defun adhoc-custom-set-faces (faces) (apply (function custom-set-faces) (loop for face in faces collect (adhoc-make-font-face (first face) (second face))))) and then indeed you'd call it as: (adhoc-custom-set-faces '((font-lock-builtin-face (:foreground "yellow")) (font-lock-comment-face (:foreground "red")) (font-lock-function-name-face (:foreground "cyan" :underline "cyan")))) > I'll be appreciated if anybody can give some hints about how to fix > the problem. So the problem was that for some strange reason you used defmacro instead of defun. ;-) -- __Pascal Bourguignon__ http://www.informatimago.com http://pjb.ogamita.org