aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond2008-05-03 10:18:08 +0000
committerEric S. Raymond2008-05-03 10:18:08 +0000
commit17f039f312eba0f304a33abd7890328a02417fd4 (patch)
treea3e1a9e65dbd437eb567c850712470515aac1186
parent7412d4290304cd6debddc704fa4a758687587d4c (diff)
downloademacs-17f039f312eba0f304a33abd7890328a02417fd4.tar.gz
emacs-17f039f312eba0f304a33abd7890328a02417fd4.zip
Move context-preservation machinery.
-rw-r--r--lisp/vc-dispatcher.el203
-rw-r--r--lisp/vc.el241
2 files changed, 199 insertions, 245 deletions
diff --git a/lisp/vc-dispatcher.el b/lisp/vc-dispatcher.el
index 16fd17a1467..0fc1c0636d5 100644
--- a/lisp/vc-dispatcher.el
+++ b/lisp/vc-dispatcher.el
@@ -85,7 +85,21 @@ version control backend imposes itself."
85 :type 'hook 85 :type 'hook
86 :group 'vc) 86 :group 'vc)
87 87
88(defcustom vc-delete-logbuf-window t
89 "If non-nil, delete the *VC-log* buffer and window after each logical action.
90If nil, bury that buffer instead.
91This is most useful if you have multiple windows on a frame and would like to
92preserve the setting."
93 :type 'boolean
94 :group 'vc)
95
96(defcustom vc-command-messages nil
97 "If non-nil, display run messages from back-end commands."
98 :type 'boolean
99 :group 'vc)
100
88;; Variables the user doesn't need to know about. 101;; Variables the user doesn't need to know about.
102
89(defvar vc-log-operation nil) 103(defvar vc-log-operation nil)
90(defvar vc-log-after-operation-hook nil) 104(defvar vc-log-after-operation-hook nil)
91(defvar vc-log-fileset) 105(defvar vc-log-fileset)
@@ -310,6 +324,187 @@ that is inserted into the command line before the filename."
310 ',command ',file-or-list ',flags)) 324 ',command ',file-or-list ',flags))
311 status)))) 325 status))))
312 326
327;; These functions are used to ensure that the view the user sees is up to date
328;; even if the dispatcher client mode has messed with file contents (as in,
329;; for example, VCS keyword expansion).
330
331(declare-function view-mode-exit "view" (&optional return-to-alist exit-action all-win))
332
333(defun vc-position-context (posn)
334 "Save a bit of the text around POSN in the current buffer.
335Used to help us find the corresponding position again later
336if markers are destroyed or corrupted."
337 ;; A lot of this was shamelessly lifted from Sebastian Kremer's
338 ;; rcs.el mode.
339 (list posn
340 (buffer-size)
341 (buffer-substring posn
342 (min (point-max) (+ posn 100)))))
343
344(defun vc-find-position-by-context (context)
345 "Return the position of CONTEXT in the current buffer.
346If CONTEXT cannot be found, return nil."
347 (let ((context-string (nth 2 context)))
348 (if (equal "" context-string)
349 (point-max)
350 (save-excursion
351 (let ((diff (- (nth 1 context) (buffer-size))))
352 (when (< diff 0) (setq diff (- diff)))
353 (goto-char (nth 0 context))
354 (if (or (search-forward context-string nil t)
355 ;; Can't use search-backward since the match may continue
356 ;; after point.
357 (progn (goto-char (- (point) diff (length context-string)))
358 ;; goto-char doesn't signal an error at
359 ;; beginning of buffer like backward-char would
360 (search-forward context-string nil t)))
361 ;; to beginning of OSTRING
362 (- (point) (length context-string))))))))
363
364(defun vc-context-matches-p (posn context)
365 "Return t if POSN matches CONTEXT, nil otherwise."
366 (let* ((context-string (nth 2 context))
367 (len (length context-string))
368 (end (+ posn len)))
369 (if (> end (1+ (buffer-size)))
370 nil
371 (string= context-string (buffer-substring posn end)))))
372
373(defun vc-buffer-context ()
374 "Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE).
375Used by `vc-restore-buffer-context' to later restore the context."
376 (let ((point-context (vc-position-context (point)))
377 ;; Use mark-marker to avoid confusion in transient-mark-mode.
378 (mark-context (when (eq (marker-buffer (mark-marker)) (current-buffer))
379 (vc-position-context (mark-marker))))
380 ;; Make the right thing happen in transient-mark-mode.
381 (mark-active nil)
382 ;; The new compilation code does not use compilation-error-list any
383 ;; more, so the code below is now ineffective and might as well
384 ;; be disabled. -- Stef
385 ;; ;; We may want to reparse the compilation buffer after revert
386 ;; (reparse (and (boundp 'compilation-error-list) ;compile loaded
387 ;; ;; Construct a list; each elt is nil or a buffer
388 ;; ;; if that buffer is a compilation output buffer
389 ;; ;; that contains markers into the current buffer.
390 ;; (save-current-buffer
391 ;; (mapcar (lambda (buffer)
392 ;; (set-buffer buffer)
393 ;; (let ((errors (or
394 ;; compilation-old-error-list
395 ;; compilation-error-list))
396 ;; (buffer-error-marked-p nil))
397 ;; (while (and (consp errors)
398 ;; (not buffer-error-marked-p))
399 ;; (and (markerp (cdr (car errors)))
400 ;; (eq buffer
401 ;; (marker-buffer
402 ;; (cdr (car errors))))
403 ;; (setq buffer-error-marked-p t))
404 ;; (setq errors (cdr errors)))
405 ;; (if buffer-error-marked-p buffer)))
406 ;; (buffer-list)))))
407 (reparse nil))
408 (list point-context mark-context reparse)))
409
410(defun vc-restore-buffer-context (context)
411 "Restore point/mark, and reparse any affected compilation buffers.
412CONTEXT is that which `vc-buffer-context' returns."
413 (let ((point-context (nth 0 context))
414 (mark-context (nth 1 context))
415 ;; (reparse (nth 2 context))
416 )
417 ;; The new compilation code does not use compilation-error-list any
418 ;; more, so the code below is now ineffective and might as well
419 ;; be disabled. -- Stef
420 ;; ;; Reparse affected compilation buffers.
421 ;; (while reparse
422 ;; (if (car reparse)
423 ;; (with-current-buffer (car reparse)
424 ;; (let ((compilation-last-buffer (current-buffer)) ;select buffer
425 ;; ;; Record the position in the compilation buffer of
426 ;; ;; the last error next-error went to.
427 ;; (error-pos (marker-position
428 ;; (car (car-safe compilation-error-list)))))
429 ;; ;; Reparse the error messages as far as they were parsed before.
430 ;; (compile-reinitialize-errors '(4) compilation-parsing-end)
431 ;; ;; Move the pointer up to find the error we were at before
432 ;; ;; reparsing. Now next-error should properly go to the next one.
433 ;; (while (and compilation-error-list
434 ;; (/= error-pos (car (car compilation-error-list))))
435 ;; (setq compilation-error-list (cdr compilation-error-list))))))
436 ;; (setq reparse (cdr reparse)))
437
438 ;; if necessary, restore point and mark
439 (if (not (vc-context-matches-p (point) point-context))
440 (let ((new-point (vc-find-position-by-context point-context)))
441 (when new-point (goto-char new-point))))
442 (and mark-active
443 mark-context
444 (not (vc-context-matches-p (mark) mark-context))
445 (let ((new-mark (vc-find-position-by-context mark-context)))
446 (when new-mark (set-mark new-mark))))))
447
448(defun vc-revert-buffer-internal (&optional arg no-confirm)
449 "Revert buffer, keeping point and mark where user expects them.
450Try to be clever in the face of changes due to expanded version-control
451key words. This is important for typeahead to work as expected.
452ARG and NO-CONFIRM are passed on to `revert-buffer'."
453 (interactive "P")
454 (widen)
455 (let ((context (vc-buffer-context)))
456 ;; Use save-excursion here, because it may be able to restore point
457 ;; and mark properly even in cases where vc-restore-buffer-context
458 ;; would fail. However, save-excursion might also get it wrong --
459 ;; in this case, vc-restore-buffer-context gives it a second try.
460 (save-excursion
461 ;; t means don't call normal-mode;
462 ;; that's to preserve various minor modes.
463 (revert-buffer arg no-confirm t))
464 (vc-restore-buffer-context context)))
465
466(defun vc-resynch-window (file &optional keep noquery)
467 "If FILE is in the current buffer, either revert or unvisit it.
468The choice between revert (to see expanded keywords) and unvisit
469depends on KEEP. NOQUERY if non-nil inhibits confirmation for
470reverting. NOQUERY should be t *only* if it is known the only
471difference between the buffer and the file is due to
472modifications by the dispatcher client code, rather than user
473editing!"
474 (and (string= buffer-file-name file)
475 (if keep
476 (progn
477 (vc-revert-buffer-internal t noquery)
478 ;; TODO: Adjusting view mode might no longer be necessary
479 ;; after RMS change to files.el of 1999-08-08. Investigate
480 ;; this when we install the new VC.
481 (and view-read-only
482 (if (file-writable-p file)
483 (and view-mode
484 (let ((view-old-buffer-read-only nil))
485 (view-mode-exit)))
486 (and (not view-mode)
487 (not (eq (get major-mode 'mode-class) 'special))
488 (view-mode-enter))))
489 ;; FIXME: Call into vc.el
490 (vc-mode-line buffer-file-name))
491 (kill-buffer (current-buffer)))))
492
493(defun vc-resynch-buffer (file &optional keep noquery)
494 "If FILE is currently visited, resynch its buffer."
495 (if (string= buffer-file-name file)
496 (vc-resynch-window file keep noquery)
497 (let ((buffer (get-file-buffer file)))
498 (when buffer
499 (with-current-buffer buffer
500 (vc-resynch-window file keep noquery)))))
501 ;; FIME: Call into vc.el
502 (vc-directory-resynch-file file)
503 (when (memq 'vc-dir-mark-buffer-changed after-save-hook)
504 (let ((buffer (get-file-buffer file)))
505 ;; FIME: Call into vc.el
506 (vc-dir-mark-buffer-changed file))))
507
313;; Command closures 508;; Command closures
314 509
315(defun vc-start-logentry (files extra comment initial-contents msg action &optional after-hook) 510(defun vc-start-logentry (files extra comment initial-contents msg action &optional after-hook)
@@ -331,18 +526,12 @@ for `vc-log-after-operation-hook'."
331 (if (and files (equal (length files) 1)) 526 (if (and files (equal (length files) 1))
332 (get-file-buffer (car files)) 527 (get-file-buffer (car files))
333 (current-buffer))))) 528 (current-buffer)))))
334 (when vc-before-checkin-hook
335 (if files
336 (with-current-buffer parent
337 (run-hooks 'vc-before-checkin-hook))
338 (run-hooks 'vc-before-checkin-hook)))
339 (if (and comment (not initial-contents)) 529 (if (and comment (not initial-contents))
340 (set-buffer (get-buffer-create "*VC-log*")) 530 (set-buffer (get-buffer-create "*VC-log*"))
341 (pop-to-buffer (get-buffer-create "*VC-log*"))) 531 (pop-to-buffer (get-buffer-create "*VC-log*")))
342 (set (make-local-variable 'vc-parent-buffer) parent) 532 (set (make-local-variable 'vc-parent-buffer) parent)
343 (set (make-local-variable 'vc-parent-buffer-name) 533 (set (make-local-variable 'vc-parent-buffer-name)
344 (concat " from " (buffer-name vc-parent-buffer))) 534 (concat " from " (buffer-name vc-parent-buffer)))
345 ;;(if file (vc-mode-line file))
346 (vc-log-edit files) 535 (vc-log-edit files)
347 (make-local-variable 'vc-log-after-operation-hook) 536 (make-local-variable 'vc-log-after-operation-hook)
348 (when after-hook 537 (when after-hook
@@ -401,11 +590,11 @@ the buffer contents as a comment."
401 (mapc 590 (mapc
402 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t)) 591 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t))
403 log-fileset)) 592 log-fileset))
593 ;; FIXME: Call into vc.el
404 (when vc-dired-mode 594 (when vc-dired-mode
405 (dired-move-to-filename)) 595 (dired-move-to-filename))
406 (when (eq major-mode 'vc-dir-mode) 596 (when (eq major-mode 'vc-dir-mode)
407 (vc-dir-move-to-goal-column)) 597 (vc-dir-move-to-goal-column))
408 (run-hooks after-hook 'vc-finish-logentry-hook))) 598 (run-hooks after-hook 'vc-finish-logentry-hook)))
409 599
410
411;;; vc-dispatcher.el ends here 600;;; vc-dispatcher.el ends here
diff --git a/lisp/vc.el b/lisp/vc.el
index f4bc6cb25df..76c7b3a2f64 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -714,14 +714,6 @@
714 :type 'boolean 714 :type 'boolean
715 :group 'vc) 715 :group 'vc)
716 716
717(defcustom vc-delete-logbuf-window t
718 "If non-nil, delete the *VC-log* buffer and window after each logical action.
719If nil, bury that buffer instead.
720This is most useful if you have multiple windows on a frame and would like to
721preserve the setting."
722 :type 'boolean
723 :group 'vc)
724
725(defcustom vc-initial-comment nil 717(defcustom vc-initial-comment nil
726 "If non-nil, prompt for initial comment when a file is registered." 718 "If non-nil, prompt for initial comment when a file is registered."
727 :type 'boolean 719 :type 'boolean
@@ -735,11 +727,6 @@ can also be overridden by a particular VC backend."
735 :group 'vc 727 :group 'vc
736 :version "20.3") 728 :version "20.3")
737 729
738(defcustom vc-command-messages nil
739 "If non-nil, display run messages from back-end commands."
740 :type 'boolean
741 :group 'vc)
742
743(defcustom vc-checkin-switches nil 730(defcustom vc-checkin-switches nil
744 "A string or list of strings specifying extra switches for checkin. 731 "A string or list of strings specifying extra switches for checkin.
745These are passed to the checkin program by \\[vc-checkin]." 732These are passed to the checkin program by \\[vc-checkin]."
@@ -1054,121 +1041,6 @@ However, before executing BODY, find FILE, and after BODY, save buffer."
1054 ,@body 1041 ,@body
1055 (save-buffer))))) 1042 (save-buffer)))))
1056 1043
1057(defun vc-position-context (posn)
1058 "Save a bit of the text around POSN in the current buffer.
1059Used to help us find the corresponding position again later
1060if markers are destroyed or corrupted."
1061 ;; A lot of this was shamelessly lifted from Sebastian Kremer's
1062 ;; rcs.el mode.
1063 (list posn
1064 (buffer-size)
1065 (buffer-substring posn
1066 (min (point-max) (+ posn 100)))))
1067
1068(defun vc-find-position-by-context (context)
1069 "Return the position of CONTEXT in the current buffer.
1070If CONTEXT cannot be found, return nil."
1071 (let ((context-string (nth 2 context)))
1072 (if (equal "" context-string)
1073 (point-max)
1074 (save-excursion
1075 (let ((diff (- (nth 1 context) (buffer-size))))
1076 (when (< diff 0) (setq diff (- diff)))
1077 (goto-char (nth 0 context))
1078 (if (or (search-forward context-string nil t)
1079 ;; Can't use search-backward since the match may continue
1080 ;; after point.
1081 (progn (goto-char (- (point) diff (length context-string)))
1082 ;; goto-char doesn't signal an error at
1083 ;; beginning of buffer like backward-char would
1084 (search-forward context-string nil t)))
1085 ;; to beginning of OSTRING
1086 (- (point) (length context-string))))))))
1087
1088(defun vc-context-matches-p (posn context)
1089 "Return t if POSN matches CONTEXT, nil otherwise."
1090 (let* ((context-string (nth 2 context))
1091 (len (length context-string))
1092 (end (+ posn len)))
1093 (if (> end (1+ (buffer-size)))
1094 nil
1095 (string= context-string (buffer-substring posn end)))))
1096
1097(defun vc-buffer-context ()
1098 "Return a list (POINT-CONTEXT MARK-CONTEXT REPARSE).
1099Used by `vc-restore-buffer-context' to later restore the context."
1100 (let ((point-context (vc-position-context (point)))
1101 ;; Use mark-marker to avoid confusion in transient-mark-mode.
1102 (mark-context (when (eq (marker-buffer (mark-marker)) (current-buffer))
1103 (vc-position-context (mark-marker))))
1104 ;; Make the right thing happen in transient-mark-mode.
1105 (mark-active nil)
1106 ;; The new compilation code does not use compilation-error-list any
1107 ;; more, so the code below is now ineffective and might as well
1108 ;; be disabled. -- Stef
1109 ;; ;; We may want to reparse the compilation buffer after revert
1110 ;; (reparse (and (boundp 'compilation-error-list) ;compile loaded
1111 ;; ;; Construct a list; each elt is nil or a buffer
1112 ;; ;; if that buffer is a compilation output buffer
1113 ;; ;; that contains markers into the current buffer.
1114 ;; (save-current-buffer
1115 ;; (mapcar (lambda (buffer)
1116 ;; (set-buffer buffer)
1117 ;; (let ((errors (or
1118 ;; compilation-old-error-list
1119 ;; compilation-error-list))
1120 ;; (buffer-error-marked-p nil))
1121 ;; (while (and (consp errors)
1122 ;; (not buffer-error-marked-p))
1123 ;; (and (markerp (cdr (car errors)))
1124 ;; (eq buffer
1125 ;; (marker-buffer
1126 ;; (cdr (car errors))))
1127 ;; (setq buffer-error-marked-p t))
1128 ;; (setq errors (cdr errors)))
1129 ;; (if buffer-error-marked-p buffer)))
1130 ;; (buffer-list)))))
1131 (reparse nil))
1132 (list point-context mark-context reparse)))
1133
1134(defun vc-restore-buffer-context (context)
1135 "Restore point/mark, and reparse any affected compilation buffers.
1136CONTEXT is that which `vc-buffer-context' returns."
1137 (let ((point-context (nth 0 context))
1138 (mark-context (nth 1 context))
1139 ;; (reparse (nth 2 context))
1140 )
1141 ;; The new compilation code does not use compilation-error-list any
1142 ;; more, so the code below is now ineffective and might as well
1143 ;; be disabled. -- Stef
1144 ;; ;; Reparse affected compilation buffers.
1145 ;; (while reparse
1146 ;; (if (car reparse)
1147 ;; (with-current-buffer (car reparse)
1148 ;; (let ((compilation-last-buffer (current-buffer)) ;select buffer
1149 ;; ;; Record the position in the compilation buffer of
1150 ;; ;; the last error next-error went to.
1151 ;; (error-pos (marker-position
1152 ;; (car (car-safe compilation-error-list)))))
1153 ;; ;; Reparse the error messages as far as they were parsed before.
1154 ;; (compile-reinitialize-errors '(4) compilation-parsing-end)
1155 ;; ;; Move the pointer up to find the error we were at before
1156 ;; ;; reparsing. Now next-error should properly go to the next one.
1157 ;; (while (and compilation-error-list
1158 ;; (/= error-pos (car (car compilation-error-list))))
1159 ;; (setq compilation-error-list (cdr compilation-error-list))))))
1160 ;; (setq reparse (cdr reparse)))
1161
1162 ;; if necessary, restore point and mark
1163 (if (not (vc-context-matches-p (point) point-context))
1164 (let ((new-point (vc-find-position-by-context point-context)))
1165 (when new-point (goto-char new-point))))
1166 (and mark-active
1167 mark-context
1168 (not (vc-context-matches-p (mark) mark-context))
1169 (let ((new-mark (vc-find-position-by-context mark-context)))
1170 (when new-mark (set-mark new-mark))))))
1171
1172;;; Code for deducing what fileset and backend to assume 1044;;; Code for deducing what fileset and backend to assume
1173 1045
1174(defun vc-responsible-backend (file &optional register) 1046(defun vc-responsible-backend (file &optional register)
@@ -1318,24 +1190,6 @@ Otherwise, throw an error."
1318 (or (eq (vc-checkout-model backend (list file)) 'implicit) 1190 (or (eq (vc-checkout-model backend (list file)) 'implicit)
1319 (memq (vc-state file) '(edited needs-merge conflict)))))) 1191 (memq (vc-state file) '(edited needs-merge conflict))))))
1320 1192
1321(defun vc-revert-buffer-internal (&optional arg no-confirm)
1322 "Revert buffer, keeping point and mark where user expects them.
1323Try to be clever in the face of changes due to expanded version-control
1324key words. This is important for typeahead to work as expected.
1325ARG and NO-CONFIRM are passed on to `revert-buffer'."
1326 (interactive "P")
1327 (widen)
1328 (let ((context (vc-buffer-context)))
1329 ;; Use save-excursion here, because it may be able to restore point
1330 ;; and mark properly even in cases where vc-restore-buffer-context
1331 ;; would fail. However, save-excursion might also get it wrong --
1332 ;; in this case, vc-restore-buffer-context gives it a second try.
1333 (save-excursion
1334 ;; t means don't call normal-mode;
1335 ;; that's to preserve various minor modes.
1336 (revert-buffer arg no-confirm t))
1337 (vc-restore-buffer-context context)))
1338
1339(defun vc-buffer-sync (&optional not-urgent) 1193(defun vc-buffer-sync (&optional not-urgent)
1340 "Make sure the current buffer and its working file are in sync. 1194 "Make sure the current buffer and its working file are in sync.
1341NOT-URGENT means it is ok to continue if the user says not to save." 1195NOT-URGENT means it is ok to continue if the user says not to save."
@@ -1639,46 +1493,6 @@ first backend that could register the file is used."
1639 (let ((vc-handled-backends (list backend))) 1493 (let ((vc-handled-backends (list backend)))
1640 (call-interactively 'vc-register))) 1494 (call-interactively 'vc-register)))
1641 1495
1642(declare-function view-mode-exit "view" (&optional return-to-alist exit-action all-win))
1643
1644(defun vc-resynch-window (file &optional keep noquery)
1645 "If FILE is in the current buffer, either revert or unvisit it.
1646The choice between revert (to see expanded keywords) and unvisit depends on
1647`vc-keep-workfiles'. NOQUERY if non-nil inhibits confirmation for
1648reverting. NOQUERY should be t *only* if it is known the only
1649difference between the buffer and the file is due to version control
1650rather than user editing!"
1651 (and (string= buffer-file-name file)
1652 (if keep
1653 (progn
1654 (vc-revert-buffer-internal t noquery)
1655 ;; TODO: Adjusting view mode might no longer be necessary
1656 ;; after RMS change to files.el of 1999-08-08. Investigate
1657 ;; this when we install the new VC.
1658 (and view-read-only
1659 (if (file-writable-p file)
1660 (and view-mode
1661 (let ((view-old-buffer-read-only nil))
1662 (view-mode-exit)))
1663 (and (not view-mode)
1664 (not (eq (get major-mode 'mode-class) 'special))
1665 (view-mode-enter))))
1666 (vc-mode-line buffer-file-name))
1667 (kill-buffer (current-buffer)))))
1668
1669(defun vc-resynch-buffer (file &optional keep noquery)
1670 "If FILE is currently visited, resynch its buffer."
1671 (if (string= buffer-file-name file)
1672 (vc-resynch-window file keep noquery)
1673 (let ((buffer (get-file-buffer file)))
1674 (when buffer
1675 (with-current-buffer buffer
1676 (vc-resynch-window file keep noquery)))))
1677 (vc-directory-resynch-file file)
1678 (when (memq 'vc-dir-mark-buffer-changed after-save-hook)
1679 (let ((buffer (get-file-buffer file)))
1680 (vc-dir-mark-buffer-changed file))))
1681
1682(defun vc-checkout (file &optional writable rev) 1496(defun vc-checkout (file &optional writable rev)
1683 "Retrieve a copy of the revision REV of FILE. 1497 "Retrieve a copy of the revision REV of FILE.
1684If WRITABLE is non-nil, make sure the retrieved file is writable. 1498If WRITABLE is non-nil, make sure the retrieved file is writable.
@@ -1755,7 +1569,9 @@ of the log entry buffer.
1755If `vc-keep-workfiles' is nil, FILE is deleted afterwards, provided 1569If `vc-keep-workfiles' is nil, FILE is deleted afterwards, provided
1756that the version control system supports this mode of operation. 1570that the version control system supports this mode of operation.
1757 1571
1758Runs the normal hook `vc-checkin-hook'." 1572Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'."
1573 (when vc-before-checkin-hook
1574 (run-hooks 'vc-before-checkin-hook))
1759 (vc-start-logentry 1575 (vc-start-logentry
1760 files rev comment initial-contents 1576 files rev comment initial-contents
1761 "Enter a change comment." 1577 "Enter a change comment."
@@ -1778,57 +1594,6 @@ Runs the normal hook `vc-checkin-hook'."
1778 (message "Checking in %s...done" (vc-delistify files))) 1594 (message "Checking in %s...done" (vc-delistify files)))
1779 'vc-checkin-hook)) 1595 'vc-checkin-hook))
1780 1596
1781(defun vc-finish-logentry (&optional nocomment)
1782 "Complete the operation implied by the current log entry.
1783Use the contents of the current buffer as a check-in or registration
1784comment. If the optional arg NOCOMMENT is non-nil, then don't check
1785the buffer contents as a comment."
1786 (interactive)
1787 ;; Check and record the comment, if any.
1788 (unless nocomment
1789 (run-hooks 'vc-logentry-check-hook))
1790 ;; Sync parent buffer in case the user modified it while editing the comment.
1791 ;; But not if it is a vc-dired buffer.
1792 (with-current-buffer vc-parent-buffer
1793 (or vc-dired-mode (eq major-mode 'vc-dir-mode) (vc-buffer-sync)))
1794 (unless vc-log-operation
1795 (error "No log operation is pending"))
1796 ;; save the parameters held in buffer-local variables
1797 (let ((log-operation vc-log-operation)
1798 (log-fileset vc-log-fileset)
1799 (log-revision vc-log-revision)
1800 (log-entry (buffer-string))
1801 (after-hook vc-log-after-operation-hook)
1802 (tmp-vc-parent-buffer vc-parent-buffer))
1803 (pop-to-buffer vc-parent-buffer)
1804 ;; OK, do it to it
1805 (save-excursion
1806 (funcall log-operation
1807 log-fileset
1808 log-revision
1809 log-entry))
1810 ;; Remove checkin window (after the checkin so that if that fails
1811 ;; we don't zap the *VC-log* buffer and the typing therein).
1812 ;; -- IMO this should be replaced with quit-window
1813 (let ((logbuf (get-buffer "*VC-log*")))
1814 (cond ((and logbuf vc-delete-logbuf-window)
1815 (delete-windows-on logbuf (selected-frame))
1816 ;; Kill buffer and delete any other dedicated windows/frames.
1817 (kill-buffer logbuf))
1818 (logbuf (pop-to-buffer "*VC-log*")
1819 (bury-buffer)
1820 (pop-to-buffer tmp-vc-parent-buffer))))
1821 ;; Now make sure we see the expanded headers
1822 (when log-fileset
1823 (mapc
1824 (lambda (file) (vc-resynch-buffer file vc-keep-workfiles t))
1825 log-fileset))
1826 (when vc-dired-mode
1827 (dired-move-to-filename))
1828 (when (eq major-mode 'vc-dir-mode)
1829 (vc-dir-move-to-goal-column))
1830 (run-hooks after-hook 'vc-finish-logentry-hook)))
1831
1832;;; Additional entry points for examining version histories 1597;;; Additional entry points for examining version histories
1833 1598
1834;; (defun vc-default-diff-tree (backend dir rev1 rev2) 1599;; (defun vc-default-diff-tree (backend dir rev1 rev2)