See also @code{delete-directory} in @ref{Create/Delete Dirs}.
@end deffn
-@defun set-file-modes filename mode
+@deffn Command set-file-modes filename mode
This function sets mode bits of @var{filename} to @var{mode} (which
-must be an integer). Only the low 12 bits of @var{mode} are used.
+must be an integer when the function is called non-interactively).
+Only the low 12 bits of @var{mode} are used.
+
+Interactively, @var{mode} is read from the minibuffer using
+@code{read-file-modes}, which accepts mode bits either as a number or
+as a character string representing the mode bits symbolically. See
+the description of @code{read-file-modes} below for the supported
+forms of symbolic notation for mode bits.
+
This function recursively follows symbolic links at all levels for
@var{filename}.
-@end defun
+@end deffn
@c Emacs 19 feature
@defun set-default-file-modes mode
This function returns the current default protection value.
@end defun
+@defun read-file-modes &optional prompt base-file
+This function reads file mode bits from the minibuffer. The optional
+argument @var{prompt} specifies a non-default prompt. Second optional
+argument @var{base-file} is the name of a file on whose permissions to
+base the mode bits that this function returns, if what the user types
+specifies mode bits relative to permissions of an existing file.
+
+If user input represents an octal number, this function returns that
+number. If it is a complete symbolic specification of mode bits, as
+in @code{"u=rwx"}, the function converts it to the equivalent numeric
+value using @code{file-modes-symbolic-to-number} and returns the
+result. If the specification is relative, as in @code{"o+g"}, then
+the permissions on which the specification is based are taken from the
+mode bits of @var{base-file}. If @var{base-file} is omitted or
+@code{nil}, the function uses @code{0} as the base mode bits. The
+complete and relative specifications can be combined, as in
+@code{"u+r,g+rx,o+r,g-w"}. @xref{File Permissions,,, coreutils, The
+@sc{gnu} @code{Coreutils} Manual}, for detailed description of
+symbolic mode bits specifications.
+@end defun
+
+@defun file-modes-symbolic-to-number modes &optional base-modes
+This subroutine converts a symbolic specification of file mode bits in
+@var{modes} into the equivalent numeric value. If the symbolic
+specification is based on an existing file, that file's mode bits are
+taken from the optional argument @var{base-modes}; if that argument is
+omitted or @code{nil}, it defaults to zero, i.e.@: no access rights at
+all.
+@end defun
+
@defun set-file-times filename &optional time
This function sets the access and modification times of @var{filename}
to @var{time}. The return value is @code{t} if the times are successfully
This function returns @var{filename}'s final ``extension,'' if any,
after applying @code{file-name-sans-versions} to remove any
version/backup part. The extension, in a file name, is the part that
-starts with the last @samp{.} in the last name component (minus
-any version/backup part).
+follows the last @samp{.} in the last name component (minus any
+version/backup part).
This function returns @code{nil} for extensionless file names such as
@file{foo}. It returns @code{""} for null extensions, as in
@code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p},
@code{file-truename}, @code{file-writable-p},
@code{find-backup-file-name},
-@code{find-file-noselect},@*
+@c Not sure why it was here: @code{find-file-noselect},@*
@code{get-file-buffer},
@code{insert-directory},
@code{insert-file-contents},@*
@code{file-readable-p}, @code{file-regular-p}, @code{file-symlink-p},
@code{file-truename}, @code{file-writable-p},
@code{find-backup-file-name},
-@code{find-file-noselect},
+@c Not sure why it was here: @code{find-file-noselect},
@code{get-file-buffer},
@code{insert-directory},
@code{insert-file-contents},
@end defun
@defun unhandled-file-name-directory filename
-This function returns the name of a directory that is not magic.
-It uses the directory part of @var{filename} if that is not magic.
-For a magic file name, it invokes the file name handler, which
-therefore decides what value to return. If @var{filename} is not
-accessible from a local process, then the file name handler should
-indicate it by returning nil.
+This function returns the name of a directory that is not magic. It
+uses the directory part of @var{filename} if that is not magic. For a
+magic file name, it invokes the file name handler, which therefore
+decides what value to return. If @var{filename} is not accessible
+from a local process, then the file name handler should indicate it by
+returning @code{nil}.
This is useful for running a subprocess; every subprocess must have a
non-magic directory to serve as its current directory, and this function
Each format definition is a list of this form:
@example
-(@var{name} @var{doc-string} @var{regexp} @var{from-fn} @var{to-fn} @var{modify} @var{mode-fn})
+(@var{name} @var{doc-string} @var{regexp} @var{from-fn} @var{to-fn} @var{modify} @var{mode-fn} @var{preserve})
@end example
@end defvar
A minor-mode function to call after visiting a file converted from this
format. The function is called with one argument, the integer 1;
that tells a minor-mode function to enable the mode.
+
+@item preserve
+A flag, @code{t} if @code{format-write-file} should not remove this format
+from @code{buffer-file-format}.
@end table
The function @code{insert-file-contents} automatically recognizes file
@deffn Command format-write-file file format &optional confirm
This command writes the current buffer contents into the file
@var{file} in format @var{format}, and makes that format the default
-for future saves of the buffer. The argument @var{format} is a list
-of format names. Except for the @var{format} argument, this command
+for future saves of the buffer. That is, it sets the buffer-local value
+of @code{buffer-file-format} to @var{format}. It then appends any
+elements of the previous value with a non-nil @var{preserve} flag (see
+above), if they are not already present in the new value.
+The argument @var{format} is a list of format names.
+Except for the @var{format} argument, this command
is similar to @code{write-file}. In particular, @var{confirm} has the
same meaning and interactive treatment as the corresponding argument
to @code{write-file}. @xref{Definition of write-file}.