aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Blandy1992-11-20 17:23:45 +0000
committerJim Blandy1992-11-20 17:23:45 +0000
commitc4ae7096b6ea185a527cd02cdf19d314ad2aecb6 (patch)
tree855387af7942bb61de87a0fe6d21936086d17eb1
parent397587eeb55a24d971a6669ef4ce2c87ed430284 (diff)
downloademacs-c4ae7096b6ea185a527cd02cdf19d314ad2aecb6.tar.gz
emacs-c4ae7096b6ea185a527cd02cdf19d314ad2aecb6.zip
Thu Nov 19 16:44:24 1992 Jim Blandy (jimb@totoro.cs.oberlin.edu)
* vc.el (vc-next-action): Pass t as NOQUERY argument to vc-resynch-window here too. This means that all uses of vc-resynch-window pass t; I'm going to wait until I understand the situation better before I rip out the NOQUERY argument altogether. * vc.el (vc-revert-buffer1): Try to preserve the position of mark as well as point. (vc-position-context, vc-find-position-by-context): New functions to help with that, made out of the old innards of vc-revert-buffer1.
-rw-r--r--lisp/vc.el65
1 files changed, 40 insertions, 25 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index b595b85ea8f..f3d8d37d2aa 100644
--- a/lisp/vc.el
+++ b/lisp/vc.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: 4.0 6;; Version: 4.0
7 7
8;; $Id: vc.el,v 1.15 1992/10/28 09:33:04 rms Exp rms $ 8;; $Id: vc.el,v 1.16 1992/11/08 18:58:17 rms Exp jimb $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -187,36 +187,51 @@ the master name of FILE; this is appended to an optional list of FLAGS."
187 status) 187 status)
188 ) 188 )
189 189
190;;; Save a bit of the text around POSN in the current buffer, to help
191;;; us find the corresponding position again later. This works even
192;;; if all markers are destroyed or corrupted.
193(defun vc-position-context (posn)
194 (list posn
195 (buffer-size)
196 (buffer-substring posn
197 (min (point-max) (+ posn 100)))))
198
199;;; Return the position of CONTEXT in the current buffer, or nil if we
200;;; couldn't find it.
201(defun vc-find-position-by-context (context)
202 (let ((context-string (nth 2 context)))
203 (if (equal "" context-string)
204 (point-max)
205 (save-excursion
206 (let ((diff (- (nth 1 context) (buffer-size))))
207 (if (< diff 0) (setq diff (- diff)))
208 (goto-char (nth 0 context))
209 (if (or (search-forward context-string nil t)
210 ;; Can't use search-backward since the match may continue
211 ;; after point.
212 (progn (goto-char (- (point) diff (length context-string)))
213 ;; goto-char doesn't signal an error at
214 ;; beginning of buffer like backward-char would
215 (search-forward context-string nil t)))
216 ;; to beginning of OSTRING
217 (- (point) (length context-string))))))))
218
190(defun vc-revert-buffer1 (&optional arg no-confirm) 219(defun vc-revert-buffer1 (&optional arg no-confirm)
191 ;; This code was shamelessly lifted from Sebastian Kremer's rcs.el mode. 220 ;; This code was shamelessly lifted from Sebastian Kremer's rcs.el mode.
192 ;; Revert buffer, try to keep point where user expects it in spite 221 ;; Revert buffer, try to keep point and mark where user expects them in spite
193 ;; of changes because of expanded version-control key words. 222 ;; of changes because of expanded version-control key words.
194 ;; This is quite important since otherwise typeahead won't work as expected. 223 ;; This is quite important since otherwise typeahead won't work as expected.
195 (interactive "P") 224 (interactive "P")
196 (widen) 225 (widen)
197 (let* ((opoint (point)) 226 (let ((point-context (vc-position-context (point)))
198 (osize (buffer-size)) 227 (mark-context (if (mark) (vc-position-context (mark)))))
199 diff
200 (context 100)
201 (ostring (buffer-substring (point)
202 (min (point-max)
203 (+ (point) context))))
204 (l (length ostring)))
205 (revert-buffer arg no-confirm) 228 (revert-buffer arg no-confirm)
206 (setq diff (- osize (buffer-size))) 229 (let ((new-point (vc-find-position-by-context point-context)))
207 (if (< diff 0) (setq diff (- diff))) 230 (if new-point (goto-char new-point)))
208 (goto-char opoint) 231 (if mark-context
209 (cond ((equal "" ostring) 232 (let ((new-mark (vc-find-position-by-context mark-context)))
210 (goto-char (point-max))) 233 (if new-mark (set-mark new-mark))))))
211 ((or (search-forward ostring nil t) 234
212 ;; Can't use search-backward since the match may continue
213 ;; after point.
214 (progn (goto-char (- (point) diff l))
215 ;; goto-char doesn't signal an error at
216 ;; beginning of buffer like backward-char would
217 (search-forward ostring nil t)))
218 ;; to beginning of OSTRING
219 (backward-char l)))))
220 235
221(defun vc-buffer-sync () 236(defun vc-buffer-sync ()
222 ;; Make sure the current buffer and its working file are in sync 237 ;; Make sure the current buffer and its working file are in sync
@@ -304,7 +319,7 @@ the option to steal the lock."
304 (not (buffer-modified-p))) 319 (not (buffer-modified-p)))
305 (progn 320 (progn
306 (vc-backend-revert file) 321 (vc-backend-revert file)
307 (vc-resynch-window file t)) 322 (vc-resynch-window file t t))
308 323
309 ;; user may want to set nonstandard parameters 324 ;; user may want to set nonstandard parameters
310 (if verbose 325 (if verbose