From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Assign a function to a variable, and invoke it Date: Mon, 30 Jul 2007 15:56:16 -0700 Message-ID: References: <1185834175.653370.242000@22g2000hsm.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: sea.gmane.org 1185836256 31965 80.91.229.12 (30 Jul 2007 22:57:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 30 Jul 2007 22:57:36 +0000 (UTC) To: "troelskn" , Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 31 00:57:29 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 1IFeB6-0003yx-HB for geh-help-gnu-emacs@m.gmane.org; Tue, 31 Jul 2007 00:57:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IFeB6-00048A-7F for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Jul 2007 18:57:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IFeAt-000484-24 for help-gnu-emacs@gnu.org; Mon, 30 Jul 2007 18:57:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IFeAq-00047s-Jg for help-gnu-emacs@gnu.org; Mon, 30 Jul 2007 18:57:13 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IFeAq-00047p-FM for help-gnu-emacs@gnu.org; Mon, 30 Jul 2007 18:57:12 -0400 Original-Received: from agminet01.oracle.com ([141.146.126.228]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IFeAq-0001o3-1B for help-gnu-emacs@gnu.org; Mon, 30 Jul 2007 18:57:12 -0400 Original-Received: from agmgw2.us.oracle.com (agmgw2.us.oracle.com [152.68.180.213]) by agminet01.oracle.com (Switch-3.2.4/Switch-3.1.7) with ESMTP id l6UMv79a018290; Mon, 30 Jul 2007 17:57:08 -0500 Original-Received: from acsmt351.oracle.com (acsmt351.oracle.com [141.146.40.151]) by agmgw2.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id l6U2Si1U002346; Mon, 30 Jul 2007 16:57:07 -0600 Original-Received: from dhcp-4op11-4op12-west-130-35-178-179.us.oracle.com by acsmt351.oracle.com with ESMTP id 3082170571185836177; Mon, 30 Jul 2007 15:56:17 -0700 X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: <1185834175.653370.242000@22g2000hsm.googlegroups.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 Importance: Normal X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-detected-kernel: Linux 2.4-2.6 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:46211 Archived-At: > (defvar my-browse-url 'browse-url) > ... > (my-browse-url "http://example.com") > > I suppose that functions and variables have different namespaces in > elisp? How do I invoke the function, which my-browse-url points to? Invoke the function using `funcall' or `apply': (funcall my-browse-url). A symbol, such as `my-browse-url' or `browse-url', has a value cell and a function cell, so the same symbol can act as a function (via its function cell) and as a variable (via its value cell). When evaluated, the symbol's value is returned (from its value cell). In a function call, as in (browse-url), its function cell is used. When you do (funcall my-browse-url), the symbol `my-browse-url' is evaluated (value cell) to the symbol `browse-url', and then the function in the function cell of that symbol, `browse-url', is called (by `funcall'). See the Elisp manual in Emacs (C-h i) for a better and more complete explanation of all of this - it is your friend.