120 |
log-edit-insert-changelog) |
log-edit-insert-changelog) |
121 |
"*Hook run at the end of `log-edit'." |
"*Hook run at the end of `log-edit'." |
122 |
:group 'log-edit |
:group 'log-edit |
123 |
:type '(hook :options (log-edit-insert-cvs-template |
:type '(hook :options (log-edit-insert-changelog |
124 |
log-edit-insert-changelog))) |
log-edit-insert-cvs-rcstemplate |
125 |
|
log-edit-insert-cvs-template |
126 |
|
log-edit-insert-filenames))) |
127 |
|
|
128 |
(defcustom log-edit-mode-hook (if (boundp 'vc-log-mode-hook) vc-log-mode-hook) |
(defcustom log-edit-mode-hook (if (boundp 'vc-log-mode-hook) vc-log-mode-hook) |
129 |
"*Hook run when entering `log-edit-mode'." |
"*Hook run when entering `log-edit-mode'." |
283 |
(insert "\n")))) |
(insert "\n")))) |
284 |
|
|
285 |
;; Compatibility with old names. |
;; Compatibility with old names. |
286 |
(defvaralias 'vc-comment-ring 'log-edit-comment-ring) |
(define-obsolete-variable-alias 'vc-comment-ring 'log-edit-comment-ring "22.1") |
287 |
(make-obsolete-variable 'vc-comment-ring 'log-edit-comment-ring "22.1") |
(define-obsolete-variable-alias 'vc-comment-ring-index 'log-edit-comment-ring-index "22.1") |
288 |
(defvaralias 'vc-comment-ring-index 'log-edit-comment-ring-index) |
(define-obsolete-function-alias 'vc-previous-comment 'log-edit-previous-comment "22.1") |
289 |
(make-obsolete-variable 'vc-comment-ring-index 'log-edit-comment-ring-index "22.1") |
(define-obsolete-function-alias 'vc-next-comment 'log-edit-next-comment "22.1") |
290 |
(defalias 'vc-previous-comment 'log-edit-previous-comment) |
(define-obsolete-function-alias 'vc-comment-search-reverse 'log-edit-comment-search-backward "22.1") |
291 |
(make-obsolete 'vc-previous-comment 'log-edit-previous-comment "22.1") |
(define-obsolete-function-alias 'vc-comment-search-forward 'log-edit-comment-search-forward "22.1") |
292 |
(defalias 'vc-next-comment 'log-edit-next-comment) |
(define-obsolete-function-alias 'vc-comment-to-change-log 'log-edit-comment-to-change-log "22.1") |
|
(make-obsolete 'vc-next-comment 'log-edit-next-comment "22.1") |
|
|
(defalias 'vc-comment-search-reverse 'log-edit-comment-search-backward) |
|
|
(make-obsolete 'vc-comment-search-reverse 'log-edit-comment-search-backward "22.1") |
|
|
(defalias 'vc-comment-search-forward 'log-edit-comment-search-forward) |
|
|
(make-obsolete 'vc-comment-search-forward 'log-edit-comment-search-forward "22.1") |
|
|
(defalias 'vc-comment-to-change-log 'log-edit-comment-to-change-log) |
|
|
(make-obsolete 'vc-comment-to-change-log 'log-edit-comment-to-change-log "22.1") |
|
293 |
|
|
294 |
;;; |
;;; |
295 |
;;; Actual code |
;;; Actual code |
391 |
"Return the list of files that are about to be committed." |
"Return the list of files that are about to be committed." |
392 |
(ignore-errors (funcall log-edit-listfun))) |
(ignore-errors (funcall log-edit-listfun))) |
393 |
|
|
|
|
|
|
(defun log-edit-insert-changelog () |
|
|
"Insert a log message by looking at the ChangeLog. |
|
|
The idea is to write your ChangeLog entries first, and then use this |
|
|
command to commit your changes. |
|
|
|
|
|
To select default log text, we: |
|
|
- find the ChangeLog entries for the files to be checked in, |
|
|
- verify that the top entry in the ChangeLog is on the current date |
|
|
and by the current user; if not, we don't provide any default text, |
|
|
- search the ChangeLog entry for paragraphs containing the names of |
|
|
the files we're checking in, and finally |
|
|
- use those paragraphs as the log text." |
|
|
(interactive) |
|
|
(log-edit-insert-changelog-entries (log-edit-files)) |
|
|
(log-edit-set-common-indentation) |
|
|
(goto-char (point-min)) |
|
|
(when (looking-at "\\*\\s-+") |
|
|
(forward-line 1) |
|
|
(when (not (re-search-forward "^\\*\\s-+" nil t)) |
|
|
(goto-char (point-min)) |
|
|
(skip-chars-forward "^():") |
|
|
(skip-chars-forward ": ") |
|
|
(delete-region (point-min) (point))))) |
|
|
|
|
394 |
(defun log-edit-mode-help () |
(defun log-edit-mode-help () |
395 |
"Provide help for the `log-edit-mode-map'." |
"Provide help for the `log-edit-mode-map'." |
396 |
(interactive) |
(interactive) |
435 |
(selected-window))))) |
(selected-window))))) |
436 |
|
|
437 |
(defun log-edit-insert-cvs-template () |
(defun log-edit-insert-cvs-template () |
438 |
"Insert the template specified by the CVS administrator, if any." |
"Insert the template specified by the CVS administrator, if any. |
439 |
|
This simply uses the local CVS/Template file." |
440 |
|
(interactive) |
441 |
|
(when (or (interactive-p) (= (point-min) (point-max))) |
442 |
|
(when (file-readable-p "CVS/Template") |
443 |
|
(insert-file-contents "CVS/Template")))) |
444 |
|
|
445 |
|
(defun log-edit-insert-cvs-rcstemplate () |
446 |
|
"Insert the rcstemplate from the CVS repository. |
447 |
|
This contacts the repository to get the rcstemplate file and |
448 |
|
can thus take some time." |
449 |
(interactive) |
(interactive) |
450 |
(when (file-readable-p "CVS/Template") |
(when (or (interactive-p) (= (point-min) (point-max))) |
451 |
(insert-file-contents "CVS/Template"))) |
(when (file-readable-p "CVS/Entries") |
452 |
|
(call-process "cvs" nil t nil "checkout" "-p" "CVSROOT/rcstemplate")))) |
453 |
|
|
454 |
|
(defun log-edit-insert-filenames () |
455 |
|
"Insert the list of files that are to be committed." |
456 |
|
(interactive) |
457 |
|
(insert "Affected files: \n" |
458 |
|
(mapconcat 'identity (log-edit-files) " \n"))) |
459 |
|
|
460 |
(defun log-edit-add-to-changelog () |
(defun log-edit-add-to-changelog () |
461 |
"Insert this log message into the appropriate ChangeLog file." |
"Insert this log message into the appropriate ChangeLog file." |
468 |
(save-excursion |
(save-excursion |
469 |
(log-edit-comment-to-change-log))))) |
(log-edit-comment-to-change-log))))) |
470 |
|
|
471 |
|
(defvar log-edit-changelog-use-first nil) |
472 |
|
(defun log-edit-insert-changelog (&optional use-first) |
473 |
|
"Insert a log message by looking at the ChangeLog. |
474 |
|
The idea is to write your ChangeLog entries first, and then use this |
475 |
|
command to commit your changes. |
476 |
|
|
477 |
|
To select default log text, we: |
478 |
|
- find the ChangeLog entries for the files to be checked in, |
479 |
|
- verify that the top entry in the ChangeLog is on the current date |
480 |
|
and by the current user; if not, we don't provide any default text, |
481 |
|
- search the ChangeLog entry for paragraphs containing the names of |
482 |
|
the files we're checking in, and finally |
483 |
|
- use those paragraphs as the log text. |
484 |
|
|
485 |
|
If the optional prefix arg USE-FIRST is given (via \\[universal-argument]), |
486 |
|
or if the command is repeated a second time in a row, use the first log entry |
487 |
|
regardless of user name or time." |
488 |
|
(interactive "P") |
489 |
|
(let ((log-edit-changelog-use-first |
490 |
|
(or use-first (eq last-command 'log-edit-insert-changelog)))) |
491 |
|
(log-edit-insert-changelog-entries (log-edit-files))) |
492 |
|
(log-edit-set-common-indentation) |
493 |
|
(goto-char (point-min)) |
494 |
|
(when (looking-at "\\*\\s-+") |
495 |
|
(forward-line 1) |
496 |
|
(when (not (re-search-forward "^\\*\\s-+" nil t)) |
497 |
|
(goto-char (point-min)) |
498 |
|
(skip-chars-forward "^():") |
499 |
|
(skip-chars-forward ": ") |
500 |
|
(delete-region (point-min) (point))))) |
501 |
|
|
502 |
;;;; |
;;;; |
503 |
;;;; functions for getting commit message from ChangeLog a file... |
;;;; functions for getting commit message from ChangeLog a file... |
504 |
;;;; Courtesy Jim Blandy |
;;;; Courtesy Jim Blandy |
578 |
(functionp add-log-time-format) |
(functionp add-log-time-format) |
579 |
(funcall add-log-time-format)) |
(funcall add-log-time-format)) |
580 |
(format-time-string "%Y-%m-%d")))) |
(format-time-string "%Y-%m-%d")))) |
581 |
(looking-at (regexp-quote (format "%s %s <%s>" time name mail))))) |
(looking-at (if log-edit-changelog-use-first |
582 |
|
"[^ \t]" |
583 |
|
(regexp-quote (format "%s %s <%s>" time name mail)))))) |
584 |
|
|
585 |
(defun log-edit-changelog-entries (file) |
(defun log-edit-changelog-entries (file) |
586 |
"Return the ChangeLog entries for FILE, and the ChangeLog they came from. |
"Return the ChangeLog entries for FILE, and the ChangeLog they came from. |