Mercurial > emacs
comparison lisp/add-log.el @ 30809:3aa7c156087a
(change-log-merge): Doc fix.
(change-log-redate): New command.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 15 Aug 2000 13:26:16 +0000 |
parents | 5b85d9e700da |
children | 601145997e91 |
comparison
equal
deleted
inserted
replaced
30808:fa45a01185c0 | 30809:3aa7c156087a |
---|---|
206 (if change-log-time-zone-rule | 206 (if change-log-time-zone-rule |
207 (let ((tz (getenv "TZ")) | 207 (let ((tz (getenv "TZ")) |
208 (now (current-time))) | 208 (now (current-time))) |
209 (unwind-protect | 209 (unwind-protect |
210 (progn | 210 (progn |
211 (set-time-zone-rule | 211 (set-time-zone-rule change-log-time-zone-rule) |
212 change-log-time-zone-rule) | |
213 (concat | 212 (concat |
214 (format-time-string "%Y-%m-%d " now) | 213 (format-time-string "%Y-%m-%d " now) |
215 (add-log-iso8601-time-zone now))) | 214 (add-log-iso8601-time-zone now))) |
216 (set-time-zone-rule tz))) | 215 (set-time-zone-rule tz))) |
217 (format-time-string "%Y-%m-%d"))) | 216 (format-time-string "%Y-%m-%d"))) |
423 (re-search-forward "^\\s *$\\|^\\s \\*") | 422 (re-search-forward "^\\s *$\\|^\\s \\*") |
424 (goto-char (match-beginning 0)) | 423 (goto-char (match-beginning 0)) |
425 ;; Delete excess empty lines; make just 2. | 424 ;; Delete excess empty lines; make just 2. |
426 (while (and (not (eobp)) (looking-at "^\\s *$")) | 425 (while (and (not (eobp)) (looking-at "^\\s *$")) |
427 (delete-region (point) (line-beginning-position 2))) | 426 (delete-region (point) (line-beginning-position 2))) |
428 (insert "\n\n") | 427 (insert-char ?\n 2) |
429 (forward-line -2) | 428 (forward-line -2) |
430 (indent-relative-maybe)) | 429 (indent-relative-maybe)) |
431 (t | 430 (t |
432 ;; Make a new entry. | 431 ;; Make a new entry. |
433 (forward-line 1) | 432 (forward-line 1) |
434 (while (looking-at "\\sW") | 433 (while (looking-at "\\sW") |
435 (forward-line 1)) | 434 (forward-line 1)) |
436 (while (and (not (eobp)) (looking-at "^\\s *$")) | 435 (while (and (not (eobp)) (looking-at "^\\s *$")) |
437 (delete-region (point) (line-beginning-position 2))) | 436 (delete-region (point) (line-beginning-position 2))) |
438 (insert "\n\n\n") | 437 (insert-char ?\n 3) |
439 (forward-line -2) | 438 (forward-line -2) |
440 (indent-to left-margin) | 439 (indent-to left-margin) |
441 (insert "* " (or entry "")))) | 440 (insert "* ") |
441 (if entry (insert entry)))) | |
442 ;; Now insert the function name, if we have one. | 442 ;; Now insert the function name, if we have one. |
443 ;; Point is at the entry for this file, | 443 ;; Point is at the entry for this file, |
444 ;; either at the end of the line or at the first blank line. | 444 ;; either at the end of the line or at the first blank line. |
445 (if defun | 445 (if defun |
446 (progn | 446 (progn |
809 (defun change-log-merge (other-log) | 809 (defun change-log-merge (other-log) |
810 "Merge the contents of ChangeLog file OTHER-LOG with this buffer. | 810 "Merge the contents of ChangeLog file OTHER-LOG with this buffer. |
811 Both must be found in Change Log mode (since the merging depends on | 811 Both must be found in Change Log mode (since the merging depends on |
812 the appropriate motion commands). | 812 the appropriate motion commands). |
813 | 813 |
814 Entries are inserted in chronological order. | 814 Entries are inserted in chronological order. Both the current and |
815 | 815 old-style time formats for entries are supported." |
816 Both the current and old-style time formats for entries are supported, | |
817 so this command could be used to convert old-style logs by merging | |
818 with an empty log." | |
819 (interactive "*fLog file name to merge: ") | 816 (interactive "*fLog file name to merge: ") |
820 (if (not (eq major-mode 'change-log-mode)) | 817 (if (not (eq major-mode 'change-log-mode)) |
821 (error "Not in Change Log mode")) | 818 (error "Not in Change Log mode")) |
822 (let ((other-buf (find-file-noselect other-log)) | 819 (let ((other-buf (find-file-noselect other-log)) |
823 (buf (current-buffer)) | 820 (buf (current-buffer)) |
847 (insert-buffer-substring other-buf start | 844 (insert-buffer-substring other-buf start |
848 (with-current-buffer other-buf | 845 (with-current-buffer other-buf |
849 (goto-char (point-max)) | 846 (goto-char (point-max)) |
850 (point))))))))) | 847 (point))))))))) |
851 | 848 |
849 ;;;###autoload | |
850 (defun change-log-redate () | |
851 "Fix any old-style date entries in the current log file to default format." | |
852 (interactive) | |
853 (require 'timezone) | |
854 (save-excursion | |
855 (goto-char (point-min)) | |
856 (while (re-search-forward "^\\sw.........[0-9:+ ]*" nil t) | |
857 (unless (= 12 (- (match-end 0) (match-beginning 0))) | |
858 (let* ((date (save-match-data | |
859 (timezone-fix-time (match-string 0) nil nil))) | |
860 (zone (if (consp (aref date 6)) | |
861 (nth 1 (aref date 6))))) | |
862 (replace-match (format-time-string | |
863 "%Y-%m-%d " | |
864 (encode-time (aref date 5) | |
865 (aref date 4) | |
866 (aref date 3) | |
867 (aref date 2) | |
868 (aref date 1) | |
869 (aref date 0) | |
870 zone)))))))) | |
871 | |
852 (provide 'add-log) | 872 (provide 'add-log) |
853 | 873 |
854 ;;; add-log.el ends here | 874 ;;; add-log.el ends here |