annotate lisp/add-log.el @ 684:bd574e49bfac

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