diff options
| author | Chong Yidong | 2010-05-25 18:50:56 -0400 |
|---|---|---|
| committer | Chong Yidong | 2010-05-25 18:50:56 -0400 |
| commit | bef4957b87f4fb9bd013114ec94d6a3845ddb4df (patch) | |
| tree | faa5a0af815947d45531a225cefd7a7d0830ebab | |
| parent | f5c8afe62a8b4c3404bd1bfdd62a5e3f1901eb41 (diff) | |
| download | emacs-bef4957b87f4fb9bd013114ec94d6a3845ddb4df.tar.gz emacs-bef4957b87f4fb9bd013114ec94d6a3845ddb4df.zip | |
Rename relative filenames in ChangeLog entries according to root.
* lisp/log-edit.el (log-edit-strip-single-file-name): Default to nil.
(log-edit-changelog-entries): Doc fix.
(log-edit-changelog-insert-entries): Args changed. Rename
relative filenames in ChangeLog entries. Delete tabs.
(log-edit-insert-changelog-entries): Reorganize return value of
`log-edit-changelog-entries' to pass filenames to
log-edit-changelog-insert-entries.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/log-edit.el | 69 |
2 files changed, 53 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1e8ace6af24..fd5d16a710c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2010-05-25 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * log-edit.el (log-edit-strip-single-file-name): Default to nil. | ||
| 4 | (log-edit-changelog-entries): Doc fix. | ||
| 5 | (log-edit-changelog-insert-entries): Args changed. Rename | ||
| 6 | relative filenames in ChangeLog entries. Delete tabs. | ||
| 7 | (log-edit-insert-changelog-entries): Reorganize return value of | ||
| 8 | `log-edit-changelog-entries' to pass filenames to | ||
| 9 | log-edit-changelog-insert-entries. | ||
| 10 | |||
| 1 | 2010-05-25 Thierry Volpiatto <thierry.volpiatto@gmail.com> | 11 | 2010-05-25 Thierry Volpiatto <thierry.volpiatto@gmail.com> |
| 2 | 12 | ||
| 3 | * dired.el (dired-mode-map): Rebind "\C-t\C-t" from | 13 | * dired.el (dired-mode-map): Rebind "\C-t\C-t" from |
diff --git a/lisp/log-edit.el b/lisp/log-edit.el index efcb8ba1299..5b9cc4c3a47 100644 --- a/lisp/log-edit.el +++ b/lisp/log-edit.el | |||
| @@ -149,12 +149,12 @@ can be obtained from `log-edit-files'." | |||
| 149 | :type '(hook :options (log-edit-set-common-indentation | 149 | :type '(hook :options (log-edit-set-common-indentation |
| 150 | log-edit-add-to-changelog))) | 150 | log-edit-add-to-changelog))) |
| 151 | 151 | ||
| 152 | (defcustom log-edit-strip-single-file-name t | 152 | (defcustom log-edit-strip-single-file-name nil |
| 153 | "If non-nil, remove file name from single-file log entries." | 153 | "If non-nil, remove file name from single-file log entries." |
| 154 | :type 'boolean | 154 | :type 'boolean |
| 155 | :safe 'booleanp | 155 | :safe 'booleanp |
| 156 | :group 'log-edit | 156 | :group 'log-edit |
| 157 | :version "23.2") | 157 | :version "24.1") |
| 158 | 158 | ||
| 159 | (defvar cvs-changelog-full-paragraphs t) | 159 | (defvar cvs-changelog-full-paragraphs t) |
| 160 | (make-obsolete-variable 'cvs-changelog-full-paragraphs | 160 | (make-obsolete-variable 'cvs-changelog-full-paragraphs |
| @@ -691,7 +691,7 @@ Return non-nil if it is." | |||
| 691 | (defun log-edit-changelog-entries (file) | 691 | (defun log-edit-changelog-entries (file) |
| 692 | "Return the ChangeLog entries for FILE, and the ChangeLog they came from. | 692 | "Return the ChangeLog entries for FILE, and the ChangeLog they came from. |
| 693 | The return value looks like this: | 693 | The return value looks like this: |
| 694 | (LOGBUFFER (ENTRYSTART . ENTRYEND) ...) | 694 | (LOGBUFFER (ENTRYSTART ENTRYEND) ...) |
| 695 | where LOGBUFFER is the name of the ChangeLog buffer, and each | 695 | where LOGBUFFER is the name of the ChangeLog buffer, and each |
| 696 | \(ENTRYSTART . ENTRYEND\) pair is a buffer region." | 696 | \(ENTRYSTART . ENTRYEND\) pair is a buffer region." |
| 697 | (let ((changelog-file-name | 697 | (let ((changelog-file-name |
| @@ -749,34 +749,51 @@ where LOGBUFFER is the name of the ChangeLog buffer, and each | |||
| 749 | 749 | ||
| 750 | (cons (current-buffer) texts)))))))) | 750 | (cons (current-buffer) texts)))))))) |
| 751 | 751 | ||
| 752 | (defun log-edit-changelog-insert-entries (buffer regions) | 752 | (defun log-edit-changelog-insert-entries (buffer beg end &rest files) |
| 753 | "Insert those regions in BUFFER specified in REGIONS. | 753 | "Insert the text from BUFFER between BEG and END. |
| 754 | Sort REGIONS front-to-back first." | 754 | Rename relative filenames in the ChangeLog entry as FILES." |
| 755 | (let ((regions (sort regions 'car-less-than-car)) | 755 | (let ((opoint (point)) |
| 756 | (last)) | 756 | (log-name (buffer-file-name buffer)) |
| 757 | (dolist (region regions) | 757 | (case-fold-search nil) |
| 758 | (when (and last (< last (car region))) (newline)) | 758 | bound) |
| 759 | (setq last (elt region 1)) | 759 | (insert-buffer-substring buffer beg end) |
| 760 | (apply 'insert-buffer-substring buffer region)))) | 760 | (setq bound (point-marker)) |
| 761 | (when log-name | ||
| 762 | (dolist (f files) | ||
| 763 | (save-excursion | ||
| 764 | (goto-char opoint) | ||
| 765 | (when (re-search-forward | ||
| 766 | (concat "\\(^\\|[ \t]\\)\\(" | ||
| 767 | (file-relative-name f (file-name-directory log-name)) | ||
| 768 | "\\)[, :\n]") | ||
| 769 | bound t) | ||
| 770 | (replace-match f t t nil 2))))) | ||
| 771 | ;; Eliminate tabs at the beginning of the line. | ||
| 772 | (save-excursion | ||
| 773 | (goto-char opoint) | ||
| 774 | (while (re-search-forward "^\\(\t+\\)" bound t) | ||
| 775 | (replace-match ""))))) | ||
| 761 | 776 | ||
| 762 | (defun log-edit-insert-changelog-entries (files) | 777 | (defun log-edit-insert-changelog-entries (files) |
| 763 | "Given a list of files FILES, insert the ChangeLog entries for them." | 778 | "Given a list of files FILES, insert the ChangeLog entries for them." |
| 764 | (let ((buffer-entries nil)) | 779 | (let ((log-entries nil)) |
| 765 | 780 | ;; Note that any ChangeLog entry can apply to more than one file. | |
| 766 | ;; Add each buffer to buffer-entries, and associate it with the list | 781 | ;; Here we construct a log-entries list with elements of the form |
| 767 | ;; of entries we want from that file. | 782 | ;; ((LOGBUFFER ENTRYSTART ENTRYEND) FILE1 FILE2...) |
| 768 | (dolist (file files) | 783 | (dolist (file files) |
| 769 | (let* ((entries (log-edit-changelog-entries file)) | 784 | (let* ((entries (log-edit-changelog-entries file)) |
| 770 | (pair (assq (car entries) buffer-entries))) | 785 | (buf (car entries)) |
| 771 | (if pair | 786 | key entry) |
| 772 | (setcdr pair (cvs-union (cdr pair) (cdr entries))) | 787 | (dolist (region (cdr entries)) |
| 773 | (push entries buffer-entries)))) | 788 | (setq key (cons buf region)) |
| 774 | 789 | (if (setq entry (assoc key log-entries)) | |
| 775 | ;; Now map over each buffer in buffer-entries, sort the entries for | 790 | (setcdr entry (append (cdr entry) (list file))) |
| 776 | ;; each buffer, and extract them as strings. | 791 | (push (list key file) log-entries))))) |
| 777 | (dolist (buffer-entry buffer-entries) | 792 | ;; Now map over log-entries, and extract the strings. |
| 778 | (log-edit-changelog-insert-entries (car buffer-entry) (cdr buffer-entry)) | 793 | (dolist (log-entry (nreverse log-entries)) |
| 779 | (when (cdr buffer-entry) (newline))))) | 794 | (apply 'log-edit-changelog-insert-entries |
| 795 | (append (car log-entry) (cdr log-entry))) | ||
| 796 | (insert "\n")))) | ||
| 780 | 797 | ||
| 781 | (defun log-edit-extract-headers (headers comment) | 798 | (defun log-edit-extract-headers (headers comment) |
| 782 | "Extract headers from COMMENT to form command line arguments. | 799 | "Extract headers from COMMENT to form command line arguments. |