diff options
| author | Paul Eggert | 1993-03-16 20:21:05 +0000 |
|---|---|---|
| committer | Paul Eggert | 1993-03-16 20:21:05 +0000 |
| commit | 18c8a18effe313f22c8de3350268c0825146172c (patch) | |
| tree | 75e1e77665aaa4d0ff574d76793b717bd2f565a7 /lisp | |
| parent | 2e94b813469ad3d55695c3fda31026bbdb899db5 (diff) | |
| download | emacs-18c8a18effe313f22c8de3350268c0825146172c.tar.gz emacs-18c8a18effe313f22c8de3350268c0825146172c.zip | |
Merge today's change by eric with everybody else's
change (from 1992/08/04 through 1993/02/24).
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/vc-hooks.el | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index accb7cabc67..e2f6aa2bbe0 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> | 5 | ;; Author: Eric S. Raymond <esr@snark.thyrsus.com> |
| 6 | ;; Version: 5.0 | 6 | ;; Version: 5.0 |
| 7 | 7 | ||
| 8 | ;; $Id: vc-hooks.el,v 1.48 1993/03/15 21:42:57 esr Exp $ | 8 | ;; $Id: vc-hooks.el,v 1.8.1.1 1993/03/16 20:17:07 eggert Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -68,29 +68,40 @@ the make-backup-files variable. Otherwise, prevents backups being made.") | |||
| 68 | ;;; actual version-control code starts here | 68 | ;;; actual version-control code starts here |
| 69 | 69 | ||
| 70 | (defun vc-registered (file) | 70 | (defun vc-registered (file) |
| 71 | ;; Search for a master corresponding to the given file | 71 | (let (handler handlers) |
| 72 | (let ((dirname (or (file-name-directory file) "")) | 72 | (if (boundp 'file-name-handler-alist) |
| 73 | (basename (file-name-nondirectory file))) | 73 | (save-match-data |
| 74 | (catch 'found | 74 | (setq handlers file-name-handler-alist) |
| 75 | (mapcar | 75 | (while (and (consp handlers) (null handler)) |
| 76 | (function (lambda (s) | 76 | (if (and (consp (car handlers)) |
| 77 | (let ((trial (format (car s) dirname basename))) | 77 | (stringp (car (car handlers))) |
| 78 | (if (and (file-exists-p trial) | 78 | (string-match (car (car handlers)) file)) |
| 79 | ;; Make sure the file we found with name | 79 | (setq handler (cdr (car handlers)))) |
| 80 | ;; TRIAL is not the source file itself. | 80 | (setq handlers (cdr handlers))))) |
| 81 | ;; That can happen with RCS-style names | 81 | (if handler |
| 82 | ;; if the file name is truncated | 82 | (funcall handler 'vc-registered file) |
| 83 | ;; (e.g. to 14 chars). See if either | 83 | ;; Search for a master corresponding to the given file |
| 84 | ;; directory or attributes differ. | 84 | (let ((dirname (or (file-name-directory file) "")) |
| 85 | (or (not (string= dirname | 85 | (basename (file-name-nondirectory file))) |
| 86 | (file-name-directory trial))) | 86 | (catch 'found |
| 87 | (not (equal | 87 | (mapcar |
| 88 | (file-attributes file) | 88 | (function (lambda (s) |
| 89 | (file-attributes trial))))) | 89 | (let ((trial (format (car s) dirname basename))) |
| 90 | (throw 'found (cons trial (cdr s))))))) | 90 | (if (and (file-exists-p trial) |
| 91 | vc-master-templates) | 91 | ;; Make sure the file we found with name |
| 92 | nil) | 92 | ;; TRIAL is not the source file itself. |
| 93 | )) | 93 | ;; That can happen with RCS-style names |
| 94 | ;; if the file name is truncated | ||
| 95 | ;; (e.g. to 14 chars). See if either | ||
| 96 | ;; directory or attributes differ. | ||
| 97 | (or (not (string= dirname | ||
| 98 | (file-name-directory trial))) | ||
| 99 | (not (equal | ||
| 100 | (file-attributes file) | ||
| 101 | (file-attributes trial))))) | ||
| 102 | (throw 'found (cons trial (cdr s))))))) | ||
| 103 | vc-master-templates) | ||
| 104 | nil))))) | ||
| 94 | 105 | ||
| 95 | (defun vc-backend-deduce (file) | 106 | (defun vc-backend-deduce (file) |
| 96 | "Return the version-control type of a file, nil if it is not registered" | 107 | "Return the version-control type of a file, nil if it is not registered" |
| @@ -99,7 +110,7 @@ the make-backup-files variable. Otherwise, prevents backups being made.") | |||
| 99 | (vc-file-setprop file 'vc-backend (cdr (vc-registered file)))))) | 110 | (vc-file-setprop file 'vc-backend (cdr (vc-registered file)))))) |
| 100 | 111 | ||
| 101 | (defun vc-toggle-read-only () | 112 | (defun vc-toggle-read-only () |
| 102 | "If the file in the current buffer id under version control, perform the | 113 | "If the file in the current buffer is under version control, perform the |
| 103 | logical next version-control action; otherwise, just toggle the buffer's | 114 | logical next version-control action; otherwise, just toggle the buffer's |
| 104 | read-only flag." | 115 | read-only flag." |
| 105 | (interactive) | 116 | (interactive) |
| @@ -111,6 +122,7 @@ read-only flag." | |||
| 111 | "Set `vc-mode-string' to display type of version control for FILE. | 122 | "Set `vc-mode-string' to display type of version control for FILE. |
| 112 | The value is set in the current buffer, which should be the buffer | 123 | The value is set in the current buffer, which should be the buffer |
| 113 | visiting FILE." | 124 | visiting FILE." |
| 125 | (interactive (list buffer-file-name nil)) | ||
| 114 | (let ((vc-type (vc-backend-deduce file))) | 126 | (let ((vc-type (vc-backend-deduce file))) |
| 115 | (if vc-type | 127 | (if vc-type |
| 116 | (progn | 128 | (progn |
| @@ -125,6 +137,9 @@ visiting FILE." | |||
| 125 | 137 | ||
| 126 | ;;; install a call to the above as a find-file hook | 138 | ;;; install a call to the above as a find-file hook |
| 127 | (defun vc-find-file-hook () | 139 | (defun vc-find-file-hook () |
| 140 | ;; Recompute whether file is version controlled, | ||
| 141 | ;; if user has killed the buffer and revisited. | ||
| 142 | (vc-file-setprop buffer-file-name 'vc-backend nil) | ||
| 128 | (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files)) | 143 | (if (and (vc-mode-line buffer-file-name) (not vc-make-backup-files)) |
| 129 | (progn | 144 | (progn |
| 130 | (make-local-variable 'make-backup-files) | 145 | (make-local-variable 'make-backup-files) |
| @@ -158,7 +173,7 @@ Returns t if checkout was successful, nil otherwise." | |||
| 158 | (define-key global-map "\C-xv" vc-prefix-map) | 173 | (define-key global-map "\C-xv" vc-prefix-map) |
| 159 | (define-key vc-prefix-map "a" 'vc-update-change-log) | 174 | (define-key vc-prefix-map "a" 'vc-update-change-log) |
| 160 | (define-key vc-prefix-map "c" 'vc-cancel-version) | 175 | (define-key vc-prefix-map "c" 'vc-cancel-version) |
| 161 | (define-key vc-prefix-map "=" 'vc-diff) | 176 | (define-key vc-prefix-map "d" 'vc-directory) |
| 162 | (define-key vc-prefix-map "h" 'vc-insert-headers) | 177 | (define-key vc-prefix-map "h" 'vc-insert-headers) |
| 163 | (define-key vc-prefix-map "i" 'vc-register) | 178 | (define-key vc-prefix-map "i" 'vc-register) |
| 164 | (define-key vc-prefix-map "l" 'vc-print-log) | 179 | (define-key vc-prefix-map "l" 'vc-print-log) |
| @@ -166,10 +181,9 @@ Returns t if checkout was successful, nil otherwise." | |||
| 166 | (define-key vc-prefix-map "s" 'vc-create-snapshot) | 181 | (define-key vc-prefix-map "s" 'vc-create-snapshot) |
| 167 | (define-key vc-prefix-map "u" 'vc-revert-buffer) | 182 | (define-key vc-prefix-map "u" 'vc-revert-buffer) |
| 168 | (define-key vc-prefix-map "v" 'vc-next-action) | 183 | (define-key vc-prefix-map "v" 'vc-next-action) |
| 169 | (define-key vc-prefix-map "d" 'vc-directory) | 184 | (define-key vc-prefix-map "=" 'vc-diff) |
| 170 | )) | 185 | )) |
| 171 | 186 | ||
| 172 | (provide 'vc-hooks) | 187 | (provide 'vc-hooks) |
| 173 | 188 | ||
| 174 | ;;; vc-hooks.el ends here | 189 | ;;; vc-hooks.el ends here |
| 175 | |||