aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-07-31 17:18:06 +0000
committerJuri Linkov2008-07-31 17:18:06 +0000
commit7cb41b327809c7011a6e3aefbf511db085f80b30 (patch)
tree555d164b083253d4a127963d93bb4fd66c5e6d5e
parent78be566d5c5b8838cc1b2ea4dbd5bf72f29945ab (diff)
downloademacs-7cb41b327809c7011a6e3aefbf511db085f80b30.tar.gz
emacs-7cb41b327809c7011a6e3aefbf511db085f80b30.zip
(read-file-modes): Set default value to the original
mode string using absolute notation like u=rwx,g=rx,o=rx. Use it as the `default' arg of `read-string'.
-rw-r--r--lisp/files.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/files.el b/lisp/files.el
index 1a18a1d1b17..cf9f82da51e 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5765,7 +5765,19 @@ PROMPT is used as the prompt, default to `File modes (octal or symbolic): '.
5765ORIG-FILE is the original file of which modes will be change." 5765ORIG-FILE is the original file of which modes will be change."
5766 (let* ((modes (or (if orig-file (file-modes orig-file) 0) 5766 (let* ((modes (or (if orig-file (file-modes orig-file) 0)
5767 (error "File not found"))) 5767 (error "File not found")))
5768 (value (read-string (or prompt "File modes (octal or symbolic): ")))) 5768 (modestr (and (stringp orig-file)
5769 (nth 8 (file-attributes orig-file))))
5770 (default
5771 (and (stringp modestr)
5772 (string-match "^.\\(...\\)\\(...\\)\\(...\\)$" modestr)
5773 (replace-regexp-in-string
5774 "-" ""
5775 (format "u=%s,g=%s,o=%s"
5776 (match-string 1 modestr)
5777 (match-string 2 modestr)
5778 (match-string 3 modestr)))))
5779 (value (read-string (or prompt "File modes (octal or symbolic): ")
5780 nil nil default)))
5769 (save-match-data 5781 (save-match-data
5770 (if (string-match "^[0-7]+" value) 5782 (if (string-match "^[0-7]+" value)
5771 (string-to-number value 8) 5783 (string-to-number value 8)