annotate lisp/packages/add-log.el @ 211:78478c60bfcd r20-4b4

Import from CVS: tag r20-4b4
author cvs
date Mon, 13 Aug 2007 10:05:51 +0200
parents e45d5e7c476e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; add-log.el --- change log maintenance commands for Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
3 ;; Copyright (C) 1985, 86, 88, 93, 94, 1997 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
20 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
24 ;;; Synched up with: Emacs 20.0.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This facility is documented in the Emacs Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 161
diff changeset
32 ;; XEmacs: the byte-compiler warns on `beginning-of-fortran-subprogram'.
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
33 (condition-case nil
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
34 (eval-when-compile
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
35 (require 'fortran))
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
36 (t nil))
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 161
diff changeset
37
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
38 (defgroup change-log nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
39 "Change log maintenance"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
40 :group 'tools
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
41 :group 'maint
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
42 :prefix "change-log-"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
43 :prefix "add-log-")
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
44
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
46 (defcustom change-log-default-name nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
47 "*Name of a change log file for \\[add-change-log-entry]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
48 :type '(choice (const :tag "default" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
49 string)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
50 :group 'change-log)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
51
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
52 (defcustom add-log-current-defun-function nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 *If non-nil, function to guess name of current function from surrounding text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 \\[add-change-log-entry] calls this function (if nil, `add-log-current-defun'
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
56 instead) with no arguments. It returns a string or nil if it cannot guess."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
57 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
58 :group 'change-log)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
60 (defcustom add-log-full-name nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "*Full name of user, for inclusion in ChangeLog daily headers.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
62 This defaults to the value returned by the `user-full-name' function."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
63 :type '(choice (const :tag "Default" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
64 string)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
65 :group 'change-log)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
67 (defcustom add-log-mailing-address nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 "*Electronic mail address of user, for inclusion in ChangeLog daily headers.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
69 This defaults to the value of `user-mail-address'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
70 :type '(choice (const :tag "Default" nil)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
71 string)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
72 :group 'change-log)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
74 (defcustom add-log-time-format 'iso8601-time-string
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
75 "*Function that defines the time format.
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
76 For example, `iso8601-time-string' (time in international ISO 8601 format)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
77 and `current-time-string' are valid values."
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
78 :type '(radio (const :tag "International ISO 8601 format" iso8601-time-string)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
79 (const :tag "Old format, as returned by `current-time-string'"
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
80 current-time-string)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
81 (function :tag "Other"))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
82 :group 'change-log)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
83
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (defvar change-log-font-lock-keywords
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
86 '(;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
87 ;; Date lines, new and old styles.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
88 ("^\\sw.........[0-9: ]*"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
89 (0 font-lock-string-face)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
90 ("\\([^<]+\\)<\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)>" nil nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
91 (1 font-lock-reference-face)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
92 (2 font-lock-variable-name-face)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
93 ;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
94 ;; File names.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
95 ("^\t\\* \\([^ ,:([\n]+\\)"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
96 (1 font-lock-function-name-face)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
97 ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 font-lock-function-name-face)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
98 ;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
99 ;; Function or variable names.
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 161
diff changeset
100 ("(\\([^ ,:)\n]+\\)"
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
101 (1 font-lock-keyword-face)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
102 ("\\=, \\([^ ,:\n]+\\)" nil nil (1 font-lock-keyword-face)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
103 ;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
104 ;; Conditionals.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
105 ("\\[!?\\([^]\n]+\\)\\]\\(:\\| (\\)" (1 font-lock-variable-name-face))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
106 ;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
107 ;; Acknowledgments.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
108 ("^\t\\(From\\|Reported by\\)" 1 font-lock-comment-face)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
109 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 "Additional expressions to highlight in Change Log mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (put 'change-log-mode 'font-lock-defaults
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 '(change-log-font-lock-keywords t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defvar change-log-mode-map nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 "Keymap for Change Log major mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if change-log-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 nil
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
118 (setq change-log-mode-map (make-sparse-keymap))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
119 (define-key change-log-mode-map "\C-c\C-c" 'change-log-exit)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
120 (define-key change-log-mode-map "\C-c\C-k" 'change-log-cancel))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
121
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
122 (defvar change-log-time-zone-rule nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
123 "Time zone used for calculating change log time stamps.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
124 It takes the same format as the TZ argument of `set-time-zone-rule'.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
125 If nil, use local time.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
126
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
127 (defun iso8601-time-zone (time)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
128 (let* ((utc-offset (or (car (current-time-zone time)) 0))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
129 (sign (if (< utc-offset 0) ?- ?+))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
130 (sec (abs utc-offset))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
131 (ss (% sec 60))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
132 (min (/ sec 60))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
133 (mm (% min 60))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
134 (hh (/ min 60)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
135 (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
136 ((not (zerop mm)) "%c%02d:%02d")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
137 (t "%c%02d"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
138 sign hh mm ss)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
140 (defun iso8601-time-string ()
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
141 (if change-log-time-zone-rule
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
142 (let ((tz (getenv "TZ"))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
143 (now (current-time)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
144 (unwind-protect
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
145 (progn
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
146 (set-time-zone-rule
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
147 change-log-time-zone-rule)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
148 (concat
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
149 (format-time-string "%Y-%m-%d " now)
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
150 (iso8601-time-zone now)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
151 (set-time-zone-rule tz)))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
152 (format-time-string "%Y-%m-%d")))
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
153
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun change-log-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (or change-log-default-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if (eq system-type 'vax-vms)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
157 "$CHANGE_LOG$.TXT"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
158 "ChangeLog")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defun prompt-for-change-log-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "Prompt for a change log name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (let* ((default (change-log-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (name (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (read-file-name (format "Log file (default %s): " default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 nil default))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; Handle something that is syntactically a directory name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; Look for ChangeLog or whatever in that directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (string= (file-name-nondirectory name) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (expand-file-name (file-name-nondirectory default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; Handle specifying a file that is a directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (file-directory-p name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (expand-file-name (file-name-nondirectory default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (file-name-as-directory name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defun find-change-log (&optional file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Find a change log file for \\[add-change-log-entry] and return the name.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
181
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 Optional arg FILE-NAME specifies the file to use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 If FILE-NAME is nil, use the value of `change-log-default-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 If 'change-log-default-name' is nil, behave as though it were 'ChangeLog'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 \(or whatever we use on this operating system).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 If 'change-log-default-name' contains a leading directory component, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 simply find it in the current directory. Otherwise, search in the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 directory and its successive parents for a file so named.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 Once a file is found, `change-log-default-name' is set locally in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 current buffer to the complete file name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; If user specified a file name or if this buffer knows which one to use,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; just use that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (or file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (setq file-name (and change-log-default-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (file-name-directory change-log-default-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 change-log-default-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; Chase links in the source file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; and use the change log in the dir where it points.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq file-name (or (and buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (file-chase-links buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (if (file-directory-p file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (setq file-name (expand-file-name (change-log-name) file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; Chase links before visiting the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; This makes it easier to use a single change log file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; for several related directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (setq file-name (file-chase-links file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq file-name (expand-file-name file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; Move up in the dir hierarchy till we find a change log file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((file1 file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 parent-dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (while (and (not (or (get-file-buffer file1) (file-exists-p file1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (progn (setq parent-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (directory-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (file-name-directory file1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; Give up if we are already at the root dir.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (not (string= (file-name-directory file1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 parent-dir))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; Move up to the parent dir and try again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq file1 (expand-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (file-name-nondirectory (change-log-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 parent-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; If we found a change log in a parent, use that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if (or (get-file-buffer file1) (file-exists-p file1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (setq file-name file1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; Make a local variable in this buffer so we needn't search again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (set (make-local-variable 'change-log-default-name) file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
235
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defun add-change-log-entry (&optional whoami file-name other-window new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 "Find change log file and add an entry for today.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 Optional arg (interactive prefix) non-nil means prompt for user name and site.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 Second arg is file name of change log. If nil, uses `change-log-default-name'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 Third arg OTHER-WINDOW non-nil means visit in other window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
243 never append to an existing entry. Today's date is calculated according to
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
244 `change-log-time-zone-rule' if non-nil, otherwise in local time."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (interactive (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (prompt-for-change-log-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (or add-log-full-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (setq add-log-full-name (user-full-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (or add-log-mailing-address
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 70
diff changeset
250 (setq add-log-mailing-address (user-mail-address)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if whoami
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq add-log-full-name (read-string "Full name: " add-log-full-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; Note that some sites have room and phone number fields in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; full name which look silly when inserted. Rather than do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; anything about that here, let user give prefix argument so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; s/he can edit the full name field in prompter if s/he wants.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq add-log-mailing-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (read-string "Mailing address: " add-log-mailing-address))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (let ((defun (funcall (or add-log-current-defun-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 'add-log-current-defun)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 paragraph-end entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (setq file-name (expand-file-name (find-change-log file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; Set ENTRY to the file name to use in the new entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (and buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; Never want to add a change log entry for the ChangeLog file itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (not (string= buffer-file-name file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (setq entry (if (string-match
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (concat "^" (regexp-quote (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (substring buffer-file-name (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (file-name-nondirectory buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
277 (push-window-configuration)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
278
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (and other-window (not (equal file-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (find-file-other-window file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (find-file file-name))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
282 (or (eq major-mode 'change-log-mode)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
283 (change-log-mode))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (goto-char (point-min))
161
28f395d8dc7a Import from CVS: tag r20-3b7
cvs
parents: 151
diff changeset
286 (let ((new-entry (concat (funcall add-log-time-format)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
287 " " add-log-full-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
288 " <" add-log-mailing-address ">")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
289 (if (looking-at (regexp-quote new-entry))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
290 (forward-line 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
291 (insert new-entry "\n\n")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; Search only within the first paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (if (looking-at "\n*[^\n* \t]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (skip-chars-forward "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (forward-paragraph 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq paragraph-end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; Now insert the new line for this entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; Put this file name into the existing empty entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (if entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (insert entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ((and (not new-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (let (case-fold-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (concat (regexp-quote (concat "* " entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; Don't accept `foo.bar' when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; looking for `foo':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "\\(\\s \\|[(),:]\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 paragraph-end t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; Add to the existing entry for the same file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (re-search-forward "^\\s *$\\|^\\s \\*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; Delete excess empty lines; make just 2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (while (and (not (eobp)) (looking-at "^\\s *$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (delete-region (point) (save-excursion (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (forward-line -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (indent-relative-maybe))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; Make a new entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (while (looking-at "\\sW")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (while (and (not (eobp)) (looking-at "^\\s *$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (delete-region (point) (save-excursion (forward-line 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (insert "\n\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (forward-line -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (indent-to left-margin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (insert "* " (or entry ""))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; Now insert the function name, if we have one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;; Point is at the entry for this file,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; either at the end of the line or at the first blank line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (if defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ;; Make it easy to get rid of the function name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (insert (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (looking-at "\\s *$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 "(" defun "): "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; No function name, so put in a colon unless we have just a star.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (if (not (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (looking-at "\\s *\\(\\*\\s *\\)?$")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (insert ": ")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (defun add-change-log-entry-other-window (&optional whoami file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 "Find change log file in other window and add an entry for today.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 Optional arg (interactive prefix) non-nil means prompt for user name and site.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 Second arg is file name of change log. \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 If nil, uses `change-log-default-name'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (prompt-for-change-log-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (add-change-log-entry whoami file-name t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun change-log-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "Major mode for editing change logs; like Indented Text Mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window].
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 Each entry behaves as a paragraph, and the entries for one day as a page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 Runs `change-log-mode-hook'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (indented-text-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (setq major-mode 'change-log-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 mode-name "Change Log"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 left-margin 8
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
377 fill-column 74
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
378 indent-tabs-mode t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
379 tab-width 8)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (use-local-map change-log-mode-map)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
381 (set (make-local-variable 'fill-paragraph-function)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
382 'change-log-fill-paragraph)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;; Let each entry behave as one paragraph:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; We really do want "^" in paragraph-start below: it is only the lines that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 ;; begin at column 0 (despite the left-margin of 8) that we are looking for.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
386 (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\<")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
387 (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\<")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; Let all entries for one day behave as one page.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; Match null string on the date-line so that the date-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; is grouped with what follows.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (set (make-local-variable 'page-delimiter) "^\\<\\|^\f")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (set (make-local-variable 'version-control) 'never)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (set (make-local-variable 'adaptive-fill-regexp) "\\s *")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
394 ;;(set (make-local-variable 'font-lock-defaults)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
395 ;;'(change-log-font-lock-keywords t))
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
396 (when (boundp 'filladapt-mode)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
397 ;; Filladapt works badly with ChangeLogs. Still, we disable it
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
398 ;; before change-log-mode-hook, so the users can override this
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
399 ;; choice.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
400 (setq filladapt-mode nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (run-hooks 'change-log-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
403 (defun change-log-exit ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
404 "Save the change-log buffer, and restores the old window configuration.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
405 Buries the buffer."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
406 (interactive)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
407 (save-buffer)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
408 (let ((buf (current-buffer)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
409 (pop-window-configuration)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
410 (bury-buffer buf)))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
411
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
412 (defun change-log-cancel ()
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
413 "Cancel the changes to change-log buffer.
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
414 This kills the buffer without saving, and restores the old window
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
415 configuration."
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
416 (interactive)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
417 (kill-buffer (current-buffer))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
418 (pop-window-configuration))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 173
diff changeset
419
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 ;; It might be nice to have a general feature to replace this. The idea I
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 ;; have is a variable giving a regexp matching text which should not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 ;; moved from bol by filling. change-log-mode would set this to "^\\s *\\s(".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 ;; But I don't feel up to implementing that today.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (defun change-log-fill-paragraph (&optional justify)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 "Fill the paragraph, but preserve open parentheses at beginning of lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 Prefix arg means justify as well."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (interactive "P")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
428 (let ((end (progn (forward-paragraph) (point)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
429 (beg (progn (backward-paragraph) (point)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
431 (fill-region beg end justify)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
432 t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
434 (defcustom add-log-current-defun-header-regexp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[-_a-zA-Z]+\\)[ \t]*[:=]"
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
436 "*Heuristic regexp used by `add-log-current-defun' for unknown major modes."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
437 :type 'regexp
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 114
diff changeset
438 :group 'change-log)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;;;###autoload
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
441 (defvar add-log-lisp-like-modes
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
442 '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-mode)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
443 "*Modes that look like Lisp to `add-log-current-defun'.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
444
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
445 ;;;###autoload
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
446 (defvar add-log-c-like-modes
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 161
diff changeset
447 '(c-mode c++-mode c++-c-mode objc-mode java-mode)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
448 "*Modes that look like C to `add-log-current-defun'.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
449
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
450 ;;;###autoload
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
451 (defvar add-log-tex-like-modes
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
452 '(TeX-mode plain-TeX-mode LaTeX-mode plain-tex-mode latex-mode)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
453 "*Modes that look like TeX to `add-log-current-defun'.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
454
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
455 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun add-log-current-defun ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "Return name of function definition point is in, or nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 Texinfo (@node titles), Perl, and Fortran.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 Other modes are handled by a heuristic that looks in the 10K before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 point for uppercase headings starting in the first column or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 identifiers followed by `:' or `=', see variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 `add-log-current-defun-header-regexp'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 Has a preference of looking backwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (let ((location (point)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
471 (cond ((memq major-mode add-log-lisp-like-modes)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; If we are now precisely at the beginning of a defun,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ;; make sure beginning-of-defun finds that one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ;; rather than the previous one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (or (eobp) (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 ;; Make sure we are really inside the defun found, not after it.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
478 (if (and (looking-at "\\s(")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
479 (progn (end-of-defun)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (< location (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (progn (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (>= location (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (if (looking-at "\\s(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (skip-chars-forward " '")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (progn (forward-sexp 1) (point))))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
490 ((and (memq major-mode add-log-c-like-modes)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
491 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
492 (beginning-of-line)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
493 ;; Use eq instead of = here to avoid
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
494 ;; error when at bob and char-after
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
495 ;; returns nil.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
496 (while (eq (char-after (- (point) 2)) ?\\)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
497 (forward-line -1))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
498 (looking-at "[ \t]*#[ \t]*define[ \t]")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; Handle a C macro definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (while (eq (char-after (- (point) 2)) ?\\) ;not =; note above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (search-forward "define")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (skip-chars-forward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (progn (forward-sexp 1) (point))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
507 ((memq major-mode add-log-c-like-modes)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 ;; See if we are in the beginning part of a function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 ;; before the open brace. If so, advance forward.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (while (not (looking-at "{\\|\\(\\s *$\\)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (or (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (beginning-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (if (progn (end-of-defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (< location (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (let (beg tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 ;; Skip back over typedefs of arglist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (while (and (not (bobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (looking-at "[ \t\n]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ;; See if this is using the DEFUN macro used in Emacs,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ;; or the DEFUN macro used by the C library.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (if (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (and (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (while (= (preceding-char) ?\\)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (end-of-line 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (setq tem (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (looking-at "DEFUN\\b"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (>= location tem))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (goto-char tem)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (if (= (char-after (point)) ?\")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (skip-chars-forward " ,")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (progn (forward-sexp 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (looking-at "^[+-]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (get-method-definition)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;; Ordinary C function syntax.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if (and (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;; Protect against "Unbalanced parens" error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (down-list 1) ; into arglist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (backward-up-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (skip-chars-backward " \t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;; Verify initial pos was after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 ;; real start of function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 ;; For this purpose, include the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;; that has the decl keywords. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; may also include some of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; comments before the function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (while (and (not (bobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (looking-at "[^\n\f]")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (>= location (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; Consistency check: going down and up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 ;; shouldn't take us back before BEG.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (> (point) beg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (let (end middle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; Don't include any final newline
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; in the name we use.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (if (= (preceding-char) ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (forward-char -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; Now find the right beginning of the name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 ;; Include certain keywords if they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 ;; precede the name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (setq middle (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 ;; Ignore these subparts of a class decl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; and move back to the class name itself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (while (looking-at "public \\|private ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (skip-chars-backward " \t:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (backward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (setq middle (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (forward-word -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (and (bolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (looking-at "struct \\|union \\|class ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (setq middle (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (buffer-substring middle end)))))))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 120
diff changeset
602 ((memq major-mode add-log-tex-like-modes)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if (re-search-backward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "\\\\\\(sub\\)*\\(section\\|paragraph\\|chapter\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (goto-char (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (buffer-substring (1+ (point));; without initial backslash
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ((eq major-mode 'texinfo-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ((eq major-mode 'perl-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (match-end 1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 ((eq major-mode 'fortran-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 ;; must be inside function body for this to work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (beginning-of-fortran-subprogram)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (let ((case-fold-search t)) ; case-insensitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 ;; search for fortran subprogram start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "^[ \t]*\\(program\\|subroutine\\|function\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 \\|[ \ta-z0-9*]*[ \t]+function\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; move to EOL or before first left paren
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (if (re-search-forward "[(\n]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (progn (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (skip-chars-backward " \t"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (end-of-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; Use the name preceding that.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (progn (forward-sexp -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (point)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; If all else fails, try heuristics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (let (case-fold-search)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (if (re-search-backward add-log-current-defun-header-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (- (point) 10000)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (match-end 1))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defvar get-method-definition-md)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;; Subroutine used within get-method-definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ;; Add the last match in the buffer to the end of `md',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; followed by the string END; move to the end of that match.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defun get-method-definition-1 (end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (setq get-method-definition-md
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (concat get-method-definition-md
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (goto-char (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 ;; For objective C, return the method name if we are in a method.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (defun get-method-definition ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (let ((get-method-definition-md "["))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (if (re-search-backward "^@implementation\\s-*\\([A-Za-z_]*\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (get-method-definition-1 " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 ((re-search-forward "^\\([-+]\\)[ \t\n\f\r]*\\(([^)]*)\\)?\\s-*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (get-method-definition-1 "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (while (not (looking-at "[{;]"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (looking-at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 "\\([A-Za-z_]*:?\\)\\s-*\\(([^)]*)\\)?[A-Za-z_]*[ \t\n\f\r]*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (get-method-definition-1 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (concat get-method-definition-md "]"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (provide 'add-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 ;;; add-log.el ends here