[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm 01b50bc4e4 5/5: Enhance helm-basedir PARENT argument
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm 01b50bc4e4 5/5: Enhance helm-basedir PARENT argument usage |
Date: |
Sat, 4 Jan 2025 07:00:02 -0500 (EST) |
branch: elpa/helm
commit 01b50bc4e427bb9e16581da2ddf34848297b5c59
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Enhance helm-basedir PARENT argument usage
---
helm-lib.el | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/helm-lib.el b/helm-lib.el
index 0e1b263431..8f3fda6866 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -1844,16 +1844,20 @@ e.g. (helm-basename \"~/ucs-utils-6.0-delta.py.gz\"
\\='(2 . \"\\\\.py\\\\\\='\"
(defun helm-basedir (fname &optional parent)
"Return the base directory of FNAME ending by a slash.
-If PARENT is specified and FNAME is a directory return the parent
-directory of FNAME.
+If PARENT is non nil and FNAME is a directory return the parent
+directory of FNAME, if PARENT is a number return the parent directory up to
+PARENT level.
If PARENT is not specified but FNAME doesn't end by a slash, the returned value
is same as with PARENT."
(helm-aif (and fname
(or (and (string= fname "~") "~")
(file-name-directory
- (if parent
- (directory-file-name fname)
- fname))))
+ (helm-acase parent
+ ((guard* (numberp it))
+ (cl-loop repeat it
+ for bd = (helm-basedir (or bd fname) t)
+ finally return bd))
+ (t (directory-file-name fname))))))
(file-name-as-directory it)))
(defun helm-current-directory ()