From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: bug#15888: 24.3.50; Eval-after-load eval'ed twice Date: Sat, 23 Nov 2013 15:05:29 +0100 Message-ID: <87iovj6wnq.fsf@gmail.com> References: <868uws6lgt.fsf@somewhere.org> <86ob5mxktp.fsf@somewhere.org> <4jppq1ha35.fsf@fencepost.gnu.org> <86pppwkvhg.fsf__36548.772143624$1384891681$gmane$org@somewhere.org> <87txf71zv9.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkDpk-00084f-3m for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 09:05:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VkDpe-0006Iv-SQ for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 09:05:16 -0500 Received: from mail-ea0-x22d.google.com ([2a00:1450:4013:c01::22d]:42833) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VkDpe-0006Ii-Ls for emacs-orgmode@gnu.org; Sat, 23 Nov 2013 09:05:10 -0500 Received: by mail-ea0-f173.google.com with SMTP id g15so1163260eak.32 for ; Sat, 23 Nov 2013 06:05:09 -0800 (PST) In-Reply-To: <87txf71zv9.fsf@gmail.com> (Nick Dokos's message of "Tue, 19 Nov 2013 23:06:02 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Nick Dokos Cc: emacs-orgmode@gnu.org Hello, Nick Dokos 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(# 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(# "~/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