[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: elisp programming questions
From: |
Stefan Monnier |
Subject: |
Re: elisp programming questions |
Date: |
Mon, 29 Oct 2012 10:21:29 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) |
>> (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.
> Change it to:
> (defvar say-hi-mode-map (make-keymap))
> (define-key map [left] 'say-hi)
> (define-key map [right] 'say-hi)
No, this is bad style. Instead, just use C-M-x with point within
the defvar (or use defconst).
Stefan