Commit 11cdd167 authored by Stefan Monnier's avatar Stefan Monnier

(vc-log-mode-map, vc-maximum-comment-ring-size)

(vc-comment-ring, vc-comment-ring-index, vc-last-comment-match):
Move vars to log-edit.el.
(vc-new-comment-index, vc-previous-comment, vc-next-comment)
(vc-comment-search-reverse, vc-comment-search-forward)
(vc-comment-to-change-log): Move funs to log-edit.el.
(vc-clear-context): Don't empty the comment-ring.
(vc-finish-logentry): Don't add the comment onto the comment-ring.
parent 12dd83de
;;; vc.el --- drive a version-control system from within Emacs
;; Copyright (C) 1992,93,94,95,96,97,98,2000,2001 Free Software Foundation, Inc.
;; Copyright (C) 1992,93,94,95,96,97,98,2000,01,2003
;; Free Software Foundation, Inc.
;; Author: FSF (see below for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
;; Keywords: tools
;; $Id: vc.el,v 1.351 2003/05/08 17:41:16 monnier Exp $
;; $Id: vc.el,v 1.352 2003/05/09 16:33:10 monnier Exp $
;; This file is part of GNU Emacs.
......@@ -522,9 +523,6 @@ These are passed to the checkin program by \\[vc-register]."
:type '(repeat string)
:group 'vc)
(defconst vc-maximum-comment-ring-size 32
"Maximum number of saved comments in the comment ring.")
(defcustom vc-diff-switches nil
"*A string or list of strings specifying switches for diff under VC.
When running diff under a given BACKEND, VC concatenates the values of
......@@ -669,22 +667,6 @@ and that its contents match what the master file says."
"the corresponding checks are always done now."
"21.1")
;; The main keymap
;; Initialization code, to be done just once at load-time
(defvar vc-log-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map text-mode-map)
(define-key map "\M-n" 'vc-next-comment)
(define-key map "\M-p" 'vc-previous-comment)
(define-key map "\M-r" 'vc-comment-search-reverse)
(define-key map "\M-s" 'vc-comment-search-forward)
(define-key map "\C-c\C-c" 'vc-finish-logentry)
map))
;; Compatibility with old name. Should we bother ?
(defvar vc-log-entry-mode vc-log-mode-map)
;; Variables the user doesn't need to know about.
(defvar vc-log-operation nil)
......@@ -706,10 +688,6 @@ The keys are \(BUFFER . BACKEND\). See also `vc-annotate-get-backend'.")
(defvar vc-dired-mode nil)
(make-variable-buffer-local 'vc-dired-mode)
(defvar vc-comment-ring (make-ring vc-maximum-comment-ring-size))
(defvar vc-comment-ring-index nil)
(defvar vc-last-comment-match "")
;; functions that operate on RCS revision numbers. This code should
;; also be moved into the backends. It stays for now, however, since
;; it is used in code below.
......@@ -754,12 +732,9 @@ as used by RCS and CVS."
;; File property caching
(defun vc-clear-context ()
"Clear all cached file properties and the comment ring."
"Clear all cached file properties."
(interactive)
(fillarray vc-file-prop-obarray 0)
;; Note: there is potential for minor lossage here if there is an open
;; log buffer with a nonzero local value of vc-comment-ring-index.
(setq vc-comment-ring (make-ring vc-maximum-comment-ring-size)))
(fillarray vc-file-prop-obarray 0))
(defmacro with-vc-properties (file form settings)
"Execute FORM, then maybe set per-file properties for FILE.
......@@ -1586,60 +1561,11 @@ Runs the normal hook `vc-checkin-hook'."
(message "Checking in %s...done" file))
'vc-checkin-hook))
(defun vc-comment-to-change-log (&optional whoami file-name)
"Enter last VC comment into the change log for the current file.
WHOAMI (interactive prefix) non-nil means prompt for user name
and site. FILE-NAME is the name of the change log; if nil, use
`change-log-default-name'.
This may be useful as a `vc-checkin-hook' to update change logs
automatically."
(interactive (if current-prefix-arg
(list current-prefix-arg
(prompt-for-change-log-name))))
;; Make sure the defvar for add-log-current-defun-function has been executed
;; before binding it.
(require 'add-log)
(let (;; Extract the comment first so we get any error before doing anything.
(comment (ring-ref vc-comment-ring 0))
;; Don't let add-change-log-entry insert a defun name.
(add-log-current-defun-function 'ignore)
end)
;; Call add-log to do half the work.
(add-change-log-entry whoami file-name t t)
;; Insert the VC comment, leaving point before it.
(setq end (save-excursion (insert comment) (point-marker)))
(if (looking-at "\\s *\\s(")
;; It starts with an open-paren, as in "(foo): Frobbed."
;; So remove the ": " add-log inserted.
(delete-char -2))
;; Canonicalize the white space between the file name and comment.
(just-one-space)
;; Indent rest of the text the same way add-log indented the first line.
(let ((indentation (current-indentation)))
(save-excursion
(while (< (point) end)
(forward-line 1)
(indent-to indentation))
(setq end (point))))
;; Fill the inserted text, preserving open-parens at bol.
(let ((paragraph-separate (concat paragraph-separate "\\|\\s *\\s("))
(paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
(beginning-of-line)
(fill-region (point) end))
;; Canonicalize the white space at the end of the entry so it is
;; separated from the next entry by a single blank line.
(skip-syntax-forward " " end)
(delete-char (- (skip-syntax-backward " ")))
(or (eobp) (looking-at "\n\n")
(insert "\n"))))
(defun vc-finish-logentry (&optional nocomment)
"Complete the operation implied by the current log entry.
Use the contents of the current buffer as a check-in or registration
comment. If the optional arg NOCOMMENT is non-nil, then don't check
the buffer contents as a comment, and don't add it to
`vc-comment-ring'."
the buffer contents as a comment."
(interactive)
;; Check and record the comment, if any.
(unless nocomment
......@@ -1647,13 +1573,7 @@ the buffer contents as a comment, and don't add it to
(vc-call-backend (or (and vc-log-file (vc-backend vc-log-file))
(vc-responsible-backend default-directory))
'logentry-check)
(run-hooks 'vc-logentry-check-hook)
;; Record the comment in the comment ring
(let ((comment (buffer-string)))
(unless (and (ring-p vc-comment-ring)
(not (ring-empty-p vc-comment-ring))
(equal comment (ring-ref vc-comment-ring 0)))
(ring-insert vc-comment-ring comment))))
(run-hooks 'vc-logentry-check-hook))
;; Sync parent buffer in case the user modified it while editing the comment.
;; But not if it is a vc-dired buffer.
(with-current-buffer vc-parent-buffer
......@@ -1692,62 +1612,6 @@ the buffer contents as a comment, and don't add it to
;; Code for access to the comment ring
(defun vc-new-comment-index (stride len)
"Return the comment index STRIDE elements from the current one.
LEN is the length of `vc-comment-ring'."
(mod (cond
(vc-comment-ring-index (+ vc-comment-ring-index stride))
;; Initialize the index on the first use of this command
;; so that the first M-p gets index 0, and the first M-n gets
;; index -1.
((> stride 0) (1- stride))
(t stride))
len))
(defun vc-previous-comment (arg)
"Cycle backwards through comment history.
With a numeric prefix ARG, go back ARG comments."
(interactive "*p")
(let ((len (ring-length vc-comment-ring)))
(if (<= len 0)
(progn (message "Empty comment ring") (ding))
(erase-buffer)
(setq vc-comment-ring-index (vc-new-comment-index arg len))
(message "Comment %d" (1+ vc-comment-ring-index))
(insert (ring-ref vc-comment-ring vc-comment-ring-index)))))
(defun vc-next-comment (arg)
"Cycle forwards through comment history.
With a numeric prefix ARG, go forward ARG comments."
(interactive "*p")
(vc-previous-comment (- arg)))
(defun vc-comment-search-reverse (str &optional stride)
"Search backwards through comment history for substring match of STR.
If the optional argument STRIDE is present, that is a step-width to use
when going through the comment ring."
;; Why substring rather than regexp ? -sm
(interactive
(list (read-string "Comment substring: " nil nil vc-last-comment-match)))
(unless stride (setq stride 1))
(if (string= str "")
(setq str vc-last-comment-match)
(setq vc-last-comment-match str))
(let* ((str (regexp-quote str))
(len (ring-length vc-comment-ring))
(n (vc-new-comment-index stride len)))
(while (progn (when (or (>= n len) (< n 0)) (error "Not found"))
(not (string-match str (ring-ref vc-comment-ring n))))
(setq n (+ n stride)))
(setq vc-comment-ring-index n)
(vc-previous-comment 0)))
(defun vc-comment-search-forward (str)
"Search forwards through comment history for a substring match of STR."
(interactive
(list (read-string "Comment substring: " nil nil vc-last-comment-match)))
(vc-comment-search-reverse str -1))
;; Additional entry points for examining version histories
;;;###autoload
......@@ -2451,10 +2315,10 @@ allowed and simply skipped)."
(vc-file-tree-walk
dir
(lambda (f) (and
(vc-up-to-date-p f)
(vc-error-occurred
(vc-call checkout f nil "")
(if update (vc-resynch-buffer f t t)))))))
(vc-up-to-date-p f)
(vc-error-occurred
(vc-call checkout f nil "")
(if update (vc-resynch-buffer f t t)))))))
(let ((result (vc-snapshot-precondition dir)))
(if (stringp result)
(error "File %s is locked" result)
......@@ -2462,8 +2326,8 @@ allowed and simply skipped)."
(vc-file-tree-walk
dir
(lambda (f) (vc-error-occurred
(vc-call checkout f nil name)
(if update (vc-resynch-buffer f t t)))))))))
(vc-call checkout f nil name)
(if update (vc-resynch-buffer f t t)))))))))
;; Miscellaneous other entry points
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment