Mercurial > emacs
comparison lisp/add-log.el @ 18277:7509948b0121
(add-log-time-format): New variable.
(add-log-iso8601-time-string): New function.
(add-change-log-entry): Use add-log-time-format.
(add-log-iso8601-time-zone): Renamed from iso8601-time-zone.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 17 Jun 1997 04:27:37 +0000 |
parents | 986fa91361cc |
children | db1b53ad6c80 |
comparison
equal
deleted
inserted
replaced
18276:3835d79f8978 | 18277:7509948b0121 |
---|---|
1 ;;; add-log.el --- change log maintenance commands for Emacs | 1 ;;; add-log.el --- change log maintenance commands for Emacs |
2 | 2 |
3 ;; Copyright (C) 1985, 86, 88, 93, 94, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 86, 88, 93, 94, 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Keywords: maint | 5 ;; Keywords: tools |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
8 | 8 |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | 9 ;; GNU Emacs is free software; you can redistribute it and/or modify |
10 ;; it under the terms of the GNU General Public License as published by | 10 ;; it under the terms of the GNU General Public License as published by |
62 This defaults to the value of `user-mail-address'." | 62 This defaults to the value of `user-mail-address'." |
63 :type '(choice (const :tag "Default" nil) | 63 :type '(choice (const :tag "Default" nil) |
64 string) | 64 string) |
65 :group 'change-log) | 65 :group 'change-log) |
66 | 66 |
67 (defcustom add-log-time-format 'add-log-iso8601-time-string | |
68 "*Function that defines the time format. | |
69 For example, `add-log-iso8601-time-string', which gives the | |
70 date in international ISO 8601 format, | |
71 and `current-time-string' are two valid values." | |
72 :type '(radio (const :tag "International ISO 8601 format" | |
73 add-log-iso8601-time-string) | |
74 (const :tag "Old format, as returned by `current-time-string'" | |
75 current-time-string) | |
76 (function :tag "Other")) | |
77 :group 'change-log) | |
67 | 78 |
68 (defvar change-log-font-lock-keywords | 79 (defvar change-log-font-lock-keywords |
69 '(;; | 80 '(;; |
70 ;; Date lines, new and old styles. | 81 ;; Date lines, new and old styles. |
71 ("^\\sw.........[0-9: ]*" | 82 ("^\\sw.........[0-9: ]*" |
101 (defvar change-log-time-zone-rule nil | 112 (defvar change-log-time-zone-rule nil |
102 "Time zone used for calculating change log time stamps. | 113 "Time zone used for calculating change log time stamps. |
103 It takes the same format as the TZ argument of `set-time-zone-rule'. | 114 It takes the same format as the TZ argument of `set-time-zone-rule'. |
104 If nil, use local time.") | 115 If nil, use local time.") |
105 | 116 |
106 (defun iso8601-time-zone (time) | 117 (defun add-log-iso8601-time-zone (time) |
107 (let* ((utc-offset (or (car (current-time-zone time)) 0)) | 118 (let* ((utc-offset (or (car (current-time-zone time)) 0)) |
108 (sign (if (< utc-offset 0) ?- ?+)) | 119 (sign (if (< utc-offset 0) ?- ?+)) |
109 (sec (abs utc-offset)) | 120 (sec (abs utc-offset)) |
110 (ss (% sec 60)) | 121 (ss (% sec 60)) |
111 (min (/ sec 60)) | 122 (min (/ sec 60)) |
113 (hh (/ min 60))) | 124 (hh (/ min 60))) |
114 (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d") | 125 (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d") |
115 ((not (zerop mm)) "%c%02d:%02d") | 126 ((not (zerop mm)) "%c%02d:%02d") |
116 (t "%c%02d")) | 127 (t "%c%02d")) |
117 sign hh mm ss))) | 128 sign hh mm ss))) |
129 | |
130 (defun add-log-iso8601-time-string () | |
131 (if change-log-time-zone-rule | |
132 (let ((tz (getenv "TZ")) | |
133 (now (current-time))) | |
134 (unwind-protect | |
135 (progn | |
136 (set-time-zone-rule | |
137 change-log-time-zone-rule) | |
138 (concat | |
139 (format-time-string "%Y-%m-%d " now) | |
140 (add-log-iso8601-time-zone now))) | |
141 (set-time-zone-rule tz))) | |
142 (format-time-string "%Y-%m-%d"))) | |
118 | 143 |
119 (defun change-log-name () | 144 (defun change-log-name () |
120 (or change-log-default-name | 145 (or change-log-default-name |
121 (if (eq system-type 'vax-vms) | 146 (if (eq system-type 'vax-vms) |
122 "$CHANGE_LOG$.TXT" | 147 "$CHANGE_LOG$.TXT" |
195 (setq file-name file1))))) | 220 (setq file-name file1))))) |
196 ;; Make a local variable in this buffer so we needn't search again. | 221 ;; Make a local variable in this buffer so we needn't search again. |
197 (set (make-local-variable 'change-log-default-name) file-name) | 222 (set (make-local-variable 'change-log-default-name) file-name) |
198 file-name) | 223 file-name) |
199 | 224 |
225 | |
200 ;;;###autoload | 226 ;;;###autoload |
201 (defun add-change-log-entry (&optional whoami file-name other-window new-entry) | 227 (defun add-change-log-entry (&optional whoami file-name other-window new-entry) |
202 "Find change log file and add an entry for today. | 228 "Find change log file and add an entry for today. |
203 Optional arg (interactive prefix) non-nil means prompt for user name and site. | 229 Optional arg (interactive prefix) non-nil means prompt for user name and site. |
204 Second arg is file name of change log. If nil, uses `change-log-default-name'. | 230 Second arg is file name of change log. If nil, uses `change-log-default-name'. |
243 (find-file file-name)) | 269 (find-file file-name)) |
244 (or (eq major-mode 'change-log-mode) | 270 (or (eq major-mode 'change-log-mode) |
245 (change-log-mode)) | 271 (change-log-mode)) |
246 (undo-boundary) | 272 (undo-boundary) |
247 (goto-char (point-min)) | 273 (goto-char (point-min)) |
248 (let ((new-entry (concat (if change-log-time-zone-rule | 274 (let ((new-entry (concat (funcall add-log-time-format) |
249 (let ((tz (getenv "TZ")) | |
250 (now (current-time))) | |
251 (unwind-protect | |
252 (progn | |
253 (set-time-zone-rule | |
254 change-log-time-zone-rule) | |
255 (concat | |
256 (format-time-string "%Y-%m-%d " now) | |
257 (iso8601-time-zone now))) | |
258 (set-time-zone-rule tz))) | |
259 (format-time-string "%Y-%m-%d")) | |
260 " " add-log-full-name | 275 " " add-log-full-name |
261 " <" add-log-mailing-address ">"))) | 276 " <" add-log-mailing-address ">"))) |
262 (if (looking-at (regexp-quote new-entry)) | 277 (if (looking-at (regexp-quote new-entry)) |
263 (forward-line 1) | 278 (forward-line 1) |
264 (insert new-entry "\n\n"))) | 279 (insert new-entry "\n\n"))) |