diff options
| author | Eli Zaretskii | 2024-11-09 14:02:06 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2024-11-09 14:02:06 +0200 |
| commit | dbcd9d782c94e34baf9aabdaeaa70efb791d8a25 (patch) | |
| tree | 14e8725d79090cf394f908b94b55c6f88e49f8e6 | |
| parent | 94bf7ad797bb7a3c1faa72d2066a1e9b883c4547 (diff) | |
| download | emacs-dbcd9d782c94e34baf9aabdaeaa70efb791d8a25.tar.gz emacs-dbcd9d782c94e34baf9aabdaeaa70efb791d8a25.zip | |
Fix documentation and error message of adding local variables
* lisp/files-x.el (add-file-local-variable)
(add-file-local-variable-prop-line): Doc fixes.
(add-file-local-variable): Improve the user-error text. (Bug#74267)
| -rw-r--r-- | lisp/files-x.el | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el index f70be5f7ff3..5f8c1e9aec2 100644 --- a/lisp/files-x.el +++ b/lisp/files-x.el | |||
| @@ -239,18 +239,23 @@ This command deletes all existing settings of VARIABLE (except `mode' | |||
| 239 | and `eval') and adds a new file-local VARIABLE with VALUE to the | 239 | and `eval') and adds a new file-local VARIABLE with VALUE to the |
| 240 | Local Variables list. | 240 | Local Variables list. |
| 241 | 241 | ||
| 242 | If there is no Local Variables list in the current file buffer | 242 | If there is no Local Variables list in the current file buffer, |
| 243 | then this function adds the first line containing the string | 243 | then this function adds it at the end of the file, with the first |
| 244 | `Local Variables:' and the last line containing the string `End:'." | 244 | line containing the string `Local Variables:' and the last line |
| 245 | containing the string `End:'. | ||
| 246 | |||
| 247 | For adding local variables on the first line of a file, for example | ||
| 248 | for settings like `lexical-binding, which must be specified there, | ||
| 249 | use the `add-file-local-variable-prop-line' command instead." | ||
| 245 | (interactive | 250 | (interactive |
| 246 | (let ((variable (read-file-local-variable "Add file-local variable"))) | 251 | (let ((variable (read-file-local-variable "Add file-local variable"))) |
| 247 | ;; Error before reading value. | 252 | ;; Error before reading value. |
| 248 | (if (equal variable 'lexical-binding) | 253 | (if (equal variable 'lexical-binding) |
| 249 | (user-error "The `%s' variable must be set at the start of the file" | 254 | (user-error "Use `add-file-local-variable-prop-line' to add the `%s' variable" |
| 250 | variable)) | 255 | variable)) |
| 251 | (list variable (read-file-local-variable-value variable) t))) | 256 | (list variable (read-file-local-variable-value variable) t))) |
| 252 | (if (equal variable 'lexical-binding) | 257 | (if (equal variable 'lexical-binding) |
| 253 | (user-error "The `%s' variable must be set at the start of the file" | 258 | (user-error "Use `add-file-local-variable-prop-line' to add the `%s' variable" |
| 254 | variable)) | 259 | variable)) |
| 255 | (modify-file-local-variable variable value 'add-or-replace interactive)) | 260 | (modify-file-local-variable variable value 'add-or-replace interactive)) |
| 256 | 261 | ||
| @@ -394,10 +399,13 @@ from the -*- line ignoring the input argument VALUE." | |||
| 394 | 399 | ||
| 395 | This command deletes all existing settings of VARIABLE (except `mode' | 400 | This command deletes all existing settings of VARIABLE (except `mode' |
| 396 | and `eval') and adds a new file-local VARIABLE with VALUE to | 401 | and `eval') and adds a new file-local VARIABLE with VALUE to |
| 397 | the -*- line. | 402 | the -*- line at the beginning of the file. |
| 398 | 403 | ||
| 399 | If there is no -*- line at the beginning of the current file buffer | 404 | If there is no -*- line at the beginning of the current file buffer |
| 400 | then this function adds it." | 405 | then this function adds it. |
| 406 | |||
| 407 | To add variables to the Local Variables list at the end of the file, | ||
| 408 | use the `add-file-local-variable' command instead." | ||
| 401 | (interactive | 409 | (interactive |
| 402 | (let ((variable (read-file-local-variable "Add -*- file-local variable"))) | 410 | (let ((variable (read-file-local-variable "Add -*- file-local variable"))) |
| 403 | (list variable (read-file-local-variable-value variable) t))) | 411 | (list variable (read-file-local-variable-value variable) t))) |