Created
November 16, 2012 14:50
-
-
Save syohex/4087896 to your computer and use it in GitHub Desktop.
Support chmod in direx.el
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/direx.el b/direx.el | |
index 2026806..ffd48df 100644 | |
--- a/direx.el | |
+++ b/direx.el | |
@@ -440,6 +440,7 @@ mouse-2: find this node in other window")) | |
(define-key map (kbd "C") 'direx:do-copy-files) | |
(define-key map (kbd "D") 'direx:do-delete-files) | |
(define-key map (kbd "+") 'direx:create-directory) | |
+ (define-key map (kbd "M") 'direx:do-chmod-file) | |
map)) | |
(defun direx:do-rename-file () | |
@@ -485,6 +486,19 @@ mouse-2: find this node in other window")) | |
(direx:item-refresh-parent item) | |
(direx:move-to-item-name-part item))) | |
+(defun direx:do-chmod-file () | |
+ (interactive) | |
+ (let* ((item (direx:item-at-point!)) | |
+ (file (direx:item-tree item)) | |
+ (filename (direx:file-full-name file)) | |
+ (orig-modes (file-modes filename)) | |
+ (modes (read-string "Change mode of %s to: ")) | |
+ (num-modes (when (string-match "^[0-7]+" modes) | |
+ (string-to-number modes 8)))) | |
+ (set-file-modes filename | |
+ (or num-modes | |
+ (file-modes-symbolic-to-number modes orig-modes))))) | |
+ | |
(defclass direx:regular-file-item (direx:file-item) | |
()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment