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

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

Re: A problem with eval-after-load


From: Michael Heerdegen
Subject: Re: A problem with eval-after-load
Date: Wed, 16 Oct 2013 19:48:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Marcin Borkowski <address@hidden> 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 "<f1>") 'org-tree-slide-content)
>     (define-key map (kbd "<f5>") 'org-tree-slide-move-previous-tree)
>     (define-key map (kbd "<f8>") '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:
> <shameless plug>
> http://mbork.pl/2013-10-09_Better_keymap_for_org-tree-slide
> </shameless plug>,
> 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.




reply via email to

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