aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/files.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/files.el')
-rw-r--r--lisp/files.el309
1 files changed, 194 insertions, 115 deletions
diff --git a/lisp/files.el b/lisp/files.el
index f15c523400d..7a72775ac3f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -510,14 +510,36 @@ and ignores this variable."
510 (other :tag "Query" other)) 510 (other :tag "Query" other))
511 :group 'find-file) 511 :group 'find-file)
512 512
513;; This is an odd variable IMO.
514;; You might wonder why it is needed, when we could just do:
515;; (set (make-local-variable 'enable-local-variables) nil)
516;; These two are not precisely the same.
517;; Setting this variable does not cause -*- mode settings to be
518;; ignored, whereas setting enable-local-variables does.
519;; Only three places in Emacs use this variable: tar and arc modes,
520;; and rmail. The first two don't need it. They already use
521;; inhibit-local-variables-regexps, which is probably enough, and
522;; could also just set enable-local-variables locally to nil.
523;; Them setting it has the side-effect that dir-locals cannot apply to
524;; eg tar files (?). FIXME Is this appropriate?
525;; AFAICS, rmail is the only thing that needs this, and the only
526;; reason it uses it is for BABYL files (which are obsolete).
527;; These contain "-*- rmail -*-" in the first line, which rmail wants
528;; to respect, so that find-file on a BABYL file will switch to
529;; rmail-mode automatically (this is nice, but hardly essential,
530;; since most people are used to explicitly running a command to
531;; access their mail; M-x gnus etc). Rmail files may happen to
532;; contain Local Variables sections in messages, which Rmail wants to
533;; ignore. So AFAICS the only reason this variable exists is for a
534;; minor convenience feature for handling of an obsolete Rmail file format.
513(defvar local-enable-local-variables t 535(defvar local-enable-local-variables t
514 "Like `enable-local-variables' but meant for buffer-local bindings. 536 "Like `enable-local-variables' but meant for buffer-local bindings.
515The meaningful values are nil and non-nil. The default is non-nil. 537The meaningful values are nil and non-nil. The default is non-nil.
516If a major mode sets this to nil, buffer-locally, then any local 538If a major mode sets this to nil, buffer-locally, then any local
517variables list in the file will be ignored. 539variables list in a file visited in that mode will be ignored.
518 540
519This variable does not affect the use of major modes 541This variable does not affect the use of major modes specified
520specified in a -*- line.") 542in a -*- line.")
521 543
522(defcustom enable-local-eval 'maybe 544(defcustom enable-local-eval 'maybe
523 "Control processing of the \"variable\" `eval' in a file's local variables. 545 "Control processing of the \"variable\" `eval' in a file's local variables.
@@ -2405,9 +2427,6 @@ If the element has the form (REGEXP FUNCTION NON-NIL), then after
2405calling FUNCTION (if it's not nil), we delete the suffix that matched 2427calling FUNCTION (if it's not nil), we delete the suffix that matched
2406REGEXP and search the list again for another match. 2428REGEXP and search the list again for another match.
2407 2429
2408If the file name matches `inhibit-first-line-modes-regexps',
2409then `auto-mode-alist' is not processed.
2410
2411The extensions whose FUNCTION is `archive-mode' should also 2430The extensions whose FUNCTION is `archive-mode' should also
2412appear in `auto-coding-alist' with `no-conversion' coding system. 2431appear in `auto-coding-alist' with `no-conversion' coding system.
2413 2432
@@ -2478,16 +2497,55 @@ of a script, mode MODE is enabled.
2478 2497
2479See also `auto-mode-alist'.") 2498See also `auto-mode-alist'.")
2480 2499
2481(defvar inhibit-first-line-modes-regexps 2500(define-obsolete-variable-alias 'inhibit-first-line-modes-regexps
2482 (mapcar 'purecopy '("\\.tar\\'" "\\.tgz\\'" "\\.tiff?\\'" 2501 'inhibit-file-local-variables-regexps "24.1")
2483 "\\.gif\\'" "\\.png\\'" "\\.jpe?g\\'")) 2502
2484 "List of regexps; if one matches a file name, don't look for `-*-'.") 2503;; TODO really this should be a list of modes (eg tar-mode), not regexps,
2485 2504;; because we are duplicating info from auto-mode-alist.
2486(defvar inhibit-first-line-modes-suffixes nil 2505;; TODO many elements of this list are also in auto-coding-alist.
2487 "List of regexps for what to ignore, for `inhibit-first-line-modes-regexps'. 2506(defvar inhibit-local-variables-regexps
2488When checking `inhibit-first-line-modes-regexps', we first discard 2507 (mapcar 'purecopy '("\\.tar\\'" "\\.t[bg]z\\'"
2508 "\\.arc\\'" "\\.zip\\'" "\\.lzh\\'" "\\.lha\\'"
2509 "\\.zoo\\'" "\\.[jew]ar\\'" "\\.xpi\\'" "\\.rar\\'"
2510 "\\.7z\\'"
2511 "\\.sx[dmicw]\\'" "\\.odt\\'"
2512 "\\.tiff?\\'" "\\.gif\\'" "\\.png\\'" "\\.jpe?g\\'"))
2513 "List of regexps matching file names in which to ignore local variables.
2514This includes `-*-' lines as well as trailing \"Local Variables\" sections.
2515Files matching this list are typically binary file formats.
2516They may happen to contain sequences that look like local variable
2517specifications, but are not really, or they may be containers for
2518member files with their own local variable sections, which are
2519not appropriate for the containing file.
2520See also `inhibit-local-variables-suffixes'.")
2521
2522(define-obsolete-variable-alias 'inhibit-first-line-modes-suffixes
2523 'inhibit-local-variables-suffixes "24.1")
2524
2525(defvar inhibit-local-variables-suffixes nil
2526 "List of regexps matching suffixes to remove from file names.
2527When checking `inhibit-local-variables-regexps', we first discard
2489from the end of the file name anything that matches one of these regexps.") 2528from the end of the file name anything that matches one of these regexps.")
2490 2529
2530;; TODO explicitly add case-fold-search t?
2531(defun inhibit-local-variables-p ()
2532 "Return non-nil if file local variables should be ignored.
2533This checks the file (or buffer) name against `inhibit-local-variables-regexps'
2534and `inhibit-local-variables-suffixes'."
2535 (let ((temp inhibit-local-variables-regexps)
2536 (name (if buffer-file-name
2537 (file-name-sans-versions buffer-file-name)
2538 (buffer-name))))
2539 (while (let ((sufs inhibit-local-variables-suffixes))
2540 (while (and sufs (not (string-match (car sufs) name)))
2541 (setq sufs (cdr sufs)))
2542 sufs)
2543 (setq name (substring name 0 (match-beginning 0))))
2544 (while (and temp
2545 (not (string-match (car temp) name)))
2546 (setq temp (cdr temp)))
2547 temp))
2548
2491(defvar auto-mode-interpreter-regexp 2549(defvar auto-mode-interpreter-regexp
2492 (purecopy "#![ \t]?\\([^ \t\n]*\ 2550 (purecopy "#![ \t]?\\([^ \t\n]*\
2493/bin/env[ \t]\\)?\\([^ \t\n]+\\)") 2551/bin/env[ \t]\\)?\\([^ \t\n]+\\)")
@@ -2550,21 +2608,24 @@ Also applies to `magic-fallback-mode-alist'.")
2550(defun set-auto-mode (&optional keep-mode-if-same) 2608(defun set-auto-mode (&optional keep-mode-if-same)
2551 "Select major mode appropriate for current buffer. 2609 "Select major mode appropriate for current buffer.
2552 2610
2553To find the right major mode, this function checks for a -*- mode tag, 2611To find the right major mode, this function checks for a -*- mode tag
2554checks for a `mode:' entry in the Local Variables section of the file, 2612checks for a `mode:' entry in the Local Variables section of the file,
2555checks if it uses an interpreter listed in `interpreter-mode-alist', 2613checks if it uses an interpreter listed in `interpreter-mode-alist',
2556matches the buffer beginning against `magic-mode-alist', 2614matches the buffer beginning against `magic-mode-alist',
2557compares the filename against the entries in `auto-mode-alist', 2615compares the filename against the entries in `auto-mode-alist',
2558then matches the buffer beginning against `magic-fallback-mode-alist'. 2616then matches the buffer beginning against `magic-fallback-mode-alist'.
2559 2617
2560If `enable-local-variables' is nil, this function does not check for 2618If `enable-local-variables' is nil, or if the file name matches
2561any mode: tag anywhere in the file. 2619`inhibit-local-variables-regexps', this function does not check
2620for any mode: tag anywhere in the file. If `local-enable-local-variables'
2621is nil, then the only mode: tag that can be relevant is a -*- one.
2562 2622
2563If the optional argument KEEP-MODE-IF-SAME is non-nil, then we 2623If the optional argument KEEP-MODE-IF-SAME is non-nil, then we
2564set the major mode only if that would change it. In other words 2624set the major mode only if that would change it. In other words
2565we don't actually set it to the same mode the buffer already has." 2625we don't actually set it to the same mode the buffer already has."
2566 ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*- 2626 ;; Look for -*-MODENAME-*- or -*- ... mode: MODENAME; ... -*-
2567 (let (end done mode modes) 2627 (let ((try-locals (not (inhibit-local-variables-p)))
2628 end done mode modes)
2568 ;; Once we drop the deprecated feature where mode: is also allowed to 2629 ;; Once we drop the deprecated feature where mode: is also allowed to
2569 ;; specify minor-modes (ie, there can be more than one "mode:"), we can 2630 ;; specify minor-modes (ie, there can be more than one "mode:"), we can
2570 ;; remove this section and just let (hack-local-variables t) handle it. 2631 ;; remove this section and just let (hack-local-variables t) handle it.
@@ -2572,7 +2633,9 @@ we don't actually set it to the same mode the buffer already has."
2572 (save-excursion 2633 (save-excursion
2573 (goto-char (point-min)) 2634 (goto-char (point-min))
2574 (skip-chars-forward " \t\n") 2635 (skip-chars-forward " \t\n")
2636 ;; Note by design local-enable-local-variables does not matter here.
2575 (and enable-local-variables 2637 (and enable-local-variables
2638 try-locals
2576 (setq end (set-auto-mode-1)) 2639 (setq end (set-auto-mode-1))
2577 (if (save-excursion (search-forward ":" end t)) 2640 (if (save-excursion (search-forward ":" end t))
2578 ;; Find all specifications for the `mode:' variable 2641 ;; Find all specifications for the `mode:' variable
@@ -2603,8 +2666,12 @@ we don't actually set it to the same mode the buffer already has."
2603 (or (set-auto-mode-0 mode keep-mode-if-same) 2666 (or (set-auto-mode-0 mode keep-mode-if-same)
2604 ;; continuing would call minor modes again, toggling them off 2667 ;; continuing would call minor modes again, toggling them off
2605 (throw 'nop nil)))))) 2668 (throw 'nop nil))))))
2669 ;; hack-local-variables checks local-enable-local-variables etc, but
2670 ;; we might as well be explicit here for the sake of clarity.
2606 (and (not done) 2671 (and (not done)
2607 enable-local-variables 2672 enable-local-variables
2673 local-enable-local-variables
2674 try-locals
2608 (setq mode (hack-local-variables t)) 2675 (setq mode (hack-local-variables t))
2609 (not (memq mode modes)) ; already tried and failed 2676 (not (memq mode modes)) ; already tried and failed
2610 (if (not (functionp mode)) 2677 (if (not (functionp mode))
@@ -2714,38 +2781,24 @@ same, do nothing and return nil."
2714(defun set-auto-mode-1 () 2781(defun set-auto-mode-1 ()
2715 "Find the -*- spec in the buffer. 2782 "Find the -*- spec in the buffer.
2716Call with point at the place to start searching from. 2783Call with point at the place to start searching from.
2717If one is found, set point to the beginning 2784If one is found, set point to the beginning and return the position
2718and return the position of the end. 2785of the end. Otherwise, return nil; may change point.
2719Otherwise, return nil; point may be changed." 2786The variable `inhibit-local-variables-regexps' can cause a -*- spec to
2787be ignored; but `enable-local-variables' and `local-enable-local-variables'
2788have no effect."
2720 (let (beg end) 2789 (let (beg end)
2721 (and 2790 (and
2722 ;; Don't look for -*- if this file name matches any 2791 ;; Don't look for -*- if this file name matches any
2723 ;; of the regexps in inhibit-first-line-modes-regexps. 2792 ;; of the regexps in inhibit-local-variables-regexps.
2724 (let ((temp inhibit-first-line-modes-regexps) 2793 (not (inhibit-local-variables-p))
2725 (name (if buffer-file-name
2726 (file-name-sans-versions buffer-file-name)
2727 (buffer-name))))
2728 (while (let ((sufs inhibit-first-line-modes-suffixes))
2729 (while (and sufs (not (string-match (car sufs) name)))
2730 (setq sufs (cdr sufs)))
2731 sufs)
2732 (setq name (substring name 0 (match-beginning 0))))
2733 (while (and temp
2734 (not (string-match (car temp) name)))
2735 (setq temp (cdr temp)))
2736 (not temp))
2737
2738 (search-forward "-*-" (line-end-position 2794 (search-forward "-*-" (line-end-position
2739 ;; If the file begins with "#!" 2795 ;; If the file begins with "#!" (exec
2740 ;; (exec interpreter magic), look 2796 ;; interpreter magic), look for mode frobs
2741 ;; for mode frobs in the first two 2797 ;; in the first two lines. You cannot
2742 ;; lines. You cannot necessarily 2798 ;; necessarily put them in the first line
2743 ;; put them in the first line of 2799 ;; of such a file without screwing up the
2744 ;; such a file without screwing up 2800 ;; interpreter invocation. The same holds
2745 ;; the interpreter invocation. 2801 ;; for '\" in man pages (preprocessor
2746 ;; The same holds for
2747 ;; '\"
2748 ;; in man pages (preprocessor
2749 ;; magic for the `man' program). 2802 ;; magic for the `man' program).
2750 (and (looking-at "^\\(#!\\|'\\\\\"\\)") 2)) t) 2803 (and (looking-at "^\\(#!\\|'\\\\\"\\)") 2)) t)
2751 (progn 2804 (progn
@@ -3090,19 +3143,41 @@ Uses `hack-local-variables-apply' to apply the variables.
3090If MODE-ONLY is non-nil, all we do is check whether a \"mode:\" 3143If MODE-ONLY is non-nil, all we do is check whether a \"mode:\"
3091is specified, and return the corresponding mode symbol, or nil. 3144is specified, and return the corresponding mode symbol, or nil.
3092In this case, we try to ignore minor-modes, and only return a 3145In this case, we try to ignore minor-modes, and only return a
3093major-mode." 3146major-mode.
3147
3148If `enable-local-variables' or `local-enable-local-variables' is nil,
3149this function does nothing. If `inhibit-local-variables-regexps'
3150applies to the file in question, the file is not scanned for
3151local variables, but directory-local variables may still be applied."
3152 ;; We don't let inhibit-local-variables-p influence the value of
3153 ;; enable-local-variables, because then it would affect dir-local
3154 ;; variables. We don't want to search eg tar files for file local
3155 ;; variable sections, but there is no reason dir-locals cannot apply
3156 ;; to them. The real meaning of inhibit-local-variables-p is "do
3157 ;; not scan this file for local variables".
3094 (let ((enable-local-variables 3158 (let ((enable-local-variables
3095 (and local-enable-local-variables enable-local-variables)) 3159 (and local-enable-local-variables enable-local-variables))
3096 result) 3160 result)
3097 (unless mode-only 3161 (unless mode-only
3098 (setq file-local-variables-alist nil) 3162 (setq file-local-variables-alist nil)
3099 (report-errors "Directory-local variables error: %s" 3163 (report-errors "Directory-local variables error: %s"
3164 ;; Note this is a no-op if enable-local-variables is nil.
3100 (hack-dir-local-variables))) 3165 (hack-dir-local-variables)))
3101 (when (or mode-only enable-local-variables) 3166 ;; This entire function is basically a no-op if enable-local-variables
3102 ;; If MODE-ONLY is non-nil, and the prop line specifies a mode, 3167 ;; is nil. All it does is set file-local-variables-alist to nil.
3103 ;; then we're done, and have no need to scan further. 3168 (when enable-local-variables
3104 (unless (and (setq result (hack-local-variables-prop-line mode-only)) 3169 ;; This part used to ignore enable-local-variables when mode-only
3105 mode-only) 3170 ;; was non-nil. That was inappropriate, eg consider the
3171 ;; (artificial) example of:
3172 ;; (setq local-enable-local-variables nil)
3173 ;; Open a file foo.txt that contains "mode: sh".
3174 ;; It correctly opens in text-mode.
3175 ;; M-x set-visited-file name foo.c, and it incorrectly stays in text-mode.
3176 (unless (or (inhibit-local-variables-p)
3177 ;; If MODE-ONLY is non-nil, and the prop line specifies a
3178 ;; mode, then we're done, and have no need to scan further.
3179 (and (setq result (hack-local-variables-prop-line mode-only))
3180 mode-only))
3106 ;; Look for "Local variables:" line in last page. 3181 ;; Look for "Local variables:" line in last page.
3107 (save-excursion 3182 (save-excursion
3108 (goto-char (point-max)) 3183 (goto-char (point-max))
@@ -3192,14 +3267,13 @@ major-mode."
3192 (indirect-variable var)) 3267 (indirect-variable var))
3193 val) result) 3268 val) result)
3194 (error nil))))) 3269 (error nil)))))
3195 (forward-line 1))))))))) 3270 (forward-line 1))))))))
3196 ;; Now we've read all the local variables. 3271 ;; Now we've read all the local variables.
3197 ;; If MODE-ONLY is non-nil, return whether the mode was specified. 3272 ;; If MODE-ONLY is non-nil, return whether the mode was specified.
3198 (cond (mode-only result) 3273 (if mode-only result
3199 ;; Otherwise, set the variables. 3274 ;; Otherwise, set the variables.
3200 (enable-local-variables 3275 (hack-local-variables-filter result nil)
3201 (hack-local-variables-filter result nil) 3276 (hack-local-variables-apply)))))
3202 (hack-local-variables-apply)))))
3203 3277
3204(defun hack-local-variables-apply () 3278(defun hack-local-variables-apply ()
3205 "Apply the elements of `file-local-variables-alist'. 3279 "Apply the elements of `file-local-variables-alist'.
@@ -3611,7 +3685,7 @@ the old visited file has been renamed to the new name FILENAME."
3611 (interactive "FSet visited file name: ") 3685 (interactive "FSet visited file name: ")
3612 (if (buffer-base-buffer) 3686 (if (buffer-base-buffer)
3613 (error "An indirect buffer cannot visit a file")) 3687 (error "An indirect buffer cannot visit a file"))
3614 (let (truename) 3688 (let (truename old-try-locals)
3615 (if filename 3689 (if filename
3616 (setq filename 3690 (setq filename
3617 (if (string-equal filename "") 3691 (if (string-equal filename "")
@@ -3636,7 +3710,8 @@ the old visited file has been renamed to the new name FILENAME."
3636 (progn 3710 (progn
3637 (and filename (lock-buffer filename)) 3711 (and filename (lock-buffer filename))
3638 (unlock-buffer))) 3712 (unlock-buffer)))
3639 (setq buffer-file-name filename) 3713 (setq old-try-locals (not (inhibit-local-variables-p))
3714 buffer-file-name filename)
3640 (if filename ; make buffer name reflect filename. 3715 (if filename ; make buffer name reflect filename.
3641 (let ((new-name (file-name-nondirectory buffer-file-name))) 3716 (let ((new-name (file-name-nondirectory buffer-file-name)))
3642 (setq default-directory (file-name-directory buffer-file-name)) 3717 (setq default-directory (file-name-directory buffer-file-name))
@@ -3656,59 +3731,63 @@ the old visited file has been renamed to the new name FILENAME."
3656 (setq buffer-file-number 3731 (setq buffer-file-number
3657 (if filename 3732 (if filename
3658 (nthcdr 10 (file-attributes buffer-file-name)) 3733 (nthcdr 10 (file-attributes buffer-file-name))
3659 nil))) 3734 nil))
3660 ;; write-file-functions is normally used for things like ftp-find-file 3735 ;; write-file-functions is normally used for things like ftp-find-file
3661 ;; that visit things that are not local files as if they were files. 3736 ;; that visit things that are not local files as if they were files.
3662 ;; Changing to visit an ordinary local file instead should flush the hook. 3737 ;; Changing to visit an ordinary local file instead should flush the hook.
3663 (kill-local-variable 'write-file-functions) 3738 (kill-local-variable 'write-file-functions)
3664 (kill-local-variable 'local-write-file-hooks) 3739 (kill-local-variable 'local-write-file-hooks)
3665 (kill-local-variable 'revert-buffer-function) 3740 (kill-local-variable 'revert-buffer-function)
3666 (kill-local-variable 'backup-inhibited) 3741 (kill-local-variable 'backup-inhibited)
3667 ;; If buffer was read-only because of version control, 3742 ;; If buffer was read-only because of version control,
3668 ;; that reason is gone now, so make it writable. 3743 ;; that reason is gone now, so make it writable.
3669 (if vc-mode 3744 (if vc-mode
3670 (setq buffer-read-only nil)) 3745 (setq buffer-read-only nil))
3671 (kill-local-variable 'vc-mode) 3746 (kill-local-variable 'vc-mode)
3672 ;; Turn off backup files for certain file names. 3747 ;; Turn off backup files for certain file names.
3673 ;; Since this is a permanent local, the major mode won't eliminate it. 3748 ;; Since this is a permanent local, the major mode won't eliminate it.
3674 (and buffer-file-name 3749 (and buffer-file-name
3675 backup-enable-predicate 3750 backup-enable-predicate
3676 (not (funcall backup-enable-predicate buffer-file-name)) 3751 (not (funcall backup-enable-predicate buffer-file-name))
3677 (progn 3752 (progn
3678 (make-local-variable 'backup-inhibited) 3753 (make-local-variable 'backup-inhibited)
3679 (setq backup-inhibited t))) 3754 (setq backup-inhibited t)))
3680 (let ((oauto buffer-auto-save-file-name)) 3755 (let ((oauto buffer-auto-save-file-name))
3681 ;; If auto-save was not already on, turn it on if appropriate. 3756 ;; If auto-save was not already on, turn it on if appropriate.
3682 (if (not buffer-auto-save-file-name) 3757 (if (not buffer-auto-save-file-name)
3683 (and buffer-file-name auto-save-default 3758 (and buffer-file-name auto-save-default
3684 (auto-save-mode t)) 3759 (auto-save-mode t))
3685 ;; If auto save is on, start using a new name. 3760 ;; If auto save is on, start using a new name.
3686 ;; We deliberately don't rename or delete the old auto save 3761 ;; We deliberately don't rename or delete the old auto save
3687 ;; for the old visited file name. This is because perhaps 3762 ;; for the old visited file name. This is because perhaps
3688 ;; the user wants to save the new state and then compare with the 3763 ;; the user wants to save the new state and then compare with the
3689 ;; previous state from the auto save file. 3764 ;; previous state from the auto save file.
3690 (setq buffer-auto-save-file-name 3765 (setq buffer-auto-save-file-name
3691 (make-auto-save-file-name))) 3766 (make-auto-save-file-name)))
3692 ;; Rename the old auto save file if any. 3767 ;; Rename the old auto save file if any.
3693 (and oauto buffer-auto-save-file-name 3768 (and oauto buffer-auto-save-file-name
3694 (file-exists-p oauto) 3769 (file-exists-p oauto)
3695 (rename-file oauto buffer-auto-save-file-name t))) 3770 (rename-file oauto buffer-auto-save-file-name t)))
3696 (and buffer-file-name 3771 (and buffer-file-name
3697 (not along-with-file) 3772 (not along-with-file)
3698 (set-buffer-modified-p t)) 3773 (set-buffer-modified-p t))
3699 ;; Update the major mode, if the file name determines it. 3774 ;; Update the major mode, if the file name determines it.
3700 (condition-case nil 3775 (condition-case nil
3701 ;; Don't change the mode if it is special. 3776 ;; Don't change the mode if it is special.
3702 (or (not change-major-mode-with-file-name) 3777 (or (not change-major-mode-with-file-name)
3703 (get major-mode 'mode-class) 3778 (get major-mode 'mode-class)
3704 ;; Don't change the mode if the local variable list specifies it. 3779 ;; Don't change the mode if the local variable list specifies it.
3705 (hack-local-variables t) 3780 ;; The file name can influence whether the local variables apply.
3706 ;; TODO consider making normal-mode handle this case. 3781 (and old-try-locals
3707 (let ((old major-mode)) 3782 ;; h-l-v also checks it, but might as well be explcit.
3708 (set-auto-mode t) 3783 (not (inhibit-local-variables-p))
3709 (or (eq old major-mode) 3784 (hack-local-variables t))
3710 (hack-local-variables)))) 3785 ;; TODO consider making normal-mode handle this case.
3711 (error nil))) 3786 (let ((old major-mode))
3787 (set-auto-mode t)
3788 (or (eq old major-mode)
3789 (hack-local-variables))))
3790 (error nil))))
3712 3791
3713(defun write-file (filename &optional confirm) 3792(defun write-file (filename &optional confirm)
3714 "Write current buffer into file FILENAME. 3793 "Write current buffer into file FILENAME.