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

2013-12-04 Thread Sebastien Vauban
Hello,

Nicolas Goaziou wrote:
 Nick Dokos ndo...@gmail.com writes:

 (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))

 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 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.

I want to be sure I fully grasp the problem completely...

You say that opening an Org file requires first `ob-lob' before *providing*
`org', right? [1]

IIUC, here are all the steps involved:

1. an Org file is opened
2. org.el is required -- but not yet provided at all, so loaded a first time
3. when loading it, it requires first extra packages; among others (via some
   call tree), ob-lob.el -- see [1]
4. ob-lob.el is then loaded, and in fine provided
5. eval-after-load ob-lob is run straight away, and tries to open an Org file
6. org.el is hence required -- but it still is not yet provided, so loaded a
   second time
7. at some point, org.el is provided for real
8. Eval-after-load org is run a first time, so are hooks
9. Eval-after-load org is run a second time, as the file has been loaded
   twice

IOW, isn't the problem that the `eval-after-load' is RUN AFTER EACH `provide' of
some lib, not after the FIRST `provide' of that lib?

It seems to me that such call trees can't be managed properly otherwise (I
mean, with the current rule: a lot of code may be run multiple times, while
only logically scheduled once).

Best regards,
  Seb

[1] I can't following the full library call tree:

  org - ??? - ob - ob-lob

-- 
Sebastien Vauban



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

2013-12-04 Thread Nicolas Goaziou
Hello,

Sebastien Vauban sva-n...@mygooglest.com writes:

 You say that opening an Org file requires first `ob-lob' before *providing*
 `org', right? [1]

Correct.

 IIUC, here are all the steps involved:

 1. an Org file is opened
 2. org.el is required -- but not yet provided at all, so loaded a first time
 3. when loading it, it requires first extra packages; among others (via some
call tree), ob-lob.el -- see [1]
 4. ob-lob.el is then loaded, and in fine provided
 5. eval-after-load ob-lob is run straight away, and tries to open an Org 
 file
 6. org.el is hence required -- but it still is not yet provided, so loaded a
second time
 7. at some point, org.el is provided for real
 8. Eval-after-load org is run a first time, so are hooks
 9. Eval-after-load org is run a second time, as the file has been loaded
twice

That's right.

 IOW, isn't the problem that the `eval-after-load' is RUN AFTER EACH `provide' 
 of
 some lib, not after the FIRST `provide' of that lib?

It seems to be a feature. See `after-load-alist' docstring.


Regards,

-- 
Nicolas Goaziou



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

2013-11-23 Thread Nicolas Goaziou
Hello,

Nick Dokos ndo...@gmail.com 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



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

2013-11-19 Thread Sebastien Vauban
Glenn Morris wrote:
 Apparently this is fixed:

 http://lists.gnu.org/archive/html/emacs-orgmode/2013-11/msg00682.html

Sadly, it's only partially fixed: if it is WELL fixed for the original code,
the problem comes BACK with the following minimized Emacs file:

--8---cut here---start-8---
(add-to-list 'load-path ~/Public/Repositories/org-mode/testing)
(add-to-list 'load-path ~/Public/Repositories/org-mode/contrib/lisp)
(add-to-list 'load-path ~/Public/Repositories/org-mode/lisp)

;; getting started
(require 'org-loaddefs)
(add-to-list 'auto-mode-alist '(\\.txt\\' . org-mode))
(add-to-list 'auto-mode-alist '(\\.org\\' . org-mode))

(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

(with-eval-after-load org
  (message Eval this when Org is loaded)
  (sit-for 3)
  (message ))

(message End of minimal .emacs)
--8---cut here---end---8---

FYI, I just added the lines 10-15 (expression with `ob-lob').

That's only reproducible with a development branch of Org mode, as
library-of-babel.org is not copied into the official Emacs release.

Best regards,
  Seb

-- 
Sebastien Vauban





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

2013-11-19 Thread Sebastien Vauban
Josh wrote:
 On Wed, Nov 13, 2013 at 1:27 PM, Sebastien Vauban wrote:

 (with-eval-after-load org
   (message Eval this when Org is loaded)
   (sit-for 3)
   (message ))

 the code block in the `with-eval-after-load' is eval'ed twice whenever an Org
 file is loaded.

 Have you checked to see what happens if you specify 'org (a symbol
 designating a feature) rather than org (a string representing a
 file name) above?

Yes, same problem with 'org, as shown with the following ECM.

--8---cut here---start-8---
(add-to-list 'load-path ~/Public/Repositories/org-mode/testing)
(add-to-list 'load-path ~/Public/Repositories/org-mode/contrib/lisp)
(add-to-list 'load-path ~/Public/Repositories/org-mode/lisp)

;; getting started
(require 'org-loaddefs)
(add-to-list 'auto-mode-alist '(\\.txt\\' . org-mode))
(add-to-list 'auto-mode-alist '(\\.org\\' . org-mode))

(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

(with-eval-after-load 'org
  (message Eval this when Org is loaded)
  (sit-for 3)
  (message ))

(message End of minimal .emacs)
--8---cut here---end---8---

Best regards,
  Seb

-- 
Sebastien Vauban




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

2013-11-19 Thread Nick Dokos
Sebastien Vauban sva-n...@mygooglest.com
writes:

 Glenn Morris wrote:
 Apparently this is fixed:

 http://lists.gnu.org/archive/html/emacs-orgmode/2013-11/msg00682.html

 Sadly, it's only partially fixed: if it is WELL fixed for the original code,
 the problem comes BACK with the following minimized Emacs file:

 (add-to-list 'load-path ~/Public/Repositories/org-mode/testing)
 (add-to-list 'load-path ~/Public/Repositories/org-mode/contrib/lisp)
 (add-to-list 'load-path ~/Public/Repositories/org-mode/lisp)

 ;; getting started
 (require 'org-loaddefs)
 (add-to-list 'auto-mode-alist '(\\.txt\\' . org-mode))
 (add-to-list 'auto-mode-alist '(\\.org\\' . org-mode))

 (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

 (with-eval-after-load org
   (message Eval this when Org is loaded)
   (sit-for 3)
   (message ))

 (message End of minimal .emacs)

 FYI, I just added the lines 10-15 (expression with `ob-lob').

 That's only reproducible with a development branch of Org mode, as
 library-of-babel.org is not copied into the official Emacs release.


