Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | a300bb07d72d |
children | 7d59cb494b73 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
74 :value ("\\`" . "") | 74 :value ("\\`" . "") |
75 (regexp :tag "From") | 75 (regexp :tag "From") |
76 (regexp :tag "To"))) | 76 (regexp :tag "To"))) |
77 :group 'find-file) | 77 :group 'find-file) |
78 | 78 |
79 ;;; Turn off backup files on VMS since it has version numbers. | 79 (defcustom make-backup-files t |
80 (defcustom make-backup-files (not (eq system-type 'vax-vms)) | |
81 "*Non-nil means make a backup of a file the first time it is saved. | 80 "*Non-nil means make a backup of a file the first time it is saved. |
82 This can be done by renaming the file or by copying. | 81 This can be done by renaming the file or by copying. |
83 | 82 |
84 Renaming means that XEmacs renames the existing file so that it is a | 83 Renaming means that XEmacs renames the existing file so that it is a |
85 backup file, then writes the buffer into a new file. Any other names | 84 backup file, then writes the buffer into a new file. Any other names |
412 | 411 |
413 (defun cd-absolute (dir) | 412 (defun cd-absolute (dir) |
414 "Change current directory to given absolute file name DIR." | 413 "Change current directory to given absolute file name DIR." |
415 ;; Put the name into directory syntax now, | 414 ;; Put the name into directory syntax now, |
416 ;; because otherwise expand-file-name may give some bad results. | 415 ;; because otherwise expand-file-name may give some bad results. |
417 (if (not (eq system-type 'vax-vms)) | 416 (setq dir (file-name-as-directory dir)) |
418 (setq dir (file-name-as-directory dir))) | |
419 ;; XEmacs change: stig@hackvan.com | 417 ;; XEmacs change: stig@hackvan.com |
420 (if find-file-use-truenames | 418 (if find-file-use-truenames |
421 (setq dir (file-truename dir))) | 419 (setq dir (file-truename dir))) |
422 (setq dir (abbreviate-file-name (expand-file-name dir))) | 420 (setq dir (abbreviate-file-name (expand-file-name dir))) |
423 (cond ((not (file-directory-p dir)) | 421 (cond ((not (file-directory-p dir)) |
811 ;; make it start with `~' instead. | 809 ;; make it start with `~' instead. |
812 (if (and (string-match abbreviated-home-dir filename) | 810 (if (and (string-match abbreviated-home-dir filename) |
813 ;; If the home dir is just /, don't change it. | 811 ;; If the home dir is just /, don't change it. |
814 (not (and (= (match-end 0) 1) ;#### unix-specific | 812 (not (and (= (match-end 0) 1) ;#### unix-specific |
815 (= (aref filename 0) ?/))) | 813 (= (aref filename 0) ?/))) |
816 (not (and (or (eq system-type 'ms-dos) | 814 (not (and (memq system-type '(ms-dos windows-nt)) |
817 (eq system-type 'windows-nt)) | |
818 (save-match-data | 815 (save-match-data |
819 (string-match "^[a-zA-Z]:/$" filename))))) | 816 (string-match "^[a-zA-Z]:/$" filename))))) |
820 (setq filename | 817 (setq filename |
821 (concat "~" | 818 (concat "~" |
822 (substring filename | 819 (substring filename |
823 (match-beginning 1) (match-end 1)) | 820 (match-beginning 1) (match-end 1)) |
824 (substring filename (match-end 0))))))) | 821 (substring filename (match-end 0))))))) |
825 filename))) | 822 filename))) |
826 | 823 |
827 (defcustom find-file-not-true-dirname-list nil | 824 (defcustom find-file-not-true-dirname-list nil |
828 "*List of logical names for which visiting shouldn't save the true dirname. | 825 "*List of logical names for which visiting shouldn't save the true dirname." |
829 On VMS, when you visit a file using a logical name that searches a path, | |
830 you may or may not want the visited file name to record the specific | |
831 directory where the file was found. If you *do not* want that, add the logical | |
832 name to this list as a string." | |
833 :type '(repeat (string :tag "Name")) | 826 :type '(repeat (string :tag "Name")) |
834 :group 'find-file) | 827 :group 'find-file) |
835 | 828 |
836 ;; This function is needed by FSF vc.el. I hope somebody can make it | 829 ;; This function is needed by FSF vc.el. I hope somebody can make it |
837 ;; work for XEmacs. -sb. | 830 ;; work for XEmacs. -sb. |
1002 ;; Find the file's truename, and maybe use that as visited name. | 995 ;; Find the file's truename, and maybe use that as visited name. |
1003 ;; automatically computed in XEmacs, unless jka-compr was used! | 996 ;; automatically computed in XEmacs, unless jka-compr was used! |
1004 (unless buffer-file-truename | 997 (unless buffer-file-truename |
1005 (setq buffer-file-truename truename)) | 998 (setq buffer-file-truename truename)) |
1006 (setq buffer-file-number number) | 999 (setq buffer-file-number number) |
1007 ;; On VMS, we may want to remember which directory in | |
1008 ;; a search list the file was found in. | |
1009 (and (eq system-type 'vax-vms) | |
1010 (let (logical) | |
1011 (if (string-match ":" (file-name-directory filename)) | |
1012 (setq logical (substring (file-name-directory filename) | |
1013 0 (match-beginning 0)))) | |
1014 (not (member logical find-file-not-true-dirname-list))) | |
1015 (setq buffer-file-name buffer-file-truename)) | |
1016 (and find-file-use-truenames | 1000 (and find-file-use-truenames |
1017 ;; This should be in C. Put pathname | 1001 ;; This should be in C. Put pathname |
1018 ;; abbreviations that have been explicitly | 1002 ;; abbreviations that have been explicitly |
1019 ;; requested back into the pathname. Most | 1003 ;; requested back into the pathname. Most |
1020 ;; importantly, strip out automounter /tmp_mnt | 1004 ;; importantly, strip out automounter /tmp_mnt |
1147 | 1131 |
1148 (defvar auto-mode-alist | 1132 (defvar auto-mode-alist |
1149 '(("\\.te?xt\\'" . text-mode) | 1133 '(("\\.te?xt\\'" . text-mode) |
1150 ("\\.[ch]\\'" . c-mode) | 1134 ("\\.[ch]\\'" . c-mode) |
1151 ("\\.el\\'" . emacs-lisp-mode) | 1135 ("\\.el\\'" . emacs-lisp-mode) |
1152 ("\\.\\([CH]\\|cc\\|hh\\)\\'" . c++-mode) | 1136 ("\\.\\(?:[CH]\\|cc\\|hh\\)\\'" . c++-mode) |
1153 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) | 1137 ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) |
1154 ("\\.java\\'" . java-mode) | 1138 ("\\.java\\'" . java-mode) |
1155 ("\\.idl\\'" . idl-mode) | 1139 ("\\.idl\\'" . idl-mode) |
1156 ("\\.f\\(or\\)?\\'" . fortran-mode) | 1140 ("\\.f\\(?:or\\)?\\'" . fortran-mode) |
1157 ("\\.F\\(OR\\)?\\'" . fortran-mode) | 1141 ("\\.F\\(?:OR\\)?\\'" . fortran-mode) |
1158 ("\\.[fF]90\\'" . f90-mode) | 1142 ("\\.[fF]90\\'" . f90-mode) |
1159 ;;; Less common extensions come here | 1143 ;;; Less common extensions come here |
1160 ;;; so more common ones above are found faster. | 1144 ;;; so more common ones above are found faster. |
1161 ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode) | 1145 ("\\.\\([pP][Llm]\\|al\\)\\'" . perl-mode) |
1162 ("\\.py\\'" . python-mode) | 1146 ("\\.py\\'" . python-mode) |
1163 ("\\.texi\\(nfo\\)?\\'" . texinfo-mode) | 1147 ("\\.texi\\(?:nfo\\)?\\'" . texinfo-mode) |
1164 ("\\.ad[abs]\\'" . ada-mode) | 1148 ("\\.ad[abs]\\'" . ada-mode) |
1165 ("\\.c?l\\(i?sp\\)?\\'" . lisp-mode) | 1149 ("\\.c?l\\(?:i?sp\\)?\\'" . lisp-mode) |
1166 ("\\.p\\(as\\)?\\'" . pascal-mode) | 1150 ("\\.p\\(?:as\\)?\\'" . pascal-mode) |
1167 ("\\.ltx\\'" . latex-mode) | 1151 ("\\.ltx\\'" . latex-mode) |
1168 ("\\.[sS]\\'" . asm-mode) | 1152 ("\\.[sS]\\'" . asm-mode) |
1169 ("[Cc]hange.?[Ll]og?\\(.[0-9]+\\)?\\'" . change-log-mode) | 1153 ("[Cc]hange.?[Ll]og?\\(?:.[0-9]+\\)?\\'" . change-log-mode) |
1170 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) | 1154 ("\\$CHANGE_LOG\\$\\.TXT" . change-log-mode) |
1171 ("\\.scm?\\(?:\\.[0-9]*\\)?\\'" . scheme-mode) | 1155 ("\\.scm?\\(?:\\.[0-9]*\\)?\\'" . scheme-mode) |
1172 ("\\.e\\'" . eiffel-mode) | 1156 ("\\.e\\'" . eiffel-mode) |
1173 ("\\.mss\\'" . scribe-mode) | 1157 ("\\.mss\\'" . scribe-mode) |
1174 ("\\.m\\([mes]\\|an\\)\\'" . nroff-mode) | 1158 ("\\.m\\(?:[mes]\\|an\\)\\'" . nroff-mode) |
1175 ("\\.icn\\'" . icon-mode) | 1159 ("\\.icn\\'" . icon-mode) |
1176 ("\\.\\([ckz]?sh\\|shar\\)\\'" . sh-mode) | 1160 ("\\.\\(?:[ckz]?sh\\|shar\\)\\'" . sh-mode) |
1177 ;; #### Unix-specific! | 1161 ;; #### Unix-specific! |
1178 ("/\\.\\(bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode) | 1162 ("/\\.\\(?:bash_\\|z\\)?\\(profile\\|login\||logout\\)\\'" . sh-mode) |
1179 ("/\\.\\([ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode) | 1163 ("/\\.\\(?:[ckz]sh\\|bash\\|tcsh\\|es\\|xinit\\|startx\\)rc\\'" . sh-mode) |
1180 ("/\\.\\([kz]shenv\\|xsession\\)\\'" . sh-mode) | 1164 ("/\\.\\(?:[kz]shenv\\|xsession\\)\\'" . sh-mode) |
1181 ;; The following come after the ChangeLog pattern for the sake of | 1165 ;; The following come after the ChangeLog pattern for the sake of |
1182 ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too. | 1166 ;; ChangeLog.1, etc. and after the .scm.[0-9] pattern too. |
1183 ("\\.[12345678]\\'" . nroff-mode) | 1167 ("\\.[12345678]\\'" . nroff-mode) |
1184 ("\\.[tT]e[xX]\\'" . tex-mode) | 1168 ("\\.[tT]e[xX]\\'" . tex-mode) |
1185 ("\\.\\(sty\\|cls\\|bbl\\)\\'" . latex-mode) | 1169 ("\\.\\(?:sty\\|cls\\|bbl\\)\\'" . latex-mode) |
1186 ("\\.bib\\'" . bibtex-mode) | 1170 ("\\.bib\\'" . bibtex-mode) |
1187 ("\\.article\\'" . text-mode) | 1171 ("\\.article\\'" . text-mode) |
1188 ("\\.letter\\'" . text-mode) | 1172 ("\\.letter\\'" . text-mode) |
1189 ("\\.\\(tcl\\|exp\\)\\'" . tcl-mode) | 1173 ("\\.\\(?:tcl\\|exp\\)\\'" . tcl-mode) |
1190 ("\\.wrl\\'" . vrml-mode) | 1174 ("\\.wrl\\'" . vrml-mode) |
1191 ("\\.awk\\'" . awk-mode) | 1175 ("\\.awk\\'" . awk-mode) |
1192 ("\\.prolog\\'" . prolog-mode) | 1176 ("\\.prolog\\'" . prolog-mode) |
1193 ("\\.tar\\'" . tar-mode) | 1177 ("\\.\\(?:arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) |
1194 ("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode) | |
1195 ;; Mailer puts message to be edited in /tmp/Re.... or Message | 1178 ;; Mailer puts message to be edited in /tmp/Re.... or Message |
1196 ;; #### Unix-specific! | 1179 ;; #### Unix-specific! |
1197 ("\\`/tmp/Re" . text-mode) | 1180 ("\\`/tmp/Re" . text-mode) |
1198 ("/Message[0-9]*\\'" . text-mode) | 1181 ("/Message[0-9]*\\'" . text-mode) |
1199 ("/drafts/[0-9]+\\'" . mh-letter-mode) | 1182 ("/drafts/[0-9]+\\'" . mh-letter-mode) |
1203 ("\\.lex\\'" . c-mode) | 1186 ("\\.lex\\'" . c-mode) |
1204 ("\\.m\\'" . objc-mode) | 1187 ("\\.m\\'" . objc-mode) |
1205 ("\\.oak\\'" . scheme-mode) | 1188 ("\\.oak\\'" . scheme-mode) |
1206 ("\\.s?html?\\'" . html-mode) | 1189 ("\\.s?html?\\'" . html-mode) |
1207 ("\\.htm?l?3\\'" . html3-mode) | 1190 ("\\.htm?l?3\\'" . html3-mode) |
1208 ("\\.\\(sgml?\\|dtd\\)\\'" . sgml-mode) | 1191 ("\\.\\(?:sgml?\\|dtd\\)\\'" . sgml-mode) |
1209 ("\\.c?ps\\'" . postscript-mode) | 1192 ("\\.c?ps\\'" . postscript-mode) |
1210 ;; .emacs following a directory delimiter in either Unix or | 1193 ;; .emacs following a directory delimiter in either Unix or |
1211 ;; Windows syntax. | 1194 ;; Windows syntax. |
1212 ("[/\\][._].*emacs\\'" . emacs-lisp-mode) | 1195 ("[/\\][._].*emacs\\'" . emacs-lisp-mode) |
1213 ("\\.m4\\'" . autoconf-mode) | 1196 ("\\.m4\\'" . autoconf-mode) |
1216 ("\\.ma?k\\'" . makefile-mode) | 1199 ("\\.ma?k\\'" . makefile-mode) |
1217 ("[Mm]akefile\\(\\.\\|\\'\\)" . makefile-mode) | 1200 ("[Mm]akefile\\(\\.\\|\\'\\)" . makefile-mode) |
1218 ("\\.X\\(defaults\\|environment\\|resources\\|modmap\\)\\'" . xrdb-mode) | 1201 ("\\.X\\(defaults\\|environment\\|resources\\|modmap\\)\\'" . xrdb-mode) |
1219 ;; #### The following three are Unix-specific (but do we care?) | 1202 ;; #### The following three are Unix-specific (but do we care?) |
1220 ("/app-defaults/" . xrdb-mode) | 1203 ("/app-defaults/" . xrdb-mode) |
1221 ("\\.[^/]*wm\\'" . winmgr-mode) | 1204 ("\\.[^/]*wm2?\\(?:rc\\)?\\'" . winmgr-mode) |
1222 ("\\.[^/]*wm2?rc" . winmgr-mode) | 1205 ("\\.\\(?:jpe?g\\|JPE?G\\|png\\|PNG\\|gif\\|GIF\\|tiff?\\|TIFF?\\)\\'" . image-mode) |
1223 ("\\.[Jj][Pp][Ee]?[Gg]\\'" . image-mode) | |
1224 ("\\.[Pp][Nn][Gg]\\'" . image-mode) | |
1225 ("\\.[Gg][Ii][Ff]\\'" . image-mode) | |
1226 ) | 1206 ) |
1227 "Alist of filename patterns vs. corresponding major mode functions. | 1207 "Alist of filename patterns vs. corresponding major mode functions. |
1228 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). | 1208 Each element looks like (REGEXP . FUNCTION) or (REGEXP FUNCTION NON-NIL). |
1229 \(NON-NIL stands for anything that is not nil; the value does not matter.) | 1209 \(NON-NIL stands for anything that is not nil; the value does not matter.) |
1230 Visiting a file whose name matches REGEXP specifies FUNCTION as the | 1210 Visiting a file whose name matches REGEXP specifies FUNCTION as the |
1256 Each alist element looks like (INTERPRETER . MODE). | 1236 Each alist element looks like (INTERPRETER . MODE). |
1257 The car of each element is a regular expression which is compared | 1237 The car of each element is a regular expression which is compared |
1258 with the name of the interpreter specified in the first line. | 1238 with the name of the interpreter specified in the first line. |
1259 If it matches, mode MODE is selected.") | 1239 If it matches, mode MODE is selected.") |
1260 | 1240 |
1261 (defvar inhibit-first-line-modes-regexps (purecopy '("\\.tar\\'" "\\.tgz\\'" | 1241 (defvar binary-file-regexps |
1262 "\\.tar\\.gz\\'")) | 1242 (purecopy |
1243 '("\\.\\(?:bz2\\|elc\\|g\\(if\\|z\\)\\|jp\\(eg\\|g\\)\\|png\\|t\\(ar\\|gz\\|iff\\)\\|[Zo]\\)\\'")) | |
1244 "List of regexps of filenames containing binary (non-text) data.") | |
1245 | |
1246 ; (eval-when-compile | |
1247 ; (require 'regexp-opt) | |
1248 ; (list | |
1249 ; (format "\\.\\(?:%s\\)\\'" | |
1250 ; (regexp-opt | |
1251 ; '("tar" | |
1252 ; "tgz" | |
1253 ; "gz" | |
1254 ; "bz2" | |
1255 ; "Z" | |
1256 ; "o" | |
1257 ; "elc" | |
1258 ; "png" | |
1259 ; "gif" | |
1260 ; "tiff" | |
1261 ; "jpg" | |
1262 ; "jpeg")))))) | |
1263 | |
1264 (defvar inhibit-first-line-modes-regexps | |
1265 (purecopy binary-file-regexps) | |
1263 "List of regexps; if one matches a file name, don't look for `-*-'.") | 1266 "List of regexps; if one matches a file name, don't look for `-*-'.") |
1264 | 1267 |
1265 (defvar inhibit-first-line-modes-suffixes nil | 1268 (defvar inhibit-first-line-modes-suffixes nil |
1266 "List of regexps for what to ignore, for `inhibit-first-line-modes-regexps'. | 1269 "List of regexps for what to ignore, for `inhibit-first-line-modes-regexps'. |
1267 When checking `inhibit-first-line-modes-regexps', we first discard | 1270 When checking `inhibit-first-line-modes-regexps', we first discard |
1307 (setq keep-going nil) | 1310 (setq keep-going nil) |
1308 (let ((alist auto-mode-alist) | 1311 (let ((alist auto-mode-alist) |
1309 (mode nil)) | 1312 (mode nil)) |
1310 ;; Find first matching alist entry. | 1313 ;; Find first matching alist entry. |
1311 (let ((case-fold-search | 1314 (let ((case-fold-search |
1312 (memq system-type '(vax-vms windows-nt)))) | 1315 (memq system-type '(windows-nt)))) |
1313 (while (and (not mode) alist) | 1316 (while (and (not mode) alist) |
1314 (if (string-match (car (car alist)) name) | 1317 (if (string-match (car (car alist)) name) |
1315 (if (and (consp (cdr (car alist))) | 1318 (if (and (consp (cdr (car alist))) |
1316 (nth 2 (car alist))) | 1319 (nth 2 (car alist))) |
1317 (progn | 1320 (progn |
1720 (setq buffer-file-name filename) | 1723 (setq buffer-file-name filename) |
1721 (if filename ; make buffer name reflect filename. | 1724 (if filename ; make buffer name reflect filename. |
1722 (let ((new-name (file-name-nondirectory buffer-file-name))) | 1725 (let ((new-name (file-name-nondirectory buffer-file-name))) |
1723 (if (string= new-name "") | 1726 (if (string= new-name "") |
1724 (error "Empty file name")) | 1727 (error "Empty file name")) |
1725 (if (eq system-type 'vax-vms) | |
1726 (setq new-name (downcase new-name))) | |
1727 (setq default-directory (file-name-directory buffer-file-name)) | 1728 (setq default-directory (file-name-directory buffer-file-name)) |
1728 (or (string= new-name (buffer-name)) | 1729 (or (string= new-name (buffer-name)) |
1729 (rename-buffer new-name t)))) | 1730 (rename-buffer new-name t)))) |
1730 (setq buffer-backed-up nil) | 1731 (setq buffer-backed-up nil) |
1731 (or along-with-file | 1732 (or along-with-file |
1915 (copy-file real-file-name backupname t t))))) | 1916 (copy-file real-file-name backupname t t))))) |
1916 (setq buffer-backed-up t) | 1917 (setq buffer-backed-up t) |
1917 ;; Now delete the old versions, if desired. | 1918 ;; Now delete the old versions, if desired. |
1918 (if delete-old-versions | 1919 (if delete-old-versions |
1919 (while targets | 1920 (while targets |
1920 (condition-case () | 1921 (ignore-file-errors (delete-file (car targets))) |
1921 (delete-file (car targets)) | |
1922 (file-error nil)) | |
1923 (setq targets (cdr targets)))) | 1922 (setq targets (cdr targets)))) |
1924 setmodes) | 1923 setmodes) |
1925 (file-error nil))))))))) | 1924 (file-error nil))))))))) |
1926 | 1925 |
1927 (defun file-name-sans-versions (name &optional keep-backup-version) | 1926 (defun file-name-sans-versions (name &optional keep-backup-version) |
1932 we do not remove backup version numbers, only true file version numbers." | 1931 we do not remove backup version numbers, only true file version numbers." |
1933 (let ((handler (find-file-name-handler name 'file-name-sans-versions))) | 1932 (let ((handler (find-file-name-handler name 'file-name-sans-versions))) |
1934 (if handler | 1933 (if handler |
1935 (funcall handler 'file-name-sans-versions name keep-backup-version) | 1934 (funcall handler 'file-name-sans-versions name keep-backup-version) |
1936 (substring name 0 | 1935 (substring name 0 |
1937 (if (eq system-type 'vax-vms) | 1936 (if keep-backup-version |
1938 ;; VMS version number is (a) semicolon, optional | 1937 (length name) |
1939 ;; sign, zero or more digits or (b) period, option | 1938 (or (string-match "\\.~[0-9.]+~\\'" name) |
1940 ;; sign, zero or more digits, provided this is the | 1939 ;; XEmacs - VC uses extensions like ".~tagname~" or ".~1.1.5.2~" |
1941 ;; second period encountered outside of the | 1940 (let ((pos (string-match "\\.~\\([^.~ \t]+\\|[0-9.]+\\)~\\'" name))) |
1942 ;; device/directory part of the file name. | 1941 (and pos |
1943 (or (string-match ";[-+]?[0-9]*\\'" name) | 1942 ;; #### - is this filesystem check too paranoid? |
1944 (if (string-match "\\.[^]>:]*\\(\\.[-+]?[0-9]*\\)\\'" | 1943 (file-exists-p (substring name 0 pos)) |
1945 name) | 1944 pos)) |
1946 (match-beginning 1)) | 1945 (string-match "~\\'" name) |
1947 (length name)) | 1946 (length name))))))) |
1948 (if keep-backup-version | |
1949 (length name) | |
1950 (or (string-match "\\.~[0-9.]+~\\'" name) | |
1951 ;; XEmacs - VC uses extensions like ".~tagname~" or ".~1.1.5.2~" | |
1952 (let ((pos (string-match "\\.~\\([^.~ \t]+\\|[0-9.]+\\)~\\'" name))) | |
1953 (and pos | |
1954 ;; #### - is this filesystem check too paranoid? | |
1955 (file-exists-p (substring name 0 pos)) | |
1956 pos)) | |
1957 (string-match "~\\'" name) | |
1958 (length name)))))))) | |
1959 | 1947 |
1960 (defun file-ownership-preserved-p (file) | 1948 (defun file-ownership-preserved-p (file) |
1961 "Return t if deleting FILE and rewriting it would preserve the owner." | 1949 "Return t if deleting FILE and rewriting it would preserve the owner." |
1962 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p))) | 1950 (let ((handler (find-file-name-handler file 'file-ownership-preserved-p))) |
1963 (if handler | 1951 (if handler |
2028 (if (and (string-match "[0-9]+~\\'" fn bv-length) | 2016 (if (and (string-match "[0-9]+~\\'" fn bv-length) |
2029 (= (match-beginning 0) bv-length)) | 2017 (= (match-beginning 0) bv-length)) |
2030 (string-to-int (substring fn bv-length -1)) | 2018 (string-to-int (substring fn bv-length -1)) |
2031 0)) | 2019 0)) |
2032 | 2020 |
2033 ;; I believe there is no need to alter this behavior for VMS; | |
2034 ;; since backup files are not made on VMS, it should not get called. | |
2035 (defun find-backup-file-name (fn) | 2021 (defun find-backup-file-name (fn) |
2036 "Find a file name for a backup file, and suggestions for deletions. | 2022 "Find a file name for a backup file, and suggestions for deletions. |
2037 Value is a list whose car is the name for the backup file | 2023 Value is a list whose car is the name for the backup file |
2038 and whose cdr is a list of old versions to consider deleting now. | 2024 and whose cdr is a list of old versions to consider deleting now. |
2039 If the value is nil, don't make a backup." | 2025 If the value is nil, don't make a backup." |
2094 (let ((fname (expand-file-name filename))) | 2080 (let ((fname (expand-file-name filename))) |
2095 (setq directory (file-name-as-directory | 2081 (setq directory (file-name-as-directory |
2096 (expand-file-name (or directory default-directory)))) | 2082 (expand-file-name (or directory default-directory)))) |
2097 ;; On Microsoft OSes, if FILENAME and DIRECTORY have different | 2083 ;; On Microsoft OSes, if FILENAME and DIRECTORY have different |
2098 ;; drive names, they can't be relative, so return the absolute name. | 2084 ;; drive names, they can't be relative, so return the absolute name. |
2099 (if (and (or (eq system-type 'ms-dos) | 2085 (if (and (memq system-type '(ms-dos windows-nt)) |
2100 (eq system-type 'windows-nt)) | |
2101 (not (string-equal (substring fname 0 2) | 2086 (not (string-equal (substring fname 0 2) |
2102 (substring directory 0 2)))) | 2087 (substring directory 0 2)))) |
2103 filename | 2088 filename |
2104 (let ((ancestor ".") | 2089 (let ((ancestor ".") |
2105 (fname-dir (file-name-as-directory fname))) | 2090 (fname-dir (file-name-as-directory fname))) |
2165 since the last real save, but optional arg FORCE non-nil means delete anyway." | 2150 since the last real save, but optional arg FORCE non-nil means delete anyway." |
2166 (and buffer-auto-save-file-name delete-auto-save-files | 2151 (and buffer-auto-save-file-name delete-auto-save-files |
2167 (not (string= buffer-file-name buffer-auto-save-file-name)) | 2152 (not (string= buffer-file-name buffer-auto-save-file-name)) |
2168 (or force (recent-auto-save-p)) | 2153 (or force (recent-auto-save-p)) |
2169 (progn | 2154 (progn |
2170 (condition-case () | 2155 (ignore-file-errors (delete-file buffer-auto-save-file-name)) |
2171 (delete-file buffer-auto-save-file-name) | |
2172 (file-error nil)) | |
2173 (set-buffer-auto-saved)))) | 2156 (set-buffer-auto-saved)))) |
2174 | 2157 |
2175 ;; XEmacs change (from Sun) | 2158 ;; XEmacs change (from Sun) |
2176 ;; used to communicate with continue-save-buffer: | 2159 ;; used to communicate with continue-save-buffer: |
2177 (defvar continue-save-buffer-hooks-tail nil) | 2160 (defvar continue-save-buffer-hooks-tail nil) |
2209 ;; In an indirect buffer, save its base buffer instead. | 2192 ;; In an indirect buffer, save its base buffer instead. |
2210 (if (buffer-base-buffer) | 2193 (if (buffer-base-buffer) |
2211 (set-buffer (buffer-base-buffer))) | 2194 (set-buffer (buffer-base-buffer))) |
2212 (if (buffer-modified-p) | 2195 (if (buffer-modified-p) |
2213 (let ((recent-save (recent-auto-save-p))) | 2196 (let ((recent-save (recent-auto-save-p))) |
2214 ;; On VMS, rename file and buffer to get rid of version number. | |
2215 (if (and (eq system-type 'vax-vms) | |
2216 (not (string= buffer-file-name | |
2217 (file-name-sans-versions buffer-file-name)))) | |
2218 (let (buffer-new-name) | |
2219 ;; Strip VMS version number before save. | |
2220 (setq buffer-file-name | |
2221 (file-name-sans-versions buffer-file-name)) | |
2222 ;; Construct a (unique) buffer name to correspond. | |
2223 (let ((buf (create-file-buffer (downcase buffer-file-name)))) | |
2224 (setq buffer-new-name (buffer-name buf)) | |
2225 (kill-buffer buf)) | |
2226 (rename-buffer buffer-new-name))) | |
2227 ;; If buffer has no file name, ask user for one. | 2197 ;; If buffer has no file name, ask user for one. |
2228 (or buffer-file-name | 2198 (or buffer-file-name |
2229 (let ((filename | 2199 (let ((filename |
2230 (expand-file-name | 2200 (expand-file-name |
2231 (read-file-name "File to save in: ") nil))) | 2201 (read-file-name "File to save in: ") nil))) |
2780 (cond ((if (file-exists-p file) | 2750 (cond ((if (file-exists-p file) |
2781 (not (file-newer-than-file-p file-name file)) | 2751 (not (file-newer-than-file-p file-name file)) |
2782 (not (file-exists-p file-name))) | 2752 (not (file-exists-p file-name))) |
2783 (error "Auto-save file %s not current" file-name)) | 2753 (error "Auto-save file %s not current" file-name)) |
2784 ((save-window-excursion | 2754 ((save-window-excursion |
2785 (if (not (eq system-type 'vax-vms)) | 2755 (with-output-to-temp-buffer "*Directory*" |
2786 (with-output-to-temp-buffer "*Directory*" | 2756 (buffer-disable-undo standard-output) |
2787 (buffer-disable-undo standard-output) | 2757 (call-process "ls" nil standard-output nil |
2788 (call-process "ls" nil standard-output nil | 2758 (if (file-symlink-p file) "-lL" "-l") |
2789 (if (file-symlink-p file) "-lL" "-l") | 2759 file file-name)) |
2790 file file-name))) | |
2791 (yes-or-no-p (format "Recover auto save file %s? " file-name))) | 2760 (yes-or-no-p (format "Recover auto save file %s? " file-name))) |
2792 (switch-to-buffer (find-file-noselect file t)) | 2761 (switch-to-buffer (find-file-noselect file t)) |
2793 (let ((buffer-read-only nil)) | 2762 (let ((buffer-read-only nil)) |
2794 (erase-buffer) | 2763 (erase-buffer) |
2795 (insert-file-contents file-name nil)) | 2764 (insert-file-contents file-name nil)) |
3085 (setq i (1+ i))))) | 3054 (setq i (1+ i))))) |
3086 ;; Shell wildcards should match the entire filename, | 3055 ;; Shell wildcards should match the entire filename, |
3087 ;; not its part. Make the regexp say so. | 3056 ;; not its part. Make the regexp say so. |
3088 (concat "\\`" result "\\'"))) | 3057 (concat "\\`" result "\\'"))) |
3089 | 3058 |
3090 (defcustom list-directory-brief-switches | 3059 (defcustom list-directory-brief-switches "-CF" |
3091 (if (eq system-type 'vax-vms) "" "-CF") | |
3092 "*Switches for list-directory to pass to `ls' for brief listing." | 3060 "*Switches for list-directory to pass to `ls' for brief listing." |
3093 :type 'string | 3061 :type 'string |
3094 :group 'dired) | 3062 :group 'dired) |
3095 | 3063 |
3096 (defcustom list-directory-verbose-switches | 3064 (defcustom list-directory-verbose-switches "-l" |
3097 (if (eq system-type 'vax-vms) | |
3098 "/PROTECTION/SIZE/DATE/OWNER/WIDTH=(OWNER:10)" | |
3099 "-l") | |
3100 "*Switches for list-directory to pass to `ls' for verbose listing," | 3065 "*Switches for list-directory to pass to `ls' for verbose listing," |
3101 :type 'string | 3066 :type 'string |
3102 :group 'dired) | 3067 :group 'dired) |
3103 | 3068 |
3104 (defun list-directory (dirname &optional verbose) | 3069 (defun list-directory (dirname &optional verbose) |
3164 'insert-directory))) | 3129 'insert-directory))) |
3165 (if handler | 3130 (if handler |
3166 (funcall handler 'insert-directory file switches | 3131 (funcall handler 'insert-directory file switches |
3167 wildcard full-directory-p) | 3132 wildcard full-directory-p) |
3168 (cond | 3133 (cond |
3169 ((eq system-type 'vax-vms) | |
3170 (vms-read-directory file switches (current-buffer))) | |
3171 ((and (fboundp 'mswindows-insert-directory) | 3134 ((and (fboundp 'mswindows-insert-directory) |
3172 (eq system-type 'windows-nt)) | 3135 (eq system-type 'windows-nt)) |
3173 (mswindows-insert-directory file switches wildcard full-directory-p)) | 3136 (mswindows-insert-directory file switches wildcard full-directory-p)) |
3174 (t | 3137 (t |
3175 (if wildcard | 3138 (if wildcard |