Mercurial > emacs
annotate lisp/add-log.el @ 4154:20a0593431b7
(add-log-current-defun-function): New defvar.
(add-change-log-entry): Call its value if non-nil instead of
add-log-current-defun.
(add-change-log-entry-other-window): Doc fix.
author | Roland McGrath <roland@gnu.org> |
---|---|
date | Sun, 18 Jul 1993 22:23:44 +0000 |
parents | 83d0fc1ccca9 |
children | d2316090d029 |
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 |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1999
diff
changeset
|
5 ;; Keywords: maint |
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1999
diff
changeset
|
6 |
661 | 7 ;; This file is part of GNU Emacs. |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; 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
|
11 ;; the Free Software Foundation; either version 2, or (at your option) |
661 | 12 ;; any later version. |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
23 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
24 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 ;; This facility is documented in the Emacs Manual. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
27 ;;; Code: |
661 | 28 |
29 ;;;###autoload | |
30 (defvar change-log-default-name nil | |
31 "*Name of a change log file for \\[add-change-log-entry].") | |
32 | |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
33 ;;;###autoload |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
34 (defvar add-log-current-defun-function nil |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
35 "\ |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
36 *If non-nil, function to guess name of current function from surrounding text. |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
37 \\[add-change-log-entry] calls this function (if nil, `add-log-current-defun' |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
38 instead) with no arguments. It returns a string or nil if it cannot guess.") |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
39 |
661 | 40 (defun change-log-name () |
41 (or change-log-default-name | |
42 (if (eq system-type 'vax-vms) "$CHANGE_LOG$.TXT" "ChangeLog"))) | |
43 | |
44 (defun prompt-for-change-log-name () | |
45 "Prompt for a change log name." | |
46 (let ((default (change-log-name))) | |
47 (expand-file-name | |
48 (read-file-name (format "Log file (default %s): " default) | |
49 nil default)))) | |
50 | |
51 ;;;###autoload | |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
52 (defun find-change-log (&optional file-name) |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
53 "Find a change log file for \\[add-change-log-entry] and return the name. |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
54 Optional arg FILE-NAME is a name to try first. |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
55 If FILE-NAME is nil, use the value of `change-log-default-name' if non-nil. |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
56 Failing that, use \"ChangeLog\" in the current directory. |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
57 If the file does not exist in the named directory, successive parent |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
58 directories are tried. |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
59 |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
60 Once a file is found, `change-log-default-name' is set locally in the |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
61 current buffer to the complete file name." |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
62 (or file-name |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
63 (setq file-name (or change-log-default-name |
3221
8e605e107faa
(find-log-file): Use source file's truename dir.
Richard M. Stallman <rms@gnu.org>
parents:
3201
diff
changeset
|
64 ;; Chase links in the source file |
8e605e107faa
(find-log-file): Use source file's truename dir.
Richard M. Stallman <rms@gnu.org>
parents:
3201
diff
changeset
|
65 ;; and use the change log in the dir where it points. |
8e605e107faa
(find-log-file): Use source file's truename dir.
Richard M. Stallman <rms@gnu.org>
parents:
3201
diff
changeset
|
66 (and buffer-file-name |
3261
50b8f8d5f932
(find-change-log): Use file-chase-links.
Richard M. Stallman <rms@gnu.org>
parents:
3222
diff
changeset
|
67 (file-name-directory |
50b8f8d5f932
(find-change-log): Use file-chase-links.
Richard M. Stallman <rms@gnu.org>
parents:
3222
diff
changeset
|
68 (file-chase-links buffer-file-name))) |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
69 default-directory))) |
2712
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
70 (if (and (eq file-name change-log-default-name) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
71 (assq 'change-log-default-name (buffer-local-variables))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
72 ;; Don't do the searching if we already have a buffer-local value. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
73 file-name |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
74 |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
75 (if (file-directory-p file-name) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
76 (setq file-name (expand-file-name (change-log-name) file-name))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
77 ;; Chase links before visiting the file. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
78 ;; This makes it easier to use a single change log file |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
79 ;; for several related directories. |
3261
50b8f8d5f932
(find-change-log): Use file-chase-links.
Richard M. Stallman <rms@gnu.org>
parents:
3222
diff
changeset
|
80 (setq file-name (file-chase-links file-name)) |
3201
6ae7487f1a3d
(find-change-log): Chase symlinks multiple levels.
Richard M. Stallman <rms@gnu.org>
parents:
2712
diff
changeset
|
81 (setq file-name (expand-file-name file-name)) |
2712
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
82 ;; Move up in the dir hierarchy till we find a change log file. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
83 (let ((file1 file-name) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
84 parent-dir) |
3897
83d0fc1ccca9
(find-change-log): Try get-file-buffer before file-exists-p.
Roland McGrath <roland@gnu.org>
parents:
3853
diff
changeset
|
85 (while (and (not (or (get-file-buffer file1) (file-exists-p file1))) |
2712
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
86 (progn (setq parent-dir |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
87 (file-name-directory |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
88 (directory-file-name |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
89 (file-name-directory file1)))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
90 ;; Give up if we are already at the root dir. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
91 (not (string= (file-name-directory file1) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
92 parent-dir)))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
93 ;; Move up to the parent dir and try again. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
94 (setq file1 (expand-file-name (change-log-name) parent-dir))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
95 ;; If we found a change log in a parent, use that. |
3897
83d0fc1ccca9
(find-change-log): Try get-file-buffer before file-exists-p.
Roland McGrath <roland@gnu.org>
parents:
3853
diff
changeset
|
96 (if (or (get-file-buffer file1) (file-exists-p file1)) |
2712
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
97 (setq file-name file1))) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
98 ;; Make a local variable in this buffer so we needn't search again. |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
99 (set (make-local-variable 'change-log-default-name) file-name) |
8291de1718d4
(find-change-log): If there is a buffer-local value of
Roland McGrath <roland@gnu.org>
parents:
2463
diff
changeset
|
100 file-name)) |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
101 |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
102 ;;;###autoload |
661 | 103 (defun add-change-log-entry (&optional whoami file-name other-window) |
104 "Find change log file and add an entry for today. | |
105 Optional arg (interactive prefix) non-nil means prompt for user name and site. | |
106 Second arg is file name of change log. If nil, uses `change-log-default-name'. | |
107 Third arg OTHER-WINDOW non-nil means visit in other window." | |
108 (interactive (list current-prefix-arg | |
109 (prompt-for-change-log-name))) | |
678 | 110 (let* ((full-name (if whoami |
661 | 111 (read-input "Full name: " (user-full-name)) |
112 (user-full-name))) | |
113 ;; Note that some sites have room and phone number fields in | |
114 ;; full name which look silly when inserted. Rather than do | |
115 ;; anything about that here, let user give prefix argument so that | |
116 ;; s/he can edit the full name field in prompter if s/he wants. | |
117 (login-name (if whoami | |
118 (read-input "Login name: " (user-login-name)) | |
119 (user-login-name))) | |
120 (site-name (if whoami | |
121 (read-input "Site name: " (system-name)) | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
122 (system-name))) |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
123 (defun (funcall (or add-log-current-defun-function |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
124 '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
|
125 paragraph-end entry) |
1752
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
126 |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
127 (setq file-name (find-change-log 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
|
128 |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
129 ;; 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
|
130 (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
|
131 ;; 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
|
132 (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
|
133 (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
|
134 (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
|
135 file-name))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
136 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
|
137 (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
|
138 (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
|
139 |
661 | 140 (if (and other-window (not (equal file-name buffer-file-name))) |
141 (find-file-other-window file-name) | |
142 (find-file file-name)) | |
143 (undo-boundary) | |
144 (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
|
145 (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
|
146 0 10)) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
147 ".* " (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
|
148 " (" (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
|
149 (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
|
150 (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
|
151 " " 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
|
152 " (" 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
|
153 |
1847
63af9f715bd3
(add-change-log-entry): Undo Jan 25 change. It worked for buffers in
Roland McGrath <roland@gnu.org>
parents:
1813
diff
changeset
|
154 ;; Search only within the first paragraph. |
1999
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
155 (if (looking-at "\n*[^\n* \t]") |
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
156 (skip-chars-forward "\n") |
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
157 (forward-paragraph 1)) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
158 (setq paragraph-end (point)) |
661 | 159 (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
|
160 |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
161 ;; 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
|
162 (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
|
163 ;; 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
|
164 (if entry |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
165 (insert entry))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
166 ((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
|
167 (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
|
168 ;; 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
|
169 ;; 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
|
170 "\\(\\s \\|[(),:]\\)") |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
171 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
|
172 ;; 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
|
173 (re-search-forward "^\\s *$\\|^\\s \\*") |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
174 (beginning-of-line) |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
175 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
176 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
177 (insert "\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
178 (forward-line -2) |
678 | 179 (indent-relative-maybe)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
180 (t |
678 | 181 ;; Make a new entry. |
182 (forward-line 1) | |
183 (while (looking-at "\\sW") | |
184 (forward-line 1)) | |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
185 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
186 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
187 (insert "\n\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
188 (forward-line -2) |
678 | 189 (indent-to left-margin) |
190 (insert "* " (or entry "")))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
191 ;; 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
|
192 ;; Point is at the entry for this file, |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
193 ;; 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
|
194 (if defun |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
195 (progn |
678 | 196 ;; 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
|
197 (undo-boundary) |
678 | 198 (insert (if (save-excursion |
199 (beginning-of-line 1) | |
200 (looking-at "\\s *$")) | |
201 "" | |
202 " ") | |
203 "(" defun "): ")) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
204 ;; No function name, so put in a colon unless we have just a star. |
678 | 205 (if (not (save-excursion |
206 (beginning-of-line 1) | |
207 (looking-at "\\s *\\(\\*\\s *\\)?$"))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
208 (insert ": "))))) |
661 | 209 |
210 ;;;###autoload | |
211 (defun add-change-log-entry-other-window (&optional whoami file-name) | |
212 "Find change log file in other window and add an entry for today. | |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
213 Optional arg (interactive prefix) non-nil means prompt for user name and site. |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
214 Second arg is file name of change log. \ |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
215 If nil, uses `change-log-default-name'." |
661 | 216 (interactive (if current-prefix-arg |
217 (list current-prefix-arg | |
218 (prompt-for-change-log-name)))) | |
219 (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
|
220 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) |
661 | 221 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
222 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
223 (defun change-log-mode () |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3499
diff
changeset
|
224 "Major mode for editing change logs; like Indented Text Mode. |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
225 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. |
951 | 226 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window]. |
227 Each entry behaves as a paragraph, and the entries for one day as a page. | |
228 Runs `change-log-mode-hook'." | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
229 (interactive) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
230 (kill-all-local-variables) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
231 (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
|
232 (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
|
233 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
|
234 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
|
235 fill-column 74) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
236 ;; Let each entry behave as one paragraph: |
678 | 237 (set (make-local-variable 'paragraph-start) "^\\s *$\\|^^L") |
238 (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
|
239 ;; 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
|
240 ;; 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
|
241 ;; is grouped with what follows. |
15b4ed20e524
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1062
diff
changeset
|
242 (set (make-local-variable 'page-delimiter) "^\\<\\|^") |
678 | 243 (set (make-local-variable 'version-control) 'never) |
244 (set (make-local-variable 'adaptive-fill-regexp) "\\s *") | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
245 (run-hooks 'change-log-mode-hook)) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
246 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
247 (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
|
248 "^\\([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
|
249 "*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
|
250 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
251 (defun add-log-current-defun () |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
252 "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
|
253 |
3499
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
254 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...), |
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
255 Texinfo (@node titles), and Fortran. |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
256 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
257 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
|
258 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
|
259 identifiers followed by `:' or `=', see variable |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
260 `add-log-current-defun-header-regexp'. |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
261 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
262 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
|
263 (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
264 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
265 (let ((location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
266 (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
|
267 ;; 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
|
268 ;; 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
|
269 ;; rather than the previous one. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
270 (or (eobp) (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
271 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
272 ;; 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
|
273 (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
|
274 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
275 (progn (forward-sexp -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
276 (>= location (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
277 (progn |
3853
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
278 (if (looking-at "\\s(") |
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
279 (forward-char 1)) |
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
280 (forward-sexp 1) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
281 (skip-chars-forward " ") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
282 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
283 (progn (forward-sexp 1) (point)))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
284 ((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
|
285 (save-excursion (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
286 ;; 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
|
287 ;; 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
|
288 ;; returns nil. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
289 (while (eq (char-after (- (point) 2)) ?\\) |
953 | 290 (forward-line -1)) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
291 (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
|
292 ;; Handle a C macro definition. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
293 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
294 (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
|
295 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
296 (search-forward "define") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
297 (skip-chars-forward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
298 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
299 (progn (forward-sexp 1) (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
300 ((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
|
301 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
302 ;; 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
|
303 ;; 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
|
304 (while (not (looking-at "{\\|\\(\\s *$\\)")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
305 (forward-line 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
306 (or (eobp) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
307 (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
308 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
309 (if (progn (end-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
310 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
311 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
312 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
313 (let (beg tem) |
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 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
316 ;; 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
|
317 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
318 (looking-at "[ \t\n]")) |
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 ;; 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
|
321 ;; 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
|
322 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
323 (and (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
324 (forward-line 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
325 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
326 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
327 (setq tem (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
328 (looking-at "DEFUN\\b")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
329 (>= location tem)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
330 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
331 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
332 (goto-char tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
333 (down-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
334 (if (= (char-after (point)) ?\") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
335 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
336 (forward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
337 (skip-chars-forward " ,"))) |
953 | 338 (buffer-substring (point) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
339 (progn (forward-sexp 1) (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
340 ;; Ordinary C function syntax. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
341 (setq beg (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
342 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
343 ;; Protect against "Unbalanced parens" error. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
344 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
345 (down-list 1) ; into arglist |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
346 (backward-up-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
347 (skip-chars-backward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
348 t) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
349 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
350 ;; Verify initial pos was after |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
351 ;; real start of function. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
352 (if (and (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
353 (goto-char beg) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
354 ;; 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
|
355 ;; 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
|
356 ;; 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
|
357 ;; comments before the function. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
358 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
359 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
360 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
361 (looking-at "[^\n\f]"))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
362 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
363 (>= location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
364 ;; 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
|
365 ;; 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
|
366 (> (point) beg)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
367 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
368 (progn (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
369 (point)))))))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
370 ((memq major-mode |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
371 '(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
|
372 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
|
373 )) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
374 (if (re-search-backward |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
375 "\\\\\\(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
|
376 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
377 (goto-char (match-beginning 0)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
378 (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
|
379 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
380 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
381 (point)))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
382 ((eq major-mode 'texinfo-mode) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
383 (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
|
384 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
385 (match-end 1)))) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
386 ((eq major-mode 'fortran-mode) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
387 ;; must be inside function body for this to work |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
388 (beginning-of-fortran-subprogram) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
389 (let ((case-fold-search t)) ; case-insensitive |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
390 ;; search for fortran subprogram start |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
391 (if (re-search-forward |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
392 "^[ \t]*\\(program\\|subroutine\\|function\ |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
393 \\|[ \ta-z0-9*]*[ \t]+function\\)" |
3499
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
394 nil t) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
395 (progn |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
396 ;; move to EOL or before first left paren |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
397 (if (re-search-forward "[(\n]" nil t) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
398 (progn (forward-char -1) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
399 (skip-chars-backward " \t")) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
400 (end-of-line)) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
401 ;; Use the name preceding that. |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
402 (buffer-substring (point) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
403 (progn (forward-sexp -1) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
404 (point))))))) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
405 (t |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
406 ;; 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
|
407 (let (case-fold-search) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
408 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
409 (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
|
410 (- (point) 10000) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
411 t) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
412 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
413 (match-end 1)))))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
414 (error nil))) |
999 | 415 |
416 | |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
417 (provide 'add-log) |
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
418 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
419 ;;; add-log.el ends here |