From owner-freebsd-questions@FreeBSD.ORG Tue Jul 22 18:09:02 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6FD737B401 for ; Tue, 22 Jul 2003 18:09:02 -0700 (PDT) Received: from lifesupport.shutdown.com (dsl092-048-059.sfo2.dsl.speakeasy.net [66.92.48.59]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0286B43F3F for ; Tue, 22 Jul 2003 18:09:02 -0700 (PDT) (envelope-from llewelly@lifesupport.shutdown.com) Received: (from llewelly@localhost) by lifesupport.shutdown.com (8.11.2/8.11.2) id h6N14Sn18807; Tue, 22 Jul 2003 18:04:28 -0700 (PDT) To: "Fredrik =?iso-8859-1?q?Carl=E9n?=" References: From: LLeweLLyn Reese Date: 22 Jul 2003 18:04:26 -0700 In-Reply-To: Message-ID: Lines: 51 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable cc: freebsd-questions@freebsd.org Subject: Re: Off-topic Emacs question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2003 01:09:02 -0000 "Fredrik Carl=E9n" writes: > I know, this is non-specific to FreeBSD, but I have learned to love you=20 > all on this list, and this should be an easy nut to crack (as we say=20 > idiomatically at least here in Sweden...): >=20 > I want to define key bindings for the function sgml-tag > like this > (global-set-key "\C-t" 'sgml-tag) >=20 > But I don't want it to be interactive: For speedy markup, I would like to= =20 > be able to do something like=20 > (sgml-tag "head" -1) >=20 > ...but I need to do it when defining a key binding, something like this I= =20 > thought, but Emacs tells me "No": > (global-set-key "\C-t" (sgml-tag "head" -1)) >=20 > 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.=20 >=20 > 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=20 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 =20=20=20=20