Mercurial > emacs
annotate lisp/add-log.el @ 1973:3a08dacd8bfb
These are in preparation for a more thorough renaming to occur soon.
* scroll-bar.el: Provide `scroll-bar', not `scrollbar'.
* term/x-win.el: Require `scroll-bar', not `scrollbar'.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Tue, 02 Mar 1993 02:11:18 +0000 |
parents | 02bb7721b67c |
children | ced6a5b2519d |
rev | line source |
---|---|
661 | 1 ;;; add-log.el --- change log maintenance commands for Emacs |
2 | |
1956
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1988, 1993 Free Software Foundation, Inc. |
661 | 4 |
5 ;; This file is part of GNU Emacs. | |
6 | |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
8 ;; it under the terms of the GNU General Public License as published by | |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
9 ;; the Free Software Foundation; either version 2, or (at your option) |
661 | 10 ;; any later version. |
11 | |
12 ;; GNU Emacs is distributed in the hope that it will be useful, | |
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 ;; GNU General Public License for more details. | |
16 | |
17 ;; You should have received a copy of the GNU General Public License | |
18 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 | |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
21 ;;; Code: |
661 | 22 |
23 ;;;###autoload | |
24 (defvar change-log-default-name nil | |
25 "*Name of a change log file for \\[add-change-log-entry].") | |
26 | |
27 (defun change-log-name () | |
28 (or change-log-default-name | |
29 (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog"))) | |
30 | |
31 (defun prompt-for-change-log-name () | |
32 "Prompt for a change log name." | |
33 (let ((default (change-log-name))) | |
34 (expand-file-name | |
35 (read-file-name (format "Log file (default %s): " default) | |
36 nil default)))) | |
37 | |
38 ;;;###autoload | |
39 (defun add-change-log-entry (&optional whoami file-name other-window) | |
40 "Find change log file and add an entry for today. | |
41 Optional arg (interactive prefix) non-nil means prompt for user name and site. | |
42 Second arg is file name of change log. If nil, uses `change-log-default-name'. | |
43 Third arg OTHER-WINDOW non-nil means visit in other window." | |
44 (interactive (list current-prefix-arg | |
45 (prompt-for-change-log-name))) | |
678 | 46 (let* ((full-name (if whoami |
661 | 47 (read-input "Full name: " (user-full-name)) |
48 (user-full-name))) | |
49 ;; Note that some sites have room and phone number fields in | |
50 ;; full name which look silly when inserted. Rather than do | |
51 ;; anything about that here, let user give prefix argument so that | |
52 ;; s/he can edit the full name field in prompter if s/he wants. | |
53 (login-name (if whoami | |
54 (read-input "Login name: " (user-login-name)) | |
55 (user-login-name))) | |
56 (site-name (if whoami | |
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)) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
60 paragraph-end entry) |
661 | 61 (or file-name |
62 (setq file-name (or change-log-default-name | |
63 default-directory))) | |
678 | 64 (setq file-name (if (file-directory-p file-name) |
65 (expand-file-name (change-log-name) file-name) | |
66 (expand-file-name file-name))) | |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
67 ;; Chase links before visiting the file. |
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
68 ;; 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
|
69 ;; 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
|
70 (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
|
71 (expand-file-name (or (file-symlink-p file-name) file-name))) |
1752
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
72 ;; Move up in the dir hierarchy till we find a change log file. |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
73 (let ((file1 file-name) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
74 parent-dir) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
75 (while (and (not (file-exists-p file1)) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
76 (progn (setq parent-dir |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
77 (file-name-directory |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
78 (directory-file-name |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
79 (file-name-directory file1)))) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
80 ;; Give up if we are already at the root dir. |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
81 (not (string= (file-name-directory file1) parent-dir)))) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
82 ;; Move up to the parent dir and try again. |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
83 (setq file1 (expand-file-name (change-log-name) parent-dir))) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
84 ;; If we found a change log in a parent, use that. |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
85 (if (file-exists-p file1) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
86 (setq file-name file1))) |
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
87 |
661 | 88 (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
|
89 |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
90 ;; 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
|
91 (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
|
92 ;; 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
|
93 (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
|
94 (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
|
95 (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
|
96 file-name))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
97 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
|
98 (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
|
99 (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
|
100 |
661 | 101 (if (and other-window (not (equal file-name buffer-file-name))) |
102 (find-file-other-window file-name) | |
103 (find-file file-name)) | |
104 (undo-boundary) | |
105 (goto-char (point-min)) | |
1956
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
106 (if (looking-at (concat (regexp-quote (substring (current-time-string) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
107 0 10)) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
108 ".* " (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
|
109 " (" (regexp-quote login-name) "@")) |
1956
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
110 (forward-line 1) |
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
111 (insert (current-time-string) |
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
112 " " full-name |
02bb7721b67c
(add-change-log-entry): Find end of first paragraph from after the header line.
Richard M. Stallman <rms@gnu.org>
parents:
1847
diff
changeset
|
113 " (" login-name "@" site-name ")\n\n")) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
114 |
1847
63af9f715bd3
(add-change-log-entry): Undo Jan 25 change. It worked for buffers in
Roland McGrath <roland@gnu.org>
parents:
1813
diff
changeset
|
115 ;; Search only within the first paragraph. |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
116 (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
|
117 (setq paragraph-end (point)) |
661 | 118 (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
|
119 |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
120 ;; 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
|
121 (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
|
122 ;; 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
|
123 (if entry |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
124 (insert entry))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
125 ((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
|
126 (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
|
127 ;; 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
|
128 ;; 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
|
129 "\\(\\s \\|[(),:]\\)") |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
130 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
|
131 ;; 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
|
132 (re-search-forward "^\\s *$\\|^\\s \\*") |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
133 (beginning-of-line) |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
134 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
135 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
136 (insert "\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
137 (forward-line -2) |
678 | 138 (indent-relative-maybe)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
139 (t |
678 | 140 ;; Make a new entry. |
141 (forward-line 1) | |
142 (while (looking-at "\\sW") | |
143 (forward-line 1)) | |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
144 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
145 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
146 (insert "\n\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
147 (forward-line -2) |
678 | 148 (indent-to left-margin) |
149 (insert "* " (or entry "")))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
150 ;; 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
|
151 ;; Point is at the entry for this file, |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
152 ;; 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
|
153 (if defun |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
154 (progn |
678 | 155 ;; 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
|
156 (undo-boundary) |
678 | 157 (insert (if (save-excursion |
158 (beginning-of-line 1) | |
159 (looking-at "\\s *$")) | |
160 "" | |
161 " ") | |
162 "(" defun "): ")) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
163 ;; No function name, so put in a colon unless we have just a star. |
678 | 164 (if (not (save-excursion |
165 (beginning-of-line 1) | |
166 (looking-at "\\s *\\(\\*\\s *\\)?$"))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
167 (insert ": "))))) |
661 | 168 |
169 ;;;###autoload | |
170 (defun add-change-log-entry-other-window (&optional whoami file-name) | |
171 "Find change log file in other window and add an entry for today. | |
172 First arg (interactive prefix) non-nil means prompt for user name and site. | |
173 Second arg is file name of change log. | |
174 Interactively, with a prefix argument, the file name is prompted for." | |
175 (interactive (if current-prefix-arg | |
176 (list current-prefix-arg | |
177 (prompt-for-change-log-name)))) | |
178 (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
|
179 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) |
661 | 180 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
181 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
182 (defun change-log-mode () |
678 | 183 "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
|
184 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. |
951 | 185 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window]. |
186 Each entry behaves as a paragraph, and the entries for one day as a page. | |
187 Runs `change-log-mode-hook'." | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
188 (interactive) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
189 (kill-all-local-variables) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
190 (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
|
191 (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
|
192 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
|
193 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
|
194 fill-column 74) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
195 ;; Let each entry behave as one paragraph: |
678 | 196 (set (make-local-variable 'paragraph-start) "^\\s *$\\|^^L") |
197 (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
|
198 ;; 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
|
199 ;; 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
|
200 ;; is grouped with what follows. |
15b4ed20e524
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1062
diff
changeset
|
201 (set (make-local-variable 'page-delimiter) "^\\<\\|^") |
678 | 202 (set (make-local-variable 'version-control) 'never) |
203 (set (make-local-variable 'adaptive-fill-regexp) "\\s *") | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
204 (run-hooks 'change-log-mode-hook)) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
205 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
206 (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
|
207 "^\\([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
|
208 "*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
|
209 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
210 (defun add-log-current-defun () |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
211 "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
|
212 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
213 Understands Lisp, LaTeX (\"functions\" are chapters, sections, ...), |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
214 Texinfo (@node titles), and C. |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
215 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
216 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
|
217 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
|
218 identifiers followed by `:' or `=', see variable |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
219 `add-log-current-defun-header-regexp'. |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
220 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
221 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
|
222 (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
223 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
224 (let ((location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
225 (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
|
226 ;; 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
|
227 ;; 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
|
228 ;; rather than the previous one. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
229 (or (eobp) (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
230 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
231 ;; 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
|
232 (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
|
233 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
234 (progn (forward-sexp -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
235 (>= location (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
236 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
237 (forward-word 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
238 (skip-chars-forward " ") |
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 ((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
|
242 (save-excursion (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
243 ;; 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
|
244 ;; 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
|
245 ;; returns nil. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
246 (while (eq (char-after (- (point) 2)) ?\\) |
953 | 247 (forward-line -1)) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
248 (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
|
249 ;; Handle a C macro definition. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
250 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
251 (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
|
252 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
253 (search-forward "define") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
254 (skip-chars-forward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
255 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
256 (progn (forward-sexp 1) (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
257 ((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
|
258 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
259 ;; 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
|
260 ;; 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
|
261 (while (not (looking-at "{\\|\\(\\s *$\\)")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
262 (forward-line 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
263 (or (eobp) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
264 (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
265 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
266 (if (progn (end-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
267 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
268 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
269 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
270 (let (beg tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
271 |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
272 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
273 ;; 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
|
274 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
275 (looking-at "[ \t\n]")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
276 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
277 ;; 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
|
278 ;; 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
|
279 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
280 (and (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
281 (forward-line 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
282 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
283 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
284 (setq tem (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
285 (looking-at "DEFUN\\b")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
286 (>= location tem)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
287 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
288 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
289 (goto-char tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
290 (down-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
291 (if (= (char-after (point)) ?\") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
292 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
293 (forward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
294 (skip-chars-forward " ,"))) |
953 | 295 (buffer-substring (point) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
296 (progn (forward-sexp 1) (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
297 ;; Ordinary C function syntax. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
298 (setq beg (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
299 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
300 ;; Protect against "Unbalanced parens" error. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
301 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
302 (down-list 1) ; into arglist |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
303 (backward-up-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
304 (skip-chars-backward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
305 t) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
306 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
307 ;; Verify initial pos was after |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
308 ;; real start of function. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
309 (if (and (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
310 (goto-char beg) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
311 ;; 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
|
312 ;; 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
|
313 ;; 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
|
314 ;; comments before the function. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
315 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
316 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
317 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
318 (looking-at "[^\n\f]"))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
319 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
320 (>= location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
321 ;; 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
|
322 ;; 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
|
323 (> (point) beg)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
324 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
325 (progn (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
326 (point)))))))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
327 ((memq major-mode |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
328 '(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
|
329 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
|
330 )) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
331 (if (re-search-backward |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
332 "\\\\\\(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
|
333 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
334 (goto-char (match-beginning 0)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
335 (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
|
336 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
337 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
338 (point)))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
339 ((eq major-mode 'texinfo-mode) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
340 (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
|
341 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
342 (match-end 1)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
343 (t |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
344 ;; 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
|
345 (let (case-fold-search) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
346 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
347 (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
|
348 (- (point) 10000) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
349 t) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
350 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
351 (match-end 1)))))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
352 (error nil))) |
999 | 353 |
354 | |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
355 (provide 'add-log) |
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
356 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
357 ;;; add-log.el ends here |