diff options
| author | Eli Zaretskii | 2008-10-18 18:41:32 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2008-10-18 18:41:32 +0000 |
| commit | e240aaa99e92d7903abd68f217231bdc6b8684dd (patch) | |
| tree | 332c05937295b47e0dec5a4c94e592b4d9605723 | |
| parent | 7e51d89b73bd14ca12480c476af995adda41c41d (diff) | |
| download | emacs-e240aaa99e92d7903abd68f217231bdc6b8684dd.tar.gz emacs-e240aaa99e92d7903abd68f217231bdc6b8684dd.zip | |
(trash-directory): Run thru `convert-standard-filename'.
(file-modes-char-to-who, file-modes-char-to-right)
(file-modes-rights-to-number, file-modes-symbolic-to-number)
(read-file-modes): Doc fixes.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/files.el | 38 |
2 files changed, 31 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cd89f7ed4b9..1470dd09e05 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-10-18 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * files.el (trash-directory): Run thru `convert-standard-filename'. | ||
| 4 | (file-modes-char-to-who, file-modes-char-to-right) | ||
| 5 | (file-modes-rights-to-number, file-modes-symbolic-to-number) | ||
| 6 | (read-file-modes): Doc fixes. | ||
| 7 | |||
| 1 | 2008-10-17 Chong Yidong <cyd@stupidchicken.com> | 8 | 2008-10-17 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 9 | ||
| 3 | * abbrev.el (define-abbrev): Doc fix. | 10 | * abbrev.el (define-abbrev): Doc fix. |
diff --git a/lisp/files.el b/lisp/files.el index 10c4574cb53..1fd6265e949 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -5694,8 +5694,11 @@ only these files will be asked to be saved." | |||
| 5694 | ;; Symbolic modes and read-file-modes. | 5694 | ;; Symbolic modes and read-file-modes. |
| 5695 | 5695 | ||
| 5696 | (defun file-modes-char-to-who (char) | 5696 | (defun file-modes-char-to-who (char) |
| 5697 | "Convert CHAR to a who-mask from a symbolic mode notation. | 5697 | "Convert CHAR to a numeric bit-mask for extracting mode bits. |
| 5698 | CHAR is in [ugoa] and represents the users on which rights are applied." | 5698 | CHAR is in [ugoa] and represents the category of users (Owner, Group, |
| 5699 | Others, or All) for whom to produce the mask. | ||
| 5700 | The bit-mask that is returned extracts from mode bits the access rights | ||
| 5701 | for the specified category of users." | ||
| 5699 | (cond ((= char ?u) #o4700) | 5702 | (cond ((= char ?u) #o4700) |
| 5700 | ((= char ?g) #o2070) | 5703 | ((= char ?g) #o2070) |
| 5701 | ((= char ?o) #o1007) | 5704 | ((= char ?o) #o1007) |
| @@ -5703,9 +5706,9 @@ CHAR is in [ugoa] and represents the users on which rights are applied." | |||
| 5703 | (t (error "%c: bad `who' character" char)))) | 5706 | (t (error "%c: bad `who' character" char)))) |
| 5704 | 5707 | ||
| 5705 | (defun file-modes-char-to-right (char &optional from) | 5708 | (defun file-modes-char-to-right (char &optional from) |
| 5706 | "Convert CHAR to a right-mask from a symbolic mode notation. | 5709 | "Convert CHAR to a numeric value of mode bits. |
| 5707 | CHAR is in [rwxXstugo] and represents a right. | 5710 | CHAR is in [rwxXstugo] and represents symbolic access permissions. |
| 5708 | If CHAR is in [Xugo], the value is extracted from FROM (or 0 if nil)." | 5711 | If CHAR is in [Xugo], the value is taken from FROM (or 0 if omitted)." |
| 5709 | (or from (setq from 0)) | 5712 | (or from (setq from 0)) |
| 5710 | (cond ((= char ?r) #o0444) | 5713 | (cond ((= char ?r) #o0444) |
| 5711 | ((= char ?w) #o0222) | 5714 | ((= char ?w) #o0222) |
| @@ -5723,10 +5726,13 @@ If CHAR is in [Xugo], the value is extracted from FROM (or 0 if nil)." | |||
| 5723 | (t (error "%c: bad right character" char)))) | 5726 | (t (error "%c: bad right character" char)))) |
| 5724 | 5727 | ||
| 5725 | (defun file-modes-rights-to-number (rights who-mask &optional from) | 5728 | (defun file-modes-rights-to-number (rights who-mask &optional from) |
| 5726 | "Convert a right string to a right-mask from a symbolic modes notation. | 5729 | "Convert a symbolic mode string specification to an equivalent number. |
| 5727 | RIGHTS is the right string, it should match \"([+=-][rwxXstugo]+)+\". | 5730 | RIGHTS is the symbolic mode spec, it should match \"([+=-][rwxXstugo]+)+\". |
| 5728 | WHO-MASK is the mask number of the users on which the rights are to be applied. | 5731 | WHO-MASK is the bit-mask specifying the category of users to which to |
| 5729 | FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed." | 5732 | apply the access permissions. See `file-modes-char-to-who'. |
| 5733 | FROM (or 0 if nil) gives the mode bits on which to base permissions if | ||
| 5734 | RIGHTS request to add, remove, or set permissions based on existing ones, | ||
| 5735 | as in \"og+rX-w\"." | ||
| 5730 | (let* ((num-rights (or from 0)) | 5736 | (let* ((num-rights (or from 0)) |
| 5731 | (list-rights (string-to-list rights)) | 5737 | (list-rights (string-to-list rights)) |
| 5732 | (op (pop list-rights))) | 5738 | (op (pop list-rights))) |
| @@ -5752,7 +5758,9 @@ MODES is the string to convert, it should match | |||
| 5752 | \"[ugoa]*([+-=][rwxXstugo]+)+,...\". | 5758 | \"[ugoa]*([+-=][rwxXstugo]+)+,...\". |
| 5753 | See (info \"(coreutils)File permissions\") for more information on this | 5759 | See (info \"(coreutils)File permissions\") for more information on this |
| 5754 | notation. | 5760 | notation. |
| 5755 | FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed." | 5761 | FROM (or 0 if nil) gives the mode bits on which to base permissions if |
| 5762 | MODES request to add, remove, or set permissions based on existing ones, | ||
| 5763 | as in \"og+rX-w\"." | ||
| 5756 | (save-match-data | 5764 | (save-match-data |
| 5757 | (let ((case-fold-search nil) | 5765 | (let ((case-fold-search nil) |
| 5758 | (num-modes (or from 0))) | 5766 | (num-modes (or from 0))) |
| @@ -5771,9 +5779,11 @@ FROM (or 0 if nil) is the orginal modes of the file to be chmod'ed." | |||
| 5771 | num-modes))) | 5779 | num-modes))) |
| 5772 | 5780 | ||
| 5773 | (defun read-file-modes (&optional prompt orig-file) | 5781 | (defun read-file-modes (&optional prompt orig-file) |
| 5774 | "Read file modes in octal or symbolic notation. | 5782 | "Read file modes in octal or symbolic notation and return its numeric value. |
| 5775 | PROMPT is used as the prompt, default to `File modes (octal or symbolic): '. | 5783 | PROMPT is used as the prompt, default to `File modes (octal or symbolic): '. |
| 5776 | ORIG-FILE is the original file of which modes will be changed." | 5784 | ORIG-FILE is the name of a file on whose mode bits to base returned |
| 5785 | permissions if what user types requests to add, remove, or set permissions | ||
| 5786 | based on existing mode bits, as in \"og+rX-w\"." | ||
| 5777 | (let* ((modes (or (if orig-file (file-modes orig-file) 0) | 5787 | (let* ((modes (or (if orig-file (file-modes orig-file) 0) |
| 5778 | (error "File not found"))) | 5788 | (error "File not found"))) |
| 5779 | (modestr (and (stringp orig-file) | 5789 | (modestr (and (stringp orig-file) |
| @@ -5795,8 +5805,8 @@ ORIG-FILE is the original file of which modes will be changed." | |||
| 5795 | (file-modes-symbolic-to-number value modes))))) | 5805 | (file-modes-symbolic-to-number value modes))))) |
| 5796 | 5806 | ||
| 5797 | 5807 | ||
| 5798 | ;; Trash can handling. | 5808 | ;; Trashcan handling. |
| 5799 | (defcustom trash-directory "~/.Trash" | 5809 | (defcustom trash-directory (convert-standard-filename "~/.Trash") |
| 5800 | "Directory for `move-file-to-trash' to move files and directories to. | 5810 | "Directory for `move-file-to-trash' to move files and directories to. |
| 5801 | This directory is only used when the function `system-move-file-to-trash' is | 5811 | This directory is only used when the function `system-move-file-to-trash' is |
| 5802 | not defined. Relative paths are interpreted relative to `default-directory'. | 5812 | not defined. Relative paths are interpreted relative to `default-directory'. |