[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm d68e524fca 1/2: Add chmod action to HFF
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm d68e524fca 1/2: Add chmod action to HFF |
Date: |
Wed, 5 Oct 2022 14:58:51 -0400 (EDT) |
branch: elpa/helm
commit d68e524fcab7b3be3d53152e90bf418fe900709a
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Add chmod action to HFF
---
helm-files.el | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/helm-files.el b/helm-files.el
index 3473e48ee8..568d8e0ba8 100644
--- a/helm-files.el
+++ b/helm-files.el
@@ -197,6 +197,7 @@ This is used only as a let binding.")
(define-key map (kbd "M-D") 'helm-ff-run-delete-file)
(define-key map (kbd "M-K") 'helm-ff-run-kill-buffer-persistent)
(define-key map (kbd "M-T") 'helm-ff-run-touch-files)
+ (define-key map (kbd "M-M") 'helm-ff-run-chmod)
(define-key map (kbd "C-c d") 'helm-ff-persistent-delete)
(define-key map (kbd "M-e") 'helm-ff-run-switch-to-shell)
(define-key map (kbd "C-c i") 'helm-ff-run-complete-fn-at-point)
@@ -751,6 +752,7 @@ when moving out of directory when non nil."
"Symlink files(s) `M-S, C-u to follow'" 'helm-find-files-symlink
"Relsymlink file(s) `M-Y, C-u to follow'" 'helm-find-files-relsymlink
"Hardlink file(s) `M-H, C-u to follow'" 'helm-find-files-hardlink
+ "Change mode on file(s) `M-M'" 'helm-ff-chmod
"Find file other window `C-c o'" 'helm-find-files-other-window
"Find file other frame `C-c C-o'" 'find-file-other-frame
(lambda () (and (fboundp 'tab-bar-mode)
@@ -1368,6 +1370,26 @@ This reproduce the behavior of \"cp --backup=numbered
from to\"."
"Hardlink files from `helm-find-files'."
(helm-find-files-do-action 'hardlink))
+(defun helm-ff-chmod (_candidate)
+ "Set file mode on marked files.
+If no mode is specified in prompt, default mode will be the mode of
+the car of marked files i.e. the first marked file."
+ (let* ((mkd (helm-marked-candidates))
+ (model (car mkd))
+ (default (helm-file-attributes model :octal t))
+ (mode (read-file-modes nil model))
+ (smode (file-modes-number-to-symbolic mode))
+ (candidates (if (string= default (format "%o" mode))
+ (cdr mkd) mkd)))
+ (with-helm-display-marked-candidates
+ helm-marked-buffer-name
+ (helm-ff--count-and-collect-dups candidates)
+ (when (y-or-n-p (format "Change file mode to `%s'? " smode))
+ (dolist (f candidates)
+ (set-file-modes f mode 'nofollow))
+ (message "Changed file mode to `%s' on %s file(s)"
+ smode (length candidates))))))
+
(defun helm-find-files-other-window (_candidate)
"Keep current-buffer and open files in separate windows.
When a prefix arg is detected files are opened in a vertical
@@ -2369,6 +2391,10 @@ Called with a prefix arg open menu unconditionally."
"Run Hardlink file action from `helm-source-find-files'."
'helm-find-files-hardlink)
+(helm-make-command-from-action helm-ff-run-chmod
+ "Run chmod action from `helm-source-find-files'."
+ 'helm-ff-chmod)
+
(defun helm-ff-delete-files (candidate)
"Delete files default action."
(funcall helm-ff-delete-files-function candidate))