aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-07-31 17:17:35 +0000
committerJuri Linkov2008-07-31 17:17:35 +0000
commit78be566d5c5b8838cc1b2ea4dbd5bf72f29945ab (patch)
treeb98c4c3e47bd2ad056ab3621db9cee11f42ae338
parentc0a67379ac59dea7b0491b4aa47a07a243f10f54 (diff)
downloademacs-78be566d5c5b8838cc1b2ea4dbd5bf72f29945ab.tar.gz
emacs-78be566d5c5b8838cc1b2ea4dbd5bf72f29945ab.zip
(dired-do-chmod): Set default value to the original
mode string using absolute notation like u=rwx,g=rx,o=rx. Use it as a new arg `default' of `dired-mark-read-string'. (dired-mark-read-string): Add new optional arg `default'.
-rw-r--r--lisp/dired-aux.el19
1 files changed, 15 insertions, 4 deletions
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index a55b0a70fbc..bf87ce7bbdd 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -255,9 +255,20 @@ List has a form of (file-name full-file-name (attribute-list))"
255Symbolic modes like `g+w' are allowed." 255Symbolic modes like `g+w' are allowed."
256 (interactive "P") 256 (interactive "P")
257 (let* ((files (dired-get-marked-files t arg)) 257 (let* ((files (dired-get-marked-files t arg))
258 (modestr (and (stringp (car files))
259 (nth 8 (file-attributes (car files)))))
260 (default
261 (and (stringp modestr)
262 (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
263 (replace-regexp-in-string
264 "-" ""
265 (format "u=%s,g=%s,o=%s"
266 (match-string 1 modestr)
267 (match-string 2 modestr)
268 (match-string 3 modestr)))))
258 (modes (dired-mark-read-string 269 (modes (dired-mark-read-string
259 "Change mode of %s to: " nil 270 "Change mode of %s to: " nil
260 'chmod arg files)) 271 'chmod arg files default))
261 (num-modes (if (string-match "^[0-7]+" modes) 272 (num-modes (if (string-match "^[0-7]+" modes)
262 (string-to-number modes 8)))) 273 (string-to-number modes 8))))
263 (dolist (file files) 274 (dolist (file files)
@@ -358,14 +369,14 @@ Uses the shell command coming from variables `lpr-command' and
358;; If the current file was used, the list has but one element and ARG 369;; If the current file was used, the list has but one element and ARG
359;; does not matter. (It is non-nil, non-integer in that case, namely '(4)). 370;; does not matter. (It is non-nil, non-integer in that case, namely '(4)).
360 371
361(defun dired-mark-read-string (prompt initial op-symbol arg files) 372(defun dired-mark-read-string (prompt initial op-symbol arg files &optional default)
362 ;; PROMPT for a string, with INITIAL input. 373 ;; PROMPT for a string, with INITIAL input and DEFAULT value.
363 ;; Other args are used to give user feedback and pop-up: 374 ;; Other args are used to give user feedback and pop-up:
364 ;; OP-SYMBOL of command, prefix ARG, marked FILES. 375 ;; OP-SYMBOL of command, prefix ARG, marked FILES.
365 (dired-mark-pop-up 376 (dired-mark-pop-up
366 nil op-symbol files 377 nil op-symbol files
367 (function read-string) 378 (function read-string)
368 (format prompt (dired-mark-prompt arg files)) initial)) 379 (format prompt (dired-mark-prompt arg files)) initial nil default))
369 380
370;;; Cleaning a directory: flagging some backups for deletion. 381;;; Cleaning a directory: flagging some backups for deletion.
371 382