Index: files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.959 diff -b -u -w -r1.959 files.el --- files.el 30 Jan 2008 21:25:08 -0000 1.959 +++ files.el 11 Feb 2008 23:38:35 -0000 @@ -5464,7 +5464,7 @@ (t (apply operation arguments))))) -;; Symbolic modes and read-file-modes. +;; Symbolic modes, ls-type modes, and read-file-modes. (defun file-modes-char-to-who (char) "Convert CHAR to a who-mask from a symbolic mode notation. @@ -5543,13 +5543,38 @@ (error "Parse error in modes near `%s'" (substring modes 0)))) num-modes))) +(defun file-modes-number-to-ls (modes) + "Convert the numerical MODES into the `ls' notation." + (let (string) + (dotimes (i 3 string) + (let* ((is-executable (/= 0 (logand modes 1))) + (exec-bit + (or (cond ((and (= i 0) ;; Sticky. + (/= 0 (logand modes #o1000))) + (if is-executable "t" "T")) + ((or (and (= i 1) ;; Set-gid. + (/= 0 (logand modes #o200))) + (and (= i 2) ;; Set-uid. + (/= 0 (logand modes #o40)))) + (if is-executable "s" "S"))) + (if is-executable "x" "-")))) + (setq string (concat (if (/= 0 (logand modes 4)) "r" "-") + (if (/= 0 (logand modes 2)) "w" "-") + exec-bit string)) + (setq modes (lsh modes -3)))))) + (defun read-file-modes (&optional prompt orig-file) "Read file modes in octal or symbolic notation. -PROMPT is used as the prompt, default to `File modes (octal or symbolic): '. -ORIG-FILE is the original file of which modes will be change." +PROMPT is used as the prompt, default to `File modes, octal or symbolic' +followed by the current modes of ORIG-FILE. +ORIG-FILE is the file of which modes will be changed." (let* ((modes (or (if orig-file (file-modes orig-file) 0) (error "File not found"))) - (value (read-string (or prompt "File modes (octal or symbolic): ")))) + (ls-type-modes (when orig-file + (concat " (current: " (file-modes-number-to-ls modes) + ")"))) + (value (read-string (or prompt (concat "File modes, octal or symbolic" + ls-type-modes ": "))))) (save-match-data (if (string-match "^[0-7]+" value) (string-to-number value 8) Diffs between working revision and workfile end here.