Mercurial > emacs
comparison lisp/files.el @ 90225:a3716f7538f2
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-79
Merge from emacs--cvs-trunk--0
Patches applied:
* emacs--cvs-trunk--0 (patch 519-530)
- Update from CVS
- Merge from gnus--rel--5.10
* gnus--rel--5.10 (patch 106-111)
- Merge from emacs--cvs-trunk--0
- Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 06 Sep 2005 00:25:20 +0000 |
parents | 2d92f5c9d6ae bb72cd763704 |
children | fa0da9b57058 |
comparison
equal
deleted
inserted
replaced
90224:2d92f5c9d6ae | 90225:a3716f7538f2 |
---|---|
27 ;; Defines most of Emacs's file- and directory-handling functions, | 27 ;; Defines most of Emacs's file- and directory-handling functions, |
28 ;; including basic file visiting, backup generation, link handling, | 28 ;; including basic file visiting, backup generation, link handling, |
29 ;; ITS-id version control, load- and write-hook handling, and the like. | 29 ;; ITS-id version control, load- and write-hook handling, and the like. |
30 | 30 |
31 ;;; Code: | 31 ;;; Code: |
32 | |
33 (defvar font-lock-keywords) | |
34 | |
32 | 35 |
33 (defgroup backup nil | 36 (defgroup backup nil |
34 "Backups of edited data files." | 37 "Backups of edited data files." |
35 :group 'files) | 38 :group 'files) |
36 | 39 |
2405 "Non-nil if SYM could be dangerous as a file-local variable with value VAL. | 2408 "Non-nil if SYM could be dangerous as a file-local variable with value VAL. |
2406 If VAL is nil or omitted, the question is whether any value might be | 2409 If VAL is nil or omitted, the question is whether any value might be |
2407 dangerous." | 2410 dangerous." |
2408 (let ((safep (get sym 'safe-local-variable))) | 2411 (let ((safep (get sym 'safe-local-variable))) |
2409 (or (get sym 'risky-local-variable) | 2412 (or (get sym 'risky-local-variable) |
2410 (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-command$\\|-predicate$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" | 2413 (and (string-match "-hooks?$\\|-functions?$\\|-forms?$\\|-program$\\|-commands?$\\|-predicates?$\\|font-lock-keywords$\\|font-lock-keywords-[0-9]+$\\|font-lock-syntactic-keywords$\\|-frame-alist$\\|-mode-alist$\\|-map$\\|-map-alist$" |
2411 (symbol-name sym)) | 2414 (symbol-name sym)) |
2412 (not safep)) | 2415 (not safep)) |
2413 ;; If the safe-local-variable property isn't t or nil, | 2416 ;; If the safe-local-variable property isn't t or nil, |
2414 ;; then it must return non-nil on the proposed value to be safe. | 2417 ;; then it must return non-nil on the proposed value to be safe. |
2415 (and (not (memq safep '(t nil))) | 2418 (and (not (memq safep '(t nil))) |
4060 "Return file name to use for auto-saves of current buffer. | 4063 "Return file name to use for auto-saves of current buffer. |
4061 Does not consider `auto-save-visited-file-name' as that variable is checked | 4064 Does not consider `auto-save-visited-file-name' as that variable is checked |
4062 before calling this function. You can redefine this for customization. | 4065 before calling this function. You can redefine this for customization. |
4063 See also `auto-save-file-name-p'." | 4066 See also `auto-save-file-name-p'." |
4064 (if buffer-file-name | 4067 (if buffer-file-name |
4065 (let ((list auto-save-file-name-transforms) | 4068 (let ((handler (find-file-name-handler buffer-file-name |
4066 (filename buffer-file-name) | 4069 'make-auto-save-file-name))) |
4067 result uniq) | 4070 (if handler |
4068 ;; Apply user-specified translations | 4071 (funcall handler 'make-auto-save-file-name) |
4069 ;; to the file name. | 4072 (let ((list auto-save-file-name-transforms) |
4070 (while (and list (not result)) | 4073 (filename buffer-file-name) |
4071 (if (string-match (car (car list)) filename) | 4074 result uniq) |
4072 (setq result (replace-match (cadr (car list)) t nil | 4075 ;; Apply user-specified translations |
4073 filename) | 4076 ;; to the file name. |
4074 uniq (car (cddr (car list))))) | 4077 (while (and list (not result)) |
4075 (setq list (cdr list))) | 4078 (if (string-match (car (car list)) filename) |
4076 (if result | 4079 (setq result (replace-match (cadr (car list)) t nil |
4077 (if uniq | 4080 filename) |
4078 (setq filename (concat | 4081 uniq (car (cddr (car list))))) |
4079 (file-name-directory result) | 4082 (setq list (cdr list))) |
4080 (subst-char-in-string | 4083 (if result |
4081 ?/ ?! | 4084 (if uniq |
4082 (replace-regexp-in-string "!" "!!" | 4085 (setq filename (concat |
4083 filename)))) | 4086 (file-name-directory result) |
4084 (setq filename result))) | 4087 (subst-char-in-string |
4085 (setq result | 4088 ?/ ?! |
4086 (if (and (eq system-type 'ms-dos) | 4089 (replace-regexp-in-string "!" "!!" |
4087 (not (msdos-long-file-names))) | 4090 filename)))) |
4088 ;; We truncate the file name to DOS 8+3 limits | 4091 (setq filename result))) |
4089 ;; before doing anything else, because the regexp | 4092 (setq result |
4090 ;; passed to string-match below cannot handle | 4093 (if (and (eq system-type 'ms-dos) |
4091 ;; extensions longer than 3 characters, multiple | 4094 (not (msdos-long-file-names))) |
4092 ;; dots, and other atrocities. | 4095 ;; We truncate the file name to DOS 8+3 limits |
4093 (let ((fn (dos-8+3-filename | 4096 ;; before doing anything else, because the regexp |
4094 (file-name-nondirectory buffer-file-name)))) | 4097 ;; passed to string-match below cannot handle |
4095 (string-match | 4098 ;; extensions longer than 3 characters, multiple |
4096 "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" | 4099 ;; dots, and other atrocities. |
4097 fn) | 4100 (let ((fn (dos-8+3-filename |
4098 (concat (file-name-directory buffer-file-name) | 4101 (file-name-nondirectory buffer-file-name)))) |
4099 "#" (match-string 1 fn) | 4102 (string-match |
4100 "." (match-string 3 fn) "#")) | 4103 "\\`\\([^.]+\\)\\(\\.\\(..?\\)?.?\\|\\)\\'" |
4101 (concat (file-name-directory filename) | 4104 fn) |
4102 "#" | 4105 (concat (file-name-directory buffer-file-name) |
4103 (file-name-nondirectory filename) | 4106 "#" (match-string 1 fn) |
4104 "#"))) | 4107 "." (match-string 3 fn) "#")) |
4105 ;; Make sure auto-save file names don't contain characters | 4108 (concat (file-name-directory filename) |
4106 ;; invalid for the underlying filesystem. | 4109 "#" |
4107 (if (and (memq system-type '(ms-dos windows-nt)) | 4110 (file-name-nondirectory filename) |
4108 ;; Don't modify remote (ange-ftp) filenames | 4111 "#"))) |
4109 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result))) | 4112 ;; Make sure auto-save file names don't contain characters |
4110 (convert-standard-filename result) | 4113 ;; invalid for the underlying filesystem. |
4111 result)) | 4114 (if (and (memq system-type '(ms-dos windows-nt)) |
4115 ;; Don't modify remote (ange-ftp) filenames | |
4116 (not (string-match "^/\\w+@[-A-Za-z0-9._]+:" result))) | |
4117 (convert-standard-filename result) | |
4118 result)))) | |
4112 | 4119 |
4113 ;; Deal with buffers that don't have any associated files. (Mail | 4120 ;; Deal with buffers that don't have any associated files. (Mail |
4114 ;; mode tends to create a good number of these.) | 4121 ;; mode tends to create a good number of these.) |
4115 | 4122 |
4116 (let ((buffer-name (buffer-name)) | 4123 (let ((buffer-name (buffer-name)) |