• Alan Mackenzie's avatar
    Call hack-local-variables from major modes rather than from file visiting · 25f45581
    Alan Mackenzie authored
    This prevents file/directory local variables from being lost when the major
    mode is set or changed.
    This fixes bug #15577 and bug #23407.
    * lisp/files.el (normal-mode): Call `hack-local-variables' when the major mode
    function hasn't already done so.
    (hack-local-variables): Rename parameter `mode-only' to `handle-mode', make
    its previous non-nil setting be t, and introduce the following action for a
    non-nil non-t value: apply all settings apart from `mode'.
    * lisp/subr.el (run-mode-hooks): call `hack-local-variables' for buffers
    which are visiting files.
    * doc/emacs/custom.texi (File Variables): Note that setting a major mode also
    sets file variables.
    (Directory Variables): Note that `mode', `eval', and `unibyte' can be set as
    dir local variables, but `coding' can't.
    * doc/lispref/modes.texi (Major Mode Conventions): Say that `run-mode-hooks'
    also calls `hack-local-variables'.
    (Auto Major Mode): Say that `find-file' no longer runs `hack-local-variables',
    as from 25.2.  Remove vagueness from `normal-mode' and `set-auto-mode' by
    saying that the mode IS SET, not merely "selected" or "chosen".
    (Mode Hooks): Document change to `run-mode-hooks'.
    * doc/lispref/variables.texi (File Local Variables): Document change to
files.el 295 KB