# HG changeset patch # User Dave Love # Date 966345976 0 # Node ID 3aa7c156087a101b5028a91e94affdc13c6cc634 # Parent fa45a01185c02e36f1020c988dfe001b87200c14 (change-log-merge): Doc fix. (change-log-redate): New command. diff -r fa45a01185c0 -r 3aa7c156087a lisp/add-log.el --- a/lisp/add-log.el Tue Aug 15 13:22:09 2000 +0000 +++ b/lisp/add-log.el Tue Aug 15 13:26:16 2000 +0000 @@ -208,8 +208,7 @@ (now (current-time))) (unwind-protect (progn - (set-time-zone-rule - change-log-time-zone-rule) + (set-time-zone-rule change-log-time-zone-rule) (concat (format-time-string "%Y-%m-%d " now) (add-log-iso8601-time-zone now))) @@ -425,7 +424,7 @@ ;; Delete excess empty lines; make just 2. (while (and (not (eobp)) (looking-at "^\\s *$")) (delete-region (point) (line-beginning-position 2))) - (insert "\n\n") + (insert-char ?\n 2) (forward-line -2) (indent-relative-maybe)) (t @@ -435,10 +434,11 @@ (forward-line 1)) (while (and (not (eobp)) (looking-at "^\\s *$")) (delete-region (point) (line-beginning-position 2))) - (insert "\n\n\n") + (insert-char ?\n 3) (forward-line -2) (indent-to left-margin) - (insert "* " (or entry "")))) + (insert "* ") + (if entry (insert entry)))) ;; Now insert the function name, if we have one. ;; Point is at the entry for this file, ;; either at the end of the line or at the first blank line. @@ -811,11 +811,8 @@ Both must be found in Change Log mode (since the merging depends on the appropriate motion commands). -Entries are inserted in chronological order. - -Both the current and old-style time formats for entries are supported, -so this command could be used to convert old-style logs by merging -with an empty log." +Entries are inserted in chronological order. Both the current and +old-style time formats for entries are supported." (interactive "*fLog file name to merge: ") (if (not (eq major-mode 'change-log-mode)) (error "Not in Change Log mode")) @@ -849,6 +846,29 @@ (goto-char (point-max)) (point))))))))) +;;;###autoload +(defun change-log-redate () + "Fix any old-style date entries in the current log file to default format." + (interactive) + (require 'timezone) + (save-excursion + (goto-char (point-min)) + (while (re-search-forward "^\\sw.........[0-9:+ ]*" nil t) + (unless (= 12 (- (match-end 0) (match-beginning 0))) + (let* ((date (save-match-data + (timezone-fix-time (match-string 0) nil nil))) + (zone (if (consp (aref date 6)) + (nth 1 (aref date 6))))) + (replace-match (format-time-string + "%Y-%m-%d " + (encode-time (aref date 5) + (aref date 4) + (aref date 3) + (aref date 2) + (aref date 1) + (aref date 0) + zone)))))))) + (provide 'add-log) ;;; add-log.el ends here