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

Uniquify fix #92

Open Fuco1 opened 6 years ago

Fuco1 commented 6 years ago

This is continuation of #63

I've extracted the function @FrancisMurillo wrote and changed some of the operations to Emacs primitives so it's faster and then applied it to the f--uniquify problem instead of a lambda funcall.

Fuco1 commented 6 years ago

There's a bunch of other changes related to the readme/docs, I can split it out but meh... ? :D

rejeep commented 6 years ago

As long as they are separate commits, I'm good.

Fuco1 commented 6 years ago

Oh damn, directory-name-p is emacs 25 only. Are we cool with compat/polyfills or should I reimplement it somehow else?

The implementation is

(defsubst directory-name-p (name)
  "Return non-nil if NAME ends with a directory separator character."
  (let ((len (length name))
        (lastc ?.))
    (if (> len 0)
        (setq lastc (aref name (1- len))))
    (or (= lastc ?/)
        (and (memq system-type '(windows-nt ms-dos))
             (= lastc ?\\)))))
rejeep commented 6 years ago

I trust you judgement 🙂

Fuco1 commented 6 years ago

I've added f-directory-name? which exposes this to older versions of Emacs. So it is stand-alone function while not shadowing the "global" so that we have a "unified" API for all versions. On E25+ it simply aliases.

Fuco1 commented 6 years ago

@rejeep There seems to be some issue with the build regarding the snapshot emacs version. I stalls and never produces any error. I've added Emacs 25.2 and 25.3 to the build to cover all released versions.

Are you comfortable merging this with failing build on the snapshot? I'm not quite sure what is there to do about that :O

rejeep commented 6 years ago

@Fuco1 I think we should allow failures for snapshot.

Fuco1 commented 6 years ago

Ugh... I think I will reimplement the function in some other way, this breaks quite spectacularly with remote file names. And it shouldn't as this is purely string manipulation so we don't actually even need to connect to the remote host.