diff options
| -rw-r--r-- | lisp/files.el | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lisp/files.el b/lisp/files.el index e953a174448..92135d94714 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -326,9 +326,12 @@ See also `write-file-hooks'.") | |||
| 326 | The value can be t, nil or something else. | 326 | The value can be t, nil or something else. |
| 327 | A value of t means file local variables specifications are obeyed; | 327 | A value of t means file local variables specifications are obeyed; |
| 328 | nil means they are ignored; anything else means query. | 328 | nil means they are ignored; anything else means query. |
| 329 | This variable also controls use of major modes specified in | ||
| 330 | a -*- line. | ||
| 329 | 331 | ||
| 330 | The command \\[normal-mode] always obeys file local variable | 332 | The command \\[normal-mode], when used interactively, |
| 331 | specifications and ignores this variable." | 333 | always obeys file local variable specifications and the -*- line, |
| 334 | and ignores this variable." | ||
| 332 | :type '(choice (const :tag "Obey" t) | 335 | :type '(choice (const :tag "Obey" t) |
| 333 | (const :tag "Ignore" nil) | 336 | (const :tag "Ignore" nil) |
| 334 | (other :tag "Query" other)) | 337 | (other :tag "Query" other)) |
| @@ -336,8 +339,12 @@ specifications and ignores this variable." | |||
| 336 | 339 | ||
| 337 | (defvar local-enable-local-variables t | 340 | (defvar local-enable-local-variables t |
| 338 | "Like `enable-local-variables' but meant for buffer-local bindings. | 341 | "Like `enable-local-variables' but meant for buffer-local bindings. |
| 342 | The meaningful values are nil and non-nil. The default is non-nil. | ||
| 339 | If a major mode sets this to nil, buffer-locally, then any local | 343 | If a major mode sets this to nil, buffer-locally, then any local |
| 340 | variables list in the file will be ignored.") | 344 | variables list in the file will be ignored. |
| 345 | |||
| 346 | This variable does not affect the use of major modes | ||
| 347 | specified in a -*- line.") | ||
| 341 | 348 | ||
| 342 | (defcustom enable-local-eval 'maybe | 349 | (defcustom enable-local-eval 'maybe |
| 343 | "*Control processing of the \"variable\" `eval' in a file's local variables. | 350 | "*Control processing of the \"variable\" `eval' in a file's local variables. |
| @@ -1168,10 +1175,15 @@ Also sets up any specified local variables of the file. | |||
| 1168 | Uses the visited file name, the -*- line, and the local variables spec. | 1175 | Uses the visited file name, the -*- line, and the local variables spec. |
| 1169 | 1176 | ||
| 1170 | This function is called automatically from `find-file'. In that case, | 1177 | This function is called automatically from `find-file'. In that case, |
| 1171 | we may set up specified local variables depending on the value of | 1178 | we may set up the file-specified mode and local variables, |
| 1172 | `enable-local-variables': if it is t, we do; if it is nil, we don't; | 1179 | depending on the value of `enable-local-variables': if it is t, we do; |
| 1173 | otherwise, we query. `enable-local-variables' is ignored if you | 1180 | if it is nil, we don't; otherwise, we query. |
| 1174 | run `normal-mode' explicitly." | 1181 | In addition, if `local-enable-local-variables' is nil, we do |
| 1182 | not set local variables (though we do notice a mode specified with -*-.) | ||
| 1183 | |||
| 1184 | `enable-local-variables' is ignored if you run `normal-mode' interactively, | ||
| 1185 | or from Lisp without specifying the optional argument FIND-FILE; | ||
| 1186 | in that case, this function acts as if `enable-local-variables' were t." | ||
| 1175 | (interactive) | 1187 | (interactive) |
| 1176 | (or find-file (funcall (or default-major-mode 'fundamental-mode))) | 1188 | (or find-file (funcall (or default-major-mode 'fundamental-mode))) |
| 1177 | (condition-case err | 1189 | (condition-case err |
| @@ -1391,7 +1403,6 @@ and we don't even do that unless it would come from the file name." | |||
| 1391 | (goto-char (point-min)) | 1403 | (goto-char (point-min)) |
| 1392 | (skip-chars-forward " \t\n") | 1404 | (skip-chars-forward " \t\n") |
| 1393 | (and enable-local-variables | 1405 | (and enable-local-variables |
| 1394 | local-enable-local-variables | ||
| 1395 | ;; Don't look for -*- if this file name matches any | 1406 | ;; Don't look for -*- if this file name matches any |
| 1396 | ;; of the regexps in inhibit-first-line-modes-regexps. | 1407 | ;; of the regexps in inhibit-first-line-modes-regexps. |
| 1397 | (let ((temp inhibit-first-line-modes-regexps) | 1408 | (let ((temp inhibit-first-line-modes-regexps) |
| @@ -1512,7 +1523,9 @@ and we don't even do that unless it would come from the file name." | |||
| 1512 | (save-excursion | 1523 | (save-excursion |
| 1513 | (goto-char (point-min)) | 1524 | (goto-char (point-min)) |
| 1514 | (let ((result nil) | 1525 | (let ((result nil) |
| 1515 | (end (save-excursion (end-of-line (and (looking-at "^#!") 2)) (point)))) | 1526 | (end (save-excursion (end-of-line (and (looking-at "^#!") 2)) (point))) |
| 1527 | (enable-local-variables | ||
| 1528 | (and local-enable-local-variables enable-local-variables))) | ||
| 1516 | ;; Parse the -*- line into the `result' alist. | 1529 | ;; Parse the -*- line into the `result' alist. |
| 1517 | (cond ((not (search-forward "-*-" end t)) | 1530 | (cond ((not (search-forward "-*-" end t)) |
| 1518 | ;; doesn't have one. | 1531 | ;; doesn't have one. |
| @@ -1584,7 +1597,9 @@ is specified, returning t if it is specified." | |||
| 1584 | (unless mode-only | 1597 | (unless mode-only |
| 1585 | (hack-local-variables-prop-line)) | 1598 | (hack-local-variables-prop-line)) |
| 1586 | ;; Look for "Local variables:" line in last page. | 1599 | ;; Look for "Local variables:" line in last page. |
| 1587 | (let (mode-specified) | 1600 | (let (mode-specified |
| 1601 | (enable-local-variables | ||
| 1602 | (and local-enable-local-variables enable-local-variables))) | ||
| 1588 | (save-excursion | 1603 | (save-excursion |
| 1589 | (goto-char (point-max)) | 1604 | (goto-char (point-max)) |
| 1590 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | 1605 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |