annotate lisp/add-log.el @ 1745:341d551a3411

Initial revision
author Richard M. Stallman <rms@gnu.org>
date Fri, 08 Jan 1993 15:30:08 +0000
parents d6cc12c97a59
children b2af3186e7a7
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
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 678
diff changeset
10 ;; the Free Software Foundation; either version 2, or (at your option)
661
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
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 678
diff changeset
22 ;;; Code:
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
24 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
25 (defvar change-log-default-name nil
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
26 "*Name of a change log file for \\[add-change-log-entry].")
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 (defun change-log-name ()
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29 (or change-log-default-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
30 (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog")))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
31
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
32 (defun prompt-for-change-log-name ()
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33 "Prompt for a change log name."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 (let ((default (change-log-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35 (expand-file-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
36 (read-file-name (format "Log file (default %s): " default)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
37 nil default))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
38
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
39 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
40 (defun add-change-log-entry (&optional whoami file-name other-window)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
41 "Find change log file and add an entry for today.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
42 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
43 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
44 Third arg OTHER-WINDOW non-nil means visit in other window."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
45 (interactive (list current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
46 (prompt-for-change-log-name)))
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
47 (let* ((full-name (if whoami
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
48 (read-input "Full name: " (user-full-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
49 (user-full-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
50 ;; Note that some sites have room and phone number fields in
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
51 ;; full name which look silly when inserted. Rather than do
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
52 ;; anything about that here, let user give prefix argument so that
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
53 ;; 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
54 (login-name (if whoami
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
55 (read-input "Login name: " (user-login-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
56 (user-login-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
57 (site-name (if whoami
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
58 (read-input "Site name: " (system-name))
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
59 (system-name)))
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
60 (defun (add-log-current-defun))
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
61 paragraph-end entry)
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
62 (or file-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
63 (setq file-name (or change-log-default-name
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
64 default-directory)))
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
65 (setq file-name (if (file-directory-p file-name)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
66 (expand-file-name (change-log-name) file-name)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
67 (expand-file-name file-name)))
912
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
68 ;; Chase links before visiting the file.
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
69 ;; This makes it easier to use a single change log file
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
70 ;; for several related directories.
1644
35fbd349c58d (add-change-log-entry): Expand file-name again after chasing links.
Richard M. Stallman <rms@gnu.org>
parents: 1447
diff changeset
71 (setq file-name
35fbd349c58d (add-change-log-entry): Expand file-name again after chasing links.
Richard M. Stallman <rms@gnu.org>
parents: 1447
diff changeset
72 (expand-file-name (or (file-symlink-p file-name) file-name)))
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
73 (set (make-local-variable 'change-log-default-name) file-name)
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
74
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
75 ;; Set ENTRY to the file name to use in the new entry.
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
76 (and buffer-file-name
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
77 ;; Never want to add a change log entry for the ChangeLog file itself.
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
78 (not (string= buffer-file-name file-name))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
79 (setq entry (if (string-match
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
80 (concat "^" (regexp-quote (file-name-directory
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
81 file-name)))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
82 buffer-file-name)
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
83 (substring buffer-file-name (match-end 0))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
84 (file-name-nondirectory buffer-file-name))))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
85
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86 (if (and other-window (not (equal file-name buffer-file-name)))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
87 (find-file-other-window file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
88 (find-file file-name))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
89 (undo-boundary)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
90 (goto-char (point-min))
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
91 (or (looking-at (concat (regexp-quote (substring (current-time-string)
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
92 0 10))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
93 ".* " (regexp-quote full-name)
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
94 " (" (regexp-quote login-name) "@"))
951
c23539669808 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 947
diff changeset
95 (insert (current-time-string)
c23539669808 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 947
diff changeset
96 " " full-name
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
97 " (" login-name "@" site-name ")\n\n"))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
98
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
99 ;; Search only within the first paragraph.
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
100 (forward-paragraph 1)
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
101 (setq paragraph-end (point))
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
102 (goto-char (point-min))
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
103
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
104 ;; Now insert the new line for this entry.
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
105 (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t)
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
106 ;; Put this file name into the existing empty entry.
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
107 (if entry
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
108 (insert entry)))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
109 ((and (re-search-forward
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
110 (concat (regexp-quote (concat "* " entry))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
111 ;; Don't accept `foo.bar' when
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
112 ;; looking for `foo':
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
113 "\\(\\s \\|[(),:]\\)")
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
114 paragraph-end t))
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
115 ;; Add to the existing entry for the same file.
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
116 (re-search-forward "^\\s *$\\|^\\s \\*")
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
117 (beginning-of-line)
912
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
118 (while (and (not (eobp)) (looking-at "^\\s *$"))
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
119 (delete-region (point) (save-excursion (forward-line 1) (point))))
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
120 (insert "\n\n")
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
121 (forward-line -2)
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
122 (indent-relative-maybe))
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
123 (t
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
124 ;; Make a new entry.
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
125 (forward-line 1)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
126 (while (looking-at "\\sW")
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
127 (forward-line 1))
912
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
128 (while (and (not (eobp)) (looking-at "^\\s *$"))
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
129 (delete-region (point) (save-excursion (forward-line 1) (point))))
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
130 (insert "\n\n\n")
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
131 (forward-line -2)
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
132 (indent-to left-margin)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
133 (insert "* " (or entry ""))))
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
134 ;; Now insert the function name, if we have one.
666
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
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
139 ;; 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
140 (undo-boundary)
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
141 (insert (if (save-excursion
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
142 (beginning-of-line 1)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
143 (looking-at "\\s *$"))
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
144 ""
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
145 " ")
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
146 "(" defun "): "))
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
147 ;; No function name, so put in a colon unless we have just a star.
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
148 (if (not (save-excursion
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
149 (beginning-of-line 1)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
150 (looking-at "\\s *\\(\\*\\s *\\)?$")))
837
a8aef92e0025 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 811
diff changeset
151 (insert ": ")))))
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
152
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
153 ;;;###autoload
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
154 (defun add-change-log-entry-other-window (&optional whoami file-name)
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
155 "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
156 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
157 Second arg is file name of change log.
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
158 Interactively, with a prefix argument, the file name is prompted for."
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
159 (interactive (if current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
160 (list current-prefix-arg
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
161 (prompt-for-change-log-name))))
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
162 (add-change-log-entry whoami file-name t))
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
163 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
661
36fbc3f71803 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
164
980
b62886fbf2a7 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 953
diff changeset
165 ;;;###autoload
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
166 (defun change-log-mode ()
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
167 "Major mode for editting change logs; like Indented Text Mode.
912
1c37c99856de *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
168 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
951
c23539669808 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 947
diff changeset
169 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
c23539669808 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 947
diff changeset
170 Each entry behaves as a paragraph, and the entries for one day as a page.
c23539669808 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 947
diff changeset
171 Runs `change-log-mode-hook'."
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
172 (interactive)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
173 (kill-all-local-variables)
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
174 (indented-text-mode)
1727
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
175 (setq major-mode 'change-log-mode
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
176 mode-name "Change Log"
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
177 left-margin 8
d6cc12c97a59 (add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents: 1644
diff changeset
178 fill-column 74)
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
179 ;; Let each entry behave as one paragraph:
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
180 (set (make-local-variable 'paragraph-start) "^\\s *$\\|^^L")
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
181 (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
182 ;; Let all entries for one day behave as one page.
1078
15b4ed20e524 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1062
diff changeset
183 ;; Match null string on the date-line so that the date-line
15b4ed20e524 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1062
diff changeset
184 ;; is grouped with what follows.
15b4ed20e524 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1062
diff changeset
185 (set (make-local-variable 'page-delimiter) "^\\<\\|^ ")
678
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
186 (set (make-local-variable 'version-control) 'never)
8cff3b3bd089 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 666
diff changeset
187 (set (make-local-variable 'adaptive-fill-regexp) "\\s *")
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
188 (run-hooks 'change-log-mode-hook))
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 (defvar add-log-current-defun-header-regexp
1369
e5cb5060bb51 (add-log-current-defun): In normal C case,
Richard M. Stallman <rms@gnu.org>
parents: 1351
diff changeset
191 "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[a-z_---A-Z]+\\)[ \t]*[:=]"
666
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
192 "*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
193
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
194 (defun add-log-current-defun ()
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
195 "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
196
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
197 Understands Lisp, LaTeX (\"functions\" are chapters, sections, ...),
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
198 Texinfo (@node titles), and C.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
199
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
200 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
201 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
202 identifiers followed by `:' or `=', see variable
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
203 `add-log-current-defun-header-regexp'.
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
204
7fa6b835da67 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 661
diff changeset
205 Has a preference of looking backwards."
1447
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
206 (condition-case nil
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
207 (save-excursion
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
208 (let ((location (point)))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
209 (cond ((memq major-mode '(emacs-lisp-mode lisp-mode scheme-mode))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
210 ;; If we are now precisely a the beginning of a defun,
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
211 ;; make sure beginning-of-defun finds that one
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
212 ;; rather than the previous one.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
213 (or (eobp) (forward-char 1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
214 (beginning-of-defun)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
215 ;; Make sure we are really inside the defun found, not after it.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
216 (if (and (progn (end-of-defun)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
217 (< location (point)))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
218 (progn (forward-sexp -1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
219 (>= location (point))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
220 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
221 (forward-word 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
222 (skip-chars-forward " ")
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
223 (buffer-substring (point)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
224 (progn (forward-sexp 1) (point))))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
225 ((and (memq major-mode '(c-mode 'c++-mode))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
226 (save-excursion (beginning-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
227 ;; Use eq instead of = here to avoid
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
228 ;; error when at bob and char-after
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
229 ;; returns nil.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
230 (while (eq (char-after (- (point) 2)) ?\\)
953
7c035a87c691 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 951
diff changeset
231 (forward-line -1))
1447
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
232 (looking-at "[ \t]*#[ \t]*define[ \t]")))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
233 ;; Handle a C macro definition.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
234 (beginning-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
235 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
236 (forward-line -1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
237 (search-forward "define")
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
238 (skip-chars-forward " \t")
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
239 (buffer-substring (point)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
240 (progn (forward-sexp 1) (point))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
241 ((memq major-mode '(c-mode 'c++-mode))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
242 (beginning-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
243 ;; See if we are in the beginning part of a function,
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
244 ;; before the open brace. If so, advance forward.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
245 (while (not (looking-at "{\\|\\(\\s *$\\)"))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
246 (forward-line 1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
247 (or (eobp)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
248 (forward-char 1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
249 (beginning-of-defun)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
250 (if (progn (end-of-defun)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
251 (< location (point)))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
252 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
253 (backward-sexp 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
254 (let (beg tem)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
255
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
256 (forward-line -1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
257 ;; Skip back over typedefs of arglist.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
258 (while (and (not (bobp))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
259 (looking-at "[ \t\n]"))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
260 (forward-line -1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
261 ;; See if this is using the DEFUN macro used in Emacs,
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
262 ;; or the DEFUN macro used by the C library.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
263 (if (condition-case nil
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
264 (and (save-excursion
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
265 (forward-line 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
266 (backward-sexp 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
267 (beginning-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
268 (setq tem (point))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
269 (looking-at "DEFUN\\b"))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
270 (>= location tem))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
271 (error nil))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
272 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
273 (goto-char tem)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
274 (down-list 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
275 (if (= (char-after (point)) ?\")
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
276 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
277 (forward-sexp 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
278 (skip-chars-forward " ,")))
953
7c035a87c691 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 951
diff changeset
279 (buffer-substring (point)
1447
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
280 (progn (forward-sexp 1) (point))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
281 ;; Ordinary C function syntax.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
282 (setq beg (point))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
283 (if (condition-case nil
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
284 ;; Protect against "Unbalanced parens" error.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
285 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
286 (down-list 1) ; into arglist
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
287 (backward-up-list 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
288 (skip-chars-backward " \t")
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
289 t)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
290 (error nil))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
291 ;; Verify initial pos was after
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
292 ;; real start of function.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
293 (if (and (save-excursion
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
294 (goto-char beg)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
295 ;; For this purpose, include the line
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
296 ;; that has the decl keywords. This
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
297 ;; may also include some of the
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
298 ;; comments before the function.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
299 (while (and (not (bobp))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
300 (save-excursion
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
301 (forward-line -1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
302 (looking-at "[^\n\f]")))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
303 (forward-line -1))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
304 (>= location (point)))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
305 ;; Consistency check: going down and up
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
306 ;; shouldn't take us back before BEG.
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
307 (> (point) beg))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
308 (buffer-substring (point)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
309 (progn (backward-sexp 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
310 (point))))))))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
311 ((memq major-mode
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
312 '(TeX-mode plain-TeX-mode LaTeX-mode;; tex-mode.el
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
313 plain-tex-mode latex-mode;; cmutex.el
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
314 ))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
315 (if (re-search-backward
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
316 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
317 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
318 (goto-char (match-beginning 0))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
319 (buffer-substring (1+ (point));; without initial backslash
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
320 (progn
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
321 (end-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
322 (point))))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
323 ((eq major-mode 'texinfo-mode)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
324 (if (re-search-backward "^@node[ \t]+\\([^,]+\\)," nil t)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
325 (buffer-substring (match-beginning 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
326 (match-end 1))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
327 (t
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
328 ;; If all else fails, try heuristics
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
329 (let (case-fold-search)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
330 (end-of-line)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
331 (if (re-search-backward add-log-current-defun-header-regexp
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
332 (- (point) 10000)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
333 t)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
334 (buffer-substring (match-beginning 1)
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
335 (match-end 1))))))))
75fa9ad982a5 (add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents: 1369
diff changeset
336 (error nil)))
999
d8d503897aa5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 980
diff changeset
337
d8d503897aa5 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 980
diff changeset
338
980
b62886fbf2a7 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 953
diff changeset
339 (provide 'add-log)
b62886fbf2a7 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 953
diff changeset
340
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 678
diff changeset
341 ;;; add-log.el ends here