diff options
| author | Richard M. Stallman | 2005-05-10 09:08:28 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-05-10 09:08:28 +0000 |
| commit | cc45837e571e9dd9845f1e00ab56893d8dde7dd5 (patch) | |
| tree | 03a39249c063ea061896617019143211675700d3 | |
| parent | 0003d2e3191b1eb64ac347323f52c8649cbe0100 (diff) | |
| download | emacs-cc45837e571e9dd9845f1e00ab56893d8dde7dd5.tar.gz emacs-cc45837e571e9dd9845f1e00ab56893d8dde7dd5.zip | |
(read-directory-name): Fix previous change.
(hack-local-variables-confirm): New function.
(hack-local-variables-prop-line, hack-local-variables)
(hack-one-local-variable): Use it.
| -rw-r--r-- | lisp/files.el | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/lisp/files.el b/lisp/files.el index e74e1adcf3d..fa6d91fa421 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -541,9 +541,6 @@ DIR should be an absolute directory name. It defaults to | |||
| 541 | the value of `default-directory'." | 541 | the value of `default-directory'." |
| 542 | (unless dir | 542 | (unless dir |
| 543 | (setq dir default-directory)) | 543 | (setq dir default-directory)) |
| 544 | (unless default-dirname | ||
| 545 | (setq default-dirname | ||
| 546 | (if initial (concat dir initial) default-directory))) | ||
| 547 | (read-file-name prompt dir (or default-dirname | 544 | (read-file-name prompt dir (or default-dirname |
| 548 | (if initial (expand-file-name initial dir) | 545 | (if initial (expand-file-name initial dir) |
| 549 | dir)) | 546 | dir)) |
| @@ -2147,6 +2144,26 @@ Otherwise, return nil; point may be changed." | |||
| 2147 | (goto-char beg) | 2144 | (goto-char beg) |
| 2148 | end)))) | 2145 | end)))) |
| 2149 | 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 | |||
| 2150 | (defun hack-local-variables-prop-line (&optional mode-only) | 2167 | (defun hack-local-variables-prop-line (&optional mode-only) |
| 2151 | "Set local variables specified in the -*- line. | 2168 | "Set local variables specified in the -*- line. |
| 2152 | Ignore any specification for `mode:' and `coding:'; | 2169 | Ignore any specification for `mode:' and `coding:'; |
| @@ -2201,21 +2218,7 @@ is specified, returning t if it is specified." | |||
| 2201 | (if mode-only mode-specified | 2218 | (if mode-only mode-specified |
| 2202 | (if (and result | 2219 | (if (and result |
| 2203 | (or mode-only | 2220 | (or mode-only |
| 2204 | (eq enable-local-variables t) | 2221 | (hack-local-variables-confirm))) |
| 2205 | (and enable-local-variables | ||
| 2206 | (save-window-excursion | ||
| 2207 | (condition-case nil | ||
| 2208 | (switch-to-buffer (current-buffer)) | ||
| 2209 | (error | ||
| 2210 | ;; If we fail to switch in the selected window, | ||
| 2211 | ;; it is probably a minibuffer. | ||
| 2212 | ;; So try another window. | ||
| 2213 | (condition-case nil | ||
| 2214 | (switch-to-buffer-other-window (current-buffer)) | ||
| 2215 | (error | ||
| 2216 | (switch-to-buffer-other-frame (current-buffer)))))) | ||
| 2217 | (y-or-n-p (format "Set local variables as specified in -*- line of %s? " | ||
| 2218 | (file-name-nondirectory buffer-file-name))))))) | ||
| 2219 | (let ((enable-local-eval enable-local-eval)) | 2222 | (let ((enable-local-eval enable-local-eval)) |
| 2220 | (while result | 2223 | (while result |
| 2221 | (hack-one-local-variable (car (car result)) (cdr (car result))) | 2224 | (hack-one-local-variable (car (car result)) (cdr (car result))) |
| @@ -2244,20 +2247,8 @@ is specified, returning t if it is specified." | |||
| 2244 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) | 2247 | (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) 'move) |
| 2245 | (when (let ((case-fold-search t)) | 2248 | (when (let ((case-fold-search t)) |
| 2246 | (and (search-forward "Local Variables:" nil t) | 2249 | (and (search-forward "Local Variables:" nil t) |
| 2247 | (or (eq enable-local-variables t) | 2250 | (or mode-only |
| 2248 | mode-only | 2251 | (hack-local-variables-confirm)))) |
| 2249 | (and enable-local-variables | ||
| 2250 | (save-window-excursion | ||
| 2251 | (switch-to-buffer (current-buffer)) | ||
| 2252 | (save-excursion | ||
| 2253 | (beginning-of-line) | ||
| 2254 | (set-window-start (selected-window) (point))) | ||
| 2255 | (y-or-n-p (format "Set local variables as specified at end of %s? " | ||
| 2256 | (if buffer-file-name | ||
| 2257 | (file-name-nondirectory | ||
| 2258 | buffer-file-name) | ||
| 2259 | (concat "buffer " | ||
| 2260 | (buffer-name)))))))))) | ||
| 2261 | (skip-chars-forward " \t") | 2252 | (skip-chars-forward " \t") |
| 2262 | (let ((enable-local-eval enable-local-eval) | 2253 | (let ((enable-local-eval enable-local-eval) |
| 2263 | ;; suffix is what comes after "local variables:" in its line. | 2254 | ;; suffix is what comes after "local variables:" in its line. |
| @@ -2478,18 +2469,7 @@ is considered risky." | |||
| 2478 | (hack-one-local-variable-eval-safep val)) | 2469 | (hack-one-local-variable-eval-safep val)) |
| 2479 | ;; Permit eval if not root and user says ok. | 2470 | ;; Permit eval if not root and user says ok. |
| 2480 | (and (not (zerop (user-uid))) | 2471 | (and (not (zerop (user-uid))) |
| 2481 | (or (eq enable-local-eval t) | 2472 | (hack-local-variables-confirm))) |
| 2482 | (and enable-local-eval | ||
| 2483 | (save-window-excursion | ||
| 2484 | (switch-to-buffer (current-buffer)) | ||
| 2485 | (save-excursion | ||
| 2486 | (beginning-of-line) | ||
| 2487 | (set-window-start (selected-window) (point))) | ||
| 2488 | (setq enable-local-eval | ||
| 2489 | (y-or-n-p (format "Process `eval' or hook local variables in %s? " | ||
| 2490 | (if buffer-file-name | ||
| 2491 | (concat "file " (file-name-nondirectory buffer-file-name)) | ||
| 2492 | (concat "buffer " (buffer-name))))))))))) | ||
| 2493 | (if (eq var 'eval) | 2473 | (if (eq var 'eval) |
| 2494 | (save-excursion (eval val)) | 2474 | (save-excursion (eval val)) |
| 2495 | (make-local-variable var) | 2475 | (make-local-variable var) |