aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2010-10-27 17:47:09 -0400
committerStefan Monnier2010-10-27 17:47:09 -0400
commitce8794df2c8fb158f6feb0036a1e0f27db02ecc8 (patch)
tree355777d64be55f814484f39f48aa2765d0866a26
parentd19dc73db6fc2b90ab6d058e2f4cb9c44a4aa4bc (diff)
downloademacs-ce8794df2c8fb158f6feb0036a1e0f27db02ecc8.tar.gz
emacs-ce8794df2c8fb158f6feb0036a1e0f27db02ecc8.zip
* lisp/vc/log-edit.el (log-edit-rewrite-fixes): New var.
(log-edit-author): New dynamic var. (log-edit-changelog-ours-p, log-edit-insert-changelog-entries): Use it to return the author if different from committer. (log-edit-insert-changelog): Use them to add Author: and Fixes headers.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/vc/log-edit.el77
2 files changed, 66 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cd74b76d415..8d77f0159f9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
12010-10-27 Stefan Monnier <monnier@iro.umontreal.ca> 12010-10-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * vc/log-edit.el (log-edit-rewrite-fixes): New var.
4 (log-edit-author): New dynamic var.
5 (log-edit-changelog-ours-p, log-edit-insert-changelog-entries): Use it
6 to return the author if different from committer.
7 (log-edit-insert-changelog): Use them to add Author: and Fixes headers.
8
3 * play/landmark.el: Adjust commenting convention. 9 * play/landmark.el: Adjust commenting convention.
4 (lm-nil-score): Rename from nil-score. 10 (lm-nil-score): Rename from nil-score.
5 (Xscore, XXscore, XXXscore, XXXXscore, Oscore, OOscore, OOOscore) 11 (Xscore, XXscore, XXXscore, XXXXscore, Oscore, OOscore, OOOscore)
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el
index 27290eeec8a..80d77213abf 100644
--- a/lisp/vc/log-edit.el
+++ b/lisp/vc/log-edit.el
@@ -572,6 +572,14 @@ can thus take some time."
572 (log-edit-comment-to-change-log))))) 572 (log-edit-comment-to-change-log)))))
573 573
574(defvar log-edit-changelog-use-first nil) 574(defvar log-edit-changelog-use-first nil)
575
576(defvar log-edit-rewrite-fixes nil
577 "Rule to rewrite bug numbers into Fixes: headers.
578The value should be of the form (REGEXP . REPLACEMENT)
579where REGEXP should match the expression referring to a bug number
580in the text, and REPLACEMENT is an expression to pass to `replace-match'
581to build the Fixes: header.")
582
575(defun log-edit-insert-changelog (&optional use-first) 583(defun log-edit-insert-changelog (&optional use-first)
576 "Insert a log message by looking at the ChangeLog. 584 "Insert a log message by looking at the ChangeLog.
577The idea is to write your ChangeLog entries first, and then use this 585The idea is to write your ChangeLog entries first, and then use this
@@ -593,18 +601,34 @@ regardless of user name or time."
593 (when (<= (point) eoh) 601 (when (<= (point) eoh)
594 (goto-char eoh) 602 (goto-char eoh)
595 (if (looking-at "\n") (forward-char 1)))) 603 (if (looking-at "\n") (forward-char 1))))
596 (let ((log-edit-changelog-use-first 604 (let ((author
597 (or use-first (eq last-command 'log-edit-insert-changelog)))) 605 (let ((log-edit-changelog-use-first
598 (log-edit-insert-changelog-entries (log-edit-files))) 606 (or use-first (eq last-command 'log-edit-insert-changelog))))
599 (log-edit-set-common-indentation) 607 (log-edit-insert-changelog-entries (log-edit-files)))))
600 (goto-char (point-min)) 608 (log-edit-set-common-indentation)
601 (when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+")) 609 ;; Add an Author: field if appropriate.
602 (forward-line 1) 610 (when author
603 (when (not (re-search-forward "^\\*\\s-+" nil t)) 611 (rfc822-goto-eoh)
604 (goto-char (point-min)) 612 (insert "Author: " author "\n" (if (looking-at "\n") "" "\n")))
605 (skip-chars-forward "^():") 613 ;; Add a Fixes: field if applicable.
606 (skip-chars-forward ": ") 614 (when (consp log-edit-rewrite-fixes)
607 (delete-region (point-min) (point))))) 615 (rfc822-goto-eoh)
616 (when (re-search-forward (car log-edit-rewrite-fixes) nil t)
617 (let ((start (match-beginning 0))
618 (end (match-end 0))
619 (fixes (match-substitute-replacement
620 (cdr log-edit-rewrite-fixes))))
621 (delete-region start end)
622 (rfc822-goto-eoh)
623 (insert "Fixes: " fixes "\n" (if (looking-at "\n") "" "\n")))))
624 (goto-char (point-min))
625 (when (and log-edit-strip-single-file-name (looking-at "\\*\\s-+"))
626 (forward-line 1)
627 (when (not (re-search-forward "^\\*\\s-+" nil t))
628 (goto-char (point-min))
629 (skip-chars-forward "^():")
630 (skip-chars-forward ": ")
631 (delete-region (point-min) (point))))))
608 632
609;;;; 633;;;;
610;;;; functions for getting commit message from ChangeLog a file... 634;;;; functions for getting commit message from ChangeLog a file...
@@ -670,6 +694,9 @@ for more details."
670 694
671(defvar user-full-name) 695(defvar user-full-name)
672(defvar user-mail-address) 696(defvar user-mail-address)
697
698(defvar log-edit-author) ;Dynamically scoped.
699
673(defun log-edit-changelog-ours-p () 700(defun log-edit-changelog-ours-p ()
674 "See if ChangeLog entry at point is for the current user, today. 701 "See if ChangeLog entry at point is for the current user, today.
675Return non-nil if it is." 702Return non-nil if it is."
@@ -684,9 +711,23 @@ Return non-nil if it is."
684 (functionp add-log-time-format) 711 (functionp add-log-time-format)
685 (funcall add-log-time-format)) 712 (funcall add-log-time-format))
686 (format-time-string "%Y-%m-%d")))) 713 (format-time-string "%Y-%m-%d"))))
687 (looking-at (if log-edit-changelog-use-first 714 (if (null log-edit-changelog-use-first)
688 "[^ \t]" 715 (looking-at (regexp-quote (format "%s %s <%s>" time name mail)))
689 (regexp-quote (format "%s %s <%s>" time name mail)))))) 716 ;; Check the author, to potentially add it as a "Author: " header.
717 (when (looking-at "[^ \t]")
718 (when (and (boundp 'log-edit-author)
719 (not (looking-at (format ".+ .+ <%s>"
720 (regexp-quote mail))))
721 (looking-at ".+ \\(.+ <.+>\\)"))
722 (let ((author (replace-regexp-in-string " " " "
723 (match-string 1))))
724 (unless (and log-edit-author
725 (string-match (regexp-quote author) log-edit-author))
726 (setq log-edit-author
727 (if log-edit-author
728 (concat log-edit-author ", " author)
729 author)))))
730 t))))
690 731
691(defun log-edit-changelog-entries (file) 732(defun log-edit-changelog-entries (file)
692 "Return the ChangeLog entries for FILE, and the ChangeLog they came from. 733 "Return the ChangeLog entries for FILE, and the ChangeLog they came from.
@@ -776,7 +817,8 @@ Rename relative filenames in the ChangeLog entry as FILES."
776 817
777(defun log-edit-insert-changelog-entries (files) 818(defun log-edit-insert-changelog-entries (files)
778 "Given a list of files FILES, insert the ChangeLog entries for them." 819 "Given a list of files FILES, insert the ChangeLog entries for them."
779 (let ((log-entries nil)) 820 (let ((log-entries nil)
821 (log-edit-author nil))
780 ;; Note that any ChangeLog entry can apply to more than one file. 822 ;; Note that any ChangeLog entry can apply to more than one file.
781 ;; Here we construct a log-entries list with elements of the form 823 ;; Here we construct a log-entries list with elements of the form
782 ;; ((LOGBUFFER ENTRYSTART ENTRYEND) FILE1 FILE2...) 824 ;; ((LOGBUFFER ENTRYSTART ENTRYEND) FILE1 FILE2...)
@@ -793,7 +835,8 @@ Rename relative filenames in the ChangeLog entry as FILES."
793 (dolist (log-entry (nreverse log-entries)) 835 (dolist (log-entry (nreverse log-entries))
794 (apply 'log-edit-changelog-insert-entries 836 (apply 'log-edit-changelog-insert-entries
795 (append (car log-entry) (cdr log-entry))) 837 (append (car log-entry) (cdr log-entry)))
796 (insert "\n")))) 838 (insert "\n"))
839 log-edit-author))
797 840
798(defun log-edit-extract-headers (headers comment) 841(defun log-edit-extract-headers (headers comment)
799 "Extract headers from COMMENT to form command line arguments. 842 "Extract headers from COMMENT to form command line arguments.