From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexander Shukaev Newsgroups: gmane.emacs.help Subject: Re: Macro Expansion Inconsistency Date: Wed, 17 Dec 2014 03:19:14 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1418782784 4740 80.91.229.3 (17 Dec 2014 02:19:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 17 Dec 2014 02:19:44 +0000 (UTC) Cc: help-gnu-emacs To: John Mastro Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 17 03:19:38 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 1Y14D5-0001c8-2E for geh-help-gnu-emacs@m.gmane.org; Wed, 17 Dec 2014 03:19:31 +0100 Original-Received: from localhost ([::1]:47619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y14D3-0004w4-Ka for geh-help-gnu-emacs@m.gmane.org; Tue, 16 Dec 2014 21:19:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y14Cr-0004vx-9P for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 21:19:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y14Cq-0004wS-2c for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 21:19:17 -0500 Original-Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:44263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y14Cp-0004wO-M9 for help-gnu-emacs@gnu.org; Tue, 16 Dec 2014 21:19:16 -0500 Original-Received: by mail-lb0-f171.google.com with SMTP id w7so7756118lbi.30 for ; Tue, 16 Dec 2014 18:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=V1YP48kU4+CCJSu+ls6Icldx8eLHktEJDuj7aPx4Lmk=; b=v8CP+nykLntUSU9Mqon0s5990OeTL/rYTaRGZNpWb8+tQNx7PUyAgWA+AJky1QS/e0 f0Oi9PQr1RDIKlFg7ByE5yj82usxUexsVVL1j6NPJ2TAPOFD6FMsPvTjvD1FYbPeEwr3 mFQMkBBor59V0jO4WQoFD2Vo3Mn/wyvdFePWr56/7CV//u7eed3rSVdBdeurRsX/gnF0 hXnFgzyxPGVuSgVi7yf8dccMtpycSYe1Gz2sckdc+wEoIryZgHsw7BAB2gKdOSzmrCMM AFDFBJA+rxWhhENOgGb9aIR/Q3p5Bjd9AAtC1/URkskN5hdNb0KoBBj1CiWd+yW4Uf1S FVzg== X-Received: by 10.112.150.71 with SMTP id ug7mr38434446lbb.73.1418782754830; Tue, 16 Dec 2014 18:19:14 -0800 (PST) Original-Received: by 10.112.123.235 with HTTP; Tue, 16 Dec 2014 18:19:14 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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:101621 Archived-At: I currently have the following macro baked: (defmacro bm-define-flag (name index character foreground) (let* ((symbol (intern (format "bm-%s-flag" (symbol-name name)))) (character-symbol (intern (format "%s-character" (symbol-name symbol))))) (put symbol 'index index) (put symbol 'character character-symbol) (eval `(defcustom ,character-symbol ,character "Character for flag." :tag "BM Flag Character" :group 'buffer-manager :type 'character)) (eval `(defface ,symbol `((t :foreground ,foreground :weight bold)) "Face for flag." :tag "BM Flag Face" :group 'buffer-manager-faces)))) and running (bm-define-flag xxx 777 ?$ "yellow") gives the expected results, i.e. all the data structures are populated properly. The only problem is that `defface' seems to be returning `,symbol' itself (would be `bm-xxx-flag' in the above test case) and that causes the error: (void-variable bm-xxx-flag) in `eval', i.e. in eval(bm-xxx-flag nil) How to overcome it? Do you have any further recommendations on this macro? P.S. It's my first somewhat serious macro in Emacs Lisp ever, so I'd love to learn more from pros until I do something dumb.