From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: A problem with eval-after-load Date: Wed, 16 Oct 2013 19:48:46 +0200 Message-ID: <87bo2pnm2p.fsf@web.de> References: <20131016111314.7fa2ccc9@aga-netbook> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1381945769 8926 80.91.229.3 (16 Oct 2013 17:49:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Oct 2013 17:49:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 16 19:49:32 2013 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 1VWVDr-0003wT-2X for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Oct 2013 19:49:27 +0200 Original-Received: from localhost ([::1]:48722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWVDq-0006co-ON for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Oct 2013 13:49:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWVDY-0006bZ-32 for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 13:49:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWVDS-0006Og-Mg for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 13:49:08 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:44057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWVDS-0006Np-Fi for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 13:49:02 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VWVDQ-0003h7-Fd for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 19:49:00 +0200 Original-Received: from ip-90-186-76-237.web.vodafone.de ([90.186.76.237]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Oct 2013 19:49:00 +0200 Original-Received: from michael_heerdegen by ip-90-186-76-237.web.vodafone.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 16 Oct 2013 19:49:00 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-90-186-76-237.web.vodafone.de User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:eh3oqOLC6wA/HDTAL7d5tRU50u4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:94046 Archived-At: Marcin Borkowski writes: > Hi all, Hi! > I have a problem with eval-after-load. (In fact, this is one of the > reasons I subscribed to this list;).) I have something like this in my > init.el: > > (eval-after-load 'org-tree-slide '(setq org-tree-slide-mode-map > (let ((map (make-sparse-keymap))) > (define-key map (kbd "") 'org-tree-slide-content) > (define-key map (kbd "") 'org-tree-slide-move-previous-tree) > (define-key map (kbd "") 'org-tree-slide-move-next-tree) > map))) > > (load-file "~/some/path/org-tree-slide/org-tree-slide.el") > > The rationale is that I did not like the default keybindings of > org-tree-slide (which is an Org-mode based simple presentation tool). > > The problem is that this doesn't work: the keymap is not updated. When > I load the org-tree-slide.el *manually*, somehow it gets updated. (It > is a bit embarassing that I noticed it before I posted this blog post: > > http://mbork.pl/2013-10-09_Better_keymap_for_org-tree-slide > , > but I didn't notice this at first. I will update the said post as soon > as I understand what's going on here.) > > Of course, I could just get rid of eval-after-load and change the order > of the loading and redefining the keymap - but I want to know what's > the problem. (Initially, I didn't want to load org-tree-slide by > default, hence the eval-after-load stuff. Then, I decided it won't > hurt to have it loaded always. I should probably learn to use > autoload.) > > Am I doing something wrong? AFAIK, when the minor mode is defined, the _value_ of the map variable is used. The function object representing the mode doesn't refer to the keymap variable, but only to the value (a keymap, typically a nested list structure). That implies that setting the variable has no effect once the mode has been defined. So, `eval-after-load' is wrong here, you must set the map variable _before_ loading the file. BTW, I don't like that behavior, too, it's a bit surprising that how you tried it doesn't work. I stumbled across this issue myself several times. Regards, Michael.