annotate lisp/add-log.el @ 671:21d23fa6fa2a

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Tue, 02 Jun 1992 04:00:54 +0000
parents 7fa6b835da67
children 8cff3b3bd089
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1 ;;; add-log.el --- change log maintenance commands for Emacs
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
3 ;; Copyright (C) 1985-1991 Free Software Foundation, Inc.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
4
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
6
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 1, or (at your option)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10 ;; any later version.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
15 ;; GNU General Public License for more details.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 (defvar change-log-default-name nil
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 "*Name of a change log file for \\[add-change-log-entry].")
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 (defun change-log-name ()
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27 (or change-log-default-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog")))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 (defun prompt-for-change-log-name ()
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31 "Prompt for a change log name."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 (let ((default (change-log-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 (expand-file-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 (read-file-name (format "Log file (default %s): " default)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 nil default))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38 (defun add-change-log-entry (&optional whoami file-name other-window)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 "Find change log file and add an entry for today.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 Optional arg (interactive prefix) non-nil means prompt for user name and site.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 Second arg is file name of change log. If nil, uses `change-log-default-name'.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 Third arg OTHER-WINDOW non-nil means visit in other window."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
43 (interactive (list current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
44 (prompt-for-change-log-name)))
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
45 (let* ((default (if (eq system-type 'vax-vms)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
46 "$CHANGE_LOG$.TXT"
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
47 "ChangeLog"))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
48 (full-name (if whoami
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 (read-input "Full name: " (user-full-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 (user-full-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 ;; Note that some sites have room and phone number fields in
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 ;; full name which look silly when inserted. Rather than do
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 ;; anything about that here, let user give prefix argument so that
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
54 ;; s/he can edit the full name field in prompter if s/he wants.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 (login-name (if whoami
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 (read-input "Login name: " (user-login-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (user-login-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 (site-name (if whoami
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
59 (read-input "Site name: " (system-name))
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
60 (system-name)))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
61 (defun (add-log-current-defun))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
62 (entry (and buffer-file-name
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
63 (file-name-nondirectory buffer-file-name)))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
64 entry-position entry-boundary empty-entry)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
65 ;; Never want to add a change log entry for the ChangeLog buffer itself:
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
66 (if (equal default entry)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
67 (setq entry nil
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
68 formatted-revision nil
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
69 defun nil))
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
70 (or file-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
71 (setq file-name (or change-log-default-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
72 default-directory)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73 (if (file-directory-p file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
74 (setq file-name (concat (file-name-as-directory file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
75 (change-log-name))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
76 (set (make-local-variable 'change-log-default-name) file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
77 (if (and other-window (not (equal file-name buffer-file-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
78 (find-file-other-window file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
79 (find-file file-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
80 (undo-boundary)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
81 (goto-char (point-min))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
82 (if (not (and (looking-at (substring (current-time-string) 0 10))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
83 (looking-at (concat ".* " full-name " (" login-name "@"))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
84 (progn (insert (current-time-string)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
85 " " full-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 " (" login-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87 "@" site-name ")\n\n")))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88 (goto-char (point-min))
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
89 (setq empty-entry
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
90 (and (search-forward "\n\t* \n" nil t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
91 (1- (point))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
92 (if (and entry
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
93 (not empty-entry))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
94 ;; Look for today's entry for same file
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
95 ;; If there is an empty entry (just a `*'), take the hint and
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
96 ;; use it. This is so that C-x a from the ChangeLog buffer
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
97 ;; itself can be used to force the next entry to be added at
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
98 ;; the beginning, even if there are today's entries for the
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
99 ;; same file (but perhaps different revisions).
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
100 (setq entry-boundary (save-excursion
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
101 (and (re-search-forward "\n[A-Z]" nil t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
102 (point)))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
103 entry-position (save-excursion
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
104 (and (re-search-forward
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
105 (concat
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
106 (regexp-quote (concat "* " entry))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
107 ;; don't accept `foo.bar' when
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
108 ;; looking for `foo':
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
109 "[ \n\t,]")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
110 entry-boundary
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
111 t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
112 (1- (match-end 0))))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
113 (cond (entry-position
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
114 ;; Move to existing entry for same file.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
115 (goto-char entry-position)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
116 (search-forward "\n\n")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
117 (forward-line -1))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
118 (empty-entry
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
119 ;; Put this file name into existing empty entry.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
120 (goto-char empty-entry)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
121 (insert (or entry "")))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
122 (t
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
123 ;; Make a new entry
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
124 (forward-line 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
125 (while (looking-at "\\sW")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
126 (forward-line 1))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
127 (delete-region (point)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
128 (progn
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
129 (skip-chars-backward "\n")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
130 (point)))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
131 (open-line 3)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
132 (forward-line 2)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
133 (indent-to left-margin)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
134 (insert "* " (or entry ""))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
135 ;; Point is at the entry for this file,
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
136 ;; either at the end of the line or at the first blank line.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
137 (if defun
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
138 (progn
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
139 ;; Make it easy to get rid of the defun name.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
140 (undo-boundary)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
141 (insert "(" defun "): ")))))
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
142
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
143 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
144 (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
145
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
146 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
147 (defun add-change-log-entry-other-window (&optional whoami file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
148 "Find change log file in other window and add an entry for today.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
149 First arg (interactive prefix) non-nil means prompt for user name and site.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
150 Second arg is file name of change log.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
151 Interactively, with a prefix argument, the file name is prompted for."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152 (interactive (if current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 (list current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154 (prompt-for-change-log-name))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 (add-change-log-entry whoami file-name t))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
156
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
157 (defun change-log-mode ()
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
158 (interactive)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
159 (kill-all-local-variables)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
160 (indented-text-mode)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
161 (setq major-mode 'change-log-mode)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
162 (setq mode-name "Change Log")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
163 ;; Let each entry behave as one paragraph:
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
164 (set (make-local-variable 'paragraph-start) "^$\\|^^L")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
165 (set (make-local-variable 'paragraph-separate) "^$\\|^^L")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
166 ;; Let all entries for one day behave as one page.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
167 ;; Note that a page boundary is also a paragraph boundary.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
168 ;; Unfortunately the date line of a page actually belongs to
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
169 ;; the next day, but I don't see how to avoid that since
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
170 ;; page moving cmds go to the end of the match, and Emacs
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
171 ;; regexps don't have a context feature.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
172 (set (make-local-variable 'page-delimiter) "^[A-Z][a-z][a-z] .*\n\\|^ ")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
173 (run-hooks 'change-log-mode-hook))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
174
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
175 (defvar add-log-current-defun-header-regexp
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
176 "^\\([A-Z][A-Z_ ]+\\|[a-z_---A-Z]+\\)[ \t]*[:=]"
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
177 "*Heuristic regexp used by `add-log-current-defun' for unknown major modes.")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
178
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
179 (defun add-log-current-defun ()
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
180 "Return name of function definition point is in, or nil.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
181
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
182 Understands Lisp, LaTeX (\"functions\" are chapters, sections, ...),
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
183 Texinfo (@node titles), and C.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
184
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
185 Other modes are handled by a heuristic that looks in the 10K before
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
186 point for uppercase headings starting in the first column or
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
187 identifiers followed by `:' or `=', see variable
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
188 `add-log-current-defun-header-regexp'.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
189
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
190 Has a preference of looking backwards."
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
191 (save-excursion
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
192 (cond ((memq major-mode '(emacs-lisp-mode lisp-mode))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
193 (beginning-of-defun)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
194 (forward-word 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
195 (skip-chars-forward " ")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
196 (buffer-substring (point)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
197 (progn (forward-sexp 1) (point))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
198 ((eq major-mode 'c-mode)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
199 ;; must be inside function body for this to work
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
200 (beginning-of-defun)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
201 (forward-line -1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
202 (while (looking-at "[ \t\n]") ; skip typedefs of arglist
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
203 (forward-line -1))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
204 (down-list 1) ; into arglist
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
205 (backward-up-list 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
206 (skip-chars-backward " \t")
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
207 (buffer-substring (point)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
208 (progn (backward-sexp 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
209 (point))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
210 ((memq major-mode
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
211 '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
212 plain-tex-mode latex-mode;; cmutex.el
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
213 ))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
214 (if (re-search-backward
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
215 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
216 (progn
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
217 (goto-char (match-beginning 0))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
218 (buffer-substring (1+ (point));; without initial backslash
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
219 (progn
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
220 (end-of-line)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
221 (point))))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
222 ((eq major-mode 'texinfo-mode)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
223 (if (re-search-backward "^@node[ \t]+\\([^,]+\\)," nil t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
224 (buffer-substring (match-beginning 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
225 (match-end 1))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
226 (t
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
227 ;; If all else fails, try heuristics
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
228 (let (case-fold-search)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
229 (if (re-search-backward add-log-current-defun-header-regexp
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
230 (- (point) 10000)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
231 t)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
232 (buffer-substring (match-beginning 1)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
233 (match-end 1))))))))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
234
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 ;;; add-log.el ends here