From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: elisp programming questions Date: Mon, 29 Oct 2012 10:21:29 -0400 Organization: A noiseless patient Spider Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1351520719 26117 80.91.229.3 (29 Oct 2012 14:25:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2012 14:25:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 29 15:25:28 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TSqHN-0002iF-6u for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Oct 2012 15:25:25 +0100 Original-Received: from localhost ([::1]:54803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSqHD-0004Ll-IW for geh-help-gnu-emacs@m.gmane.org; Mon, 29 Oct 2012 10:25:15 -0400 Original-Path: usenet.stanford.edu!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 22 Injection-Info: mx04.eternal-september.org; posting-host="9476eb3185f812e862f943f2f5680783"; logging-data="17094"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JBzc43E6h+HNQjREOQ/qT" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) Cancel-Lock: sha1:HMLwayBl9vJ2wSBCVBkDm1BjmLc= sha1:uv8RnU+XwQInb6OIUEoG88B3O4c= Original-Xref: usenet.stanford.edu gnu.emacs.help:195153 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87482 Archived-At: >> (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