Closed mihaiolteanu closed 2 years ago
The comment could also mean the directory /default/directory/dir
is created, not necessarily that f-mkdir
returns it as a value. Is it possible to clarify this @rejeep?
It was too long ago so I don't know. I don't have an opinion so you can decide which is best and change accordingly.
In my opinion, creating a directory means you already have its path, so I don’t really see the point of returning it. This is also consistent with the behaviour of `make-directory'.
That being said, it is not hard to implement it, here is something I came up with, based on the current f-mkdir' implementation. ,---- | (defun f-mkdir (&rest dirs) | (let (path) | (mapcar (lambda (dir) | (setq path (f-expand dir path)) | (unless (f-directory? path) | (f--destructive path (make-directory path))) | path) | dirs)))
----
However, there is the possibility this change in behavior might be a breaking change, and we can’t introduce a new argument to toggle this behavior since f-mkdir' already uses
&rest' arguments.
The solution, if we want this behaviour to exist, might be to introduce a new function, something like `f-mkdir-paths'.
-- Lucien “Phundrak” Cartier-Tilet
https://phundrak.com (Français)
https://phundrak.com/en (English)
Sent from GNU/Emacs
Hi,
I'm not sure if this is the place to ask, but does f.el
offer the functionality to create directories recursively? f-mkdir
does not do this.
I don’t think there is a function for that in f.el indeed. A solution
would be to use make-directory' like so: ,---- | (make-directory "path/to/your/dir" t)
----
The second argument allows the recursive creation of directories. If
you need to create several of them, you could use a dolist'. ,---- | (dolist (dir '("path/1/to/2/dir" "path/2/to/3/dir")) | (make-directory dir t))
----
If you wish for a dedicated function in f.el, I think you should open a new feature request issue.
-- Lucien “Phundrak” Cartier-Tilet https://phundrak.com (Français) https://phundrak.com/en (English) Sent from GNU/Emacs
Hi, yes. I was using (make-directory dir t)
, but wanted to switch completely to f.el
.
I just finished (like, 5 minutes ago!) writing such a function for my own use. I'll open a feature request with the code. If it is good enough, maybe it can be included in f.el
.
May I ask you why f.el exclusively? make-directory' is faster than
f-mkdir' if you only want to create one directory.
,---- | (let ((path "/tmp/test-bench")) | (benchmark-run 10000 | (progn | (make-directory path) | (f-delete path)))) `----
1.8171470570000001 0 0.0
,---- | (let ((path "/tmp/test-bench")) | (benchmark-run 10000 | (progn | (f-mkdir path) | (f-delete path)))) `----
2.1770691600000003 0 0.0
-- Lucien “Phundrak” Cartier-Tilet https://phundrak.com (Français) https://phundrak.com/en (English) Sent from GNU/Emacs
f-mkdir
returns nil.The documentation says it returns the created path, similar to
f-join
, for example.