help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: elisp programming questions


From: Pascal J. Bourguignon
Subject: Re: elisp programming questions
Date: Sat, 03 Nov 2012 04:18:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (darwin)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>> (defvar say-hi-mode-map
>>>   (let ((map (make-keymap)))
>>>     (define-key map [left] 'say-hi)
>>>     ;;(define-key map [right] 'say-hi)
>>>     map))
>
>> DEFVAR only assigns the variable if it doesn't already have a value. So 
>> when you run it the second time, it doesn't do anything because the 
>> variable is already initialized.
>
> That's right.

I use defparameter instead.


(defmacro defparameter (symbol &optional initvalue docstring)
  `(progn
     (defvar ,symbol nil ,docstring)
     (setq   ,symbol ,initvalue)))


-- 
__Pascal Bourguignon__
http://www.informatimago.com


reply via email to

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