From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Evan Driscoll Newsgroups: gmane.emacs.help Subject: elisp programming questions Date: Wed, 24 Oct 2012 23:39:27 -0500 Message-ID: <5088C27F.40009@cs.wisc.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1351140000 31649 80.91.229.3 (25 Oct 2012 04:40:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Oct 2012 04:40:00 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 25 06:40:08 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 1TRFEe-00037A-Aq for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Oct 2012 06:40:00 +0200 Original-Received: from localhost ([::1]:53877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRFEW-0008NY-Hj for geh-help-gnu-emacs@m.gmane.org; Thu, 25 Oct 2012 00:39:52 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRFEQ-0008NR-SB for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 00:39:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRFEP-0000zK-R3 for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 00:39:46 -0400 Original-Received: from sabe.cs.wisc.edu ([128.105.6.20]:39419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRFEP-0000xi-L8 for help-gnu-emacs@gnu.org; Thu, 25 Oct 2012 00:39:45 -0400 Original-Received: from [192.168.0.2] (h216-165-158-75.mdtnwi.dsl.dynamic.tds.net [216.165.158.75]) (authenticated bits=0) by sabe.cs.wisc.edu (8.14.1/8.14.1) with ESMTP id q9P4dXWL018409 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 24 Oct 2012 23:39:37 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 X-Enigmail-Version: 1.4.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 128.105.6.20 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:87416 Archived-At: I have a question: I'm working on a (major) mode, and when I make changes to the keymap, they don't "stick" until I restart emacs. It'd be nice to know how to fix this, but as I was typing it, I realized there may be a better way to solve this problem anyway; see below. To demo my problem: 1. Save the code below to a file, open in emacs 2. M-x eval-buffer 3. M-x say-hi-mode 4. Press [left]; note how the minibuffer says hi Press [right]; note how the cursor moves 5. M-x revert-buffer 6. Uncomment the second define-key on line 8 7. M-x eval-buffer 8. Repeat steps 3 and 4. Note how [right] still moves the cursor instead of saying hi Can someone tell me if there's a way to make the changes take effect? ----- ALTERNATELY: is there some hook or something I can use which will get called whenever (after) the point is moved by any means? I will be overriding the cursor controls, but really what I want is just to display some stuff related to the point's new location, and ideally it'd work whether the user uses arrow keys, C-p/C-n/etc., the mouse, or anything else. Thanks, Evan ----- The code: (defun say-hi () (interactive) (message "Hello!")) (defvar say-hi-mode-map (let ((map (make-keymap))) (define-key map [left] 'say-hi) ;;(define-key map [right] 'say-hi) map )) (define-derived-mode say-hi-mode special-mode "Trace" "Major mode for viewing IO traces" (use-local-map say-hi-mode-map))