emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/helm fb3df89c7b: Handle sticky bit in helm-ff-octal-permis


From: ELPA Syncer
Subject: [nongnu] elpa/helm fb3df89c7b: Handle sticky bit in helm-ff-octal-permissions
Date: Tue, 21 Feb 2023 08:59:40 -0500 (EST)

branch: elpa/helm
commit fb3df89c7b0a68c79d6725beb20d3dc6ccd348a1
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>

    Handle sticky bit in helm-ff-octal-permissions
---
 helm-utils.el | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/helm-utils.el b/helm-utils.el
index 6a514ce5dc..3269011888 100644
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -799,6 +799,17 @@ If STRING is non--nil return instead a space separated 
string."
 
 (defun helm-ff-octal-permissions (perms)
   "Return the numeric representation of PERMS.
+PERMS is the list of permissions for owner, group and others."
+  (if (fboundp 'file-modes-symbolic-to-number)
+      (helm-ff-octal-permissions-1 perms)
+    (helm-ff-octal-permissions-2 perms)))
+
+(defun helm-ff-octal-permissions-1 (perms)
+  (let ((modes (apply 'format "u=%s,g=%s,o=%s" perms)))
+    (format "%o" (file-modes-symbolic-to-number modes))))
+
+(defun helm-ff-octal-permissions-2 (perms)
+  "Return the numeric representation of PERMS.
 PERMS is the list of permissions for owner, group and others."
   (cl-flet ((string-to-octal (str)
               (cl-loop for c across str
@@ -806,9 +817,13 @@ PERMS is the list of permissions for owner, group and 
others."
                              (?r 4)
                              (?w 2)
                              (?x 1)
-                             (?- 0)))))
-    (cl-loop for str in perms
-             concat (number-to-string (string-to-octal str)))))
+                             (_ 0)))))
+    (cl-loop with sb = ""
+             for str in perms
+             when (string-match "t" str)
+             do (setq sb "1")
+             concat (number-to-string (string-to-octal str)) into modes
+             finally return (concat sb modes))))
 
 (defun helm-format-columns-of-files (files)
   "Same as `dired-format-columns-of-files'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]