[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parametrized function definition

From: Lennart Borgman (gmail)
Subject: Re: parametrized function definition
Date: Wed, 09 Jul 2008 09:06:30 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Joe Bloggs wrote:
Hi, I am trying to write a function that allows me to quickly bind a key 
to insert arbitrary text:

(defun set-local-key-insert ()
  "set a local key to insert some text"
(let (keystring textinsert) (setq keystring (read-key-sequence "Key combination to bind: "))
    (setq textinsert (read-string "Text to insert: "))
    (local-set-key (read-kbd-macro keystring) (lambda () (interactive) (insert 

However, this doesn't work since textinsert is not evaluated until the function 
is called with the keybinding. How can I get this to work properly? I am new to 
elisp so I imagine it's very simple.

You can remove textinsert from let and make it a defvar instead.

  (defvar textinsert nil)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]