-
Notifications
You must be signed in to change notification settings - Fork 311
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
auto-compilation and visit-compiled-snippets features #262
base: master
Are you sure you want to change the base?
Conversation
My use case is a slow USB drive which I run emacs on both windows and mac. On the mac the usb-drive access is fast, but on the PC it is slow. Hence, a compilation greatly speeds up my initial load time. I would like it included. It does not have to be on by default. |
Auto-compilationRegarding 565dc5c, I agree it has to be customizable. And maybe the condition for re-compiling the directory could be made a little broader: regenerate and overwrite This has the advantages:
The disadvantage:
We would have to have some benchmarks, measuring load times for small, medium and big snippet collections, under with the following conditions.
1, 2 and 3. could be different settings of the customization variable you propose. 4 is what we had before I implemented jit happened, should be the slowest. Using the file field in the
|
…ppets file. Signed-off-by: Matthew L. Fidler <[email protected]>
Regarding auto-compilation, I cherry-picked your change into a new
The penultimate case, checking for mtimes, is only a bit slower than the previous one, so I'm thinking of merging it after a few more tests. |
…pets/emacs-lisp-mode, but doesn't without this fix. It also makes compile snippet directory work correctly. Signed-off-by: Matthew L. Fidler <[email protected]>
Signed-off-by: Matthew L. Fidler <[email protected]>
…ion/deletion of snippets from a directory. This requires MD5 checksum of the snippet directory. Signed-off-by: Matthew L. Fidler <[email protected]>
Signed-off-by: Matthew L. Fidler <[email protected]>
I partially agree with your assessment. However, I think you also have to consider files that are deleted. The only way I can think of doing that is to list all the files, with their modification times, and take a MD5 of that. Save that checksum and then compare the calculated checksum to see if the snippets need to be recompiled. I also added a bug fix for loading snippets and compiling snippets (bea8b79) without this, you cannot compile a snippet directory without any sub-directories. |
I would benchmark these results, but unfortunately, I don't have access to the dictionary. |
You're right about deleted snippets. While the md5 idea is very ingenious, it is not the only way. This sounds easier and faster: we can first check the You don't need that dictionary file any old file of words will do... Very important: regarding version control, please note that I am developing this in the Unfortunately, according to http://stackoverflow.com/questions/10081053/how-to-change-the-base-branch-of-a-pull-request, though, you'd have to open a new pull request. I prefer to keep the discussion here, if there are any commits worth |
I tested your theory on windows. On windows XP deleting a file on a FAT32 drive does not change the modification time of the folder. Therefore without the checksum, the snippets are not updated correctly. |
Conflicts: yasnippet.el Signed-off-by: Matthew L. Fidler <[email protected]>
See Issue #264 |
I kept in the MD5 checksum since deleting files in a snippet directory didn't change the mtime of the directory. in Windows XP |
Signed-off-by: Matthew L. Fidler <[email protected]>
Added small changes so this works on my setup. note that your setup doesn't load directories properly. If you try to load for example snippets/emacs-lisp-mode, it won't load anything. Fix bea8b79 still needs to be applied. |
Using my hunspell dictionary list still doesn't work for benchmarks since (yas/with-snippet-dirs is undefined. |
Hi Matthew, So I went ahead and enhanced my version with your md5-checking idea in the
These are the results I get in my
It's quite important that the 4th and 5th cases don't differ a lot in performance, since it defeats the purpose of auto-recompilation. The reason why your recompilation checks take so much more might be that the directory is only listed once with Also, my version:
I still don't know why you think bea8b79 is needed, since my code passes all tests. Can you write a test where it doesn't? If you have no objections I'll close both these pull requests. Thank you for an amazing effort, I've given you credit for the idea in 66aaf61, and will do so again in the 0.7 release notes. |
Thanks. I think that by hashing out the changes the auto-compilation is better than I would have made on my own. I do have a few comments:
A use-case for this is anyone who is creating snippets that have some elisp component to it.. As far as bea8b79, I can write a test where your code doesn't pass on Windows XP. I'm not sure how to do this with ert or even how to use ert, so this is my best guess: (ert-deftest compile-single-dir ()
(let ((test-dir (expand-file-name "snippets/emacs-lisp-mode"
(file-name-directory
(or (buffer-file-name) (load-file))))))
(yas/compile-directory test-dir)
(should (file-readable-p (expand-file-name ".yas-compiled-snippets.el" test-dir))))) For me I can't load/reload a snippet directory without any sub-directories without the patch. I can't compile that directory either. |
Hmmm, I see, but you are mistaken. Good point about Regarding c4b310a, I'll create another branch called |
João, I would prefer to keep .yas-setup.el in .yas-compiled-snippets.el. As you said previously, it allows a single file to represent a snippet collection. Additionally, by gzipping the file, you fulfill enhancement #119. You could name it anything and load the snippet collection easily since emacs loads both As far as yas/compile-directory, I understand that my use case was different from what you intended. Therefore, it was a feature not a bug :). I would request, then, that both yas/compile-directory and yas/load-directory to load individual snippet directories as well as top-level snippet directories. It expands it's functionality, and keeps the previous functonality. Often, I prefer just to load a single snippet directory instead of a full top-level directory. Do I need to add another issue for this functionality? Additionally, this allows a single file to be created for a snippet collection. Therefore, a snippet bundle can easily be created for major-modes that want to include specific snippets generated from yasnippet. |
As far as issue #119 is concerned, by adding the ability to edit snippets that aren't present in the filesystem, and then possibly recompiling (and maybe even deleting the files afterward to save on space), I believe the enhancement is 90% fulfilled. It wouldn't be that hard to add commands to compile a zip-bundle into a el.gz bundle. |
Matthew, I see your points. I'll get back to this issues over the next week, I have real life to attend to, doing #119 would be great I agree. |
I will be out next week too :) |
Funny, I did spot and fix a bug (see 7c094cd), but nothing like what you say. Are you sure you're using the very latest? I saw that behaviour once in some tests, but I think I fixed it. Can you give a very simple recipe for reproduction? |
Sorry. My mistake. I didn't pull the latest. |
See Pull #261