Mercurial > emacs
comparison lisp/files.el @ 23657:7f5af9d1766d
(hack-local-variables): Test local-enable-local-variables.
(hack-local-variables-prop-line): Likewise.
(set-auto-mode): Don't test local-enable-local-variables here.
(enable-local-variables): Doc fix.
(local-enable-local-variables): Doc fix.
(normal-mode): Doc fix.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 07 Nov 1998 02:01:59 +0000 |
parents | 57e437a51073 |
children | 68c3d9e82bb7 |
comparison
equal
deleted
inserted
replaced
23656:031653c4634a | 23657:7f5af9d1766d |
---|---|
324 (defcustom enable-local-variables t | 324 (defcustom enable-local-variables t |
325 "*Control use of local variables in files you visit. | 325 "*Control use of local variables in files you visit. |
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 | 329 This variable also controls use of major modes specified in |
330 The command \\[normal-mode] always obeys file local variable | 330 a -*- line. |
331 specifications and ignores this variable." | 331 |
332 The command \\[normal-mode], when used interactively, | |
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)) |
335 :group 'find-file) | 338 :group 'find-file) |
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. |
344 The value can be t, nil or something else. | 351 The value can be t, nil or something else. |
345 A value of t means obey `eval' variables; | 352 A value of t means obey `eval' variables; |
1166 "Choose the major mode for this buffer automatically. | 1173 "Choose the major mode for this buffer automatically. |
1167 Also sets up any specified local variables of the file. | 1174 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 |
1178 (set-auto-mode) | 1190 (set-auto-mode) |
1179 (error (message "File mode specification error: %s" | 1191 (error (message "File mode specification error: %s" |
1389 (let (beg end done modes) | 1401 (let (beg end done modes) |
1390 (save-excursion | 1402 (save-excursion |
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) |
1398 (name (if buffer-file-name | 1409 (name (if buffer-file-name |
1399 (file-name-sans-versions buffer-file-name) | 1410 (file-name-sans-versions buffer-file-name) |
1510 ;; set-auto-mode should already have handled `mode:', | 1521 ;; set-auto-mode should already have handled `mode:', |
1511 ;; set-auto-coding should already have handled `coding:'. | 1522 ;; set-auto-coding should already have handled `coding:'. |
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. |
1519 nil) | 1532 nil) |
1520 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") | 1533 ((looking-at "[ \t]*\\([^ \t\n\r:;]+\\)\\([ \t]*-\\*-\\)") |
1582 If MODE-ONLY is non-nil, all we do is check whether the major mode | 1595 If MODE-ONLY is non-nil, all we do is check whether the major mode |
1583 is specified, returning t if it is specified." | 1596 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) |
1591 (if (let ((case-fold-search t)) | 1606 (if (let ((case-fold-search t)) |
1592 (and (search-forward "Local Variables:" nil t) | 1607 (and (search-forward "Local Variables:" nil t) |