comparison lisp/files.el @ 68907:b596dc11d441

* files.el (hack-local-variables-confirm): Allow scrolling if the file variable list is too long.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 15 Feb 2006 01:21:31 +0000
parents ca6b93e0f08b
children 7d7207d65934
comparison
equal deleted inserted replaced
68906:53503f63cc05 68907:b596dc11d441
2225 (let ((name (if buffer-file-name 2225 (let ((name (if buffer-file-name
2226 (file-name-nondirectory buffer-file-name) 2226 (file-name-nondirectory buffer-file-name)
2227 (concat "buffer " (buffer-name)))) 2227 (concat "buffer " (buffer-name))))
2228 char) 2228 char)
2229 (save-window-excursion 2229 (save-window-excursion
2230 (with-output-to-temp-buffer "*Local Variables*" 2230 (let ((buf (get-buffer-create "*Local Variables*"))
2231 (prompt))
2232 (pop-to-buffer buf)
2233 (set (make-local-variable 'cursor-type) nil)
2234 (erase-buffer)
2231 (if unsafe-vars 2235 (if unsafe-vars
2232 (progn (princ "The local variables list in ") 2236 (insert "The local variables list in " name
2233 (princ name) 2237 "\ncontains values that may not be safe (*)"
2234 (princ "\ncontains values that may not be safe (*)") 2238 (if risky-vars
2235 (if risky-vars 2239 ", and variables that are risky (**)."
2236 (princ ", and variables that are risky (**).") 2240 "."))
2237 (princ ".")))
2238 (if risky-vars 2241 (if risky-vars
2239 (progn (princ "The local variables list in ") 2242 (insert "The local variables list in " name
2240 (princ name) 2243 "\ncontains variables that are risky (**).")
2241 (princ "\ncontains variables that are risky (**).")) 2244 (insert "A local variables list is specified in " name ".")))
2242 (princ "A local variables list is specified in ") 2245 (insert "\n\nDo you want to apply it? You can type
2243 (princ name)
2244 (princ ".")))
2245 (princ "\n\nDo you want to apply it? You can type
2246 y -- to apply the local variables list. 2246 y -- to apply the local variables list.
2247 n -- to ignore the local variables list. 2247 n -- to ignore the local variables list.
2248 ! -- to apply the local variables list, and mark these values (*) as 2248 ! -- to apply the local variables list, and mark these values (*) as
2249 safe (in the future, they can be set automatically.)\n\n") 2249 safe (in the future, they can be set automatically.)\n\n")
2250 (dolist (elt vars) 2250 (dolist (elt vars)
2251 (cond ((member elt unsafe-vars) 2251 (cond ((member elt unsafe-vars)
2252 (princ " * ")) 2252 (insert " * "))
2253 ((member elt risky-vars) 2253 ((member elt risky-vars)
2254 (princ " ** ")) 2254 (insert " ** "))
2255 (t 2255 (t
2256 (princ " "))) 2256 (insert " ")))
2257 (princ (car elt)) 2257 (princ (car elt) buf)
2258 (princ " : ") 2258 (insert " : ")
2259 (princ (cdr elt)) 2259 (princ (cdr elt) buf)
2260 (princ "\n"))) 2260 (insert "\n"))
2261 (message "Please type y, n, or !: ") 2261 (if (< (line-number-at-pos) (window-body-height))
2262 (let ((inhibit-quit t) 2262 (setq prompt "Please type y, n, or !: ")
2263 (cursor-in-echo-area t)) 2263 (goto-char (point-min))
2264 (while (or (not (numberp (setq char (read-event)))) 2264 (setq prompt "Please type y, n, or !, or C-v to scroll: "))
2265 (not (memq (downcase char) 2265 (let ((inhibit-quit t)
2266 '(?! ?y ?n ?\s ?\C-g)))) 2266 (cursor-in-echo-area t)
2267 (message "Please type y, n, or !: ")) 2267 done)
2268 (if (= char ?\C-g) 2268 (while (not done)
2269 (setq quit-flag nil))) 2269 (message prompt)
2270 (setq char (downcase char)) 2270 (setq char (read-event))
2271 (when (and (= char ?!) unsafe-vars) 2271 (if (numberp char)
2272 (dolist (elt unsafe-vars) 2272 (if (eq char ?\C-v)
2273 (push elt safe-local-variable-values)) 2273 (condition-case nil
2274 (customize-save-variable 2274 (scroll-up)
2275 'safe-local-variable-values 2275 (error (goto-char (point-min))))
2276 safe-local-variable-values)) 2276 (setq done (memq (downcase char)
2277 (or (= char ?!) 2277 '(?! ?y ?n ?\s ?\C-g))))))
2278 (= char ?\s) 2278 (if (= char ?\C-g)
2279 (= char ?y)))))) 2279 (setq quit-flag nil)))
2280 (setq char (downcase char))
2281 (when (and (= char ?!) unsafe-vars)
2282 (dolist (elt unsafe-vars)
2283 (add-to-list 'safe-local-variable-values elt))
2284 (customize-save-variable
2285 'safe-local-variable-values
2286 safe-local-variable-values))
2287 (or (= char ?!)
2288 (= char ?\s)
2289 (= char ?y)))))))
2280 2290
2281 (defun hack-local-variables-prop-line (&optional mode-only) 2291 (defun hack-local-variables-prop-line (&optional mode-only)
2282 "Return local variables specified in the -*- line. 2292 "Return local variables specified in the -*- line.
2283 Ignore any specification for `mode:' and `coding:'; 2293 Ignore any specification for `mode:' and `coding:';
2284 `set-auto-mode' should already have handled `mode:', 2294 `set-auto-mode' should already have handled `mode:',