Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 263:727739f917cb r20-5b30
Import from CVS: tag r20-5b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:24:41 +0200 |
parents | 084402c475ba |
children | 8efd647ea9ca |
comparison
equal
deleted
inserted
replaced
262:9d8607af9e13 | 263:727739f917cb |
---|---|
128 :type 'boolean | 128 :type 'boolean |
129 :group 'backup) | 129 :group 'backup) |
130 | 130 |
131 (defvar backup-enable-predicate | 131 (defvar backup-enable-predicate |
132 '(lambda (name) | 132 '(lambda (name) |
133 (or (< (length name) 5) | 133 (not (or (string-equal "/tmp/" (substring name 0 5)) |
134 (not (string-equal "/tmp/" (substring name 0 5))))) | 134 (let ((tmpdir (temp-directory))) |
135 (and tmpdir | |
136 (string-equal (concat tmpdir "/") | |
137 (substring name 0 (1+ (length tmpdir))))))))) | |
135 "Predicate that looks at a file name and decides whether to make backups. | 138 "Predicate that looks at a file name and decides whether to make backups. |
136 Called with an absolute file name as argument, it returns t to enable backup.") | 139 Called with an absolute file name as argument, it returns t to enable backup.") |
137 | 140 |
138 (defcustom buffer-offer-save nil | 141 (defcustom buffer-offer-save nil |
139 "*Non-nil in a buffer means offer to save the buffer on exit | 142 "*Non-nil in a buffer means offer to save the buffer on exit |
972 (dired-noselect (if find-file-use-truenames | 975 (dired-noselect (if find-file-use-truenames |
973 (abbreviate-file-name (file-truename filename)) | 976 (abbreviate-file-name (file-truename filename)) |
974 filename)) | 977 filename)) |
975 (error "%s is a directory." filename)) | 978 (error "%s is a directory." filename)) |
976 (let* ((buf (get-file-buffer filename)) | 979 (let* ((buf (get-file-buffer filename)) |
977 ; (truename (abbreviate-file-name (file-truename filename))) | 980 (truename (abbreviate-file-name (file-truename filename))) |
978 (number (nthcdr 10 (file-attributes (file-truename filename)))) | 981 (number (nthcdr 10 (file-attributes (file-truename filename)))) |
979 ; (number (and buffer-file-truename | 982 ; (number (and buffer-file-truename |
980 ; (nthcdr 10 (file-attributes buffer-file-truename)))) | 983 ; (nthcdr 10 (file-attributes buffer-file-truename)))) |
981 ; ;; Find any buffer for a file which has same truename. | 984 ; ;; Find any buffer for a file which has same truename. |
982 ; (other (and (not buf) (find-buffer-visiting filename))) | 985 ; (other (and (not buf) (find-buffer-visiting filename))) |
1062 ;; Run find-file-not-found-hooks until one returns non-nil. | 1065 ;; Run find-file-not-found-hooks until one returns non-nil. |
1063 (or (run-hook-with-args-until-success 'find-file-not-found-hooks) | 1066 (or (run-hook-with-args-until-success 'find-file-not-found-hooks) |
1064 ;; If they fail too, set error. | 1067 ;; If they fail too, set error. |
1065 (setq error e))))) | 1068 (setq error e))))) |
1066 ;; Find the file's truename, and maybe use that as visited name. | 1069 ;; Find the file's truename, and maybe use that as visited name. |
1067 ;; automatically computed in XEmacs. | 1070 ;; automatically computed in XEmacs, unless jka-compr was used! |
1068 ; (setq buffer-file-truename truename) | 1071 (unless buffer-file-truename |
1072 (setq buffer-file-truename truename)) | |
1069 (setq buffer-file-number number) | 1073 (setq buffer-file-number number) |
1070 ;; On VMS, we may want to remember which directory in a search list | 1074 ;; On VMS, we may want to remember which directory in a search list |
1071 ;; the file was found in. | 1075 ;; the file was found in. |
1072 (and (eq system-type 'vax-vms) | 1076 (and (eq system-type 'vax-vms) |
1073 (let (logical) | 1077 (let (logical) |
2937 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. | 2941 "Return non-nil if FILENAME can be yielded by `make-auto-save-file-name'. |
2938 FILENAME should lack slashes. | 2942 FILENAME should lack slashes. |
2939 You can redefine this for customization." | 2943 You can redefine this for customization." |
2940 (string-match "\\`#.*#\\'" filename)) | 2944 (string-match "\\`#.*#\\'" filename)) |
2941 | 2945 |
2946 (defun wildcard-to-regexp (wildcard) | |
2947 "Given a shell file name pattern WILDCARD, return an equivalent regexp. | |
2948 The generated regexp will match a filename iff the filename | |
2949 matches that wildcard according to shell rules. Only wildcards known | |
2950 by `sh' are supported." | |
2951 (let* ((i (string-match "[[.*+\\^$?]" wildcard)) | |
2952 ;; Copy the initial run of non-special characters. | |
2953 (result (substring wildcard 0 i)) | |
2954 (len (length wildcard))) | |
2955 ;; If no special characters, we're almost done. | |
2956 (if i | |
2957 (while (< i len) | |
2958 (let ((ch (aref wildcard i)) | |
2959 j) | |
2960 (setq | |
2961 result | |
2962 (concat result | |
2963 (cond | |
2964 ((eq ch ?\[) ; [...] maps to regexp char class | |
2965 (progn | |
2966 (setq i (1+ i)) | |
2967 (concat | |
2968 (cond | |
2969 ((eq (aref wildcard i) ?!) ; [!...] -> [^...] | |
2970 (progn | |
2971 (setq i (1+ i)) | |
2972 (if (eq (aref wildcard i) ?\]) | |
2973 (progn | |
2974 (setq i (1+ i)) | |
2975 "[^]") | |
2976 "[^"))) | |
2977 ((eq (aref wildcard i) ?^) | |
2978 ;; Found "[^". Insert a `\0' character | |
2979 ;; (which cannot happen in a filename) | |
2980 ;; into the character class, so that `^' | |
2981 ;; is not the first character after `[', | |
2982 ;; and thus non-special in a regexp. | |
2983 (progn | |
2984 (setq i (1+ i)) | |
2985 "[\000^")) | |
2986 ((eq (aref wildcard i) ?\]) | |
2987 ;; I don't think `]' can appear in a | |
2988 ;; character class in a wildcard, but | |
2989 ;; let's be general here. | |
2990 (progn | |
2991 (setq i (1+ i)) | |
2992 "[]")) | |
2993 (t "[")) | |
2994 (prog1 ; copy everything upto next `]'. | |
2995 (substring wildcard | |
2996 i | |
2997 (setq j (string-match | |
2998 "]" wildcard i))) | |
2999 (setq i (if j (1- j) (1- len))))))) | |
3000 ((eq ch ?.) "\\.") | |
3001 ((eq ch ?*) "[^\000]*") | |
3002 ((eq ch ?+) "\\+") | |
3003 ((eq ch ?^) "\\^") | |
3004 ((eq ch ?$) "\\$") | |
3005 ((eq ch ?\\) "\\\\") ; probably cannot happen... | |
3006 ((eq ch ??) "[^\000]") | |
3007 (t (char-to-string ch))))) | |
3008 (setq i (1+ i))))) | |
3009 ;; Shell wildcards should match the entire filename, | |
3010 ;; not its part. Make the regexp say so. | |
3011 (concat "\\`" result "\\'"))) | |
3012 | |
2942 (defcustom list-directory-brief-switches | 3013 (defcustom list-directory-brief-switches |
2943 (if (eq system-type 'vax-vms) "" "-CF") | 3014 (if (eq system-type 'vax-vms) "" "-CF") |
2944 "*Switches for list-directory to pass to `ls' for brief listing." | 3015 "*Switches for list-directory to pass to `ls' for brief listing." |
2945 :type 'string | 3016 :type 'string |
2946 :group 'dired) | 3017 :group 'dired) |
3015 (let ((handler (find-file-name-handler (expand-file-name file) | 3086 (let ((handler (find-file-name-handler (expand-file-name file) |
3016 'insert-directory))) | 3087 'insert-directory))) |
3017 (if handler | 3088 (if handler |
3018 (funcall handler 'insert-directory file switches | 3089 (funcall handler 'insert-directory file switches |
3019 wildcard full-directory-p) | 3090 wildcard full-directory-p) |
3020 (if (eq system-type 'vax-vms) | 3091 (cond |
3021 (vms-read-directory file switches (current-buffer)) | 3092 ((eq system-type 'vax-vms) |
3093 (vms-read-directory file switches (current-buffer))) | |
3094 ((and (fboundp 'mswindows-insert-directory) | |
3095 (eq system-type 'windows-nt)) | |
3096 (mswindows-insert-directory file switches wildcard full-directory-p)) | |
3097 (t | |
3022 (if wildcard | 3098 (if wildcard |
3023 ;; Run ls in the directory of the file pattern we asked for. | 3099 ;; Run ls in the directory of the file pattern we asked for. |
3024 (let ((default-directory | 3100 (let ((default-directory |
3025 (if (file-name-absolute-p file) | 3101 (if (file-name-absolute-p file) |
3026 (file-name-directory file) | 3102 (file-name-directory file) |
3068 (list | 3144 (list |
3069 (if full-directory-p | 3145 (if full-directory-p |
3070 (concat (file-name-as-directory file) | 3146 (concat (file-name-as-directory file) |
3071 ;;#### Unix-specific | 3147 ;;#### Unix-specific |
3072 ".") | 3148 ".") |
3073 file)))))))))) | 3149 file))))))))))) |
3074 | 3150 |
3075 (defvar kill-emacs-query-functions nil | 3151 (defvar kill-emacs-query-functions nil |
3076 "Functions to call with no arguments to query about killing XEmacs. | 3152 "Functions to call with no arguments to query about killing XEmacs. |
3077 If any of these functions returns nil, killing Emacs is cancelled. | 3153 If any of these functions returns nil, killing Emacs is cancelled. |
3078 `save-buffers-kill-emacs' (\\[save-buffers-kill-emacs]) calls these functions, | 3154 `save-buffers-kill-emacs' (\\[save-buffers-kill-emacs]) calls these functions, |