Mercurial > hg > xemacs-beta
comparison lisp/prim/files.el @ 195:a2f645c6b9f8 r20-3b24
Import from CVS: tag r20-3b24
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:59:05 +0200 |
parents | f53b5ca2e663 |
children | eb5470882647 |
comparison
equal
deleted
inserted
replaced
194:2947057885e5 | 195:a2f645c6b9f8 |
---|---|
135 (make-variable-buffer-local 'buffer-offer-save) | 135 (make-variable-buffer-local 'buffer-offer-save) |
136 | 136 |
137 ;; FSF uses normal defconst | 137 ;; FSF uses normal defconst |
138 (defvaralias 'find-file-visit-truename 'find-file-use-truenames) | 138 (defvaralias 'find-file-visit-truename 'find-file-use-truenames) |
139 (defvaralias 'find-file-existing-other-name 'find-file-compare-truenames) | 139 (defvaralias 'find-file-existing-other-name 'find-file-compare-truenames) |
140 | |
141 (defcustom revert-without-query nil | |
142 "*Specify which files should be reverted without query. | |
143 The value is a list of regular expressions. | |
144 If the file name matches one of these regular expressions, | |
145 then `revert-buffer' reverts the file without querying | |
146 if the file has changed on disk and you have not edited the buffer." | |
147 :type 'boolean | |
148 :group 'find-file) | |
140 | 149 |
141 (defvar buffer-file-number nil | 150 (defvar buffer-file-number nil |
142 "The device number and file number of the file visited in the current buffer. | 151 "The device number and file number of the file visited in the current buffer. |
143 The value is a list of the form (FILENUM DEVNUM). | 152 The value is a list of the form (FILENUM DEVNUM). |
144 This pair of numbers uniquely identifies the file. | 153 This pair of numbers uniquely identifies the file. |
991 (if buf | 1000 (if buf |
992 (or nowarn | 1001 (or nowarn |
993 (verify-visited-file-modtime buf) | 1002 (verify-visited-file-modtime buf) |
994 (cond ((not (file-exists-p filename)) | 1003 (cond ((not (file-exists-p filename)) |
995 (error "File %s no longer exists!" filename)) | 1004 (error "File %s no longer exists!" filename)) |
1005 ;; Certain files should be reverted automatically | |
1006 ;; if they have changed on disk and not in the buffer. | |
1007 ((and (not (buffer-modified-p buf)) | |
1008 (let (found) | |
1009 (dolist (rx revert-without-query found) | |
1010 (when (string-match rx filename) | |
1011 (setq found t))))) | |
1012 (with-current-buffer buf | |
1013 (message "Reverting file %s..." filename) | |
1014 (revert-buffer t t) | |
1015 (message "Reverting file %s... done" filename))) | |
996 ((yes-or-no-p | 1016 ((yes-or-no-p |
997 (if (string= (file-name-nondirectory filename) | 1017 (if (string= (file-name-nondirectory filename) |
998 (buffer-name buf)) | 1018 (buffer-name buf)) |
999 (format | 1019 (format |
1000 (if (buffer-modified-p buf) | 1020 (if (buffer-modified-p buf) |
1114 ;; If the directory the buffer is in doesn't exist, | 1134 ;; If the directory the buffer is in doesn't exist, |
1115 ;; offer to create it. It's better to do this now | 1135 ;; offer to create it. It's better to do this now |
1116 ;; than when we save the buffer, because we want | 1136 ;; than when we save the buffer, because we want |
1117 ;; autosaving to work. | 1137 ;; autosaving to work. |
1118 (setq buffer-read-only nil) | 1138 (setq buffer-read-only nil) |
1119 (if (file-exists-p (file-name-directory (directory-file-name (file-name-directory buffer-file-name)))) | 1139 ;; XEmacs |
1120 "Use M-x make-dir RET RET to create the directory" | 1140 (or (file-exists-p (file-name-directory buffer-file-name)) |
1121 "Use C-u M-x make-dir RET RET to create directory and its parents"))))) | 1141 (if (yes-or-no-p |
1142 (format | |
1143 "The directory containing %s does not exist. Create? " | |
1144 (abbreviate-file-name buffer-file-name))) | |
1145 (make-directory (file-name-directory | |
1146 buffer-file-name) | |
1147 t))) | |
1148 nil)))) | |
1122 (if msg | 1149 (if msg |
1123 (progn | 1150 (progn |
1124 (message msg) | 1151 (message msg) |
1125 (or not-serious (sit-for 1 t))))) | 1152 (or not-serious (sit-for 1 t))))) |
1126 (if (and auto-save-default (not noauto)) | 1153 (if (and auto-save-default (not noauto)) |
2562 buffer-auto-save-file-name | 2589 buffer-auto-save-file-name |
2563 buffer-file-name))) | 2590 buffer-file-name))) |
2564 (cond ((null file-name) | 2591 (cond ((null file-name) |
2565 (error "Buffer does not seem to be associated with any file")) | 2592 (error "Buffer does not seem to be associated with any file")) |
2566 ((or noconfirm | 2593 ((or noconfirm |
2594 (and (not (buffer-modified-p)) | |
2595 (let (found) | |
2596 (dolist (rx revert-without-query found) | |
2597 (when (string-match rx file-name) | |
2598 (setq found t))))) | |
2567 (yes-or-no-p (format "Revert buffer from file %s? " | 2599 (yes-or-no-p (format "Revert buffer from file %s? " |
2568 file-name))) | 2600 file-name))) |
2569 (run-hooks 'before-revert-hook) | 2601 (run-hooks 'before-revert-hook) |
2570 ;; If file was backed up but has changed since, | 2602 ;; If file was backed up but has changed since, |
2571 ;; we shd make another backup. | 2603 ;; we shd make another backup. |