rejeep / f.el

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

Clarify f-ext documentation #60

Closed akoehn closed 8 years ago

akoehn commented 8 years ago

Currently, f-ext is described as follows:

Return the file extension of PATH.

However, it uses file-name-extension, which strips version numbers and backup suffixes. It would be nice if that fact could be mentioned as well. I fell for that today, because

(f-files "/some/path"
         (lambda (x)
           (f-ext? x "md")))

will also return all backup files (ending in "md~")

rejeep commented 8 years ago

I don't think it should return backup files. It uses file-name-sans-versions, so the versions should not be there. You mean they are? Can you provide an example?

akoehn commented 8 years ago

Sure: (f-ext? "foo.md~" "md") yields t.

As far as I can see, f-ext does not use file-name-sans-versions but is a wrapper forfile-name-extension and f-ext? uses f-ext, propagating this behaviour.

rejeep commented 8 years ago

Sure: (f-ext? "foo.md~" "md") yields t.

I'm not really sure what I like best here. Outside of Emacs it would make sense to return nil, but inside Emacs maybe it does make sense to return t as the backup files are special. Not sure where I stand on this really... 😕

The function file-name-extension uses file-name-sans-versions in turn.

akoehn commented 8 years ago

I would keep it as is, since you can easily use s-ends-with if you are interested in the exact ending.

the doc string of file-name-extension contains this:

The extension, in a file name, is the part that follows the last ‘.’, excluding version numbers and backup suffixes

You could add that to the documentation and maybe also add a pointer to s-ends-with if the user wants a different behaviour. If you are using f, you already require s.

rejeep commented 8 years ago

Closing in favour of https://github.com/rejeep/f.el/pull/61 @akoehn Can you take a look?