Mercurial > emacs
comparison lisp/add-log.el @ 15909:088510eef043
Change to ISO 8601 date formats, without time of day.
(change-log-font-lock-keywords): Adjust accordingly.
(add-change-log-entry): Compare and insert with new date format.
(change-log-mode): Make `paragraph-start' and `paragraph-separate' use \<
like `page-delimiter' for consistency.
(change-log-time-zone-rule): New variable.
(iso8601-time-zone): New function.
(add-change-log-entry): If change-log-time-zone-rule is non-nil, calculate
date according to that rule, and indicate resulting time zone.
author | Erik Naggum <erik@naggum.no> |
---|---|
date | Sat, 24 Aug 1996 21:10:47 +0000 |
parents | ca8f142ef5d2 |
children | 9d8b374b5bb1 |
comparison
equal
deleted
inserted
replaced
15908:045bf20a0e7c | 15909:088510eef043 |
---|---|
45 (defvar add-log-mailing-address nil | 45 (defvar add-log-mailing-address nil |
46 "*Electronic mail address of user, for inclusion in ChangeLog daily headers. | 46 "*Electronic mail address of user, for inclusion in ChangeLog daily headers. |
47 This defaults to the value of `user-mail-address'.") | 47 This defaults to the value of `user-mail-address'.") |
48 | 48 |
49 (defvar change-log-font-lock-keywords | 49 (defvar change-log-font-lock-keywords |
50 '(("^[SMTWF].+" . font-lock-function-name-face) ; Date line. | 50 '(("^[12].+" . font-lock-function-name-face) ; Date line. |
51 ("^\t\\* \\([^ :\n]+\\)" 1 font-lock-comment-face) ; File name. | 51 ("^\t\\* \\([^ :\n]+\\)" 1 font-lock-comment-face) ; File name. |
52 ("(\\([^)\n]+\\)):" 1 font-lock-keyword-face)) ; Function name. | 52 ("(\\([^)\n]+\\)):" 1 font-lock-keyword-face)) ; Function name. |
53 "Additional expressions to highlight in Change Log mode.") | 53 "Additional expressions to highlight in Change Log mode.") |
54 | 54 |
55 (defvar change-log-mode-map nil | 55 (defvar change-log-mode-map nil |
56 "Keymap for Change Log major mode.") | 56 "Keymap for Change Log major mode.") |
57 (if change-log-mode-map | 57 (if change-log-mode-map |
58 nil | 58 nil |
59 (setq change-log-mode-map (make-sparse-keymap))) | 59 (setq change-log-mode-map (make-sparse-keymap))) |
60 | |
61 (defvar change-log-time-zone-rule nil | |
62 "Time zone used for calculating change log time stamps. | |
63 It takes the same format as the TZ argument of `set-time-zone-rule'. | |
64 If nil, use local time.") | |
65 | |
66 (defun iso8601-time-zone (time) | |
67 (let* ((utc-offset (or (car (current-time-zone time)) 0)) | |
68 (sign (if (< utc-offset 0) ?- ?+)) | |
69 (sec (abs utc-offset)) | |
70 (ss (% sec 60)) | |
71 (min (/ sec 60)) | |
72 (mm (% min 60)) | |
73 (hh (/ min 60))) | |
74 (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d") | |
75 ((not (zerop mm)) "%c%02d:%02d") | |
76 (t "%c%02d")) | |
77 sign hh mm ss))) | |
60 | 78 |
61 (defun change-log-name () | 79 (defun change-log-name () |
62 (or change-log-default-name | 80 (or change-log-default-name |
63 (if (eq system-type 'vax-vms) | 81 (if (eq system-type 'vax-vms) |
64 "$CHANGE_LOG$.TXT" | 82 "$CHANGE_LOG$.TXT" |
146 "Find change log file and add an entry for today. | 164 "Find change log file and add an entry for today. |
147 Optional arg (interactive prefix) non-nil means prompt for user name and site. | 165 Optional arg (interactive prefix) non-nil means prompt for user name and site. |
148 Second arg is file name of change log. If nil, uses `change-log-default-name'. | 166 Second arg is file name of change log. If nil, uses `change-log-default-name'. |
149 Third arg OTHER-WINDOW non-nil means visit in other window. | 167 Third arg OTHER-WINDOW non-nil means visit in other window. |
150 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; | 168 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; |
151 never append to an existing entry." | 169 never append to an existing entry. Today's date is calculated according to |
170 `change-log-time-zone-rule' if non-nil, otherwise in local time." | |
152 (interactive (list current-prefix-arg | 171 (interactive (list current-prefix-arg |
153 (prompt-for-change-log-name))) | 172 (prompt-for-change-log-name))) |
154 (or add-log-full-name | 173 (or add-log-full-name |
155 (setq add-log-full-name (user-full-name))) | 174 (setq add-log-full-name (user-full-name))) |
156 (or add-log-mailing-address | 175 (or add-log-mailing-address |
186 (find-file file-name)) | 205 (find-file file-name)) |
187 (or (eq major-mode 'change-log-mode) | 206 (or (eq major-mode 'change-log-mode) |
188 (change-log-mode)) | 207 (change-log-mode)) |
189 (undo-boundary) | 208 (undo-boundary) |
190 (goto-char (point-min)) | 209 (goto-char (point-min)) |
191 (if (looking-at (concat (regexp-quote (substring (current-time-string) | 210 (let ((new-entry (concat (if change-log-time-zone-rule |
192 0 10)) | 211 (let ((tz (getenv "TZ")) |
193 ".* " (regexp-quote add-log-full-name) | 212 (now (current-time))) |
194 " <" (regexp-quote add-log-mailing-address))) | 213 (unwind-protect |
195 (forward-line 1) | 214 (progn |
196 (insert (current-time-string) | 215 (set-time-zone-rule |
197 " " add-log-full-name | 216 change-log-time-zone-rule) |
198 " <" add-log-mailing-address ">\n\n")) | 217 (concat |
218 (format-time-string "%Y-%m-%d " now) | |
219 (iso8601-time-zone now))) | |
220 (set-time-zone-rule tz))) | |
221 (format-time-string "%Y-%m-%d")) | |
222 " " add-log-full-name | |
223 " <" add-log-mailing-address ">"))) | |
224 (if (looking-at (regexp-quote new-entry)) | |
225 (forward-line 1) | |
226 (insert new-entry "\n\n"))) | |
199 | 227 |
200 ;; Search only within the first paragraph. | 228 ;; Search only within the first paragraph. |
201 (if (looking-at "\n*[^\n* \t]") | 229 (if (looking-at "\n*[^\n* \t]") |
202 (skip-chars-forward "\n") | 230 (skip-chars-forward "\n") |
203 (forward-paragraph 1)) | 231 (forward-paragraph 1)) |
288 (set (make-local-variable 'fill-paragraph-function) | 316 (set (make-local-variable 'fill-paragraph-function) |
289 'change-log-fill-paragraph) | 317 'change-log-fill-paragraph) |
290 ;; Let each entry behave as one paragraph: | 318 ;; Let each entry behave as one paragraph: |
291 ;; We really do want "^" in paragraph-start below: it is only the lines that | 319 ;; We really do want "^" in paragraph-start below: it is only the lines that |
292 ;; begin at column 0 (despite the left-margin of 8) that we are looking for. | 320 ;; begin at column 0 (despite the left-margin of 8) that we are looking for. |
293 (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\sw") | 321 (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\<") |
294 (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\sw") | 322 (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\<") |
295 ;; Let all entries for one day behave as one page. | 323 ;; Let all entries for one day behave as one page. |
296 ;; Match null string on the date-line so that the date-line | 324 ;; Match null string on the date-line so that the date-line |
297 ;; is grouped with what follows. | 325 ;; is grouped with what follows. |
298 (set (make-local-variable 'page-delimiter) "^\\<\\|^\f") | 326 (set (make-local-variable 'page-delimiter) "^\\<\\|^\f") |
299 (set (make-local-variable 'version-control) 'never) | 327 (set (make-local-variable 'version-control) 'never) |