From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim Landscheidt Newsgroups: gmane.emacs.help Subject: Re: emacs lisp - unable to write a function maker Date: Fri, 23 Sep 2011 15:31:21 +0000 Organization: Message-ID: References: <87pqj0q2wo.fsf@ambire.localdomain> <87iposlshu.fsf@ericabrahamsen.net> <47D4EF93ED6C47B8AD53845AECED59D4@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1316791917 8492 80.91.229.12 (23 Sep 2011 15:31:57 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 23 Sep 2011 15:31:57 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 23 17:31:52 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R77jD-0007tB-Ld for geh-help-gnu-emacs@m.gmane.org; Fri, 23 Sep 2011 17:31:51 +0200 Original-Received: from localhost ([::1]:52582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R77jA-0001d8-4b for geh-help-gnu-emacs@m.gmane.org; Fri, 23 Sep 2011 11:31:48 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:41552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R77j6-0001d3-C5 for help-gnu-emacs@gnu.org; Fri, 23 Sep 2011 11:31:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R77j5-00051e-86 for help-gnu-emacs@gnu.org; Fri, 23 Sep 2011 11:31:44 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:41163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R77j5-00051Y-1I for help-gnu-emacs@gnu.org; Fri, 23 Sep 2011 11:31:43 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R77ix-0007lu-Ku for help-gnu-emacs@gnu.org; Fri, 23 Sep 2011 17:31:35 +0200 Original-Received: from g231145028.adsl.alicedsl.de ([92.231.145.28]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Sep 2011 17:31:35 +0200 Original-Received: from tim by g231145028.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 23 Sep 2011 17:31:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 34 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g231145028.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Z/jpAUxzV9/5K+Fw2ajoviMgsXE= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 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:82303 Archived-At: "Drew Adams" wrote: > [...] > Well, not quite - the OP quoted the function symbol, indicating that s?he would > pass something that needs to be eval'd. If that's rally part of the requirement, > then: > (defmacro makeAbrevFun (name val) > `(defun ,(eval name) () (insert ,val))) > (makeAbrevFun 'aa "aaaaaaaaaaaaaa") > In both cases: (symbol-function 'aa) gives: > (lambda () (insert "aaaaaaaaaaaaaa")) On a related note - how do I proceed if I do not want to create a macro that creates a function, but create multiple functions directly? For example, after some trial and error my ~/.emacs ended up with (paraphrased): | (dolist (i '(("once" . 1) | ("twice" . 2) | ("thrice" . 3))) | (fset (intern (concat "tl-say-" (downcase (car i)))) | `(lambda (s) | ,(concat "Say S only " (car i) ".") | (interactive "sWhat to message: ") | (dotimes (j ,(cdr i)) | (message "I say it only %s: %s." ,(car i) s))))) I didn't manage to use defun as I got stuck in quoting and non-quoting "magic". Tim