Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird issues since cleanup commit 18f7b1 #673

Closed
syl20bnr opened this issue Apr 9, 2016 · 11 comments · Fixed by #676
Closed

Weird issues since cleanup commit 18f7b1 #673

syl20bnr opened this issue Apr 9, 2016 · 11 comments · Fixed by #676
Labels

Comments

@syl20bnr
Copy link

syl20bnr commented Apr 9, 2016

Hey guys,

Bear with me since I have no repro steps but I will try to explain the symptoms clearly enough for you to find a solution.

First I'm pretty sure it does not come from Spacemacs config but OTOH if I emacs -Q and require yasnippet the symptoms does not appear.

Here are the symptoms:

  • Starting Emacs gives (void-function yas--load-pending-jits)
  • So I tried with emacs -Q --> works
  • Then I removed some configuration of Yasnippet from Spacemacs, still the error
  • The error seems to be triggered as soon as I add yas-minor-mode to emacs-lisp-mode-hook
  • I dug into yasnippet.el and move around some code, namely moving yas--load-pending-jits before define-minor-mode and the error disappeared and was replaced by another missing symbol used in yas--load-pending-jits
  • This was pulling an endless string so I put the definition of the minor mode at the end of the file and then I got a Recursive load error.

Sorry for lacking a repro step, I will try to add one at some point. I hope this description of the symptoms will be enough and most importantly I hope to learn why those errors are triggered.

cc @monnier @npostavs

EDIT: these errors let a dangling hook in post-command-hook and prevent Emacs from being usable.

@npostavs
Copy link
Collaborator

npostavs commented Apr 9, 2016

Oh, I think see what it is. The change below creates a buffer in emacs-lisp-mode while loading yasnippet.el, creating this buffer starts yas-minor-mode (if you've added it to the hook), but yasnippet.el isn't completely loaded yet.

 (defvar yas--font-lock-keywords
   (append '(("^#.*$" . font-lock-comment-face))
-          lisp-font-lock-keywords-2
+          (with-temp-buffer
+            (emacs-lisp-mode)
+            (font-lock-set-defaults)
+            (if (eq t (car-safe font-lock-keywords))
+                ;; They're "compiled", so extract the source.
+                (cadr font-lock-keywords)
+              font-lock-keywords))

@npostavs npostavs added the bug label Apr 9, 2016
@syl20bnr
Copy link
Author

syl20bnr commented Apr 9, 2016

Makes sense, thank you for the quick response. In the mean time we switched temporarily to the last stable version.

@syl20bnr
Copy link
Author

syl20bnr commented Apr 9, 2016

Proposed fix in #674
Note that I did not have signed the paper yet so feel free to amend the author, just merge it quick if the fix is adequate.

@npostavs
Copy link
Collaborator

npostavs commented Apr 9, 2016

I'm thinking a smaller fix, like #676. Can you try that out and confirm it works? I was using (add-hook 'emacs-lisp-mode-hook 'yas-minor-mode) (require 'yasnippet) as a reproducer, though I'm not 100% sure it's equivalent.

@syl20bnr
Copy link
Author

syl20bnr commented Apr 9, 2016

Testing it.

@syl20bnr
Copy link
Author

syl20bnr commented Apr 9, 2016

Fixes the OP error but if a snippet is visited without yasnippet loaded first the following error happens:

Ignoring unknown mode `snippet-mode'
File local-variables error: (void-function snippet-mode)

@npostavs
Copy link
Collaborator

npostavs commented Apr 9, 2016

I added an ;;;###autoload cookie to fix that, but it seems the font lock settings don't take effect the first time with this change, hmm...

@syl20bnr
Copy link
Author

syl20bnr commented Apr 9, 2016

Oh ok, I indeed tested without updating the autoload. LGTM 👍

@npostavs
Copy link
Collaborator

npostavs commented Apr 9, 2016

Oh ok, I indeed tested without updating the autoload.

Well yes, because I only added it after you reported the problem :)

There is still the problem of font lock not working the first time.

@monnier
Copy link
Collaborator

monnier commented Apr 9, 2016

  • The error seems to be triggered as soon as I add yas-minor-mode to emacs-lisp-mode-hook

Indeed, if you do that before yasnippet.el is loaded we might get
into trouble. We can probably fix this by appropriately moving things
around (i.e. make sure yas-minor-mode is defined before we do the
with-temp-buffer + emacs-lisp-mode dance), but it's probably preferable
to wrap the call to emacs-lisp-mode inside an ignore-errors.

    Stefan

@npostavs
Copy link
Collaborator

npostavs commented Apr 9, 2016

wrap the call to emacs-lisp-mode inside an ignore-errors.

Yeah, that seems to work better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants