From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: apatheticagnostic Newsgroups: gmane.emacs.help Subject: elisp - anonymous function in an association list? Date: Thu, 29 Nov 2007 06:00:19 -0800 (PST) Organization: http://groups.google.com Message-ID: <10f246a9-2a9b-477e-806d-7e3b38ce2607@i29g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1196347275 12224 80.91.229.12 (29 Nov 2007 14:41:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 29 Nov 2007 14:41:15 +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 Nov 29 15:41:23 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 1IxkZt-0008W6-JI for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 15:41:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IxkZe-0001IY-2b for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 09:41:06 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i29g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-NNTP-Posting-Host: 76.251.226.7 Original-X-Trace: posting.google.com 1196344819 12508 127.0.0.1 (29 Nov 2007 14:00:19 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Thu, 29 Nov 2007 14:00:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i29g2000prf.googlegroups.com; posting-host=76.251.226.7; posting-account=NwyZJgoAAACP04-gqkVuGlZqnbHiXJ8v User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.10) Gecko/20071126 Ubuntu/7.10 (gutsy) Firefox/2.0.0.10, gzip(gfe), gzip(gfe) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154254 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:49682 Archived-At: Hey everyone - I'm rather new to the world of lisp in general, so I'm probably missing something rather obvious here. I've searched the documentation, tried googling around, searched on emacswiki, and tried just about every permutation of the following code that I could think of, and am having no success. The goal is to have an anonymous function in an association list - I have a feeling my not being able to get this to work is because of me not having a clear understanding of how funcall works. take, for example this code showing what I mean: (defvar sample-alist '(("a" '(lambda () (message "We worked!"))) ("b" #'(lambda () (message "B worked too!"))))) (defun test-call (x) (funcall (cdr (assoc x sample-alist)))) (test-call "a") (test-call "b") Both calls fail, with an error message like so: for "b": Debugger entered--Lisp error: (invalid-function ((function (lambda nil (message "B worked too!"))))) for "a": Debugger entered--Lisp error: (invalid-function ((quote (lambda nil (message "We worked!"))))) Oh, looks like it's a nested list, maybe calling the car works? Nope. So would someone be so kind as to explain what is going on here to this poor, confused, wanna-be emacs-customizer?