rejeep / f.el

Modern API for working with files and directories in Emacs
GNU General Public License v3.0
680 stars 68 forks source link

Add f-empty? and alias. #88

Closed mwfogleman closed 6 years ago

mwfogleman commented 6 years ago

I needed this function and didn't find it, and thought it might be useful to others.

I realize this isn't in the predicates section, but the function it uses - f-size - comes later in the file. Any thoughts about that? Is there a better implementation?

rejeep commented 6 years ago

Makes sense. Can you please add some docs and specs. Also move it to the predicates section.

mwfogleman commented 6 years ago

Sure, I'm happy to add some docs. If the function that it calls, f-size, is later in the file, does that matter in ELisp? I know in Clojure you can't call functions that come later in the file.

rejeep commented 6 years ago

I don't think it's an issue unless it's a macro. Either way, if you write some specs it should catch that if that's the case.

mwfogleman commented 6 years ago

OK - how do I write specs? :)

rejeep commented 6 years ago

There are tons of tests already so you should be able to figure it out by looking at them. Take a look at https://github.com/rejeep/f.el/blob/master/test/f-predicates-test.el for example. Also read this section: https://github.com/rejeep/f.el#contribution

mwfogleman commented 6 years ago

I moved the functions, added a docstring, and wrote some tests, but I don't think they're working. I'll try to chew on this but assists are welcome :)

mwfogleman commented 6 years ago

Ah, great suggestions! I didn't think about directories because I just needed files for my program :)

I've implemented and tested that functionality - let me know if you think there's a better way of checking if the directory is empty or not. :)

mwfogleman commented 6 years ago

Do you want me to squash these commits?

rejeep commented 6 years ago

Sure go ahead and squash and then I will merge

mwfogleman commented 6 years ago

Squashed! Thanks for your help - I learned a little bit about how to write tests in Emacs :) Cheers!

rejeep commented 6 years ago

One last thing, can you also update the readme template (https://github.com/rejeep/f.el/blob/master/README.md.tpl) and then run make docs.

mwfogleman commented 6 years ago

Sure, so, I added something based on what I saw in that template. However when I run make docs, I get this error: cask exec emacs -Q --script bin/docs.el Cannot open load file: No such file or directory, s make: *** [Makefile:16: docs] Error 255

rejeep commented 6 years ago

You have to install Cask and run cask install first.

rejeep commented 6 years ago

Also, the docs should be in two places. Look at the other examples in the file.

mwfogleman commented 6 years ago

Cool, thanks! Happy to squash this if it looks good to you.

rejeep commented 6 years ago

Lovely, squash and I'll merge!

mwfogleman commented 6 years ago

Done! :)

rejeep commented 6 years ago

Great stuff, thanks for contributing! 👍