Mercurial > hg > xemacs-beta
comparison lisp/files.el @ 440:8de8e3f6228a r21-2-28
Import from CVS: tag r21-2-28
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:33:38 +0200 |
parents | 84b14dcb0985 |
children | abe6d1db359e |
comparison
equal
deleted
inserted
replaced
439:357dd071b03c | 440:8de8e3f6228a |
---|---|
792 (setq filename | 792 (setq filename |
793 (concat (cdr (car tail)) (substring filename (match-end 0))))) | 793 (concat (cdr (car tail)) (substring filename (match-end 0))))) |
794 (setq tail (cdr tail)))) | 794 (setq tail (cdr tail)))) |
795 (when hack-homedir | 795 (when hack-homedir |
796 ;; Compute and save the abbreviated homedir name. | 796 ;; Compute and save the abbreviated homedir name. |
797 ;; We defer computing this until the first time it's needed, to | 797 ;; We defer computing this until the first time it's needed, |
798 ;; give time for directory-abbrev-alist to be set properly. | 798 ;; to give time for directory-abbrev-alist to be set properly. |
799 ;; We include a slash at the end, to avoid spurious matches | 799 ;; We include the separator at the end, to avoid spurious |
800 ;; such as `/usr/foobar' when the home dir is `/usr/foo'. | 800 ;; matches such as `/usr/foobar' when the home dir is |
801 ;; `/usr/foo'. | |
801 (or abbreviated-home-dir | 802 (or abbreviated-home-dir |
802 (setq abbreviated-home-dir | 803 (setq abbreviated-home-dir |
803 (let ((abbreviated-home-dir "$foo")) | 804 (let ((abbreviated-home-dir "$foo")) |
804 (concat "\\`" (regexp-quote (abbreviate-file-name | 805 (concat "\\`" |
805 (expand-file-name "~"))) | 806 (regexp-quote |
806 "\\(/\\|\\'\\)")))) | 807 (abbreviate-file-name (expand-file-name "~"))) |
808 "\\(" | |
809 (regexp-quote (string directory-sep-char)) | |
810 "\\|\\'\\)")))) | |
807 ;; If FILENAME starts with the abbreviated homedir, | 811 ;; If FILENAME starts with the abbreviated homedir, |
808 ;; make it start with `~' instead. | 812 ;; make it start with `~' instead. |
809 (if (and (string-match abbreviated-home-dir filename) | 813 (if (and (string-match abbreviated-home-dir filename) |
810 ;; If the home dir is just /, don't change it. | 814 ;; If the home dir is just /, don't change it. |
811 (not (and (= (match-end 0) 1) ;#### unix-specific | 815 (not (and (= (match-end 0) 1) |
812 (= (aref filename 0) ?/))) | 816 (= (aref filename 0) directory-sep-char))) |
813 (not (and (memq system-type '(ms-dos windows-nt)) | 817 (not (and (eq system-type 'windows-nt) |
814 (save-match-data | 818 (save-match-data |
815 (string-match "^[a-zA-Z]:/$" filename))))) | 819 (string-match (concat "\\`[a-zA-Z]:" |
820 (regexp-quote | |
821 (string directory-sep-char)) | |
822 "\\'") | |
823 filename))))) | |
816 (setq filename | 824 (setq filename |
817 (concat "~" | 825 (concat "~" |
818 (substring filename | 826 (match-string 1 filename) |
819 (match-beginning 1) (match-end 1)) | |
820 (substring filename (match-end 0)))))) | 827 (substring filename (match-end 0)))))) |
821 filename))) | 828 filename))) |
822 | 829 |
823 (defcustom find-file-not-true-dirname-list nil | 830 (defcustom find-file-not-true-dirname-list nil |
824 "*List of logical names for which visiting shouldn't save the true dirname." | 831 "*List of logical names for which visiting shouldn't save the true dirname." |
1310 (keep-going t)) | 1317 (keep-going t)) |
1311 (while keep-going | 1318 (while keep-going |
1312 (setq keep-going nil) | 1319 (setq keep-going nil) |
1313 (let ((alist auto-mode-alist) | 1320 (let ((alist auto-mode-alist) |
1314 (mode nil)) | 1321 (mode nil)) |
1322 | |
1315 ;; Find first matching alist entry. | 1323 ;; Find first matching alist entry. |
1324 | |
1325 ;; #### This is incorrect. In NT, case sensitivity is a volume | |
1326 ;; property. For instance, NFS mounts *are* case sensitive. | |
1327 ;; Need internal function (file-name-case-sensitive f), F | |
1328 ;; being file or directory name. - kkm | |
1316 (let ((case-fold-search | 1329 (let ((case-fold-search |
1317 (memq system-type '(windows-nt)))) | 1330 (eq system-type 'windows-nt))) |
1318 (while (and (not mode) alist) | 1331 (while (and (not mode) alist) |
1319 (if (string-match (car (car alist)) name) | 1332 (if (string-match (car (car alist)) name) |
1320 (if (and (consp (cdr (car alist))) | 1333 (if (and (consp (cdr (car alist))) |
1321 (nth 2 (car alist))) | 1334 (nth 2 (car alist))) |
1322 (progn | 1335 (progn |
1870 (if backup-info | 1883 (if backup-info |
1871 (condition-case () | 1884 (condition-case () |
1872 (let ((delete-old-versions | 1885 (let ((delete-old-versions |
1873 ;; If have old versions to maybe delete, | 1886 ;; If have old versions to maybe delete, |
1874 ;; ask the user to confirm now, before doing anything. | 1887 ;; ask the user to confirm now, before doing anything. |
1875 ;; But don't actually delete til later. | 1888 ;; But don't actually delete till later. |
1876 (and targets | 1889 (and targets |
1877 (or (eq delete-old-versions t) | 1890 (or (eq delete-old-versions t) |
1878 (eq delete-old-versions nil)) | 1891 (eq delete-old-versions nil)) |
1879 (or delete-old-versions | 1892 (or delete-old-versions |
1880 (y-or-n-p (format "Delete excess backup versions of %s? " | 1893 (y-or-n-p (format "Delete excess backup versions of %s? " |
1988 ""))))) | 2001 ""))))) |
1989 | 2002 |
1990 (defun make-backup-file-name (file) | 2003 (defun make-backup-file-name (file) |
1991 "Create the non-numeric backup file name for FILE. | 2004 "Create the non-numeric backup file name for FILE. |
1992 This is a separate function so you can redefine it for customization." | 2005 This is a separate function so you can redefine it for customization." |
1993 (if (eq system-type 'ms-dos) | 2006 (concat file "~")) |
1994 (let ((fn (file-name-nondirectory file))) | |
1995 (concat (file-name-directory file) | |
1996 (if (string-match "\\([^.]*\\)\\(\\..*\\)?" fn) | |
1997 (substring fn 0 (match-end 1))) | |
1998 ".bak")) | |
1999 (concat file "~"))) | |
2000 | 2007 |
2001 (defun backup-file-name-p (file) | 2008 (defun backup-file-name-p (file) |
2002 "Return non-nil if FILE is a backup file name (numeric or not). | 2009 "Return non-nil if FILE is a backup file name (numeric or not). |
2003 This is a separate function so you can redefine it for customization. | 2010 This is a separate function so you can redefine it for customization. |
2004 You may need to redefine `file-name-sans-versions' as well." | 2011 You may need to redefine `file-name-sans-versions' as well." |
2005 (if (eq system-type 'ms-dos) | 2012 (string-match "~\\'" file)) |
2006 (string-match "\\.bak\\'" file) | |
2007 (string-match "~\\'" file))) | |
2008 | 2013 |
2009 ;; This is used in various files. | 2014 ;; This is used in various files. |
2010 ;; The usage of bv-length is not very clean, | 2015 ;; The usage of bv-length is not very clean, |
2011 ;; but I can't see a good alternative, | 2016 ;; but I can't see a good alternative, |
2012 ;; so as of now I am leaving it alone. | 2017 ;; so as of now I am leaving it alone. |
2082 (let ((fname (expand-file-name filename))) | 2087 (let ((fname (expand-file-name filename))) |
2083 (setq directory (file-name-as-directory | 2088 (setq directory (file-name-as-directory |
2084 (expand-file-name (or directory default-directory)))) | 2089 (expand-file-name (or directory default-directory)))) |
2085 ;; On Microsoft OSes, if FILENAME and DIRECTORY have different | 2090 ;; On Microsoft OSes, if FILENAME and DIRECTORY have different |
2086 ;; drive names, they can't be relative, so return the absolute name. | 2091 ;; drive names, they can't be relative, so return the absolute name. |
2087 (if (and (memq system-type '(ms-dos windows-nt)) | 2092 (if (and (eq system-type 'windows-nt) |
2088 (not (string-equal (substring fname 0 2) | 2093 (not (string-equal (substring fname 0 2) |
2089 (substring directory 0 2)))) | 2094 (substring directory 0 2)))) |
2090 filename | 2095 filename |
2091 (let ((ancestor ".") | 2096 (let ((ancestor ".") |
2092 (fname-dir (file-name-as-directory fname))) | 2097 (fname-dir (file-name-as-directory fname))) |
2683 (setq found t))))) | 2688 (setq found t))))) |
2684 (yes-or-no-p (format "Revert buffer from file %s? " | 2689 (yes-or-no-p (format "Revert buffer from file %s? " |
2685 file-name))) | 2690 file-name))) |
2686 (run-hooks 'before-revert-hook) | 2691 (run-hooks 'before-revert-hook) |
2687 ;; If file was backed up but has changed since, | 2692 ;; If file was backed up but has changed since, |
2688 ;; we shd make another backup. | 2693 ;; we should make another backup. |
2689 (and (not auto-save-p) | 2694 (and (not auto-save-p) |
2690 (not (verify-visited-file-modtime (current-buffer))) | 2695 (not (verify-visited-file-modtime (current-buffer))) |
2691 (setq buffer-backed-up nil)) | 2696 (setq buffer-backed-up nil)) |
2692 ;; Get rid of all undo records for this buffer. | 2697 ;; Get rid of all undo records for this buffer. |
2693 (or (eq buffer-undo-list t) | 2698 (or (eq buffer-undo-list t) |
3134 'insert-directory))) | 3139 'insert-directory))) |
3135 (if handler | 3140 (if handler |
3136 (funcall handler 'insert-directory file switches | 3141 (funcall handler 'insert-directory file switches |
3137 wildcard full-directory-p) | 3142 wildcard full-directory-p) |
3138 (cond | 3143 (cond |
3144 ;; #### mswindows-insert-directory should be called | |
3145 ;; nt-insert-directory - kkm. | |
3139 ((and (fboundp 'mswindows-insert-directory) | 3146 ((and (fboundp 'mswindows-insert-directory) |
3140 (eq system-type 'windows-nt)) | 3147 (eq system-type 'windows-nt)) |
3141 (mswindows-insert-directory file switches wildcard full-directory-p)) | 3148 (mswindows-insert-directory file switches wildcard full-directory-p)) |
3142 (t | 3149 (t |
3143 (if wildcard | 3150 (if wildcard |