Off-topic Emacs question

LLeweLLyn Reese llewelly at lifesupport.shutdown.com
Tue Jul 22 18:09:02 PDT 2003


"Fredrik Carlén" <baterista at arrhythmetic.net> writes:

> I know, this is non-specific to FreeBSD, but I have learned to love you 
> all on this list, and this should be an easy nut to crack (as we say 
> idiomatically at least here in Sweden...):
> 
> I want to define key bindings for the function sgml-tag
> like this
> (global-set-key "\C-t" 'sgml-tag)
> 
> But I don't want it to be interactive: For speedy markup, I would like to 
> be able to do something like 
> (sgml-tag "head" -1)
> 
> ...but I need to do it when defining a key binding, something like this I 
> thought, but Emacs tells me "No":
> (global-set-key "\C-t" (sgml-tag "head" -1))
> 
> Isn't it possible to bind complete function calls to keys? It must
> be...

(global-set-key "\C-t" (lambda () (interactive) (sgml-tag "head" -1)))


'lambda' is necessary to create a function. '()' means it takes no
    arguments. '(interactive)' means the function may be called
    interactivly. 

> 
> The doc for global-set-key only says
> -------------------------------------------------
> global-set-key is an interactive compiled Lisp function in `subr'.
> (global-set-key KEY COMMAND)
[snip]

C-h i g (emacs) Init Rebinding
or 
http://www.gnu.org/manual/emacs/html_node/emacs_497.html#SEC497

    for general rebinding instructions.

C-h i g (emacs-lisp-intro) Interactive
or
http://www.gnu.org/manual/emacs-lisp-intro/html_node/Interactive.html

    for writing interactive functions.

Note: the second emacs command may require
    # cd /usr/ports/lang/emacs-lisp-intro
    # make install clean
    


More information about the freebsd-questions mailing list