;;; log-edit.el --- Major mode for editing CVS commit messages
;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
;; Keywords: pcl-cvs cvs commit log
:help "Search backwards through comment history for substring match of str"]))
(defcustom log-edit-confirm 'changed
- "*If non-nil, `log-edit-done' will request confirmation.
+ "If non-nil, `log-edit-done' will request confirmation.
If 'changed, only request confirmation if the list of files has
changed since the beginning of the log-edit session."
:group 'log-edit
:type '(choice (const changed) (const t) (const nil)))
(defcustom log-edit-keep-buffer nil
- "*If non-nil, don't hide the buffer after `log-edit-done'."
+ "If non-nil, don't hide the buffer after `log-edit-done'."
:group 'log-edit
:type 'boolean)
(defcustom log-edit-require-final-newline
cvs-commit-buffer-require-final-newline
- "*Enforce a newline at the end of commit log messages.
+ "Enforce a newline at the end of commit log messages.
Enforce it silently if t, query if non-nil and don't do anything if nil."
:group 'log-edit
:type '(choice (const ask) (const t) (const nil)))
(defcustom log-edit-setup-invert nil
- "*Non-nil means `log-edit' should invert the meaning of its SETUP arg.
+ "Non-nil means `log-edit' should invert the meaning of its SETUP arg.
If SETUP is 'force, this variable has no effect."
:group 'log-edit
:type 'boolean)
(defcustom log-edit-hook '(log-edit-insert-cvs-template
log-edit-insert-changelog)
- "*Hook run at the end of `log-edit'."
+ "Hook run at the end of `log-edit'."
:group 'log-edit
:type '(hook :options (log-edit-insert-changelog
log-edit-insert-cvs-rcstemplate
log-edit-insert-filenames)))
(defcustom log-edit-mode-hook (if (boundp 'vc-log-mode-hook) vc-log-mode-hook)
- "*Hook run when entering `log-edit-mode'."
+ "Hook run when entering `log-edit-mode'."
:group 'log-edit
:type 'hook)
(defcustom log-edit-done-hook nil
- "*Hook run before doing the actual commit.
+ "Hook run before doing the actual commit.
This hook can be used to cleanup the message, enforce various
conventions, or to allow recording the message in some other database,
such as a bug-tracking system. The list of files about to be committed
:type '(hook :options (log-edit-set-common-indentation
log-edit-add-to-changelog)))
+(defcustom log-edit-strip-single-file-name t
+ "If non-nil, remove file name from single-file log entries."
+ :type 'boolean)
+
(defvar cvs-changelog-full-paragraphs t)
(make-obsolete-variable 'cvs-changelog-full-paragraphs
'log-edit-changelog-full-paragraphs
"Insert the template specified by the CVS administrator, if any.
This simply uses the local CVS/Template file."
(interactive)
- (when (or (interactive-p) (= (point-min) (point-max)))
+ (when (or (called-interactively-p 'interactive)
+ (= (point-min) (point-max)))
(when (file-readable-p "CVS/Template")
(insert-file-contents "CVS/Template"))))
This contacts the repository to get the rcstemplate file and
can thus take some time."
(interactive)
- (when (or (interactive-p) (= (point-min) (point-max)))
+ (when (or (called-interactively-p 'interactive)
+ (= (point-min) (point-max)))
(when (file-readable-p "CVS/Root")
;; Ignore the stderr stuff, even if it's an error.
(call-process "cvs" nil '(t nil) nil
(log-edit-insert-changelog-entries (log-edit-files)))
(log-edit-set-common-indentation)
(goto-char (point-min))
- (when (looking-at "\\*\\s-+")
+ (when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
(forward-line 1)
(when (not (re-search-forward "^\\*\\s-+" nil t))
(goto-char (point-min))
(defun log-edit-changelog-paragraph ()
"Return the bounds of the ChangeLog paragraph containing point.
If we are between paragraphs, return the previous paragraph."
- (save-excursion
- (beginning-of-line)
- (if (looking-at "^[ \t]*$")
- (skip-chars-backward " \t\n" (point-min)))
- (list (progn
- (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
- (goto-char (match-end 0)))
- (point))
- (if (re-search-forward "^[ \t\n]*$" nil t)
- (match-beginning 0)
- (point-max)))))
+ (beginning-of-line)
+ (if (looking-at "^[ \t]*$")
+ (skip-chars-backward " \t\n" (point-min)))
+ (list (progn
+ (if (re-search-backward "^[ \t]*\n" nil 'or-to-limit)
+ (goto-char (match-end 0)))
+ (point))
+ (if (re-search-forward "^[ \t\n]*$" nil t)
+ (match-beginning 0)
+ (point-max))))
(defun log-edit-changelog-subparagraph ()
"Return the bounds of the ChangeLog subparagraph containing point.
A subparagraph is a block of non-blank lines beginning with an asterisk.
If we are between sub-paragraphs, return the previous subparagraph."
- (save-excursion
(end-of-line)
(if (search-backward "*" nil t)
(list (progn (beginning-of-line) (point))
(if (re-search-forward "^[ \t]*[\n*]" nil t)
(match-beginning 0)
(point-max))))
- (list (point) (point)))))
+ (list (point) (point))))
(defun log-edit-changelog-entry ()
"Return the bounds of the ChangeLog entry containing point.
The variable `log-edit-changelog-full-paragraphs' decides whether an
\"entry\" is a paragraph or a subparagraph; see its documentation string
for more details."
- (if log-edit-changelog-full-paragraphs
- (log-edit-changelog-paragraph)
- (log-edit-changelog-subparagraph)))
+ (save-excursion
+ (if log-edit-changelog-full-paragraphs
+ (log-edit-changelog-paragraph)
+ (log-edit-changelog-subparagraph))))
(defvar user-full-name)
(defvar user-mail-address)
pattern
"\\($\\|[^[:alnum:]]\\)"))
- (let (texts)
- (while (re-search-forward pattern nil t)
+ (let (texts
+ (pos (point)))
+ (while (and (not (eobp)) (re-search-forward pattern nil t))
(let ((entry (log-edit-changelog-entry)))
- (push entry texts)
- (goto-char (elt entry 1))))
+ (if (< (elt entry 1) (max (1+ pos) (point)))
+ ;; This is not relevant, actually.
+ nil
+ (push entry texts))
+ ;; Make sure we make progress.
+ (setq pos (max (1+ pos) (elt entry 1)))
+ (goto-char pos)))
(cons (current-buffer) texts))))))))