Mercurial > emacs
comparison lisp/files.el @ 71555:d9b9f70ec91a
(find-file-noselect-1): Remove unused var assignment.
(hack-local-variables-confirm): Print lists of strings as lists of
strings rather than lists of symbols.
(abbreviate-file-name, hack-local-variables-prop-line):
Use match-string.
(hack-one-local-variable): Move `make-local-variable' nearer its use.
(recover-session-finish): Use line-end-position.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 02 Jul 2006 14:26:53 +0000 |
parents | 2b086f630764 |
children | 4a2a2f40a43f |
comparison
equal
deleted
inserted
replaced
71554:0b31608be4a1 | 71555:d9b9f70ec91a |
---|---|
486 | 486 |
487 This variable does not affect the use of major modes | 487 This variable does not affect the use of major modes |
488 specified in a -*- line.") | 488 specified in a -*- line.") |
489 | 489 |
490 (defcustom enable-local-eval 'maybe | 490 (defcustom enable-local-eval 'maybe |
491 "*Control processing of the \"variable\" `eval' in a file's local variables. | 491 "Control processing of the \"variable\" `eval' in a file's local variables. |
492 The value can be t, nil or something else. | 492 The value can be t, nil or something else. |
493 A value of t means obey `eval' variables; | 493 A value of t means obey `eval' variables; |
494 nil means ignore them; anything else means query." | 494 nil means ignore them; anything else means query." |
495 :type '(choice (const :tag "Obey" t) | 495 :type '(choice (const :tag "Obey" t) |
496 (const :tag "Ignore" nil) | 496 (const :tag "Ignore" nil) |
1312 (eq system-type 'windows-nt)) | 1312 (eq system-type 'windows-nt)) |
1313 (save-match-data | 1313 (save-match-data |
1314 (string-match "^[a-zA-`]:/$" filename))))) | 1314 (string-match "^[a-zA-`]:/$" filename))))) |
1315 (setq filename | 1315 (setq filename |
1316 (concat "~" | 1316 (concat "~" |
1317 (substring filename (match-beginning 1) (match-end 1)) | 1317 (match-string 1 filename) |
1318 (substring filename (match-end 0))))) | 1318 (substring filename (match-end 0))))) |
1319 filename)) | 1319 filename)) |
1320 | 1320 |
1321 (defcustom find-file-not-true-dirname-list nil | 1321 (defcustom find-file-not-true-dirname-list nil |
1322 "*List of logical names for which visiting shouldn't save the true dirname. | 1322 "*List of logical names for which visiting shouldn't save the true dirname. |
1625 (setq logical (substring (file-name-directory filename) | 1625 (setq logical (substring (file-name-directory filename) |
1626 0 (match-beginning 0)))) | 1626 0 (match-beginning 0)))) |
1627 (not (member logical find-file-not-true-dirname-list))) | 1627 (not (member logical find-file-not-true-dirname-list))) |
1628 (setq buffer-file-name buffer-file-truename)) | 1628 (setq buffer-file-name buffer-file-truename)) |
1629 (if find-file-visit-truename | 1629 (if find-file-visit-truename |
1630 (setq buffer-file-name | 1630 (setq buffer-file-name (expand-file-name buffer-file-truename))) |
1631 (setq filename | |
1632 (expand-file-name buffer-file-truename)))) | |
1633 ;; Set buffer's default directory to that of the file. | 1631 ;; Set buffer's default directory to that of the file. |
1634 (setq default-directory (file-name-directory buffer-file-name)) | 1632 (setq default-directory (file-name-directory buffer-file-name)) |
1635 ;; Turn off backup files for certain file names. Since | 1633 ;; Turn off backup files for certain file names. Since |
1636 ;; this is a permanent local, the major mode won't eliminate it. | 1634 ;; this is a permanent local, the major mode won't eliminate it. |
1637 (and (not (funcall backup-enable-predicate buffer-file-name)) | 1635 (and (not (funcall backup-enable-predicate buffer-file-name)) |
2434 (insert " ** ")) | 2432 (insert " ** ")) |
2435 (t | 2433 (t |
2436 (insert " "))) | 2434 (insert " "))) |
2437 (princ (car elt) buf) | 2435 (princ (car elt) buf) |
2438 (insert " : ") | 2436 (insert " : ") |
2439 (if (stringp (cdr elt)) | 2437 ;; Make strings with embedded whitespace easier to read. |
2440 ;; Make strings with embedded whitespace easier to read. | 2438 (let ((print-escape-newlines t)) |
2441 (let ((print-escape-newlines t)) | 2439 (prin1 (cdr elt) buf)) |
2442 (prin1 (cdr elt) buf)) | |
2443 (princ (cdr elt) buf)) | |
2444 (insert "\n")) | 2440 (insert "\n")) |
2445 (setq prompt | 2441 (setq prompt |
2446 (format "Please type %s%s: " | 2442 (format "Please type %s%s: " |
2447 (if offer-save "y, n, or !" "y or n") | 2443 (if offer-save "y, n, or !" "y or n") |
2448 (if (< (line-number-at-pos) (window-body-height)) | 2444 (if (< (line-number-at-pos) (window-body-height)) |
2509 (error "Malformed -*- line")) | 2505 (error "Malformed -*- line")) |
2510 (goto-char (match-end 0)) | 2506 (goto-char (match-end 0)) |
2511 ;; There used to be a downcase here, | 2507 ;; There used to be a downcase here, |
2512 ;; but the manual didn't say so, | 2508 ;; but the manual didn't say so, |
2513 ;; and people want to set var names that aren't all lc. | 2509 ;; and people want to set var names that aren't all lc. |
2514 (let ((key (intern (buffer-substring | 2510 (let ((key (intern (match-string 1))) |
2515 (match-beginning 1) | |
2516 (match-end 1)))) | |
2517 (val (save-restriction | 2511 (val (save-restriction |
2518 (narrow-to-region (point) end) | 2512 (narrow-to-region (point) end) |
2519 (read (current-buffer))))) | 2513 (read (current-buffer))))) |
2520 ;; It is traditional to ignore | 2514 ;; It is traditional to ignore |
2521 ;; case when checking for `mode' in set-auto-mode, | 2515 ;; case when checking for `mode' in set-auto-mode, |
2750 ok))))))) | 2744 ok))))))) |
2751 | 2745 |
2752 (defun hack-one-local-variable (var val) | 2746 (defun hack-one-local-variable (var val) |
2753 "Set local variable VAR with value VAL." | 2747 "Set local variable VAR with value VAL." |
2754 (cond ((eq var 'mode) | 2748 (cond ((eq var 'mode) |
2755 (funcall (intern (concat (downcase (symbol-name val)) | 2749 (funcall (intern (concat (downcase (symbol-name val)) "-mode")))) |
2756 "-mode")))) | |
2757 ((eq var 'eval) | 2750 ((eq var 'eval) |
2758 (save-excursion (eval val))) | 2751 (save-excursion (eval val))) |
2759 (t (make-local-variable var) | 2752 (t |
2760 ;; Make sure the string has no text properties. | 2753 ;; Make sure the string has no text properties. |
2761 ;; Some text properties can get evaluated in various ways, | 2754 ;; Some text properties can get evaluated in various ways, |
2762 ;; so it is risky to put them on with a local variable list. | 2755 ;; so it is risky to put them on with a local variable list. |
2763 (if (stringp val) | 2756 (if (stringp val) |
2764 (set-text-properties 0 (length val) nil val)) | 2757 (set-text-properties 0 (length val) nil val)) |
2765 (set var val)))) | 2758 (set (make-local-variable var) val)))) |
2766 | 2759 |
2767 | 2760 |
2768 (defcustom change-major-mode-with-file-name t | 2761 (defcustom change-major-mode-with-file-name t |
2769 "*Non-nil means \\[write-file] should set the major mode from the file name. | 2762 "*Non-nil means \\[write-file] should set the major mode from the file name. |
2770 However, the mode will not be changed if | 2763 However, the mode will not be changed if |
4218 ;; auto-save-list file is probably corrupted. | 4211 ;; auto-save-list file is probably corrupted. |
4219 (unless (eolp) | 4212 (unless (eolp) |
4220 (setq autofile | 4213 (setq autofile |
4221 (buffer-substring-no-properties | 4214 (buffer-substring-no-properties |
4222 (point) | 4215 (point) |
4223 (save-excursion | 4216 (line-end-position))) |
4224 (end-of-line) | |
4225 (point)))) | |
4226 (setq thisfile | 4217 (setq thisfile |
4227 (expand-file-name | 4218 (expand-file-name |
4228 (substring | 4219 (substring |
4229 (file-name-nondirectory autofile) | 4220 (file-name-nondirectory autofile) |
4230 1 -1) | 4221 1 -1) |