unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to use elisp's closure
@ 2008-06-16 14:15 netawater
  2008-06-16 15:42 ` David Hansen
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: netawater @ 2008-06-16 14:15 UTC (permalink / raw)
  To: help-gnu-emacs

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!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-17 13:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-16 14:15 How to use elisp's closure netawater
2008-06-16 15:42 ` David Hansen
2008-06-16 15:49 ` beaubert
     [not found] ` <mailman.13401.1213631425.18990.help-gnu-emacs@gnu.org>
2008-06-17 13:02   ` netawater
     [not found] ` <mailman.13402.1213631610.18990.help-gnu-emacs@gnu.org>
2008-06-17 13:06   ` netawater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).