unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marcin Borkowski <mbork@wmi.amu.edu.pl>
To: help-gnu-emacs@gnu.org
Subject: Re: A problem with eval-after-load
Date: Wed, 16 Oct 2013 20:31:39 +0200	[thread overview]
Message-ID: <20131016203139.020765da@aga-netbook> (raw)
In-Reply-To: <87bo2pnm2p.fsf@web.de>

Dnia 2013-10-16, o godz. 19:48:46
Michael Heerdegen <michael_heerdegen@web.de> napisał(a):

> Marcin Borkowski <mbork@wmi.amu.edu.pl> 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.

Thanks!  It's so obvious now...  (I didn't see this in the manual,
though I didn't read it *very* carefully, so maybe I missed it.)

> Regards,
> 
> Michael.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



  reply	other threads:[~2013-10-16 18:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16  9:13 A problem with eval-after-load Marcin Borkowski
2013-10-16 17:48 ` Michael Heerdegen
2013-10-16 18:31   ` Marcin Borkowski [this message]
     [not found]   ` <mailman.4156.1381948316.10748.help-gnu-emacs@gnu.org>
2013-10-17  2:37     ` Emanuel Berg
2013-10-17 19:52       ` Marcin Borkowski
     [not found]       ` <mailman.4208.1382039548.10748.help-gnu-emacs@gnu.org>
2013-10-19  0:43         ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131016203139.020765da@aga-netbook \
    --to=mbork@wmi.amu.edu.pl \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).