541 |
the value of `default-directory'." |
the value of `default-directory'." |
542 |
(unless dir |
(unless dir |
543 |
(setq dir default-directory)) |
(setq dir default-directory)) |
|
(unless default-dirname |
|
|
(setq default-dirname |
|
|
(if initial (concat dir initial) default-directory))) |
|
544 |
(read-file-name prompt dir (or default-dirname |
(read-file-name prompt dir (or default-dirname |
545 |
(if initial (expand-file-name initial dir) |
(if initial (expand-file-name initial dir) |
546 |
dir)) |
dir)) |
2144 |
(goto-char beg) |
(goto-char beg) |
2145 |
end)))) |
end)))) |
2146 |
|
|
2147 |
|
(defun hack-local-variables-confirm () |
2148 |
|
(or (eq enable-local-variables t) |
2149 |
|
(and enable-local-variables |
2150 |
|
(save-window-excursion |
2151 |
|
(condition-case nil |
2152 |
|
(switch-to-buffer (current-buffer)) |
2153 |
|
(error |
2154 |
|
;; If we fail to switch in the selected window, |
2155 |
|
;; it is probably a minibuffer or dedicated window. |
2156 |
|
;; So try another window. |
2157 |
|
(let ((pop-up-frames nil)) |
2158 |
|
;; Refrain from popping up frames since it can't |
2159 |
|
;; be undone by save-window-excursion. |
2160 |
|
(pop-to-buffer (current-buffer))))) |
2161 |
|
(save-excursion |
2162 |
|
(beginning-of-line) |
2163 |
|
(set-window-start (selected-window) (point))) |
2164 |
|
(y-or-n-p (format "Set local variables as specified in -*- line of %s? " |
2165 |
|
(file-name-nondirectory buffer-file-name))))))) |
2166 |
|
|
2167 |
(defun hack-local-variables-prop-line (&optional mode-only) |
(defun hack-local-variables-prop-line (&optional mode-only) |
2168 |
"Set local variables specified in the -*- line. |
"Set local variables specified in the -*- line. |
2169 |
Ignore any specification for `mode:' and `coding:'; |
Ignore any specification for `mode:' and `coding:'; |
2218 |
(if mode-only mode-specified |
(if mode-only mode-specified |
2219 |
(if (and result |
(if (and result |
2220 |
(or mode-only |
(or mode-only |
2221 |
(eq enable-local-variables t) |
(hack-local-variables-confirm))) |
|
(and enable-local-variables |
|
|
(save-window-excursion |
|
|
(condition-case nil |
|
|
(switch-to-buffer (current-buffer)) |
|
|
(error |
|
|
;; If we fail to switch in the selected window, |
|
|
;; it is probably a minibuffer. |
|
|
;; So try another window. |
|
|
(condition-case nil |
|
|
(switch-to-buffer-other-window (current-buffer)) |
|
|
(error |
|
|
(switch-to-buffer-other-frame (current-buffer)))))) |
|
|
(y-or-n-p (format "Set local variables as specified in -*- line of %s? " |
|
|
(file-name-nondirectory buffer-file-name))))))) |
|
2222 |
(let ((enable-local-eval enable-local-eval)) |
(let ((enable-local-eval enable-local-eval)) |
2223 |
(while result |
(while result |
2224 |
(hack-one-local-variable (car (car result)) (cdr (car result))) |
(hack-one-local-variable (car (car result)) (cdr (car result))) |
2247 |
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
2248 |
(when (let ((case-fold-search t)) |
(when (let ((case-fold-search t)) |
2249 |
(and (search-forward "Local Variables:" nil t) |
(and (search-forward "Local Variables:" nil t) |
2250 |
(or (eq enable-local-variables t) |
(or mode-only |
2251 |
mode-only |
(hack-local-variables-confirm)))) |
|
(and enable-local-variables |
|
|
(save-window-excursion |
|
|
(switch-to-buffer (current-buffer)) |
|
|
(save-excursion |
|
|
(beginning-of-line) |
|
|
(set-window-start (selected-window) (point))) |
|
|
(y-or-n-p (format "Set local variables as specified at end of %s? " |
|
|
(if buffer-file-name |
|
|
(file-name-nondirectory |
|
|
buffer-file-name) |
|
|
(concat "buffer " |
|
|
(buffer-name)))))))))) |
|
2252 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
2253 |
(let ((enable-local-eval enable-local-eval) |
(let ((enable-local-eval enable-local-eval) |
2254 |
;; suffix is what comes after "local variables:" in its line. |
;; suffix is what comes after "local variables:" in its line. |
2469 |
(hack-one-local-variable-eval-safep val)) |
(hack-one-local-variable-eval-safep val)) |
2470 |
;; Permit eval if not root and user says ok. |
;; Permit eval if not root and user says ok. |
2471 |
(and (not (zerop (user-uid))) |
(and (not (zerop (user-uid))) |
2472 |
(or (eq enable-local-eval t) |
(hack-local-variables-confirm))) |
|
(and enable-local-eval |
|
|
(save-window-excursion |
|
|
(switch-to-buffer (current-buffer)) |
|
|
(save-excursion |
|
|
(beginning-of-line) |
|
|
(set-window-start (selected-window) (point))) |
|
|
(setq enable-local-eval |
|
|
(y-or-n-p (format "Process `eval' or hook local variables in %s? " |
|
|
(if buffer-file-name |
|
|
(concat "file " (file-name-nondirectory buffer-file-name)) |
|
|
(concat "buffer " (buffer-name))))))))))) |
|
2473 |
(if (eq var 'eval) |
(if (eq var 'eval) |
2474 |
(save-excursion (eval val)) |
(save-excursion (eval val)) |
2475 |
(make-local-variable var) |
(make-local-variable var) |