diff options
| -rw-r--r-- | doc/lispref/ChangeLog | 27 | ||||
| -rw-r--r-- | doc/lispref/backups.texi | 14 | ||||
| -rw-r--r-- | doc/lispref/commands.texi | 27 | ||||
| -rw-r--r-- | doc/lispref/compile.texi | 63 | ||||
| -rw-r--r-- | doc/lispref/customize.texi | 18 | ||||
| -rw-r--r-- | doc/lispref/elisp.texi | 3 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 499 | ||||
| -rw-r--r-- | doc/lispref/minibuf.texi | 6 | ||||
| -rw-r--r-- | doc/lispref/variables.texi | 21 | ||||
| -rw-r--r-- | etc/NEWS | 7 |
10 files changed, 373 insertions, 312 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 124ee8fe1dd..454e716a5bf 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2014-01-05 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * backups.texi (Making Backups): Document backup-buffer change. | ||
| 4 | |||
| 5 | * files.texi (Visiting Files): Copyedits. | ||
| 6 | (Testing Accessibility): Mention ACLs. Move file-modes here from | ||
| 7 | File Attributes. | ||
| 8 | (Truenames): Move file-equal-p here from Kinds of Files. | ||
| 9 | (File Attributes): Move file-newer-than-file-p here from Testing | ||
| 10 | Accessibility. | ||
| 11 | (Extended Attributes): New node. Add file-extended-attributes. | ||
| 12 | (Changing Files): Document set-file-extended-attributes. | ||
| 13 | |||
| 14 | * commands.texi (Defining Commands): Document the interactive-form | ||
| 15 | property more carefully. Document interactive-only. | ||
| 16 | |||
| 17 | * compile.texi (Compiler Errors): Copyedits. Note that the | ||
| 18 | details for byte-compile-warnings are in its docstring. | ||
| 19 | |||
| 20 | * minibuf.texi (Minibuffer Contents): Remove obsolete function | ||
| 21 | minibuffer-completion-contents. | ||
| 22 | |||
| 23 | * variables.texi (Defining Variables): Note that defvar acts | ||
| 24 | always on the dynamic value. | ||
| 25 | |||
| 26 | * customize.texi (Variable Definitions): Likewise. | ||
| 27 | |||
| 1 | 2014-01-05 Paul Eggert <eggert@cs.ucla.edu> | 28 | 2014-01-05 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 29 | ||
| 3 | Document vconcat and the empty vector (Bug#16246). | 30 | Document vconcat and the empty vector (Bug#16246). |
diff --git a/doc/lispref/backups.texi b/doc/lispref/backups.texi index ac3a81931c1..83ffb2f95e4 100644 --- a/doc/lispref/backups.texi +++ b/doc/lispref/backups.texi | |||
| @@ -57,13 +57,15 @@ buffer, if appropriate. It is called by @code{save-buffer} before | |||
| 57 | saving the buffer the first time. | 57 | saving the buffer the first time. |
| 58 | 58 | ||
| 59 | If a backup was made by renaming, the return value is a cons cell of | 59 | If a backup was made by renaming, the return value is a cons cell of |
| 60 | the form (@var{modes} @var{context} @var{backupname}), where | 60 | the form (@var{modes} @var{extra-alist} @var{backupname}), where |
| 61 | @var{modes} are the mode bits of the original file, as returned by | 61 | @var{modes} are the mode bits of the original file, as returned by |
| 62 | @code{file-modes} (@pxref{File Attributes,, Other Information about | 62 | @code{file-modes} (@pxref{Testing Accessibility}), @var{extra-alist} |
| 63 | Files}), @var{context} is a list describing the original file's | 63 | is an alist describing the original file's extended attributes, as |
| 64 | SELinux context (@pxref{File Attributes}), and @var{backupname} is the | 64 | returned by @code{file-extended-attributes} (@pxref{Extended |
| 65 | name of the backup. In all other cases, that is, if a backup was made | 65 | Attributes}), and @var{backupname} is the name of the backup. |
| 66 | by copying or if no backup was made, this function returns @code{nil}. | 66 | |
| 67 | In all other cases (i.e., if a backup was made by copying or if no | ||
| 68 | backup was made), this function returns @code{nil}. | ||
| 67 | @end defun | 69 | @end defun |
| 68 | 70 | ||
| 69 | @defvar buffer-backed-up | 71 | @defvar buffer-backed-up |
diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index a118e9132a3..f9476e5e34c 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi | |||
| @@ -108,13 +108,26 @@ command does. | |||
| 108 | 108 | ||
| 109 | The special form @code{interactive} turns a Lisp function into a | 109 | The special form @code{interactive} turns a Lisp function into a |
| 110 | command. The @code{interactive} form must be located at top-level in | 110 | command. The @code{interactive} form must be located at top-level in |
| 111 | the function body (usually as the first form in the body), or in the | 111 | the function body, usually as the first form in the body; this applies |
| 112 | @code{interactive-form} property of the function symbol. When the | 112 | to both lambda expressions (@pxref{Lambda Expressions}) and |
| 113 | @code{interactive} form is located in the function body, it does | 113 | @code{defun} forms (@pxref{Defining Functions}). This form does |
| 114 | nothing when actually executed. Its presence serves as a flag, which | 114 | nothing during the actual execution of the function; its presence |
| 115 | tells the Emacs command loop that the function can be called | 115 | serves as a flag, telling the Emacs command loop that the function can |
| 116 | interactively. The argument of the @code{interactive} form controls | 116 | be called interactively. The argument of the @code{interactive} form |
| 117 | the reading of arguments for an interactive call. | 117 | specifies how the arguments for an interactive call should be read. |
| 118 | |||
| 119 | @cindex @code{interactive-form} property | ||
| 120 | Alternatively, an @code{interactive} form may be specified in a | ||
| 121 | function symbol's @code{interactive-form} property. A non-@code{nil} | ||
| 122 | value for this property takes precedence over any @code{interactive} | ||
| 123 | form in the function body itself. This feature is seldom used. | ||
| 124 | |||
| 125 | @cindex @code{interactive-only} property | ||
| 126 | Sometimes, a named command is only intended to be called | ||
| 127 | interactively, never directly from Lisp. In that case, give it a | ||
| 128 | non-@code{nil} @code{interactive-only} property. In that case, the | ||
| 129 | byte compiler will print a warning message if the command is called | ||
| 130 | from Lisp. | ||
| 118 | 131 | ||
| 119 | @menu | 132 | @menu |
| 120 | * Using Interactive:: General rules for @code{interactive}. | 133 | * Using Interactive:: General rules for @code{interactive}. |
diff --git a/doc/lispref/compile.texi b/doc/lispref/compile.texi index 85c9ac5f73c..fe492df1d94 100644 --- a/doc/lispref/compile.texi +++ b/doc/lispref/compile.texi | |||
| @@ -430,29 +430,35 @@ to what @code{eval-when-compile} does. | |||
| 430 | @section Compiler Errors | 430 | @section Compiler Errors |
| 431 | @cindex compiler errors | 431 | @cindex compiler errors |
| 432 | 432 | ||
| 433 | Byte compilation outputs all errors and warnings into the buffer | 433 | Error and warning messages from byte compilation are printed in a |
| 434 | @file{*Compile-Log*}. The messages include file names and line | 434 | buffer named @file{*Compile-Log*}. These messages include file names |
| 435 | numbers that identify the location of the problem. The usual Emacs | 435 | and line numbers identifying the location of the problem. The usual |
| 436 | commands for operating on compiler diagnostics work properly on these | 436 | Emacs commands for operating on compiler output can be used on these |
| 437 | messages. | 437 | messages. |
| 438 | 438 | ||
| 439 | When an error is due to invalid syntax in the program, the byte | 439 | When an error is due to invalid syntax in the program, the byte |
| 440 | compiler might get confused about the errors' exact location. One way | 440 | compiler might get confused about the errors' exact location. One way |
| 441 | to investigate is to switch to the buffer @w{@file{ *Compiler Input*}}. | 441 | to investigate is to switch to the buffer @w{@file{ *Compiler |
| 442 | (This buffer name starts with a space, so it does not show up in | 442 | Input*}}. (This buffer name starts with a space, so it does not show |
| 443 | @kbd{M-x list-buffers}.) This buffer contains the program being | 443 | up in the Buffer Menu.) This buffer contains the program being |
| 444 | compiled, and point shows how far the byte compiler was able to read; | 444 | compiled, and point shows how far the byte compiler was able to read; |
| 445 | the cause of the error might be nearby. @xref{Syntax Errors}, for | 445 | the cause of the error might be nearby. @xref{Syntax Errors}, for |
| 446 | some tips for locating syntax errors. | 446 | some tips for locating syntax errors. |
| 447 | 447 | ||
| 448 | When the byte compiler warns about functions that were used but not | 448 | A common type of warning issued by the byte compiler is for |
| 449 | defined, it always reports the line number for the end of the file, | 449 | functions and variables that were used but not defined. Such warnings |
| 450 | not the locations where the missing functions were called. To find | 450 | report the line number for the end of the file, not the locations |
| 451 | the latter, you must search for the function names. | 451 | where the missing functions or variables were used; to find these, you |
| 452 | must search the file manually. | ||
| 452 | 453 | ||
| 453 | You can suppress the compiler warning for calling an undefined | 454 | If you are sure that a warning message about a missing function or |
| 454 | function @var{func} by conditionalizing the function call on an | 455 | variable is unjustified, there are several ways to suppress it: |
| 455 | @code{fboundp} test, like this: | 456 | |
| 457 | @itemize @bullet | ||
| 458 | @item | ||
| 459 | You can suppress the warning for a specific call to a function | ||
| 460 | @var{func} by conditionalizing it on an @code{fboundp} test, like | ||
| 461 | this: | ||
| 456 | 462 | ||
| 457 | @example | 463 | @example |
| 458 | (if (fboundp '@var{func}) ...(@var{func} ...)...) | 464 | (if (fboundp '@var{func}) ...(@var{func} ...)...) |
| @@ -463,14 +469,10 @@ The call to @var{func} must be in the @var{then-form} of the | |||
| 463 | @code{if}, and @var{func} must appear quoted in the call to | 469 | @code{if}, and @var{func} must appear quoted in the call to |
| 464 | @code{fboundp}. (This feature operates for @code{cond} as well.) | 470 | @code{fboundp}. (This feature operates for @code{cond} as well.) |
| 465 | 471 | ||
| 466 | You can tell the compiler that a function is defined using | 472 | @item |
| 467 | @code{declare-function} (@pxref{Declaring Functions}). Likewise, you | 473 | Likewise, you can suppress the warning for a specific use of a |
| 468 | can tell the compiler that a variable is defined using @code{defvar} | 474 | variable @var{variable} by conditionalizing it on a @code{boundp} |
| 469 | with no initial value. | 475 | test: |
| 470 | |||
| 471 | You can suppress the compiler warning for a specific use of an | ||
| 472 | undefined variable @var{variable} by conditionalizing its use on a | ||
| 473 | @code{boundp} test, like this: | ||
| 474 | 476 | ||
| 475 | @example | 477 | @example |
| 476 | (if (boundp '@var{variable}) ...@var{variable}...) | 478 | (if (boundp '@var{variable}) ...@var{variable}...) |
| @@ -481,7 +483,17 @@ The reference to @var{variable} must be in the @var{then-form} of the | |||
| 481 | @code{if}, and @var{variable} must appear quoted in the call to | 483 | @code{if}, and @var{variable} must appear quoted in the call to |
| 482 | @code{boundp}. | 484 | @code{boundp}. |
| 483 | 485 | ||
| 484 | You can suppress any and all compiler warnings within a certain | 486 | @item |
| 487 | You can tell the compiler that a function is defined using | ||
| 488 | @code{declare-function}. @xref{Declaring Functions}. | ||
| 489 | |||
| 490 | @item | ||
| 491 | Likewise, you can tell the compiler that a variable is defined using | ||
| 492 | @code{defvar} with no initial value. (Note that this marks the | ||
| 493 | variable as special.) @xref{Defining Variables}. | ||
| 494 | @end itemize | ||
| 495 | |||
| 496 | You can also suppress any and all compiler warnings within a certain | ||
| 485 | expression using the construct @code{with-no-warnings}: | 497 | expression using the construct @code{with-no-warnings}: |
| 486 | 498 | ||
| 487 | @c This is implemented with a defun, but conceptually it is | 499 | @c This is implemented with a defun, but conceptually it is |
| @@ -497,8 +509,9 @@ possible piece of code, to avoid missing possible warnings other than | |||
| 497 | one you intend to suppress. | 509 | one you intend to suppress. |
| 498 | @end defspec | 510 | @end defspec |
| 499 | 511 | ||
| 500 | More precise control of warnings is possible by setting the variable | 512 | Byte compiler warnings can be controlled more precisely by setting |
| 501 | @code{byte-compile-warnings}. | 513 | the variable @code{byte-compile-warnings}. See its documentation |
| 514 | string for details. | ||
| 502 | 515 | ||
| 503 | @node Byte-Code Objects | 516 | @node Byte-Code Objects |
| 504 | @section Byte-Code Function Objects | 517 | @section Byte-Code Function Objects |
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 1e54a7fa444..4b0a0a9ba2c 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi | |||
| @@ -287,13 +287,17 @@ customizable variable). You should not quote @var{option}. | |||
| 287 | 287 | ||
| 288 | The argument @var{standard} is an expression that specifies the | 288 | The argument @var{standard} is an expression that specifies the |
| 289 | standard value for @var{option}. Evaluating the @code{defcustom} form | 289 | standard value for @var{option}. Evaluating the @code{defcustom} form |
| 290 | evaluates @var{standard}, but does not necessarily install the | 290 | evaluates @var{standard}, but does not necessarily bind the option to |
| 291 | standard value. If @var{option} already has a default value, | 291 | that value. If @var{option} already has a default value, it is left |
| 292 | @code{defcustom} does not change it. If the user has saved a | 292 | unchanged. If the user has already saved a customization for |
| 293 | customization for @var{option}, @code{defcustom} installs the user's | 293 | @var{option}, the user's customized value is installed as the default |
| 294 | customized value as @var{option}'s default value. If neither of those | 294 | value. Otherwise, the result of evaluating @var{standard} is |
| 295 | cases applies, @code{defcustom} installs the result of evaluating | 295 | installed as the default value. |
| 296 | @var{standard} as the default value. | 296 | |
| 297 | Like @code{defvar}, this macro marks @code{option} as a special | ||
| 298 | variable, meaning that it should always be dynamically bound. If | ||
| 299 | @var{option} is already lexically bound, that lexical binding remains | ||
| 300 | in effect until the binding construct exits. @xref{Variable Scoping}. | ||
| 297 | 301 | ||
| 298 | The expression @var{standard} can be evaluated at various other times, | 302 | The expression @var{standard} can be evaluated at various other times, |
| 299 | too---whenever the customization facility needs to know @var{option}'s | 303 | too---whenever the customization facility needs to know @var{option}'s |
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index 94c06a130b1..9681c3c42a3 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi | |||
| @@ -951,7 +951,8 @@ Information about Files | |||
| 951 | * Testing Accessibility:: Is a given file readable? Writable? | 951 | * Testing Accessibility:: Is a given file readable? Writable? |
| 952 | * Kinds of Files:: Is it a directory? A symbolic link? | 952 | * Kinds of Files:: Is it a directory? A symbolic link? |
| 953 | * Truenames:: Eliminating symbolic links from a file name. | 953 | * Truenames:: Eliminating symbolic links from a file name. |
| 954 | * File Attributes:: How large is it? Any other names? Etc. | 954 | * File Attributes:: File sizes, modification times, etc. |
| 955 | * Extended Attributes:: Extended file attributes for access control. | ||
| 955 | * Locating Files:: How to find a file in standard places. | 956 | * Locating Files:: How to find a file in standard places. |
| 956 | 957 | ||
| 957 | File Names | 958 | File Names |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 8f2ca0ccf8d..076c91c0c58 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -7,21 +7,21 @@ | |||
| 7 | @chapter Files | 7 | @chapter Files |
| 8 | 8 | ||
| 9 | This chapter describes the Emacs Lisp functions and variables to | 9 | This chapter describes the Emacs Lisp functions and variables to |
| 10 | find, create, view, save, and otherwise work with files and file | 10 | find, create, view, save, and otherwise work with files and |
| 11 | directories. A few other file-related functions are described in | 11 | directories. A few other file-related functions are described in |
| 12 | @ref{Buffers}, and those related to backups and auto-saving are | 12 | @ref{Buffers}, and those related to backups and auto-saving are |
| 13 | described in @ref{Backups and Auto-Saving}. | 13 | described in @ref{Backups and Auto-Saving}. |
| 14 | 14 | ||
| 15 | Many of the file functions take one or more arguments that are file | 15 | Many of the file functions take one or more arguments that are file |
| 16 | names. A file name is actually a string. Most of these functions | 16 | names. A file name is a string. Most of these functions expand file |
| 17 | expand file name arguments by calling @code{expand-file-name}, so that | 17 | name arguments using the function @code{expand-file-name}, so that |
| 18 | @file{~} is handled correctly, as are relative file names (including | 18 | @file{~} is handled correctly, as are relative file names (including |
| 19 | @samp{../}). @xref{File Name Expansion}. | 19 | @file{../}). @xref{File Name Expansion}. |
| 20 | 20 | ||
| 21 | In addition, certain @dfn{magic} file names are handled specially. | 21 | In addition, certain @dfn{magic} file names are handled specially. |
| 22 | For example, when a remote file name is specified, Emacs accesses the | 22 | For example, when a remote file name is specified, Emacs accesses the |
| 23 | file over the network via an appropriate protocol (@pxref{Remote | 23 | file over the network via an appropriate protocol. @xref{Remote |
| 24 | Files,, Remote Files, emacs, The GNU Emacs Manual}). This handling is | 24 | Files,, Remote Files, emacs, The GNU Emacs Manual}. This handling is |
| 25 | done at a very low level, so you may assume that all the functions | 25 | done at a very low level, so you may assume that all the functions |
| 26 | described in this chapter accept magic file names as file name | 26 | described in this chapter accept magic file names as file name |
| 27 | arguments, except where noted. @xref{Magic File Names}, for details. | 27 | arguments, except where noted. @xref{Magic File Names}, for details. |
| @@ -58,22 +58,21 @@ done, we say that the buffer is @dfn{visiting} that file, and call the | |||
| 58 | file ``the visited file'' of the buffer. | 58 | file ``the visited file'' of the buffer. |
| 59 | 59 | ||
| 60 | A file and a buffer are two different things. A file is information | 60 | A file and a buffer are two different things. A file is information |
| 61 | recorded permanently in the computer (unless you delete it). A buffer, | 61 | recorded permanently in the computer (unless you delete it). A |
| 62 | on the other hand, is information inside of Emacs that will vanish at | 62 | buffer, on the other hand, is information inside of Emacs that will |
| 63 | the end of the editing session (or when you kill the buffer). Usually, | 63 | vanish at the end of the editing session (or when you kill the |
| 64 | a buffer contains information that you have copied from a file; then we | 64 | buffer). When a buffer is visiting a file, it contains information |
| 65 | say the buffer is visiting that file. The copy in the buffer is what | 65 | copied from the file. The copy in the buffer is what you modify with |
| 66 | you modify with editing commands. Such changes to the buffer do not | 66 | editing commands. Changes to the buffer do not change the file; to |
| 67 | change the file; therefore, to make the changes permanent, you must | 67 | make the changes permanent, you must @dfn{save} the buffer, which |
| 68 | @dfn{save} the buffer, which means copying the altered buffer contents | 68 | means copying the altered buffer contents back into the file. |
| 69 | back into the file. | 69 | |
| 70 | 70 | Despite the distinction between files and buffers, people often | |
| 71 | In spite of the distinction between files and buffers, people often | 71 | refer to a file when they mean a buffer and vice-versa. Indeed, we |
| 72 | refer to a file when they mean a buffer and vice-versa. Indeed, we say, | 72 | say, ``I am editing a file'', rather than, ``I am editing a buffer |
| 73 | ``I am editing a file'', rather than, ``I am editing a buffer that I | 73 | that I will soon save as a file of the same name''. Humans do not |
| 74 | will soon save as a file of the same name''. Humans do not usually need | 74 | usually need to make the distinction explicit. When dealing with a |
| 75 | to make the distinction explicit. When dealing with a computer program, | 75 | computer program, however, it is good to keep the distinction in mind. |
| 76 | however, it is good to keep the distinction in mind. | ||
| 77 | 76 | ||
| 78 | @menu | 77 | @menu |
| 79 | * Visiting Functions:: The usual interface functions for visiting. | 78 | * Visiting Functions:: The usual interface functions for visiting. |
| @@ -507,9 +506,9 @@ Name}). | |||
| 507 | @section Reading from Files | 506 | @section Reading from Files |
| 508 | @cindex reading from files | 507 | @cindex reading from files |
| 509 | 508 | ||
| 510 | You can copy a file from the disk and insert it into a buffer | 509 | To copy the contents of a file into a buffer, use the function |
| 511 | using the @code{insert-file-contents} function. Don't use the user-level | 510 | @code{insert-file-contents}. (Don't use the command |
| 512 | command @code{insert-file} in a Lisp program, as that sets the mark. | 511 | @code{insert-file} in a Lisp program, as that sets the mark.) |
| 513 | 512 | ||
| 514 | @defun insert-file-contents filename &optional visit beg end replace | 513 | @defun insert-file-contents filename &optional visit beg end replace |
| 515 | This function inserts the contents of file @var{filename} into the | 514 | This function inserts the contents of file @var{filename} into the |
| @@ -769,26 +768,24 @@ for its usual definition is in @file{userlock.el}. | |||
| 769 | @section Information about Files | 768 | @section Information about Files |
| 770 | @cindex file, information about | 769 | @cindex file, information about |
| 771 | 770 | ||
| 772 | The functions described in this section all operate on strings that | 771 | This section describes the functions for retrieving various types of |
| 773 | designate file names. With a few exceptions, all the functions have | 772 | information about files (or directories or symbolic links), such as |
| 774 | names that begin with the word @samp{file}. These functions all | 773 | whether a file is readable or writable, and its size. These functions |
| 775 | return information about actual files or directories, so their | 774 | all take arguments which are file names. Except where noted, these |
| 776 | arguments must all exist as actual files or directories unless | 775 | arguments need to specify existing files, or an error is signaled. |
| 777 | otherwise noted. | ||
| 778 | 776 | ||
| 779 | @cindex file names, trailing whitespace | 777 | @cindex file names, trailing whitespace |
| 780 | @cindex trailing blanks in file names | 778 | @cindex trailing blanks in file names |
| 781 | Be careful with file names that end in blanks: some filesystems | 779 | Be careful with file names that end in spaces. On some filesystems |
| 782 | (notably, MS-Windows) will ignore trailing whitespace in file names, | 780 | (notably, MS-Windows), trailing whitespace characters in file names |
| 783 | and return information about the file after stripping those blanks | 781 | are silently and automatically ignored. |
| 784 | from the name, not about the file whose name you passed to the | ||
| 785 | functions described in this section. | ||
| 786 | 782 | ||
| 787 | @menu | 783 | @menu |
| 788 | * Testing Accessibility:: Is a given file readable? Writable? | 784 | * Testing Accessibility:: Is a given file readable? Writable? |
| 789 | * Kinds of Files:: Is it a directory? A symbolic link? | 785 | * Kinds of Files:: Is it a directory? A symbolic link? |
| 790 | * Truenames:: Eliminating symbolic links from a file name. | 786 | * Truenames:: Eliminating symbolic links from a file name. |
| 791 | * File Attributes:: How large is it? Any other names? Etc. | 787 | * File Attributes:: File sizes, modification times, etc. |
| 788 | * Extended Attributes:: Extended file attributes for access control. | ||
| 792 | * Locating Files:: How to find a file in standard places. | 789 | * Locating Files:: How to find a file in standard places. |
| 793 | @end menu | 790 | @end menu |
| 794 | 791 | ||
| @@ -797,10 +794,16 @@ functions described in this section. | |||
| 797 | @cindex accessibility of a file | 794 | @cindex accessibility of a file |
| 798 | @cindex file accessibility | 795 | @cindex file accessibility |
| 799 | 796 | ||
| 800 | These functions test for permission to access a file in specific | 797 | These functions test for permission to access a file for reading, |
| 801 | ways. Unless explicitly stated otherwise, they recursively follow | 798 | writing, or execution. Unless explicitly stated otherwise, they |
| 802 | symbolic links for their file name arguments, at all levels (at the | 799 | recursively follow symbolic links for their file name arguments, at |
| 803 | level of the file itself and at all levels of parent directories). | 800 | all levels (at the level of the file itself and at all levels of |
| 801 | parent directories). | ||
| 802 | |||
| 803 | On some operating systems, more complex sets of access permissions | ||
| 804 | can be specified, via mechanisms such as Access Control Lists (ACLs). | ||
| 805 | @xref{Extended Attributes}, for how to query and set those | ||
| 806 | permissions. | ||
| 804 | 807 | ||
| 805 | @defun file-exists-p filename | 808 | @defun file-exists-p filename |
| 806 | This function returns @code{t} if a file named @var{filename} appears | 809 | This function returns @code{t} if a file named @var{filename} appears |
| @@ -810,9 +813,8 @@ true if the file exists and you have execute permission on the | |||
| 810 | containing directories, regardless of the permissions of the file | 813 | containing directories, regardless of the permissions of the file |
| 811 | itself.) | 814 | itself.) |
| 812 | 815 | ||
| 813 | If the file does not exist, or if fascist access control policies | 816 | If the file does not exist, or if access control policies prevent you |
| 814 | prevent you from finding the attributes of the file, this function | 817 | from finding its attributes, this function returns @code{nil}. |
| 815 | returns @code{nil}. | ||
| 816 | 818 | ||
| 817 | Directories are files, so @code{file-exists-p} returns @code{t} when | 819 | Directories are files, so @code{file-exists-p} returns @code{t} when |
| 818 | given a directory name. However, symbolic links are treated | 820 | given a directory name. However, symbolic links are treated |
| @@ -823,24 +825,8 @@ name only if the target file exists. | |||
| 823 | @defun file-readable-p filename | 825 | @defun file-readable-p filename |
| 824 | This function returns @code{t} if a file named @var{filename} exists | 826 | This function returns @code{t} if a file named @var{filename} exists |
| 825 | and you can read it. It returns @code{nil} otherwise. | 827 | and you can read it. It returns @code{nil} otherwise. |
| 826 | |||
| 827 | @example | ||
| 828 | @group | ||
| 829 | (file-readable-p "files.texi") | ||
| 830 | @result{} t | ||
| 831 | @end group | ||
| 832 | @group | ||
| 833 | (file-exists-p "/usr/spool/mqueue") | ||
| 834 | @result{} t | ||
| 835 | @end group | ||
| 836 | @group | ||
| 837 | (file-readable-p "/usr/spool/mqueue") | ||
| 838 | @result{} nil | ||
| 839 | @end group | ||
| 840 | @end example | ||
| 841 | @end defun | 828 | @end defun |
| 842 | 829 | ||
| 843 | @c Emacs 19 feature | ||
| 844 | @defun file-executable-p filename | 830 | @defun file-executable-p filename |
| 845 | This function returns @code{t} if a file named @var{filename} exists and | 831 | This function returns @code{t} if a file named @var{filename} exists and |
| 846 | you can execute it. It returns @code{nil} otherwise. On Unix and | 832 | you can execute it. It returns @code{nil} otherwise. On Unix and |
| @@ -856,27 +842,18 @@ file exists and you can write it. It is creatable if it does not exist, | |||
| 856 | but the specified directory does exist and you can write in that | 842 | but the specified directory does exist and you can write in that |
| 857 | directory. | 843 | directory. |
| 858 | 844 | ||
| 859 | In the third example below, @file{foo} is not writable because the | 845 | In the example below, @file{foo} is not writable because the parent |
| 860 | parent directory does not exist, even though the user could create such | 846 | directory does not exist, even though the user could create such a |
| 861 | a directory. | 847 | directory. |
| 862 | 848 | ||
| 863 | @example | 849 | @example |
| 864 | @group | 850 | @group |
| 865 | (file-writable-p "~/foo") | ||
| 866 | @result{} t | ||
| 867 | @end group | ||
| 868 | @group | ||
| 869 | (file-writable-p "/foo") | ||
| 870 | @result{} nil | ||
| 871 | @end group | ||
| 872 | @group | ||
| 873 | (file-writable-p "~/no-such-dir/foo") | 851 | (file-writable-p "~/no-such-dir/foo") |
| 874 | @result{} nil | 852 | @result{} nil |
| 875 | @end group | 853 | @end group |
| 876 | @end example | 854 | @end example |
| 877 | @end defun | 855 | @end defun |
| 878 | 856 | ||
| 879 | @c Emacs 19 feature | ||
| 880 | @defun file-accessible-directory-p dirname | 857 | @defun file-accessible-directory-p dirname |
| 881 | This function returns @code{t} if you have permission to open existing | 858 | This function returns @code{t} if you have permission to open existing |
| 882 | files in the directory whose name as a file is @var{dirname}; | 859 | files in the directory whose name as a file is @var{dirname}; |
| @@ -885,16 +862,13 @@ The value of @var{dirname} may be either a directory name (such as | |||
| 885 | @file{/foo/}) or the file name of a file which is a directory | 862 | @file{/foo/}) or the file name of a file which is a directory |
| 886 | (such as @file{/foo}, without the final slash). | 863 | (such as @file{/foo}, without the final slash). |
| 887 | 864 | ||
| 888 | Example: after the following, | 865 | For example, from the following we deduce that any attempt to read a |
| 866 | file in @file{/foo/} will give an error: | ||
| 889 | 867 | ||
| 890 | @example | 868 | @example |
| 891 | (file-accessible-directory-p "/foo") | 869 | (file-accessible-directory-p "/foo") |
| 892 | @result{} nil | 870 | @result{} nil |
| 893 | @end example | 871 | @end example |
| 894 | |||
| 895 | @noindent | ||
| 896 | we can deduce that any attempt to read a file in @file{/foo/} will | ||
| 897 | give an error. | ||
| 898 | @end defun | 872 | @end defun |
| 899 | 873 | ||
| 900 | @defun access-file filename string | 874 | @defun access-file filename string |
| @@ -917,39 +891,59 @@ replace @var{filename} with its target. However, it does recursively | |||
| 917 | follow symbolic links at all levels of parent directories. | 891 | follow symbolic links at all levels of parent directories. |
| 918 | @end defun | 892 | @end defun |
| 919 | 893 | ||
| 920 | @defun file-newer-than-file-p filename1 filename2 | 894 | @defun file-modes filename |
| 921 | @cindex file age | 895 | @cindex mode bits |
| 922 | @cindex file modification time | 896 | @cindex file permissions |
| 923 | This function returns @code{t} if the file @var{filename1} is | 897 | @cindex permissions, file |
| 924 | newer than file @var{filename2}. If @var{filename1} does not | 898 | @cindex file modes |
| 925 | exist, it returns @code{nil}. If @var{filename1} does exist, but | 899 | This function returns the @dfn{mode bits} of @var{filename}---an |
| 926 | @var{filename2} does not, it returns @code{t}. | 900 | integer summarizing its read, write, and execution permissions. |
| 901 | Symbolic links in @var{filename} are recursively followed at all | ||
| 902 | levels. If the file does not exist, the return value is @code{nil}. | ||
| 927 | 903 | ||
| 928 | In the following example, assume that the file @file{aug-19} was written | 904 | @xref{File permissions,,, coreutils, The @sc{gnu} @code{Coreutils} |
| 929 | on the 19th, @file{aug-20} was written on the 20th, and the file | 905 | Manual}, for a description of mode bits. For example, if the |
| 930 | @file{no-file} doesn't exist at all. | 906 | low-order bit is 1, the file is executable by all users; if the |
| 907 | second-lowest-order bit is 1, the file is writable by all users; etc. | ||
| 908 | The highest possible value is 4095 (7777 octal), meaning that everyone | ||
| 909 | has read, write, and execute permission, the @acronym{SUID} bit is set | ||
| 910 | for both others and group, and the sticky bit is set. | ||
| 911 | |||
| 912 | @xref{Changing Files}, for the @code{set-file-modes} function, which | ||
| 913 | can be used to set these permissions. | ||
| 931 | 914 | ||
| 932 | @example | 915 | @example |
| 933 | @group | 916 | @group |
| 934 | (file-newer-than-file-p "aug-19" "aug-20") | 917 | (file-modes "~/junk/diffs") |
| 935 | @result{} nil | 918 | @result{} 492 ; @r{Decimal integer.} |
| 936 | @end group | 919 | @end group |
| 937 | @group | 920 | @group |
| 938 | (file-newer-than-file-p "aug-20" "aug-19") | 921 | (format "%o" 492) |
| 939 | @result{} t | 922 | @result{} "754" ; @r{Convert to octal.} |
| 940 | @end group | 923 | @end group |
| 924 | |||
| 941 | @group | 925 | @group |
| 942 | (file-newer-than-file-p "aug-19" "no-file") | 926 | (set-file-modes "~/junk/diffs" #o666) |
| 943 | @result{} t | 927 | @result{} nil |
| 944 | @end group | 928 | @end group |
| 929 | |||
| 945 | @group | 930 | @group |
| 946 | (file-newer-than-file-p "no-file" "aug-19") | 931 | $ ls -l diffs |
| 947 | @result{} nil | 932 | -rw-rw-rw- 1 lewis lewis 3063 Oct 30 16:00 diffs |
| 948 | @end group | 933 | @end group |
| 949 | @end example | 934 | @end example |
| 950 | 935 | ||
| 951 | You can use @code{file-attributes} to get a file's last modification | 936 | @cindex MS-DOS and file modes |
| 952 | time as a list of four integers. @xref{File Attributes}. | 937 | @cindex file modes and MS-DOS |
| 938 | @strong{MS-DOS note:} On MS-DOS, there is no such thing as an | ||
| 939 | ``executable'' file mode bit. So @code{file-modes} considers a file | ||
| 940 | executable if its name ends in one of the standard executable | ||
| 941 | extensions, such as @file{.com}, @file{.bat}, @file{.exe}, and some | ||
| 942 | others. Files that begin with the Unix-standard @samp{#!} signature, | ||
| 943 | such as shell and Perl scripts, are also considered executable. | ||
| 944 | Directories are also reported as executable, for compatibility with | ||
| 945 | Unix. These conventions are also followed by @code{file-attributes} | ||
| 946 | (@pxref{File Attributes}). | ||
| 953 | @end defun | 947 | @end defun |
| 954 | 948 | ||
| 955 | @node Kinds of Files | 949 | @node Kinds of Files |
| @@ -987,8 +981,6 @@ If the file @var{filename} is not a symbolic link (or there is no such file), | |||
| 987 | @result{} "/pub/bin" | 981 | @result{} "/pub/bin" |
| 988 | @end group | 982 | @end group |
| 989 | @end example | 983 | @end example |
| 990 | |||
| 991 | @c !!! file-symlink-p: should show output of ls -l for comparison | ||
| 992 | @end defun | 984 | @end defun |
| 993 | 985 | ||
| 994 | The next two functions recursively follow symbolic links at | 986 | The next two functions recursively follow symbolic links at |
| @@ -1029,21 +1021,6 @@ a regular file (not a directory, named pipe, terminal, or | |||
| 1029 | other I/O device). | 1021 | other I/O device). |
| 1030 | @end defun | 1022 | @end defun |
| 1031 | 1023 | ||
| 1032 | @defun file-equal-p file1 file2 | ||
| 1033 | This function returns @code{t} if the files @var{file1} and | ||
| 1034 | @var{file2} name the same file. If @var{file1} or @var{file2} does | ||
| 1035 | not exist, the return value is unspecified. | ||
| 1036 | @end defun | ||
| 1037 | |||
| 1038 | @defun file-in-directory-p file dir | ||
| 1039 | This function returns @code{t} if @var{file} is a file in directory | ||
| 1040 | @var{dir}, or in a subdirectory of @var{dir}. It also returns | ||
| 1041 | @code{t} if @var{file} and @var{dir} are the same directory. It | ||
| 1042 | compares the @code{file-truename} values of the two directories | ||
| 1043 | (@pxref{Truenames}). If @var{dir} does not name an existing | ||
| 1044 | directory, the return value is @code{nil}. | ||
| 1045 | @end defun | ||
| 1046 | |||
| 1047 | @node Truenames | 1024 | @node Truenames |
| 1048 | @subsection Truenames | 1025 | @subsection Truenames |
| 1049 | @cindex truename (of file) | 1026 | @cindex truename (of file) |
| @@ -1066,14 +1043,14 @@ This function does not expand environment variables. Only | |||
| 1066 | substitute-in-file-name}. | 1043 | substitute-in-file-name}. |
| 1067 | 1044 | ||
| 1068 | If you may need to follow symbolic links preceding @samp{..}@: | 1045 | If you may need to follow symbolic links preceding @samp{..}@: |
| 1069 | appearing as a name component, you should make sure to call | 1046 | appearing as a name component, call @code{file-truename} without prior |
| 1070 | @code{file-truename} without prior direct or indirect calls to | 1047 | direct or indirect calls to @code{expand-file-name}. Otherwise, the |
| 1071 | @code{expand-file-name}, as otherwise the file name component | 1048 | file name component immediately preceding @samp{..} will be |
| 1072 | immediately preceding @samp{..} will be ``simplified away'' before | 1049 | ``simplified away'' before @code{file-truename} is called. To |
| 1073 | @code{file-truename} is called. To eliminate the need for a call to | 1050 | eliminate the need for a call to @code{expand-file-name}, |
| 1074 | @code{expand-file-name}, @code{file-truename} handles @samp{~} in the | 1051 | @code{file-truename} handles @samp{~} in the same way that |
| 1075 | same way that @code{expand-file-name} does. @xref{File Name | 1052 | @code{expand-file-name} does. @xref{File Name Expansion,, Functions |
| 1076 | Expansion,, Functions that Expand Filenames}. | 1053 | that Expand Filenames}. |
| 1077 | @end defun | 1054 | @end defun |
| 1078 | 1055 | ||
| 1079 | @defun file-chase-links filename &optional limit | 1056 | @defun file-chase-links filename &optional limit |
| @@ -1102,70 +1079,61 @@ we would have: | |||
| 1102 | @result{} "/home/foo/hello" | 1079 | @result{} "/home/foo/hello" |
| 1103 | @end example | 1080 | @end example |
| 1104 | 1081 | ||
| 1105 | @xref{Buffer File Name}, for related information. | 1082 | @defun file-equal-p file1 file2 |
| 1083 | This function returns @code{t} if the files @var{file1} and | ||
| 1084 | @var{file2} name the same file. This is similar to comparing their | ||
| 1085 | truenames, except that remote file names are also handled in an | ||
| 1086 | appropriate manner. If @var{file1} or @var{file2} does not exist, the | ||
| 1087 | return value is unspecified. | ||
| 1088 | @end defun | ||
| 1089 | |||
| 1090 | @defun file-in-directory-p file dir | ||
| 1091 | This function returns @code{t} if @var{file} is a file in directory | ||
| 1092 | @var{dir}, or in a subdirectory of @var{dir}. It also returns | ||
| 1093 | @code{t} if @var{file} and @var{dir} are the same directory. It | ||
| 1094 | compares the truenames of the two directories. If @var{dir} does not | ||
| 1095 | name an existing directory, the return value is @code{nil}. | ||
| 1096 | @end defun | ||
| 1106 | 1097 | ||
| 1107 | @node File Attributes | 1098 | @node File Attributes |
| 1108 | @subsection Other Information about Files | 1099 | @subsection File Attributes |
| 1100 | @cindex file attributes | ||
| 1109 | 1101 | ||
| 1110 | This section describes the functions for getting detailed | 1102 | This section describes the functions for getting detailed |
| 1111 | information about a file, other than its contents. This information | 1103 | information about a file, including the owner and group numbers, the |
| 1112 | includes the mode bits that control access permissions, the owner and | 1104 | number of names, the inode number, the size, and the times of access |
| 1113 | group numbers, the number of names, the inode number, the size, and | 1105 | and modification. |
| 1114 | the times of access and modification. | ||
| 1115 | 1106 | ||
| 1116 | @defun file-modes filename | 1107 | @defun file-newer-than-file-p filename1 filename2 |
| 1117 | @cindex file permissions | 1108 | @cindex file age |
| 1118 | @cindex permissions, file | 1109 | @cindex file modification time |
| 1119 | @cindex file attributes | 1110 | This function returns @code{t} if the file @var{filename1} is |
| 1120 | @cindex file modes | 1111 | newer than file @var{filename2}. If @var{filename1} does not |
| 1121 | This function returns the @dfn{mode bits} describing the @dfn{file | 1112 | exist, it returns @code{nil}. If @var{filename1} does exist, but |
| 1122 | permissions} of @var{filename}, as an integer. It recursively follows | 1113 | @var{filename2} does not, it returns @code{t}. |
| 1123 | symbolic links in @var{filename} at all levels. If @var{filename} | ||
| 1124 | does not exist, the return value is @code{nil}. | ||
| 1125 | 1114 | ||
| 1126 | @xref{File permissions,,, coreutils, The @sc{gnu} @code{Coreutils} | 1115 | In the following example, assume that the file @file{aug-19} was written |
| 1127 | Manual}, for a description of mode bits. If the low-order bit is 1, | 1116 | on the 19th, @file{aug-20} was written on the 20th, and the file |
| 1128 | then the file is executable by all users, if the second-lowest-order | 1117 | @file{no-file} doesn't exist at all. |
| 1129 | bit is 1, then the file is writable by all users, etc. The highest | ||
| 1130 | value returnable is 4095 (7777 octal), meaning that everyone has read, | ||
| 1131 | write, and execute permission, that the @acronym{SUID} bit is set for | ||
| 1132 | both others and group, and that the sticky bit is set. | ||
| 1133 | 1118 | ||
| 1134 | @example | 1119 | @example |
| 1135 | @group | 1120 | @group |
| 1136 | (file-modes "~/junk/diffs") | 1121 | (file-newer-than-file-p "aug-19" "aug-20") |
| 1137 | @result{} 492 ; @r{Decimal integer.} | 1122 | @result{} nil |
| 1138 | @end group | 1123 | @end group |
| 1139 | @group | 1124 | @group |
| 1140 | (format "%o" 492) | 1125 | (file-newer-than-file-p "aug-20" "aug-19") |
| 1141 | @result{} "754" ; @r{Convert to octal.} | 1126 | @result{} t |
| 1142 | @end group | 1127 | @end group |
| 1143 | |||
| 1144 | @group | 1128 | @group |
| 1145 | (set-file-modes "~/junk/diffs" #o666) | 1129 | (file-newer-than-file-p "aug-19" "no-file") |
| 1146 | @result{} nil | 1130 | @result{} t |
| 1147 | @end group | 1131 | @end group |
| 1148 | |||
| 1149 | @group | 1132 | @group |
| 1150 | $ ls -l diffs | 1133 | (file-newer-than-file-p "no-file" "aug-19") |
| 1151 | -rw-rw-rw- 1 lewis lewis 3063 Oct 30 16:00 diffs | 1134 | @result{} nil |
| 1152 | @end group | 1135 | @end group |
| 1153 | @end example | 1136 | @end example |
| 1154 | |||
| 1155 | @xref{Changing Files}, for functions that change file permissions, | ||
| 1156 | such as @code{set-file-modes}. | ||
| 1157 | |||
| 1158 | @cindex MS-DOS and file modes | ||
| 1159 | @cindex file modes and MS-DOS | ||
| 1160 | @strong{MS-DOS note:} On MS-DOS, there is no such thing as an | ||
| 1161 | ``executable'' file mode bit. So @code{file-modes} considers a file | ||
| 1162 | executable if its name ends in one of the standard executable | ||
| 1163 | extensions, such as @file{.com}, @file{.bat}, @file{.exe}, and some | ||
| 1164 | others. Files that begin with the Unix-standard @samp{#!} signature, | ||
| 1165 | such as shell and Perl scripts, are also considered executable. | ||
| 1166 | Directories are also reported as executable, for compatibility with | ||
| 1167 | Unix. These conventions are also followed by @code{file-attributes}, | ||
| 1168 | below. | ||
| 1169 | @end defun | 1137 | @end defun |
| 1170 | 1138 | ||
| 1171 | If the @var{filename} argument to the next two functions is a | 1139 | If the @var{filename} argument to the next two functions is a |
| @@ -1173,31 +1141,6 @@ symbolic link, then these function do @emph{not} replace it with its | |||
| 1173 | target. However, they both recursively follow symbolic links at all | 1141 | target. However, they both recursively follow symbolic links at all |
| 1174 | levels of parent directories. | 1142 | levels of parent directories. |
| 1175 | 1143 | ||
| 1176 | @defun file-nlinks filename | ||
| 1177 | This function returns the number of names (i.e., hard links) that | ||
| 1178 | file @var{filename} has. If the file does not exist, this function | ||
| 1179 | returns @code{nil}. Note that symbolic links have no effect on this | ||
| 1180 | function, because they are not considered to be names of the files | ||
| 1181 | they link to. | ||
| 1182 | |||
| 1183 | @example | ||
| 1184 | @group | ||
| 1185 | $ ls -l foo* | ||
| 1186 | -rw-rw-rw- 2 rms rms 4 Aug 19 01:27 foo | ||
| 1187 | -rw-rw-rw- 2 rms rms 4 Aug 19 01:27 foo1 | ||
| 1188 | @end group | ||
| 1189 | |||
| 1190 | @group | ||
| 1191 | (file-nlinks "foo") | ||
| 1192 | @result{} 2 | ||
| 1193 | @end group | ||
| 1194 | @group | ||
| 1195 | (file-nlinks "doesnt-exist") | ||
| 1196 | @result{} nil | ||
| 1197 | @end group | ||
| 1198 | @end example | ||
| 1199 | @end defun | ||
| 1200 | |||
| 1201 | @defun file-attributes filename &optional id-format | 1144 | @defun file-attributes filename &optional id-format |
| 1202 | @anchor{Definition of file-attributes} | 1145 | @anchor{Definition of file-attributes} |
| 1203 | This function returns a list of attributes of file @var{filename}. If | 1146 | This function returns a list of attributes of file @var{filename}. If |
| @@ -1339,52 +1282,99 @@ is on the file-system device whose number is 1014478468. | |||
| 1339 | @end table | 1282 | @end table |
| 1340 | @end defun | 1283 | @end defun |
| 1341 | 1284 | ||
| 1342 | @cindex SELinux context | 1285 | @defun file-nlinks filename |
| 1343 | SELinux is a Linux kernel feature which provides more sophisticated | 1286 | This function returns the number of names (i.e., hard links) that |
| 1344 | file access controls than ordinary ``Unix-style'' file permissions. | 1287 | file @var{filename} has. If the file does not exist, this function |
| 1345 | If Emacs has been compiled with SELinux support on a system with | 1288 | returns @code{nil}. Note that symbolic links have no effect on this |
| 1346 | SELinux enabled, you can use the function @code{file-selinux-context} | 1289 | function, because they are not considered to be names of the files |
| 1347 | to retrieve a file's SELinux security context. For the function | 1290 | they link to. |
| 1348 | @code{set-file-selinux-context}, see @ref{Changing Files}. | ||
| 1349 | 1291 | ||
| 1350 | @defun file-selinux-context filename | 1292 | @example |
| 1351 | This function returns the SELinux security context of the file | 1293 | @group |
| 1352 | @var{filename}. This return value is a list of the form | 1294 | $ ls -l foo* |
| 1353 | @code{(@var{user} @var{role} @var{type} @var{range})}, whose elements | 1295 | -rw-rw-rw- 2 rms rms 4 Aug 19 01:27 foo |
| 1354 | are the context's user, role, type, and range respectively, as Lisp | 1296 | -rw-rw-rw- 2 rms rms 4 Aug 19 01:27 foo1 |
| 1355 | strings. See the SELinux documentation for details about what these | 1297 | @end group |
| 1356 | actually mean. | ||
| 1357 | 1298 | ||
| 1358 | If the file does not exist or is inaccessible, or if the system does | 1299 | @group |
| 1359 | not support SELinux, or if Emacs was not compiled with SELinux | 1300 | (file-nlinks "foo") |
| 1360 | support, then the return value is @code{(nil nil nil nil)}. | 1301 | @result{} 2 |
| 1302 | @end group | ||
| 1303 | @group | ||
| 1304 | (file-nlinks "doesnt-exist") | ||
| 1305 | @result{} nil | ||
| 1306 | @end group | ||
| 1307 | @end example | ||
| 1361 | @end defun | 1308 | @end defun |
| 1362 | 1309 | ||
| 1310 | @node Extended Attributes | ||
| 1311 | @subsection Extended File Attributes | ||
| 1312 | @cindex extended file attributes | ||
| 1313 | |||
| 1314 | On some operating systems, each file can be associated with arbitrary | ||
| 1315 | @dfn{extended file attributes}. At present, Emacs supports querying | ||
| 1316 | and setting two specific sets of extended file attributes: Access | ||
| 1317 | Control Lists (ACLs) and SELinux contexts. These extended file | ||
| 1318 | attributes are used, on some systems, to impose more sophisticated | ||
| 1319 | file access controls than the basic ``Unix-style'' permissions | ||
| 1320 | discussed in the previous sections. | ||
| 1321 | |||
| 1363 | @cindex access control list | 1322 | @cindex access control list |
| 1364 | @cindex ACL entries | 1323 | @cindex ACL entries |
| 1365 | If Emacs has been compiled with @dfn{ACL} (access control list) | 1324 | @cindex SELinux context |
| 1366 | support, you can use the function @code{file-acl} to retrieve a file's | 1325 | A detailed explanation of ACLs and SELinux is beyond the scope of |
| 1367 | ACL entries. The interface implementation is platform-specific; on | 1326 | this manual. For our purposes, each file can be associated with an |
| 1368 | GNU/Linux and BSD, Emacs uses the POSIX ACL interface, while on | 1327 | @dfn{ACL}, which specifies its properties under an ACL-based file |
| 1369 | MS-Windows Emacs emulates the POSIX ACL interface with native file | 1328 | control system, and/or an @dfn{SELinux context}, which specifies its |
| 1370 | security APIs. | 1329 | properties under the SELinux system. |
| 1371 | 1330 | ||
| 1372 | @defun file-acl filename | 1331 | @defun file-acl filename |
| 1373 | This function returns the ACL entries of the file @var{filename}. The | 1332 | This function returns the ACL for the file @var{filename}. The exact |
| 1374 | return value is a platform-dependent object containing some | 1333 | Lisp representation of the ACL is unspecified (and may change in |
| 1375 | representation of the ACL entries. Don't use it for anything except | 1334 | future Emacs versions), but it is the same as what @code{set-file-acl} |
| 1376 | passing it to the @code{set-file-acl} function (@pxref{Changing Files, | 1335 | takes for its @var{acl} argument (@pxref{Changing Files}). |
| 1377 | set-file-acl}). | ||
| 1378 | 1336 | ||
| 1379 | If the file does not exist or is inaccessible, or if Emacs was unable to | 1337 | The underlying ACL implementation is platform-specific; on GNU/Linux |
| 1380 | determine the ACL entries, then the return value is @code{nil}. The | 1338 | and BSD, Emacs uses the POSIX ACL interface, while on MS-Windows Emacs |
| 1381 | latter can happen for local files if Emacs was not compiled with ACL | 1339 | emulates the POSIX ACL interface with native file security APIs. |
| 1382 | support, or for remote files if the file handler returns nil for the | 1340 | |
| 1383 | file's ACL entries. | 1341 | If Emacs was not compiled with ACL support, or the file does not exist |
| 1342 | or is inaccessible, or Emacs was unable to determine the ACL entries | ||
| 1343 | for any other reason, then the return value is @code{nil}. | ||
| 1344 | @end defun | ||
| 1345 | |||
| 1346 | @defun file-selinux-context filename | ||
| 1347 | This function returns the SELinux context of the file @var{filename}, | ||
| 1348 | as a list of the form @code{(@var{user} @var{role} @var{type} | ||
| 1349 | @var{range})}. The list elements are the context's user, role, type, | ||
| 1350 | and range respectively, as Lisp strings; see the SELinux documentation | ||
| 1351 | for details about what these actually mean. The return value has the | ||
| 1352 | same form as what @code{set-file-selinux-context} takes for its | ||
| 1353 | @var{context} argument (@pxref{Changing Files}). | ||
| 1354 | |||
| 1355 | If Emacs was not compiled with SELinux support, or the file does not | ||
| 1356 | exist or is inaccessible, or if the system does not support SELinux, | ||
| 1357 | then the return value is @code{(nil nil nil nil)}. | ||
| 1358 | @end defun | ||
| 1359 | |||
| 1360 | @defun file-extended-attributes filename | ||
| 1361 | This function returns an alist of the Emacs-recognized extended | ||
| 1362 | attributes of file @var{filename}. Currently, it serves as a | ||
| 1363 | convenient way to retrieve both the ACL and SELinux context; you can | ||
| 1364 | then call the function @code{set-file-extended-attributes}, with the | ||
| 1365 | returned alist as its second argument, to apply the same file access | ||
| 1366 | attributes to another file (@pxref{Changing Files}). | ||
| 1367 | |||
| 1368 | One of the elements is @code{(acl . @var{acl})}, where @var{acl} has | ||
| 1369 | the same form returned by @code{file-acl}. | ||
| 1370 | |||
| 1371 | Another element is @code{(selinux-context . @var{context})}, where | ||
| 1372 | @var{context} is the SELinux context, in the same form returned by | ||
| 1373 | @code{file-selinux-context}. | ||
| 1384 | @end defun | 1374 | @end defun |
| 1385 | 1375 | ||
| 1386 | @node Locating Files | 1376 | @node Locating Files |
| 1387 | @subsection How to Locate Files in Standard Places | 1377 | @subsection Locating Files in Standard Places |
| 1388 | @cindex locate file in path | 1378 | @cindex locate file in path |
| 1389 | @cindex find file in path | 1379 | @cindex find file in path |
| 1390 | 1380 | ||
| @@ -1571,10 +1561,11 @@ file. This works only on some operating systems, and only if you have | |||
| 1571 | the correct permissions to do so. | 1561 | the correct permissions to do so. |
| 1572 | 1562 | ||
| 1573 | If the optional argument @var{preserve-permissions} is non-@code{nil}, | 1563 | If the optional argument @var{preserve-permissions} is non-@code{nil}, |
| 1574 | this function copies the file's permissions, such as its file modes, | 1564 | this function copies the file modes (or ``permissions''), as well as |
| 1575 | its SELinux context, and ACL entries (@pxref{File Attributes}). | 1565 | its Access Control List and SELinux context (if any). |
| 1576 | Otherwise, if the destination is created its file permission bits are | 1566 | @xref{Information about Files}. Otherwise, if the destination is |
| 1577 | those of the source, masked by the default file permissions. | 1567 | created its file permission bits are those of the source, masked by |
| 1568 | the default file permissions. | ||
| 1578 | @end deffn | 1569 | @end deffn |
| 1579 | 1570 | ||
| 1580 | @deffn Command make-symbolic-link filename newname &optional ok-if-exists | 1571 | @deffn Command make-symbolic-link filename newname &optional ok-if-exists |
| @@ -1616,7 +1607,7 @@ See also @code{delete-directory} in @ref{Create/Delete Dirs}. | |||
| 1616 | @cindex permissions, file | 1607 | @cindex permissions, file |
| 1617 | @cindex file modes, setting | 1608 | @cindex file modes, setting |
| 1618 | @deffn Command set-file-modes filename mode | 1609 | @deffn Command set-file-modes filename mode |
| 1619 | This function sets the @dfn{file mode} (or @dfn{file permissions}) of | 1610 | This function sets the @dfn{file mode} (or @dfn{permissions}) of |
| 1620 | @var{filename} to @var{mode}. It recursively follows symbolic links | 1611 | @var{filename} to @var{mode}. It recursively follows symbolic links |
| 1621 | at all levels for @var{filename}. | 1612 | at all levels for @var{filename}. |
| 1622 | 1613 | ||
| @@ -1705,25 +1696,31 @@ time and must be in the format returned by @code{current-time} | |||
| 1705 | (@pxref{Time of Day}). | 1696 | (@pxref{Time of Day}). |
| 1706 | @end defun | 1697 | @end defun |
| 1707 | 1698 | ||
| 1699 | @defun set-file-extended-attributes filename attribute-alist | ||
| 1700 | This function sets the Emacs-recognized extended file attributes for | ||
| 1701 | @code{filename}. The second argument @var{attribute-alist} should be | ||
| 1702 | an alist of the same form returned by @code{file-extended-attributes}. | ||
| 1703 | @xref{Extended Attributes}. | ||
| 1704 | @end defun | ||
| 1705 | |||
| 1708 | @defun set-file-selinux-context filename context | 1706 | @defun set-file-selinux-context filename context |
| 1709 | This function sets the SELinux security context of the file | 1707 | This function sets the SELinux security context for @var{filename} to |
| 1710 | @var{filename} to @var{context}. @xref{File Attributes}, for a brief | 1708 | @var{context}. The @var{context} argument should be a list |
| 1711 | description of SELinux contexts. The @var{context} argument should be | 1709 | @code{(@var{user} @var{role} @var{type} @var{range})}, where each |
| 1712 | a list @code{(@var{user} @var{role} @var{type} @var{range})}, like the | 1710 | element is a string. @xref{Extended Attributes}. |
| 1713 | return value of @code{file-selinux-context}. The function returns | 1711 | |
| 1714 | @code{t} if it succeeds to set the SELinux security context of | 1712 | The function returns @code{t} if it succeeds in setting the SELinux |
| 1715 | @var{filename}, @code{nil} otherwise. The function does nothing and | 1713 | context of @var{filename}. It returns @code{nil} if the context was |
| 1716 | returns @code{nil} if SELinux is disabled, or if Emacs was compiled | 1714 | not set (e.g., if SELinux is disabled, or if Emacs was compiled |
| 1717 | without SELinux support. | 1715 | without SELinux support). |
| 1718 | @end defun | 1716 | @end defun |
| 1719 | 1717 | ||
| 1720 | @defun set-file-acl filename acl-string | 1718 | @defun set-file-acl filename acl |
| 1721 | This function sets the ACL entries of the file @var{filename} to | 1719 | This function sets the Access Control List for @var{filename} to |
| 1722 | @var{acl-string}. @xref{File Attributes}, for a brief description of | 1720 | @var{acl}. The @var{acl} argument should have the same form returned |
| 1723 | ACLs. The @var{acl-string} argument should be a string containing the | 1721 | by the function @code{file-acl}. @xref{Extended Attributes}. |
| 1724 | textual representation of the desired ACL entries as returned by | 1722 | |
| 1725 | @code{file-acl} (@pxref{File Attributes, file-acl}). The function | 1723 | The function returns @code{t} if it successfully sets the ACL of |
| 1726 | returns @code{t} if it succeeds to set the ACL entries of | ||
| 1727 | @var{filename}, @code{nil} otherwise. | 1724 | @var{filename}, @code{nil} otherwise. |
| 1728 | @end defun | 1725 | @end defun |
| 1729 | 1726 | ||
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index 0e58816ecf3..e32922eef68 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -2224,12 +2224,6 @@ This is like @code{minibuffer-contents}, except that it does not copy text | |||
| 2224 | properties, just the characters themselves. @xref{Text Properties}. | 2224 | properties, just the characters themselves. @xref{Text Properties}. |
| 2225 | @end defun | 2225 | @end defun |
| 2226 | 2226 | ||
| 2227 | @defun minibuffer-completion-contents | ||
| 2228 | This is like @code{minibuffer-contents}, except that it returns only | ||
| 2229 | the contents before point. That is the part that completion commands | ||
| 2230 | operate on. @xref{Minibuffer Completion}. | ||
| 2231 | @end defun | ||
| 2232 | |||
| 2233 | @defun delete-minibuffer-contents | 2227 | @defun delete-minibuffer-contents |
| 2234 | This function erases the editable contents of the minibuffer (that is, | 2228 | This function erases the editable contents of the minibuffer (that is, |
| 2235 | everything except the prompt), if a minibuffer is current. Otherwise, | 2229 | everything except the prompt), if a minibuffer is current. Otherwise, |
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index a80a6c0b1e3..dbeebcc6ee6 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi | |||
| @@ -416,18 +416,23 @@ explicitly in the @code{defvar} form. The variable is marked as | |||
| 416 | @dfn{special}, meaning that it should always be dynamically bound | 416 | @dfn{special}, meaning that it should always be dynamically bound |
| 417 | (@pxref{Variable Scoping}). | 417 | (@pxref{Variable Scoping}). |
| 418 | 418 | ||
| 419 | If @var{symbol} is void and @var{value} is specified, @code{defvar} | 419 | If @var{value} is specified, and @var{symbol} is void (i.e., it has no |
| 420 | evaluates @var{value} and sets @var{symbol} to the result. But if | 420 | dynamically bound value; @pxref{Void Variables}), then @var{value} is |
| 421 | @var{symbol} already has a value (i.e., it is not void), @var{value} | 421 | evaluated and @var{symbol} is set to the result. But if @var{symbol} |
| 422 | is not even evaluated, and @var{symbol}'s value remains unchanged. If | 422 | is not void, @var{value} is not evaluated, and @var{symbol}'s value is |
| 423 | @var{value} is omitted, the value of @var{symbol} is not changed in | 423 | left unchanged. If @var{value} is omitted, the value of @var{symbol} |
| 424 | any case. | 424 | is not changed in any case. |
| 425 | 425 | ||
| 426 | If @var{symbol} has a buffer-local binding in the current buffer, | 426 | If @var{symbol} has a buffer-local binding in the current buffer, |
| 427 | @code{defvar} operates on the default value, which is buffer-independent, | 427 | @code{defvar} acts on the default value, which is buffer-independent, |
| 428 | not the current (buffer-local) binding. It sets the default value if | 428 | rather than the buffer-local binding. It sets the default value if |
| 429 | the default value is void. @xref{Buffer-Local Variables}. | 429 | the default value is void. @xref{Buffer-Local Variables}. |
| 430 | 430 | ||
| 431 | If @var{symbol} is already lexically bound (e.g., if the @code{defvar} | ||
| 432 | form occurs in a @code{let} form with lexical binding enabled), then | ||
| 433 | @code{defvar} sets the dynamic value. The lexical binding remains in | ||
| 434 | effect until its binding construct exits. @xref{Variable Scoping}. | ||
| 435 | |||
| 431 | When you evaluate a top-level @code{defvar} form with @kbd{C-M-x} in | 436 | When you evaluate a top-level @code{defvar} form with @kbd{C-M-x} in |
| 432 | Emacs Lisp mode (@code{eval-defun}), a special feature of | 437 | Emacs Lisp mode (@code{eval-defun}), a special feature of |
| 433 | @code{eval-defun} arranges to set the variable unconditionally, without | 438 | @code{eval-defun} arranges to set the variable unconditionally, without |
| @@ -904,6 +904,7 @@ low-level libraries gfilenotify.c, inotify.c or w32notify.c. | |||
| 904 | ** `(input-pending-p)' no longer runs other timers which are ready to | 904 | ** `(input-pending-p)' no longer runs other timers which are ready to |
| 905 | run. The new optional CHECK-TIMERS param allows for the prior behavior. | 905 | run. The new optional CHECK-TIMERS param allows for the prior behavior. |
| 906 | 906 | ||
| 907 | +++ | ||
| 907 | ** `defvar' and `defcustom' in a let-binding affect the "external" default. | 908 | ** `defvar' and `defcustom' in a let-binding affect the "external" default. |
| 908 | 909 | ||
| 909 | --- | 910 | --- |
| @@ -958,6 +959,7 @@ special-forms any more. | |||
| 958 | when lexical binding is enabled. Previously, VAR was bound to nil, | 959 | when lexical binding is enabled. Previously, VAR was bound to nil, |
| 959 | which often led to spurious unused-variable warnings. | 960 | which often led to spurious unused-variable warnings. |
| 960 | 961 | ||
| 962 | +++ | ||
| 961 | ** The return value of `backup-buffer' has changed. | 963 | ** The return value of `backup-buffer' has changed. |
| 962 | The second argument is no longer an SELinux context, instead it is an | 964 | The second argument is no longer an SELinux context, instead it is an |
| 963 | alist of extended attributes as returned by the new function | 965 | alist of extended attributes as returned by the new function |
| @@ -1083,6 +1085,7 @@ displaying the buffer in a window. | |||
| 1083 | *** `string-remove-prefix' | 1085 | *** `string-remove-prefix' |
| 1084 | *** `string-remove-suffix' | 1086 | *** `string-remove-suffix' |
| 1085 | 1087 | ||
| 1088 | +++ | ||
| 1086 | ** Obsoleted functions: | 1089 | ** Obsoleted functions: |
| 1087 | *** `log10' | 1090 | *** `log10' |
| 1088 | *** `dont-compile' | 1091 | *** `dont-compile' |
| @@ -1100,8 +1103,10 @@ The few hooks that used with-wrapper-hook are replaced as follows: | |||
| 1100 | *** `completion-in-region-function' obsoletes `completion-in-region-functions'. | 1103 | *** `completion-in-region-function' obsoletes `completion-in-region-functions'. |
| 1101 | *** `filter-buffer-substring-function' obsoletes `filter-buffer-substring-functions'. | 1104 | *** `filter-buffer-substring-function' obsoletes `filter-buffer-substring-functions'. |
| 1102 | 1105 | ||
| 1106 | +++ | ||
| 1103 | ** `byte-compile-interactive-only-functions' is now obsolete. | 1107 | ** `byte-compile-interactive-only-functions' is now obsolete. |
| 1104 | It has been replaced by the symbol property 'interactive-only. | 1108 | To specify that a command should only be called interactively, give it |
| 1109 | a non-nil `interactive-only' property. | ||
| 1105 | 1110 | ||
| 1106 | +++ | 1111 | +++ |
| 1107 | ** `split-string' now takes an optional argument TRIM. | 1112 | ** `split-string' now takes an optional argument TRIM. |