diff options
| author | Richard M. Stallman | 1997-05-10 05:44:56 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-05-10 05:44:56 +0000 |
| commit | e2b307720fe09759adfb2b880b39022b80a0e644 (patch) | |
| tree | 3467d50ad4aa815738b734572f17f22496d8a18f | |
| parent | afbd0a53acb80d33aac22202a886c0e6471c979d (diff) | |
| download | emacs-e2b307720fe09759adfb2b880b39022b80a0e644.tar.gz emacs-e2b307720fe09759adfb2b880b39022b80a0e644.zip | |
(backup-extract-version-start): New variable.
(find-backup-file-namem, backup-extract-version):
Rename bv-length to backup-extract-version-start.
(file-relative-name): Bind the variable fname.
| -rw-r--r-- | lisp/files.el | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lisp/files.el b/lisp/files.el index 2a58cb5536b..4d0e17b48f6 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1904,17 +1904,19 @@ This is a separate function so you can redefine it for customization. | |||
| 1904 | You may need to redefine `file-name-sans-versions' as well." | 1904 | You may need to redefine `file-name-sans-versions' as well." |
| 1905 | (string-match "~\\'" file)) | 1905 | (string-match "~\\'" file)) |
| 1906 | 1906 | ||
| 1907 | (defvar backup-extract-version-start) | ||
| 1908 | |||
| 1907 | ;; This is used in various files. | 1909 | ;; This is used in various files. |
| 1908 | ;; The usage of bv-length is not very clean, | 1910 | ;; The usage of bv-length is not very clean, |
| 1909 | ;; but I can't see a good alternative, | 1911 | ;; but I can't see a good alternative, |
| 1910 | ;; so as of now I am leaving it alone. | 1912 | ;; so as of now I am leaving it alone. |
| 1911 | (defun backup-extract-version (fn) | 1913 | (defun backup-extract-version (fn) |
| 1912 | "Given the name of a numeric backup file, return the backup number. | 1914 | "Given the name of a numeric backup file, return the backup number. |
| 1913 | Uses the free variable `bv-length', whose value should be | 1915 | Uses the free variable `backup-extract-version-start', whose value should be |
| 1914 | the index in the name where the version number begins." | 1916 | the index in the name where the version number begins." |
| 1915 | (if (and (string-match "[0-9]+~$" fn bv-length) | 1917 | (if (and (string-match "[0-9]+~$" fn backup-extract-version-start) |
| 1916 | (= (match-beginning 0) bv-length)) | 1918 | (= (match-beginning 0) backup-extract-version-start)) |
| 1917 | (string-to-int (substring fn bv-length -1)) | 1919 | (string-to-int (substring fn backup-extract-version-start -1)) |
| 1918 | 0)) | 1920 | 0)) |
| 1919 | 1921 | ||
| 1920 | ;; I believe there is no need to alter this behavior for VMS; | 1922 | ;; I believe there is no need to alter this behavior for VMS; |
| @@ -1931,7 +1933,7 @@ If the value is nil, don't make a backup." | |||
| 1931 | (if (eq version-control 'never) | 1933 | (if (eq version-control 'never) |
| 1932 | (list (make-backup-file-name fn)) | 1934 | (list (make-backup-file-name fn)) |
| 1933 | (let* ((base-versions (concat (file-name-nondirectory fn) ".~")) | 1935 | (let* ((base-versions (concat (file-name-nondirectory fn) ".~")) |
| 1934 | (bv-length (length base-versions)) | 1936 | (backup-extract-version-start (length base-versions)) |
| 1935 | possibilities | 1937 | possibilities |
| 1936 | (versions nil) | 1938 | (versions nil) |
| 1937 | (high-water-mark 0) | 1939 | (high-water-mark 0) |
| @@ -1977,21 +1979,21 @@ If this is impossible (which can happen on MSDOS and Windows | |||
| 1977 | when the file name and directory use different drive names) | 1979 | when the file name and directory use different drive names) |
| 1978 | then it returns FILENAME." | 1980 | then it returns FILENAME." |
| 1979 | (save-match-data | 1981 | (save-match-data |
| 1980 | (setq fname (expand-file-name filename) | 1982 | (let ((fname (expand-file-name filename))) |
| 1981 | directory (file-name-as-directory | 1983 | (setq directory (file-name-as-directory |
| 1982 | (expand-file-name (or directory default-directory)))) | 1984 | (expand-file-name (or directory default-directory)))) |
| 1983 | ;; On Microsoft OSes, if FILENAME and DIRECTORY have different | 1985 | ;; On Microsoft OSes, if FILENAME and DIRECTORY have different |
| 1984 | ;; drive names, they can't be relative, so return the absolute name. | 1986 | ;; drive names, they can't be relative, so return the absolute name. |
| 1985 | (if (and (or (eq system-type 'ms-dos) | 1987 | (if (and (or (eq system-type 'ms-dos) |
| 1986 | (eq system-type 'windows-nt)) | 1988 | (eq system-type 'windows-nt)) |
| 1987 | (not (string-equal (substring fname 0 2) | 1989 | (not (string-equal (substring fname 0 2) |
| 1988 | (substring directory 0 2)))) | 1990 | (substring directory 0 2)))) |
| 1989 | filename | 1991 | filename |
| 1990 | (let ((ancestor "")) | 1992 | (let ((ancestor "")) |
| 1991 | (while (not (string-match (concat "^" (regexp-quote directory)) fname)) | 1993 | (while (not (string-match (concat "^" (regexp-quote directory)) fname)) |
| 1992 | (setq directory (file-name-directory (substring directory 0 -1)) | 1994 | (setq directory (file-name-directory (substring directory 0 -1)) |
| 1993 | ancestor (concat "../" ancestor))) | 1995 | ancestor (concat "../" ancestor))) |
| 1994 | (concat ancestor (substring fname (match-end 0))))))) | 1996 | (concat ancestor (substring fname (match-end 0)))))))) |
| 1995 | 1997 | ||
| 1996 | (defun save-buffer (&optional args) | 1998 | (defun save-buffer (&optional args) |
| 1997 | "Save current buffer in visited file if modified. Versions described below. | 1999 | "Save current buffer in visited file if modified. Versions described below. |