Well, Nicolas warned us that we are not out of the woods yet. I repeated
the previous exercise, this time with the following file:

--8---cut here---start-8---
(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))
--8---cut here---end---8---

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:

--8---cut here---start-8---
  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)
  (progn (find-file file))
  (if file (progn (find-file file)))
  (progn (if file (progn (find-file file))) (setq to-be-removed 
(current-buffer)) (goto-char (point-min)) (while (re-search-forward 
org-babel-src-block-regexp nil t) (if (org-babel-active-location-p) (progn 
(goto-char (match-beginning 0)) (let ((full-block (match-string 0)) (beg-block 
(match-beginning 0)) (end-block (match-end 0)) (lang (match-string 2)) 
(beg-lang (match-beginning 2)) (end-lang (match-end 2)) (switches (match-string 
3)) (beg-switches (match-beginning 3)) (end-switches (match-end 3)) 
(header-args (match-string 4)) (beg-header-args (match-beginning 4)) 
(end-header-args (match-end 4)) (body (match-string 5)) (beg-body 
(match-beginning 5)) (end-body (match-end 5))) (let* ((info ...) (source-name 
...)) (if source-name (progn ...))) (goto-char end-block))
  (unwind-protect (progn (if file (progn (find-file file))) (setq to-be-removed 
(current-buffer)) (goto-char (point-min)) (while (re-search-forward 
org-babel-src-block-regexp nil t) (if (org-babel-active-location-p) (progn 
(goto-char (match-beginning 0)) (let ((full-block ...) (beg-block ...) 
(end-block ...) (lang ...) (beg-lang ...) (end-lang ...) (switches ...) 
(beg-switches ...) (end-switches ...) (header-args ...) (beg-header-args ...) 
(end-header-args ...) (body ...) (beg-body ...) (end-body ...)) (let* (... ...) 
(if source-name ...)) (goto-char end-block)) (set-window-configuration 
wconfig))
  (let ((wconfig (current-window-configuration))) (unwind-protect (progn (if 
file (progn (find-file file))) (setq to-be-removed (current-buffer)) (goto-char 
(point-min)) (while (re-search-forward org-babel-src-block-regexp nil t) (if 
(org-babel-active-location-p) (progn (goto-char (match-beginning 0)) 

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

2013-11-17 Thread Nicolas Goaziou
Hello,

Nick Dokos ndo...@gmail.com writes:

 I started emacs with 

   emacs -Q -L ~/src/emacs/org/org-mode/lisp -l double-load.el

 where double-load.el looks like this:


 (defun foobar ()
   (message LOADED) (sit-for 3) (message ))

 (setq org-load-hook (function foobar))

 and edebugged foobar. Then I did a C-x C-f foo.org. It stopped twice
 at foobar and I got backtraces (this is with the version that includes
 the change you suggested above). The first time it stopped, the backtrace
 looked like this:

Thank you. The problem should now be fixed.

Though, at some point, we will need a clear loading scheme. We're still
on thin ice.


Regards,

-- 
Nicolas Goaziou



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

2013-11-17 Thread Nick Dokos
Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Nick Dokos ndo...@gmail.com writes:

 I started emacs with 

   emacs -Q -L ~/src/emacs/org/org-mode/lisp -l double-load.el

 where double-load.el looks like this:


 (defun foobar ()
   (message LOADED) (sit-for 3) (message ))

 (setq org-load-hook (function foobar))

 and edebugged foobar. Then I did a C-x C-f foo.org. It stopped twice
 at foobar and I got backtraces (this is with the version that includes
 the change you suggested above). The first time it stopped, the backtrace
 looked like this:

 Thank you. The problem should now be fixed.


Confirm.

 Though, at some point, we will need a clear loading scheme. We're still
 on thin ice.


 Regards,

-- 
Nick




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

2013-11-17 Thread Nick Dokos
Nick Dokos ndo...@gmail.com writes:

 Nicolas Goaziou n.goaz...@gmail.com writes:
 ...

 Thank you. The problem should now be fixed.


 Confirm.


Sometimes I blab endlessly but sometimes I'm way too terse: here I meant
to say

I confirm that it is fixed.

-- 
Nick




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

2013-11-17 Thread Glenn Morris

Apparently this is fixed:

http://lists.gnu.org/archive/html/emacs-orgmode/2013-11/msg00682.html

Sadly the relevant messages were not sent to this tracker.

In case people do not know: you can think of ###@debbugs as an alias to
the bug-gnu-emacs@gnu list for bugs in package emacs, to
emacs-orgmode@gnu for bugs in package org-mode, and to both lists for
bugs in both packages. This is the whole reason why you see bug#123
messages appearing on your lists.






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

2013-11-16 Thread Josh
On Wed, Nov 13, 2013 at 1:27 PM, Sebastien Vauban
sva-n...@mygooglest.com wrote:
 (with-eval-after-load org
   (message Eval this when Org is loaded)
   (sit-for 3)
   (message ))

 the code block in the `with-eval-after-load' is eval'ed twice whenever an Org
 file is loaded.

Have you checked to see what happens if you specify 'org (a symbol
designating a feature) rather than org (a string representing a
file name) above?





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

2013-11-16 Thread Nick Dokos
Nicolas Goaziou n.goaz...@gmail.com writes:

 Hello,

 Nick Dokos ndo...@gmail.com writes:

 Glenn Morris r...@gnu.org writes:

 Sebastien Vauban wrote:

 But I wonder: how can you now reproduce it (and not before)?

 Because I downloaded a snapshot of Org.
 Your problem is not with code that is in Emacs current trunk.

 Using Glenn's reproducer, I bisected it - another one for Nicolas's
 TODO list, proving once again that no good deed goes unpunished :-)

 0cecf32a0ae559266555b96668dc305710366c96 is the first bad commit
 commit 0cecf32a0ae559266555b96668dc305710366c96
 Author: Nicolas Goaziou n.goaz...@gmail.com
 Date:   Sun Oct 27 11:09:17 2013 +0100

 Well. The only thing related to load/autoload I can think of is calling
 `org-element-cache-reset' in `org-mode' and `org-set-modules'.

 Could you try to replace these calls with

   (when (fboundp 'org-element-cache-reset) (org-element-cache-reset))

 and test again?



Assuming I've done everything correctly, this does not fix it.

Here's the diff of what I did - let me know if I goofed:

--8---cut here---start-8---
diff --git a/lisp/org.el b/lisp/org.el
index a3c1958..53eea84 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -373,7 +373,8 @@ When MESSAGE is non-nil, display a message with the 
version.
   (set var value)
   (when (featurep 'org)
 (org-load-modules-maybe 'force)
-(org-element-cache-reset 'all)))
+(when (fboundp 'org-element-cache-reset) (org-element-cache-reset 'all
+;(org-element-cache-reset 'all)))
 
 (defcustom org-modules '(org-w3m org-bbdb org-bibtex org-docview org-gnus 
org-info org-irc org-mhe org-rmail)
   Modules that should always be loaded together with org.el.
@@ -5361,7 +5362,8 @@ The following commands are available:
   ;; Comments.
   (org-setup-comments-handling)
   ;; Initialize cache.
-  (org-element-cache-reset)
+  ;; (org-element-cache-reset)
+  (when (fboundp 'org-element-cache-reset) (org-element-cache-reset))
   ;; Beginning/end of defun
   (org-set-local 'beginning-of-defun-function 'org-backward-element)
   (org-set-local 'end-of-defun-function 'org-forward-element)
--8---cut here---end---8---

 Regards,

-- 
Nick




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

2013-11-16 Thread Nick Dokos
Nicolas Goaziou n.goaz...@gmail.com writes:


 0cecf32a0ae559266555b96668dc305710366c96 is the first bad commit
 commit 0cecf32a0ae559266555b96668dc305710366c96
 Author: Nicolas Goaziou n.goaz...@gmail.com
 Date:   Sun Oct 27 11:09:17 2013 +0100

 Well. The only thing related to load/autoload I can think of is calling
 `org-element-cache-reset' in `org-mode' and `org-set-modules'.

 Could you try to replace these calls with

   (when (fboundp 'org-element-cache-reset) (org-element-cache-reset))

 and test again?


I started emacs with 

  emacs -Q -L ~/src/emacs/org/org-mode/lisp -l double-load.el

where double-load.el looks like this:

--8---cut here---start-8---

(defun foobar ()
  (message LOADED) (sit-for 3) (message ))

(setq org-load-hook (function foobar))
--8---cut here---end---8---

and edebugged foobar. Then I did a C-x C-f foo.org. It stopped twice
at foobar and I got backtraces (this is with the version that includes
the change you suggested above). The first time it stopped, the backtrace
looked like this:

--8---cut here---start-8---
  foobar()
  run-hooks(org-load-hook)
  eval-buffer(#buffer  *load*-343984 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)
  require(org)
  eval-buffer(#buffer  *load*-57513 nil 
/home/nick/src/emacs/org/org-mode/lisp/org-element.el nil t)
  
load-with-code-conversion(/home/nick/src/emacs/org/org-mode/lisp/org-element.el
 /home/nick/src/emacs/org/org-mode/lisp/org-element.el nil t)
  (org-element-cache-reset (quote all))
  (progn (org-element-cache-reset (quote all)))
  (if (fboundp (quote org-element-cache-reset)) (progn (org-element-cache-reset 
(quote all
  (lambda (var val) (set var val) (if (fboundp (quote org-element-cache-reset)) 
(progn (org-element-cache-reset (quote all)(org-footnote-section 
Footnotes)
  custom-initialize-set(org-footnote-section Footnotes)
  custom-declare-variable(org-footnote-section Footnotes Outline heading 
containing footnote definitions.\n\nThis can be nil, to place footnotes locally 
at the end of the\ncurrent outline node.  If can also be the name of a 
special\noutline heading under which footnotes should be put.\n\nThis variable 
defines the place where Org puts the definition\nautomatically, i.e. when 
creating the footnote, and when sorting\nthe notes.  However, by hand you may 
place definitions\n*anywhere*.\n\nIf this is a string, during export, all 
subtrees starting with\nthis heading will be ignored.\n\nIf you don't use the 
customize interface to change this variable,\nyou will need to run the 
following command after the change:\n\n  \\[universal-argument] 
\\[org-element-cache-reset] :group org-footnote :initialize 
custom-initialize-set :set (lambda (var val) (set var val) (if (fboundp (quote 
org-element-cache-reset)) (progn (org-element-cache-reset (quote all) :type 
(choice (string :tag Collect footnotes under heading) (const :tag Define 
footnotes locally nil)))
  eval-buffer(#buffer  *load*-118381 nil 
/home/nick/src/emacs/org/org-mode/lisp/org-footnote.el nil t)
  
load-with-code-conversion(/home/nick/src/emacs/org/org-mode/lisp/org-footnote.el
 /home/nick/src/emacs/org/org-mode/lisp/org-footnote.el nil t)
  require(org-footnote)
  eval-buffer(#buffer  *load* 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(t t)
  find-file-noselect-1(#buffer foo.org ~/src/emacs/org/org-mode/foo.org nil 
nil ~/src/emacs/org/org-mode/foo.org nil)
  find-file-noselect(~/src/emacs/org/org-mode/foo.org nil nil t)
  find-file(~/src/emacs/org/org-mode/foo.org t)
  call-interactively(find-file nil nil)
  command-execute(find-file)

--8---cut here---end---8---

The second time it stopped, the backtrace looked like this:

--8---cut here---start-8---
  foobar()
  run-hooks(org-load-hook)
  eval-buffer(#buffer  *load* 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(t t)
  find-file-noselect-1(#buffer foo.org ~/src/emacs/org/org-mode/foo.org nil 
nil ~/src/emacs/org/org-mode/foo.org nil)
  find-file-noselect(~/src/emacs/org/org-mode/foo.org nil nil t)
  find-file(~/src/emacs/org/org-mode/foo.org t)
  call-interactively(find-file nil nil)
  command-execute(find-file)
--8---cut here---end---8---

Hope this helps.


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

2013-11-15 Thread Sebastien Vauban
Eli Zaretskii wrote:
 From: Sebastien Vauban sva-n...@mygooglest.com
 Date: Thu, 14 Nov 2013 19:57:02 +0100
 Cc: 15...@debbugs.gnu.org
 
 0. Copy the minimal configuration in the clipboard
 1. Go into C:/Program Files/emacs-trunk/bin/
 2. Launch emacs -Q
 3. Paste the minimal configuration in the scratch buffer
 4. Eval it
 5. Open one random Org file (~/Public/Repositories/worg/ChangeLog.org)
 6. Look at the echo area
 7. Check in the Messages buffer - block has been executed twice!
 
 See http://screencast.com/t/pfWMZStlb23Z.
 
 I do not see where extra `load' instructions could stay hidden (and out of my
 mind) by applying this recipe.
 
 Where is the black magic?

 Instead of wondering, run all this under GDB, after putting a
 breakpoint at Fload, and see whodunit.

 Since 'load' is potentially called many times during startup, I
 suggest the following setup:

  (gdb) break Fload
  (gdb) commands
 p file
 xstring
 end
  (gdb) r -Q

 Now, when the breakpoint breaks, you will see which file is being
 loaded, and need just type c RET (or just RET after the first
 time), and wait for org-mode to show in the output of the above
 commands; then type bt to see who loaded it.

Here it is.

$ gdb -p 12788
GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-cygwin.
Type show configuration for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type help.
Type apropos word to search for commands related to word.

Attaching to process 12788
[New Thread 12788.0x396c]
[New Thread 12788.0x2a78]
[New Thread 12788.0x25ec]
Reading symbols from /cygdrive/c/Program Files 
(x86)/emacs-trunk/bin/emacs...done.
Warning: /cygdrive/c/Program Files (x86)/emacs-trunk/bin/../lwlib: No such file 
or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from 
terminal]
Environment variable DISPLAY not defined.
TERM = xterm-256color
Breakpoint 1 at 0x10e1819: file ../../repo/src/emacs.c, line 349.
Temporary breakpoint 2 at 0x1104806: file ../../repo/src/sysdep.c, line 846.
(gdb) break Fload
Breakpoint 3 at 0x119c210: file ../../repo/src/lread.c, line 1044.
(gdb) commands
Type commands for breakpoint(s) 3, one per line.
End with a line saying just end.
p file
xstring
end
(gdb) r -Q
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /cygdrive/c/Program Files (x86)/emacs-trunk/bin/emacs -Q
[New Thread 3332.0x1bfc]
[New Thread 3332.0xaf4]
[New Thread 3332.0xca4]

Breakpoint 3, Fload (file=59406449, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048../../repo/src/lread.c: No such file or directory.
$1 = 59406449
$2 = (struct Lisp_String *) 0x38a7870
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/subdirs.el
(gdb) c
Continuing.

Breakpoint 3, Fload (file=60206689, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$3 = 60206689
$4 = (struct Lisp_String *) 0x396ae60
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/vc/subdirs.el
(gdb)
Continuing.

Breakpoint 3, Fload (file=60206625, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$5 = 60206625
$6 = (struct Lisp_String *) 0x396ae20
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/url/subdirs.el
(gdb)
Continuing.

Breakpoint 3, Fload (file=60206577, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$7 = 60206577
$8 = (struct Lisp_String *) 0x396adf0
c:/Program Files 
(x86)/emacs-trunk/share/emacs/24.3.50/lisp/textmodes/subdirs.el
(gdb)
Continuing.

Breakpoint 3, Fload (file=60206529, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$9 = 60206529
$10 = (struct Lisp_String *) 0x396adc0
c:/Program Files 
(x86)/emacs-trunk/share/emacs/24.3.50/lisp/progmodes/subdirs.el
(gdb)
Continuing.

Breakpoint 3, Fload (file=60206481, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$11 = 60206481
$12 = (struct Lisp_String *) 0x396ad90
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/play/subdirs.el

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

2013-11-15 Thread Sebastien Vauban
Bastien wrote:
 Glenn Morris r...@gnu.org writes:
 Sebastien Vauban wrote:

 Where is the black magic?

 Somewhere in the labyrinthine depths of Org, so I suggest you ask the
 Org maintainers to figure out why:

 emacs -Q -L /path/to/git/org-mode/lisp
 (with-eval-after-load org
   (message Eval this when Org is loaded)
   (sit-for 3)
   (message ))
 (require 'org)

 ends up loading org twice.

 I fixed this by removing any use of `org-autoload', which looked like
 code smell to me.

 This is in Org 8.2.3c, which I just released.

 Sébastien, can you confirmed this?

I updated, made the autoloads, and rerun my test.

Conclusion: it does not solve it.

See http://screencast.com/t/JlbEBkonN.

Best regards,
  Seb

-- 
Sebastien Vauban





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

2013-11-15 Thread Eli Zaretskii
 From: Sebastien Vauban sva-n...@mygooglest.com
 Cc: r...@gnu.org,  michael_heerde...@web.de,  15...@debbugs.gnu.org
 Date: Fri, 15 Nov 2013 09:16:44 +0100
 
   (gdb) break Fload
   (gdb) commands
  p file
  xstring
  end
   (gdb) r -Q
 
  Now, when the breakpoint breaks, you will see which file is being
  loaded, and need just type c RET (or just RET after the first
  time), and wait for org-mode to show in the output of the above
  commands; then type bt to see who loaded it.
 
 Here it is.

Thanks.

Unfortunately, this:

 (gdb) No symbol backtrace_list in current context.

(whose reason I don't really understand) means that the Lisp backtrace
is absent from your data.  Nevertheless, given this part:

 Breakpoint 3, Fload (file=60203985, noerror=57608218, nomessage=57608242, 
 nosuffix=57608218, must_suffix=57608242) at ../../repo/src/lread.c:1048
 1048in ../../repo/src/lread.c
 $53 = 60203985
 $54 = (struct Lisp_String *) 0x396a3d0
 org-loaddefs
 (gdb)
 Continuing.
 [Thread 3332.0xaf4 exited with code 0]
 
 Breakpoint 3, Fload (file=59407297, noerror=57608218, nomessage=57608242, 
 nosuffix=57608218, must_suffix=57608242) at ../../repo/src/lread.c:1048
 1048in ../../repo/src/lread.c
 $55 = 59407297
 $56 = (struct Lisp_String *) 0x38a7bc0
 org

It is quite clear that org-loaddefs has something to do with the
problem.  As I understand it, Bastien just fixed that in Org trunk.

Thanks.





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

2013-11-15 Thread Sebastien Vauban
Eli Zaretskii wrote:
 Unfortunately, this:

 (gdb) No symbol backtrace_list in current context.

 (whose reason I don't really understand) means that the Lisp backtrace
 is absent from your data.

Should the following explain it?  As I had no .gdbinit file (hence, no
definition for xstring), I had to found one that would match the requirements.

I took the .gdbinit from
http://alpha.gnu.org/gnu/emacs/pretest/emacs-24.2.90.tar.gz:

--8---cut here---start-8---
# Copyright (C) 1992-1998, 2000-2012  Free Software Foundation, Inc.
#
# This file is part of GNU Emacs.
#
# GNU Emacs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

# Force loading of symbols, enough to give us VALBITS etc.
set $dummy = main + 8
# With some compilers, we need this to give us struct Lisp_Symbol etc.:
set $dummy = Fmake_symbol + 8

# Find lwlib source files too.
dir ../lwlib
#dir /gd/gnu/lesstif-0.89.9/lib/Xm

# Don't enter GDB when user types C-g to quit.
# This has one unfortunate effect: you can't type C-c
# at the GDB to stop Emacs, when using X.
# However, C-z works just as well in that case.
handle 2 noprint pass

# Make it work like SIGINT normally does.
handle SIGTSTP nopass

# Pass on user signals
handle SIGUSR1 noprint pass
handle SIGUSR2 noprint pass

# Don't pass SIGALRM to Emacs.  This makes problems when
# debugging.
handle SIGALRM ignore

# Use $bugfix so that the value isn't a constant.
# Using a constant runs into GDB bugs sometimes.
define xgetptr
  if (CHECK_LISP_OBJECT_TYPE)
set $bugfix = $arg0.i
  else
set $bugfix = $arg0
  end
  set $ptr = ($bugfix  VALMASK) | DATA_SEG_BITS
end

define xgetint
  if (CHECK_LISP_OBJECT_TYPE)
set $bugfix = $arg0.i
  else
set $bugfix = $arg0
  end
  set $int = $bugfix  (USE_LSB_TAG ? 0 : INTTYPEBITS)  INTTYPEBITS
end

define xgettype
  if (CHECK_LISP_OBJECT_TYPE)
set $bugfix = $arg0.i
  else
set $bugfix = $arg0
  end
  set $type = (enum Lisp_Type) (USE_LSB_TAG ? $bugfix  (1  GCTYPEBITS) - 1 : 
$bugfix  VALBITS)
end

# Set up something to print out s-expressions.
# We save and restore print_output_debug_flag to prevent the w32 port
# from calling OutputDebugString, which causes GDB to display each
# character twice (yuk!).
define pr
  pp $
end
document pr
Print the emacs s-expression which is $.
Works only when an inferior emacs is executing.
end

# Print out s-expressions
define pp
  set $tmp = $arg0
  set $output_debug = print_output_debug_flag
  set print_output_debug_flag = 0
  call safe_debug_print ($tmp)
  set print_output_debug_flag = $output_debug
end
document pp
Print the argument as an emacs s-expression
Works only when an inferior emacs is executing.
end

# Print value of lisp variable
define pv
  set $tmp = $arg0
  set $output_debug = print_output_debug_flag
  set print_output_debug_flag = 0
  call safe_debug_print (find_symbol_value (intern ($tmp)))
  set print_output_debug_flag = $output_debug
end
document pv
Print the value of the lisp variable given as argument.
Works only when an inferior emacs is executing.
end

# Print out current buffer point and boundaries
define ppt
  set $b = current_buffer
  set $t = $b-text
  printf BUF PT: %d, $b-pt
  if ($b-pt != $b-pt_byte)
printf [%d], $b-pt_byte
  end
  printf  of 1..%d, $t-z
  if ($t-z != $t-z_byte)
printf [%d], $t-z_byte
  end
  if ($b-begv != 1 || $b-zv != $t-z)
printf  NARROW=%d..%d, $b-begv, $b-zv
if ($b-begv != $b-begv_byte || $b-zv != $b-zv_byte)
  printf  [%d..%d], $b-begv_byte, $b-zv_byte
end
  end
  printf  GAP: %d, $t-gpt
  if ($t-gpt != $t-gpt_byte)
printf [%d], $t-gpt_byte
  end
  printf  SZ=%d\n, $t-gap_size
end
document ppt
Print current buffer's point and boundaries.
Prints values of point, beg, end, narrow, and gap for current buffer.
end

define pitmethod
  set $itmethod = $arg0
  # output $itmethod
  if ($itmethod == 0)
printf GET_FROM_BUFFER
  end
  if ($itmethod == 1)
printf GET_FROM_DISPLAY_VECTOR
  end
  if ($itmethod == 2)
printf GET_FROM_STRING
  end
  if ($itmethod == 3)
printf GET_FROM_C_STRING
  end
  if ($itmethod == 4)
printf GET_FROM_IMAGE
  end
  if ($itmethod == 5)
printf GET_FROM_STRETCH
  end
  if ($itmethod  0 || $itmethod  5)
output $itmethod
  end
end
document pitmethod
Pretty print it-method given as first arg
end

# Print out iterator 

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

2013-11-15 Thread Eli Zaretskii
 From: Sebastien Vauban sva-n...@mygooglest.com
 Cc: r...@gnu.org,  michael_heerde...@web.de,  15...@debbugs.gnu.org
 Date: Fri, 15 Nov 2013 10:06:12 +0100
 
 Eli Zaretskii wrote:
  Unfortunately, this:
 
  (gdb) No symbol backtrace_list in current context.
 
  (whose reason I don't really understand) means that the Lisp backtrace
  is absent from your data.
 
 Should the following explain it?  As I had no .gdbinit file (hence, no
 definition for xstring), I had to found one that would match the requirements.
 
 I took the .gdbinit from
 http://alpha.gnu.org/gnu/emacs/pretest/emacs-24.2.90.tar.gz:

You should use the one from the bzr revision used to produce the
binary you are running.  You should be able to get that from
http://bzr.savannah.gnu.org/lh/emacs/trunk/files.





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

2013-11-15 Thread Sebastien Vauban
Eli Zaretskii wrote:
 From: Sebastien Vauban sva-n...@mygooglest.com
 Cc: r...@gnu.org,  michael_heerde...@web.de,  15...@debbugs.gnu.org
 Date: Fri, 15 Nov 2013 10:06:12 +0100
 
 Eli Zaretskii wrote:
  Unfortunately, this:
 
  (gdb) No symbol backtrace_list in current context.
 
  (whose reason I don't really understand) means that the Lisp backtrace
  is absent from your data.
 
 Should the following explain it?  As I had no .gdbinit file (hence, no
 definition for xstring), I had to found one that would match the 
 requirements.
 
 I took the .gdbinit from
 http://alpha.gnu.org/gnu/emacs/pretest/emacs-24.2.90.tar.gz:

 You should use the one from the bzr revision used to produce the
 binary you are running.  You should be able to get that from
 http://bzr.savannah.gnu.org/lh/emacs/trunk/files.

Thanks. I've put it under ~/, and source it in the following session.

Here the new trace.

What's weird is that I only saw once org, but still have the code block
executed twice in Emacs.

--8---cut here---start-8---
$ gdb -p 12736
GNU gdb (GDB) 7.6.50.20130728-cvs (cygwin-special)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type show copying
and show warranty for details.
This GDB was configured as i686-pc-cygwin.
Type show configuration for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type help.
Type apropos word to search for commands related to word.

/cygdrive/d/Users/fni/.gdbinit:21: Error in sourced command file:
No symbol table is loaded.  Use the file command.
Attaching to process 12736
[New Thread 12736.0x7e8]
[New Thread 12736.0x3610]
[New Thread 12736.0x4cc]
Reading symbols from /cygdrive/c/Program Files 
(x86)/emacs-trunk/bin/emacs...done.
(gdb) break Fload
Breakpoint 1 at 0x119c210: file ../../repo/src/lread.c, line 1044.
(gdb) commands
Type commands for breakpoint(s) 1, one per line.
End with a line saying just end.
p file
xstring
end
(gdb) source ~/.gdbinit
Warning: /cygdrive/c/Program Files (x86)/emacs-trunk/bin/../lwlib: No such file 
or directory.
SIGINT is used by the debugger.
Are you sure you want to change it? (y or n) [answered Y; input not from 
terminal]
Environment variable DISPLAY not defined.
TERM = xterm-256color
Breakpoint 2 at 0x10e1819: file ../../repo/src/emacs.c, line 349.
Temporary breakpoint 3 at 0x1104806: file ../../repo/src/sysdep.c, line 846.
(gdb) r -Q
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /cygdrive/c/Program Files (x86)/emacs-trunk/bin/emacs -Q
[1]  + done   ./emacs -Q
[New Thread 5184.0x336c]
[New Thread 5184.0x22c0]
[New Thread 5184.0x2bc8]

Breakpoint 1, Fload (file=59406449, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048../../repo/src/lread.c: No such file or directory.
$1 = 59406449
$2 = (struct Lisp_String *) 0x38a7870
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/subdirs.el
(gdb) c
Continuing.

Breakpoint 1, Fload (file=60206689, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$3 = 60206689
$4 = (struct Lisp_String *) 0x396ae60
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/vc/subdirs.el
(gdb)
Continuing.

Breakpoint 1, Fload (file=60206625, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$5 = 60206625
$6 = (struct Lisp_String *) 0x396ae20
c:/Program Files (x86)/emacs-trunk/share/emacs/24.3.50/lisp/url/subdirs.el
(gdb)
Continuing.

Breakpoint 1, Fload (file=60206577, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$7 = 60206577
$8 = (struct Lisp_String *) 0x396adf0
c:/Program Files 
(x86)/emacs-trunk/share/emacs/24.3.50/lisp/textmodes/subdirs.el
(gdb)
Continuing.

Breakpoint 1, Fload (file=60206529, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$9 = 60206529
$10 = (struct Lisp_String *) 0x396adc0
c:/Program Files 
(x86)/emacs-trunk/share/emacs/24.3.50/lisp/progmodes/subdirs.el
(gdb)
Continuing.

Breakpoint 1, Fload (file=60206481, noerror=57608242, nomessage=57608242, 
nosuffix=57608242, must_suffix=57608218) at ../../repo/src/lread.c:1048
1048in ../../repo/src/lread.c
$11 = 60206481
$12 = (struct Lisp_String *) 0x396ad90
c:/Program Files 

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

2013-11-15 Thread Stefan Monnier
BTW, it's probably easier to debug this in Elisp.
You can start with

(add-hook 'after-load-functions
  (lambda (file) (message Loaded %S file)))

Or change your recipe to replace (sit-for 3) with (debug).


Stefan





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

2013-11-15 Thread Sebastien Vauban
Stefan Monnier wrote:
 BTW, it's probably easier to debug this in Elisp.
 You can start with

 (add-hook 'after-load-functions
   (lambda (file) (message Loaded %S file)))

 Or change your recipe to replace (sit-for 3) with (debug).

Right. The above can prove very useful. Thanks!

Best regards,
  Seb

-- 
Sebastien Vauban





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

2013-11-15 Thread Eli Zaretskii
 From: Sebastien Vauban sva-n...@mygooglest.com
 Cc: Sebastien Vauban sva-n...@mygooglest.com,  michael_heerde...@web.de,  
 15...@debbugs.gnu.org
 Date: Fri, 15 Nov 2013 14:01:10 +0100
 
 What's weird is that I only saw once org, but still have the code block
 executed twice in Emacs.

That probably means that some Lisp does the equivalent of
eval-after-load somewhere.





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

2013-11-15 Thread Glenn Morris
Sebastien Vauban wrote:

 But I wonder: how can you now reproduce it (and not before)?

Because I downloaded a snapshot of Org.
Your problem is not with code that is in Emacs current trunk.





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

2013-11-15 Thread Nick Dokos
Glenn Morris r...@gnu.org writes:

 Sebastien Vauban wrote:

 But I wonder: how can you now reproduce it (and not before)?

 Because I downloaded a snapshot of Org.
 Your problem is not with code that is in Emacs current trunk.

Using Glenn's reproducer, I bisected it - another one for Nicolas's
TODO list, proving once again that no good deed goes unpunished :-)

0cecf32a0ae559266555b96668dc305710366c96 is the first bad commit
commit 0cecf32a0ae559266555b96668dc305710366c96
Author: Nicolas Goaziou n.goaz...@gmail.com
Date:   Sun Oct 27 11:09:17 2013 +0100

org-element: Implement caching for dynamic parser

* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.

This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.

:04 04 d1c8eb78998a7fd1266ff2fb2748842dba4ea3b9 
d7f65666fe694ec51132833e45061a38d1a1bb3f M  lisp
:04 04 ed2b1f509358abd49f10431abb6b933ae4c505de 
fa669197f78a08839d14a35f4906826c69233626 M  testing




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

2013-11-15 Thread Nicolas Goaziou
Hello,

Nick Dokos ndo...@gmail.com writes:

 Glenn Morris r...@gnu.org writes:

 Sebastien Vauban wrote:

 But I wonder: how can you now reproduce it (and not before)?

 Because I downloaded a snapshot of Org.
 Your problem is not with code that is in Emacs current trunk.

 Using Glenn's reproducer, I bisected it - another one for Nicolas's
 TODO list, proving once again that no good deed goes unpunished :-)

 0cecf32a0ae559266555b96668dc305710366c96 is the first bad commit
 commit 0cecf32a0ae559266555b96668dc305710366c96
 Author: Nicolas Goaziou n.goaz...@gmail.com
 Date:   Sun Oct 27 11:09:17 2013 +0100

Well. The only thing related to load/autoload I can think of is calling
`org-element-cache-reset' in `org-mode' and `org-set-modules'.

Could you try to replace these calls with

  (when (fboundp 'org-element-cache-reset) (org-element-cache-reset))

and test again?


Regards,

-- 
Nicolas Goaziou



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

2013-11-14 Thread Glenn Morris
Sebastien Vauban wrote:

 Where is the black magic?

Somewhere in the labyrinthine depths of Org, so I suggest you ask the
Org maintainers to figure out why:

emacs -Q -L /path/to/git/org-mode/lisp
(with-eval-after-load org
  (message Eval this when Org is loaded)
  (sit-for 3)
  (message ))
(require 'org)

ends up loading org twice.





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

2013-11-14 Thread Glenn Morris

It's nothing to do with eval-after-load. Same result with:

emacs -Q -L /path/to/org/git/lisp \
   --eval '(setq org-load-hook (lambda () (message LOADED) (sit-for 3) 
(message )))'

Then (require 'org). It is some peculiarity of Org trunk.





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

2013-11-14 Thread Bastien
Glenn Morris r...@gnu.org writes:

 Sebastien Vauban wrote:

 Where is the black magic?

 Somewhere in the labyrinthine depths of Org, so I suggest you ask the
 Org maintainers to figure out why:

 emacs -Q -L /path/to/git/org-mode/lisp
 (with-eval-after-load org
   (message Eval this when Org is loaded)
   (sit-for 3)
   (message ))
 (require 'org)

 ends up loading org twice.

I fixed this by removing any use of `org-autoload', which looked like
code smell to me.

This is in Org 8.2.3c, which I just released.

Sébastien, can you confirmed this?

-- 
 Bastien





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

2013-11-14 Thread Sebastien Vauban
Glenn Morris wrote:
 It's nothing to do with eval-after-load. Same result with:

 emacs -Q -L /path/to/org/git/lisp \
--eval '(setq org-load-hook (lambda () (message LOADED) (sit-for 3) 
 (message )))'

 Then (require 'org). It is some peculiarity of Org trunk.

I'll do ask this on Org ML, and I'll make the test of Eli anyway.

But I wonder: how can you now reproduce it (and not before)?

Best regards,
  Seb

-- 
Sebastien Vauban