*** empty log message ***
[emacs.git] / lisp / add-log.el
blobf2c279ae3571336d5ed79788166afef2d61060ce
1 ;;; add-log.el --- change log maintenance commands for Emacs
3 ;; Copyright (C) 1985-1991 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
10 ;; any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 ;;;###autoload
23 (defvar change-log-default-name nil
24 "*Name of a change log file for \\[add-change-log-entry].")
26 (defun change-log-name ()
27 (or change-log-default-name
28 (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog")))
30 (defun prompt-for-change-log-name ()
31 "Prompt for a change log name."
32 (let ((default (change-log-name)))
33 (expand-file-name
34 (read-file-name (format "Log file (default %s): " default)
35 nil default))))
37 ;;;###autoload
38 (defun add-change-log-entry (&optional whoami file-name other-window)
39 "Find change log file and add an entry for today.
40 Optional arg (interactive prefix) non-nil means prompt for user name and site.
41 Second arg is file name of change log. If nil, uses `change-log-default-name'.
42 Third arg OTHER-WINDOW non-nil means visit in other window."
43 (interactive (list current-prefix-arg
44 (prompt-for-change-log-name)))
45 (let* ((full-name (if whoami
46 (read-input "Full name: " (user-full-name))
47 (user-full-name)))
48 ;; Note that some sites have room and phone number fields in
49 ;; full name which look silly when inserted. Rather than do
50 ;; anything about that here, let user give prefix argument so that
51 ;; s/he can edit the full name field in prompter if s/he wants.
52 (login-name (if whoami
53 (read-input "Login name: " (user-login-name))
54 (user-login-name)))
55 (site-name (if whoami
56 (read-input "Site name: " (system-name))
57 (system-name))))
58 (or file-name
59 (setq file-name (or change-log-default-name
60 default-directory)))
61 (if (file-directory-p file-name)
62 (setq file-name (concat (file-name-as-directory file-name)
63 (change-log-name))))
64 (set (make-local-variable 'change-log-default-name) file-name)
65 (if (and other-window (not (equal file-name buffer-file-name)))
66 (find-file-other-window file-name)
67 (find-file file-name))
68 (undo-boundary)
69 (goto-char (point-min))
70 (if (not (and (looking-at (substring (current-time-string) 0 10))
71 (looking-at (concat ".* " full-name " (" login-name "@"))))
72 (progn (insert (current-time-string)
73 " " full-name
74 " (" login-name
75 "@" site-name ")\n\n")))
76 (goto-char (point-min))
77 (forward-line 1)
78 (while (looking-at "\\sW")
79 (forward-line 1))
80 (delete-region (point)
81 (progn
82 (skip-chars-backward "\n")
83 (point)))
84 (open-line 3)
85 (forward-line 2)
86 (indent-to left-margin)
87 (insert "* ")))
89 ;;;###autoload
90 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
92 ;;;###autoload
93 (defun add-change-log-entry-other-window (&optional whoami file-name)
94 "Find change log file in other window and add an entry for today.
95 First arg (interactive prefix) non-nil means prompt for user name and site.
96 Second arg is file name of change log.
97 Interactively, with a prefix argument, the file name is prompted for."
98 (interactive (if current-prefix-arg
99 (list current-prefix-arg
100 (prompt-for-change-log-name))))
101 (add-change-log-entry whoami file-name t))
103 ;;; add-log.el ends here