From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: netawater Newsgroups: gmane.emacs.help Subject: How to use elisp's closure Date: Mon, 16 Jun 2008 22:15:21 +0800 Organization: Bentium Ltd. (CN99) Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213629653 11719 80.91.229.12 (16 Jun 2008 15:20:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Jun 2008 15:20:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jun 16 17:21:34 2008 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 1K8GWF-0004ud-OP for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Jun 2008 17:21:19 +0200 Original-Received: from localhost ([127.0.0.1]:46032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K8GVR-0006PE-Ee for geh-help-gnu-emacs@m.gmane.org; Mon, 16 Jun 2008 11:20:29 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsgate.cuhk.edu.hk!news.neu.edu.cn!news.cn99.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 35 Original-NNTP-Posting-Host: 58.25.216.163 Original-X-Trace: news.cn99.com 1213625723 7207 58.25.216.163 (16 Jun 2008 14:15:23 GMT) Original-X-Complaints-To: usenet@news.cn99.com Original-NNTP-Posting-Date: Mon, 16 Jun 2008 14:15:23 +0000 (UTC) User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux) Cancel-Lock: sha1:DryKag3RZ24n1UOw9NkDQRTUVgk= Original-Xref: news.stanford.edu gnu.emacs.help:159529 X-Mailman-Approved-At: Mon, 16 Jun 2008 11:17:55 -0400 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:54891 Archived-At: In most usual modes, TAB key is bound to an indent function and M-TAB key is bound to a complete symbol function. I want to write a function if cursor is at the end of word then try to complete symbol, else indent. It is my function. (defun my-indent-or-complete (M-TAB-func TAB-func) ;; "If cursor is at the end of word then current mode;s M-TAB function, else TAB" (lambda () (interactive) (if (looking-at "\\>") (apply M-TAB-func '()) (apply TAB-func '()) )) ) Then I try to bound it to \t key: (add-hook 'find-file-hook '(lambda () (let ((M-TAB-func (key-binding "\M-\t")) (TAB-func (key-binding "\t")) ) (local-set-key "\t" (my-indent-or-complete M-TAB-func TAB-func))) ) ) However it does not work, it says Symbol's value as variable is void: TAB-func. I think it is because my function is not a closure, but how can I resolve it? Thank you very much!