Closed eigengrau closed 9 years ago
It's interesting that this affects you and not other users (including myself). It's pretty standard for other snippets do do the same: https://github.com/mpenet/clojure-snippets/blob/master/clojure-snippets.el#L25
Do you have any idea why this may be affecting you? Does the Clojure snippet have the same problem for you?
I’m not really sure. FWIW I see this even when running emacs -q
, package-initialize
, visit buffer, yas-global-mode
. I suspect this might not be triggered if you have (yas-global-mode)
in your init, so that the buffer active during evaluation doesn’t visit any file, in which case only load-file-name
is used. Can you reproduce it with the above, making sure to visit a file before activating yas-global-mode
?
Thanks for making haskell-snippets!
Ah yes that makes sense about yas-global-mode
. Good tip.
I'm still unsure why all the other snippet loaders do this then. Either way I will accept your PR.
Thanks! I’m not an Elisp hacker, but my theory of how this comes about is that buffer-file-name
is needed when you develop such loaders, because it helps you do eval-buffer
. Without it, eval-buffer
fails because load-file-name
is nil then. No idea why this hasn’t been noticed much; maybe everyone just fires up yasnippets from their init. The problem seems to have been noted at least once, though.
haskell-snippets 20150502.1315 seems to install a hook, run after yasnippet is loaded, which is meant to append the
snippets
path below the haskell-snippet distribution directory toyas-load-directory
. However, it appears that the path setting is run inside the context of the buffer from which yasnippet is loaded. This sets the snippet path relative to some arbitrary buffer file name, so that yasnippet will fail to load and complain about a non-existing snippet directory.E.g., when invoking
yas-global-mode
within a buffer visiting a file in/home/user/Dev/bla
, I get