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

Already on GitHub? Sign in to your account

"Don't know how to make a localized variable an alias" error when loading in some modes #528

Closed
jml opened this Issue Oct 11, 2014 · 9 comments

Comments

Projects
None yet
5 participants

jml commented Oct 11, 2014

I got this error:

Don't know how to make a localized variable an alias

After running yas-global-mode in rust-mode. Debugging revealed that it happened when yasnippet defined backwards aliases:

(define-obsolete-variable-alias 'yas-extra-modes 'yas--extra-modes "0.8.1")
...
(dolist (sym yas--backported-syms) ...

Commenting out these blocks and reloading prevented the error.

Collaborator

npostavs commented Oct 11, 2014

See Important note regarding bug reporting, it's not clear to me exactly how to reproduce this. I imagine a call to make-local-variable is involved, and maybe the precise order of calls?

Collaborator

npostavs commented Oct 24, 2014

Closing as I don't know how to reproduce this. I have some ideas how to fix it based on the description, but I won't try if I can't test that the fix works...

@npostavs npostavs closed this Oct 24, 2014

I have this bug now after updating all packages.

Windows 7, "GNU Emacs 24.5.1 (i686-pc-mingw32) of 2015-04-11 on LEG570"

Debugger entered--Lisp error: (error "Don't know how to make a localized variable an alias")
  defvaralias(yas/dont-activate yas-dont-activate)
  (progn (make-obsolete-variable backported sym "yasnippet 0.8") (defvaralias backported sym))
  (if (boundp sym) (progn (make-obsolete-variable backported sym "yasnippet 0.8") (defvaralias backported sym)))
  (let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym))))) (if (boundp sym) (progn (make-obsolete-variable backported sym "yasnippet 0.8") (defvaralias backported sym))) (if (fboundp sym) (progn (make-obsolete backported sym "yasnippet 0.8") (defalias backported sym))))
  (while --dolist-tail-- (setq sym (car --dolist-tail--)) (let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym))))) (if (boundp sym) (progn (make-obsolete-variable backported sym "yasnippet 0.8") (defvaralias backported sym))) (if (fboundp sym) (progn (make-obsolete backported sym "yasnippet 0.8") (defalias backported sym)))) (setq --dolist-tail-- (cdr --dolist-tail--)))
  (let ((--dolist-tail-- yas--backported-syms) sym) (while --dolist-tail-- (setq sym (car --dolist-tail--)) (let ((backported (intern (replace-regexp-in-string "^yas-" "yas/" (symbol-name sym))))) (if (boundp sym) (progn (make-obsolete-variable backported sym "yasnippet 0.8") (defvaralias backported sym))) (if (fboundp sym) (progn (make-obsolete backported sym "yasnippet 0.8") (defalias backported sym)))) (setq --dolist-tail-- (cdr --dolist-tail--))))
  eval-buffer(#<buffer  *load*> nil "c:/users/vagn/.emacs.d/elpa/yasnippet-20150811.1222/yasnippet.el" nil t)  ; Reading at buffer position 184627
  load-with-code-conversion("c:/users/vagn/.emacs.d/elpa/yasnippet-20150811.1222/yasnippet.el" "c:/users/vagn/.emacs.d/elpa/yasnippet-20150811.1222/yasnippet.el" nil t)
  (yas-global-mode t)
  eval((yas-global-mode t) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
Collaborator

npostavs commented Aug 22, 2015

Can you get this error starting from emacs -Q?

No. it works when using -Q

Now I can start emacs without error and it is only when I eval (yas-global-mode t) i get the error

Before it happened during initialization.

The only important change I think I did was to bytecompile yasnippet.el (I deleted the elc files to get a better backtrace)

So now yasnippet is enabled after the initialization but I cannot turn it off (I get "Don't know how to make a localized variable an alias"). With -Q I can turn it off.

When I press TAB on file in a magit to show a diff I now get

Debugger entered--Lisp error: (wrong-type-argument stringp yas-try-key-from-whitespace)
  skip-syntax-backward(yas-try-key-from-whitespace)
  (save-excursion (skip-syntax-backward syntax) (setq start (point)))
  (while (and (not done) syntaxes) (setq syntax (car syntaxes)) (setq syntaxes (cdr syntaxes)) (save-excursion (skip-syntax-backward syntax) (setq start (point))) (setq templates (mapcan (function (lambda (table) (yas/fetch table (buffer-substring-no-properties start end)))) (yas/get-snippet-tables))) (if templates (setq done t) (setq start end)))
  (let ((start (point)) (end (point)) (syntaxes yas/key-syntaxes) syntax done templates) (while (and (not done) syntaxes) (setq syntax (car syntaxes)) (setq syntaxes (cdr syntaxes)) (save-excursion (skip-syntax-backward syntax) (setq start (point))) (setq templates (mapcan (function (lambda (table) (yas/fetch table (buffer-substring-no-properties start end)))) (yas/get-snippet-tables))) (if templates (setq done t) (setq start end))) (list templates start end))
  yas/current-key()
  (if field (save-restriction (narrow-to-region (yas/field-start field) (yas/field-end field)) (yas/current-key)) (yas/current-key))
  (setq templates-and-pos (if field (save-restriction (narrow-to-region (yas/field-start field) (yas/field-end field)) (yas/current-key)) (yas/current-key)))
  (if (and yas/expand-only-for-last-commands (not (member last-command yas/expand-only-for-last-commands))) nil (setq templates-and-pos (if field (save-restriction (narrow-to-region (yas/field-start field) (yas/field-end field)) (yas/current-key)) (yas/current-key))))
  (let (templates-and-pos) (if (and yas/expand-only-for-last-commands (not (member last-command yas/expand-only-for-last-commands))) nil (setq templates-and-pos (if field (save-restriction (narrow-to-region (yas/field-start field) (yas/field-end field)) (yas/current-key)) (yas/current-key)))) (if (and templates-and-pos (first templates-and-pos)) (yas/expand-or-prompt-for-template (first templates-and-pos) (second templates-and-pos) (car (cdr (cdr templates-and-pos)))) (yas/fallback (quote trigger-key))))
  yas/expand()
  call-interactively(yas/expand nil nil)
  command-execute(yas/expand)

Please ignore these bug reports for now . It seems I had two yasnippet installations (git clone and from elpa).

I was playing around with https://github.com/AndreaCrotti/minimal-emacs-configuration/blob/master/init.el which installed a yasnippet for me

Owner

joaotavora commented Aug 22, 2015

It seems I had two yasnippet installations (git clone and from elpa).

Does seem like a recipe for messing things up :-)

I found I was using the old functions through copy-and-paste :) which were being used in make-local-variable.

So look closely at your code and you should be able to spot the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment