php-auto-yasnippets
php-auto-yasnippets copied to clipboard
Error while configuring user-defined function (composer)
Following the guide for getting user-defined functions via Composer to work. I have created a .dir-locals.el file at the root of the project with the following content.
((php-mode . ((php-auto-yasnippet-required-files (list "~/project/vendor/autoload.php")))))
When I do a M-x yas/create-php-snippet I get the following error. Wrong type argument: stringp, (list "~/project/vendor/autoload.php")
Probably a syntax error, any ideas?
Sorry about the late reply. Off the top of my head I think php-auto-yasnippet-required-files
needs to be a cons, e.g.:
(php-auto-yasnippet-required-files . (list "~/project/vendor/autoload.php"))
And if that's the case then I need to correct the example in the README.
@ejmr perhaps related: I'm not seeing the error message that @krystalcode noted, but I don't get any output either. Weirdly, I can't seem to set the php-auto-yasnippet-required-files
variable through M-x set-variable
.
In my .dir-locals.el
file at ~/src/myproject/.dir-locals.el
, I have:
(php-auto-yasnippet-required-files . (list "~/src/myproject/vendor/autoload.php"))
If I run this command in my terminal:
php ~/.emacs.d/elpa/php-auto-yasnippets-20141128.1411/Create-PHP-YASnippet.php base_path --require-once ~/src/myproject/vendor/autoload.php
Then I get this output which is correct:
#key: base_path
#name: base_path
# --
base_path(${1:[$path = ]}
@kostajh Thanks for the information. I'll see if I can replicate the problem on my end and (assuming I get the same issue) see if I can figure out a solution.
Getting same error: tried ((php-mode . ((php-auto-yasnippet-required-files (list "~/project/vendor/autoload.php")))))
and ((php-mode . ((php-auto-yasnippet-required-files . (list "~/project/vendor/autoload.php")))))
. No luck
Hey, as the original author of the support for user-defined functions, I noticed the latest notification for this thread, and thought I'd see what's up.
It's been years since I actively used this library (not writing PHP these days), but I did discover the root issue here is that somehow, I submitted bogus instructions on setting .dir-locals.el
.
To call functions in .dir-locals.el
, you have to use the magic eval
pseudo-variable.
Something like this should work a lot better:
((php-mode . ((eval . (setq-local php-auto-yasnippet-required-files
(list "~/project/vendor/autoload.php"))))))
and someone should update the example in the docs accordingly.
I haven't actually tested this - just verified that the code I pasted above does set the var correctly.
Hopefully this is some help.
I think there was a problem with an invalid required filepath resulting in messed up hash tables. The latest commit should fix this. (I'm not quite sure how, but it seems to have fixed it for me, something about errors not being handled properly?).
((php-mode . ((eval . (setq-local php-auto-yasnippet-required-files
(list "~/project/vendor/autoload.php"))))))
works for me