emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] bug#15888: 24.3.50; Eval-after-load eval'ed twice


From: Nicolas Goaziou
Subject: Re: [O] bug#15888: 24.3.50; Eval-after-load eval'ed twice
Date: Sat, 23 Nov 2013 15:05:29 +0100

Hello,

Nick Dokos <address@hidden> writes:

> Well, Nicolas warned us that we are not out of the woods yet. I repeated
> the previous exercise, this time with the following file:
>
> (add-to-list 'load-path (expand-file-name "~/src/emacs/org/org-mode/lisp"))
> (add-to-list 'load-path (expand-file-name 
> "~/src/emacs/org/org-mode/contrib/lisp"))
>
> (add-to-list 'auto-mode-alist '("\\.\\(org\\|org_archive\\|txt\\)$" . 
> org-mode))
>
> (require 'org-loaddefs)
>
> (with-eval-after-load "ob-lob"
>   ;; load some code blocks into the library of Babel
>   (let ((lob-file (concat (file-name-directory (locate-library "org"))
>                           "../doc/library-of-babel.org")))
>     (when (file-exists-p lob-file)
>       (org-babel-lob-ingest lob-file))))
>
> (defun foobar ()
>   (message "LOADED") (sit-for 3) (message ""))
>
> (setq org-load-hook (function foobar))
>
> started emacs with
>
>   emacs -Q -l ./double-load.el
>
> edebugged foobar and C-x C-f foo.org. It stopped at foobar twice
> and I got the following backtraces at the two stopping points.
>
> The first backtrace looks like this:
>
>   foobar()
>   run-hooks(org-load-hook)
>   eval-buffer(#<buffer  *load*-648596> nil 
> "/home/nick/src/emacs/org/org-mode/lisp/org.el" nil t)
>   load-with-code-conversion("/home/nick/src/emacs/org/org-mode/lisp/org.el" 
> "/home/nick/src/emacs/org/org-mode/lisp/org.el" nil t)
>   org-mode()
>   set-auto-mode-0(org-mode nil)
>   set-auto-mode()
>   normal-mode(t)
>   after-find-file(nil t)
>   find-file-noselect-1(#<buffer library-of-babel.org> 
> "~/src/emacs/org/org-mode/doc/library-of-babel.org" nil nil 
> "~/src/emacs/org/org-mode/doc/library-of-babel.org" (16393680 2097))
>   
> find-file-noselect("/home/nick/src/emacs/org/org-mode/lisp/../doc/library-of-babel.org"
>  nil nil nil)
>   
> find-file("/home/nick/src/emacs/org/org-mode/lisp/../doc/library-of-babel.org")

The code in "double-load.el" calls `org-babel-lob-ingest' as soon as
"ob-lob.el" is loaded. The problem is that:

  1. `org-babel-lob-ingest' needs to open an Org file (and therefore
     call `org-mode' in its buffer);
  2. `ob-lob' is required before `org' is provided.

Therefore, org.el is read twice and hook run as many times.

A straightforward solution is to call apply `eval-after-load' on `org'
instead of `ob-lob', since Org will eventually load Babel anyway.

Eric may have a better solution, though.


Regards,

-- 
Nicolas Goaziou



reply via email to

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