all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#15389: 24.2.91; order of eval-after-load actions
@ 2013-09-15 22:41 João Távora
  2013-09-16  6:58 ` Glenn Morris
  2013-09-16 16:30 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: João Távora @ 2013-09-15 22:41 UTC (permalink / raw)
  To: 15389

Hi maintainers,

Consider a file foo-test.el consisting of this content

    (eval-after-load 'foo
      `(progn
         (message "foo1")))
     
    (eval-after-load 'foo
      `(progn
         (message "foo2")))
     
    (provide 'foo) 

If I interactively eval these forms in order using `eval-last-sexp', for
example I get

    foo1
    foo2

in the *Messages* buffer. But if i load the file like so

    emacs -Q --batch -l foo-test.el

I get

    foo2
    foo1

Is this the expected behaviour? Shouldn't the order in which the hooks
are run match the order of definition. 



In GNU Emacs 24.2.91.1 (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 AppKit 1138.51)
 of 2012-12-25 on king
Windowing system distributor `Apple Inc.', version 10.7.5
Configured using:
 `configure '--prefix=/usr/local/Cellar/emacs-mac/HEAD'
 '--enable-locallisppath=/usr/local/share/emacs/site-lisp'
 '--infodir=/usr/local/Cellar/emacs-mac/HEAD/share/info/emacs'
 '--with-mac' '--enable-mac-app' 'CC=cc''

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#15389: 24.2.91; order of eval-after-load actions
  2013-09-15 22:41 bug#15389: 24.2.91; order of eval-after-load actions João Távora
@ 2013-09-16  6:58 ` Glenn Morris
  2013-09-16 11:17   ` João Távora
  2013-09-16 16:30 ` Stefan Monnier
  1 sibling, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2013-09-16  6:58 UTC (permalink / raw)
  To: João Távora; +Cc: 15389

João Távora wrote:

> Is this the expected behaviour? Shouldn't the order in which the hooks
> are run match the order of definition. 

I don't think eval-after-load promises anything about the order of
evaluation. At the moment, it works like add-hook, ie adds to the front
of the list. Do you have an example where it actually matters?

> In GNU Emacs 24.2.91.1 (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 AppKit 1138.51)

BTW, there's zero reason to use that anymore since 24.3 was released.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#15389: 24.2.91; order of eval-after-load actions
  2013-09-16  6:58 ` Glenn Morris
@ 2013-09-16 11:17   ` João Távora
  0 siblings, 0 replies; 4+ messages in thread
From: João Távora @ 2013-09-16 11:17 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 15389

Glenn Morris <rgm@gnu.org> writes:

> João Távora wrote:
>
>> Is this the expected behaviour? Shouldn't the order in which the hooks
>> are run match the order of definition.
>
> I don't think eval-after-load promises anything about the order of
> evaluation. At the moment, it works like add-hook, ie adds to the front
> of the list.

Well, add-hook has an `append' option right? That would be nice.

> Do you have an example where it actually matters?

Yes. I use small configuration files that are loaded in a particular
order to configure emacs in different flavors, an idea that I took from
debian, i believe, some years ago.

For example, take gnus. If I activate the "common" and "work" flavors in
that order, (which I do when I'm at work) the statements in the "work"
flavor will sometimes overwrite settings that I set in the "common"
flavor, like a different smtp servers.

It all worked fine until I remembered to introduce eval-after-load to
make startup faster.

I could possibly, for instance, never `setq' a variable directly in the
progn body passed to eval-after-load.

Using a million mode-specific hooks I could ensure that "work" always
takes precedence. But this would defeat the purpose of my simple
directories-flavors and 33some-foo-config.el scheme, which has served me
wonderfully for years now and relies on this simple feature of lisp.

But it would just be neater if the order of appearance matched the order
of evaluation.

I don't have to use eval-after-load. Isn't there another similar
mechanism? Where can I start looking?

>> In GNU Emacs 24.2.91.1 (x86_64-apple-darwin11.4.2, Carbon Version 1.6.0 AppKit 1138.51)
>
> BTW, there's zero reason to use that anymore since 24.3 was released.

There's a reason: this one's working fine. It takes me time and patience
to compile another emacs with my fullscreen patches.

Thanks,
João





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#15389: 24.2.91; order of eval-after-load actions
  2013-09-15 22:41 bug#15389: 24.2.91; order of eval-after-load actions João Távora
  2013-09-16  6:58 ` Glenn Morris
@ 2013-09-16 16:30 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-09-16 16:30 UTC (permalink / raw)
  To: João Távora; +Cc: 15389

> If I interactively eval these forms in order using `eval-last-sexp', for
> example I get

>     foo1
>     foo2

> in the *Messages* buffer. But if i load the file like so

>     emacs -Q --batch -l foo-test.el

> I get

>     foo2
>     foo1

> Is this the expected behaviour?

No, indeed, thank you for the clear test case.
Should now be fixed in the emacs-24 branch with the trivial patch below.


        Stefan


--- lisp/subr.el	2013-07-03 03:13:07 +0000
+++ lisp/subr.el	2013-09-16 16:28:00 +0000
@@ -1872,7 +1872,7 @@
 				      nil
 				    (remove-hook 'after-load-functions ',fun)
 				    ,',form)))
-		     (add-hook 'after-load-functions fun))
+		     (add-hook 'after-load-functions fun 'append))
 		 ;; Not being provided from a file, run form right now.
 		 ,form)))
       ;; Add FORM to the element unless it's already there.






^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-16 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-15 22:41 bug#15389: 24.2.91; order of eval-after-load actions João Távora
2013-09-16  6:58 ` Glenn Morris
2013-09-16 11:17   ` João Távora
2013-09-16 16:30 ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.