joaotavora / yasnippet

A template system for Emacs

Home Page:http://joaotavora.github.io/yasnippet/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Self references in .yas-parents breaks Emacs

sheijk opened this issue · comments

cd /your/yasnippet/dir
mkdir -p snippets/sh-mode
echo "sh-mode" >> snippets/sh-mode/.yas-parents
emacs -Q -L . -l yasnippet.el -e yas-global-mode

Now do M-x sh-mode or open any file in sh-mode. This will cause an error in the post-command-hook which makes it impossible to still execute most commands. After this many commands will cause errors due to the post-command-hook function failing which makes it very hard to recover.

File mode specification error: (error "Lisp nesting exceeds max-lisp-eval-depth'") yas--all-parents: Lisp nesting exceedsmax-lisp-eval-depth'
Error in post-command-hook (yas-global-mode-check-buffers): (error "Lisp nesting exceeds `max-lisp-eval-depth'")

The issue is easily fixed by either deleting the .yas-parents file or fixing the invalid reference in the .yas-parents file. It would be a lot nicer to detect the error and issue an error message instead, though.

This happens at least with the most recent git version and the 0.8.0 snapshot. I have had this issue since a long time so most versions since changing to the .yas-parents system might have the issue. Also happens if no other plugins/config gets loaded. I've also been running into this on Windows (but have not reproduced it or checked the fix there).

Emacs version:

GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36) of 2012-08-27 on bob.porkrind.org

OK I understand, and marked this a bug. Your recipe has an error, you probably meant cd /your/yasnippet/dir/snippets. Still it's a valid bug report and a good example on how to report bugs. I've edited your original report to make a good example.

This fix introduces a new bug:

[yas] Cyclic parenthood: mode text-mode has already seen as a parent of mode emacs-lisp-mode
[yas] Loading for `emacs-lisp-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/emacs-lisp-mode (quote emacs-lisp-mode) (quote (text-mode)))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/emacs-lisp-mode
[yas] Loading for `text-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/text-mode (quote text-mode) (quote nil))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/text-mode
[yas] Loading for `text-mode', just-in-time: (yas--load-directory-1 /home/targzeta/.emacs.d/snippets/text-mode (quote text-mode) (quote (gpl)))!
[yas] Loading compiled snippets from /home/targzeta/.emacs.d/snippets/text-mode

And when I open a php file it shows again:

[yas] Cyclic parenthood: mode text-mode has already seen as a parent of mode emacs-lisp-mode

but the CPU grows to 100% and I have to kill emacs.

Best regards,
Emanuele

Thanks, I have just seen that happening. For now the workaround is not having cyclic dependencies in your snippet dirs.

Is there a cycling dependencies in these code?

$> grep . snippets/*/.yas-parents
snippets/sh-mode/.yas-parents:text-mode
snippets/text-mode/.yas-parents:gpl

I think the problem is because I have written a .yas-parent for text-mode where text-mode exists also in your default snippets. What do you think?

In effect, if I move my text-mode dir, I have:

[yas] Cyclic parenthood: mode text-mode has already seen as a parent of mode emacs-lisp-mode
[yas] Loading for `emacs-lisp-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/emacs-lisp-mode (quote emacs-lisp-mode) (quote (text-mode)))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/emacs-lisp-mode
[yas] Loading for `text-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/text-mode (quote text-mode) (quote nil))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/text-mode
For information about GNU Emacs and the GNU system, type C-h C-a.
(New file)
[yas] Cyclic parenthood: mode cc-mode has already seen as a parent of mode c-mode
[yas] Loading for `c-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/c-mode (quote c-mode) (quote (cc-mode)))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/c-mode
[yas] Loading for `php-mode', just-in-time: (yas--load-directory-1 /home/targzeta/.emacs.d/snippets/php-mode (quote php-mode) (quote nil))!
[yas] Loading compiled snippets from /home/targzeta/.emacs.d/snippets/php-mode
[yas] Loading for `cc-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/cc-mode (quote cc-mode) (quote (text-mode)))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/cc-mode

and, when I open a PHP file:

[yas] Cyclic parenthood: mode text-mode has already seen as a parent of mode html-mode
[yas] Loading for `html-mode', just-in-time: (yas--load-directory-1 /usr/share/emacs/site-lisp/snippets/html-mode (quote html-mode) (quote (text-mode)))!
[yas] Loading compiled snippets from /usr/share/emacs/site-lisp/snippets/html-mode

but, all works good, however.

Emanuele