mineo / yatemplate

File templates for Emacs with YASnippet
https://github.com/mineo/yatemplate
GNU General Public License v3.0
70 stars 11 forks source link

Fix hook when `buffer-file-name` is nil #15

Closed terlar closed 6 years ago

terlar commented 6 years ago

This is a fix for #14 it adds a check to see if buffer-file-name is defined before trying to use it. I see this as the solution as we can't control for which files these hooks will run.

Also fix the yatemplate-unload-function, when it tried to remove the hooks it used undefined variable references instead of referring to the functions.

I am not sure if these are things that worked differently in older emacs versions, but at least in the latest version I run into these issues.

mineo commented 6 years ago

Both changes look good to me. The unload function probably never worked, but I've never used it myself. I'll add some tests for it.

Regarding the buffer-file-name thing: would you mind trying the old code with the line https://github.com/wasamasa/nov.el/blob/7d14b6a2aa649e2213348883893a24a6a6083cb9/nov.el#L683 commented out? I suspect this might be causing the problem. I can't find any documentation that suggests major modes should not set set-visited-file-name nil, so I think your changes are good.

terlar commented 6 years ago

Good find, I can confirm that your theory is correct. I searched through all other packages quickly and only found one other instance the flycheck-ert file (inside flycheck). But could very well be other things out there that uses this trick.

Thanks for the quick feedback and the package. Wasn't sure if the package was "dead" or just stable, hehe.