Mercurial > emacs
annotate lisp/add-log.el @ 28312:034f252dd69b
(do_symval_forwarding, store_symval_forwarding)
(find_symbol_value, set_internal, default_value, Fset_default)
(Fkill_local_variable, Flocal_variable_p): Use new macros for
per-buffer variables.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sun, 26 Mar 2000 14:05:44 +0000 |
parents | c11a0bbb5c88 |
children | 28009885f082 |
rev | line source |
---|---|
22388 | 1 ;;; add-log.el --- change log maintenance commands for Emacs |
661 | 2 |
27240 | 3 ;; Copyright (C) 1985, 86, 88, 93, 94, 97, 1998, 2000 Free Software Foundation, Inc. |
661 | 4 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
5 ;; Keywords: tools |
2247
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 | |
14169 | 20 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
661 | 23 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
24 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 ;; 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
|
27 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
28 ;;; Code: |
661 | 29 |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
30 (eval-when-compile |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
31 (require 'fortran) |
27240 | 32 (require 'timezone) |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
33 (require 'cl)) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
34 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
35 (defgroup change-log nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
36 "Change log maintenance" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
37 :group 'tools |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
38 :link '(custom-manual "(emacs)Change Log") |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
39 :prefix "change-log-" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
40 :prefix "add-log-") |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
41 |
661 | 42 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
43 (defcustom change-log-default-name nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
44 "*Name of a change log file for \\[add-change-log-entry]." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
45 :type '(choice (const :tag "default" nil) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
46 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
47 :group 'change-log) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
48 |
26613
7f7e6de546ac
(change-log-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents:
25273
diff
changeset
|
49 (defcustom change-log-mode-hook nil |
7f7e6de546ac
(change-log-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents:
25273
diff
changeset
|
50 "Normal hook run by `change-log-mode'." |
7f7e6de546ac
(change-log-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents:
25273
diff
changeset
|
51 :type 'hook |
7f7e6de546ac
(change-log-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents:
25273
diff
changeset
|
52 :group 'change-log) |
7f7e6de546ac
(change-log-mode-hook): Customize.
Dave Love <fx@gnu.org>
parents:
25273
diff
changeset
|
53 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
54 (defcustom add-log-current-defun-function nil |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
55 "\ |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
56 *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
|
57 \\[add-change-log-entry] calls this function (if nil, `add-log-current-defun' |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
58 instead) with no arguments. It returns a string or nil if it cannot guess." |
19904
1e0f71fd673c
(add-log-current-defun-function): Likewise.
Richard M. Stallman <rms@gnu.org>
parents:
19632
diff
changeset
|
59 :type 'function |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
60 :group 'change-log) |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
61 |
14856
f64fa743c80f
(add-log-full-name, add-log-mailing-address): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
14528
diff
changeset
|
62 ;;;###autoload |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
63 (defcustom add-log-full-name nil |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
64 "*Full name of user, for inclusion in ChangeLog daily headers. |
27240 | 65 This defaults to the value returned by the function `user-full-name'." |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
66 :type '(choice (const :tag "Default" nil) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
67 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
68 :group 'change-log) |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
69 |
14856
f64fa743c80f
(add-log-full-name, add-log-mailing-address): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
14528
diff
changeset
|
70 ;;;###autoload |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
71 (defcustom add-log-mailing-address nil |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
72 "*Electronic mail address of user, for inclusion in ChangeLog daily headers. |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
73 This defaults to the value of `user-mail-address'." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
74 :type '(choice (const :tag "Default" nil) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
75 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
76 :group 'change-log) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
77 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
78 (defcustom add-log-time-format 'add-log-iso8601-time-string |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
79 "*Function that defines the time format. |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
80 For example, `add-log-iso8601-time-string', which gives the |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
81 date in international ISO 8601 format, |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
82 and `current-time-string' are two valid values." |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
83 :type '(radio (const :tag "International ISO 8601 format" |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
84 add-log-iso8601-time-string) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
85 (const :tag "Old format, as returned by `current-time-string'" |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
86 current-time-string) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
87 (function :tag "Other")) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
88 :group 'change-log) |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
89 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
90 (defcustom add-log-keep-changes-together nil |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
91 "*If non-nil, normally keep day's log entries for one file together. |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
92 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
93 Log entries for a given file made with \\[add-change-log-entry] or |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
94 \\[add-change-log-entry-other-window] will only be added to others \ |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
95 for that file made |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
96 today if this variable is non-nil or that file comes first in today's |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
97 entries. Otherwise another entry for that file will be started. An |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
98 original log: |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
99 |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
100 * foo (...): ... |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
101 * bar (...): change 1 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
102 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
103 in the latter case, \\[add-change-log-entry-other-window] in a \ |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
104 buffer visiting `bar', yields: |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
105 |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
106 * bar (...): -!- |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
107 * foo (...): ... |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
108 * bar (...): change 1 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
109 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
110 and in the former: |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
111 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
112 * foo (...): ... |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
113 * bar (...): change 1 |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
114 (...): -!- |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
115 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
116 The NEW-ENTRY arg to `add-change-log-entry' can override the effect of |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
117 this variable." |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
118 :version "20.3" |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
119 :type 'boolean |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
120 :group 'change-log) |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
121 |
24289
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
122 (defcustom add-log-file-name-function nil |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
123 "*If non-nil, function to call to identify the filename for a ChangeLog entry. |
27240 | 124 This function is called with one argument, the value of variable |
125 `buffer-file-name' in that buffer. If this is nil, the default is to | |
126 use the file's name relative to the directory of the change log file." | |
24289
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
127 :type 'function |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
128 :group 'change-log) |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
129 |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
130 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
131 (defcustom change-log-version-info-enabled nil |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
132 "*If non-nil, enable recording version numbers with the changes." |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
133 :version "21.1" |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
134 :type 'boolean |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
135 :group 'change-log) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
136 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
137 (defcustom change-log-version-number-regexp-list |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
138 (let ((re "\\([0-9]+\.[0-9.]+\\)")) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
139 (list |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
140 ;; (defconst ad-version "2.15" |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
141 (concat "^(def[^ \t\n]+[ \t]+[^ \t\n][ \t]\"" re) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
142 ;; Revision: pcl-cvs.el,v 1.72 1999/09/05 20:21:54 monnier Exp |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
143 (concat "^;+ *Revision: +[^ \t\n]+[ \t]+" re) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
144 ;; SCCS @(#)igrep.el 2.83 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
145 (concat "SCCS[ \t]+@(#).*[ \t]+" re) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
146 )) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
147 "*List of regexps to search for version number. |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
148 Note: The search is conducted only within 10%, at the beginning of the file." |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
149 :version "21.1" |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
150 :type '(repeat regexp) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
151 :group 'change-log) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
152 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
153 |
9377
45228a0f6b78
(change-log-mode): Set font-lock-keywords locally.
Richard M. Stallman <rms@gnu.org>
parents:
9347
diff
changeset
|
154 (defvar change-log-font-lock-keywords |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
155 '(;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
156 ;; Date lines, new and old styles. |
21009
f3149849a051
(change-log-font-lock-keywords): Recognize + in date.
Richard M. Stallman <rms@gnu.org>
parents:
20953
diff
changeset
|
157 ("^\\sw.........[0-9:+ ]*" |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
158 (0 font-lock-string-face) |
23215
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
159 ;; Name and e-mail; some people put e-mail in parens, not angles. |
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
160 ("\\([^<(]+\\)[(<]\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)[>)]" nil nil |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
20402
diff
changeset
|
161 (1 font-lock-constant-face) |
17923
986fa91361cc
(change-log-font-lock-keywords): Tweak font-lock-keywords.
Erik Naggum <erik@naggum.no>
parents:
17912
diff
changeset
|
162 (2 font-lock-variable-name-face))) |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
163 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
164 ;; File names. |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
165 ("^\t\\* \\([^ ,:([\n]+\\)" |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
166 (1 font-lock-function-name-face) |
23215
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
167 ;; Possibly further names in a list: |
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
168 ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 font-lock-function-name-face)) |
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
169 ;; Possibly a parenthesized list of names: |
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
170 ("\\= (\\([^) ,:\n]+\\)" nil nil (1 font-lock-keyword-face)) |
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
171 ("\\=, *\\([^) ,:\n]+\\)" nil nil (1 font-lock-keyword-face))) |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
172 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
173 ;; Function or variable names. |
23215
c06f07cf6bba
(change-log-font-lock-keywords): Do parenthesized
Dave Love <fx@gnu.org>
parents:
22388
diff
changeset
|
174 ("^\t(\\([^) ,:\n]+\\)" |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
175 (1 font-lock-keyword-face) |
19325
db1b53ad6c80
(change-log-font-lock-keywords): Don't consider
Richard M. Stallman <rms@gnu.org>
parents:
18277
diff
changeset
|
176 ("\\=, *\\([^) ,:\n]+\\)" nil nil (1 font-lock-keyword-face))) |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
177 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
178 ;; Conditionals. |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
179 ("\\[!?\\([^]\n]+\\)\\]\\(:\\| (\\)" (1 font-lock-variable-name-face)) |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
180 ;; |
19439 | 181 ;; Acknowledgements. |
19632
eb2d6de004b1
(change-log-font-lock-keywords): Add more to prev change.
Richard M. Stallman <rms@gnu.org>
parents:
19510
diff
changeset
|
182 ("^\t\\(From\\|Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" |
19510
11cdee30cd02
(change-log-font-lock-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
19477
diff
changeset
|
183 1 font-lock-comment-face) |
19632
eb2d6de004b1
(change-log-font-lock-keywords): Add more to prev change.
Richard M. Stallman <rms@gnu.org>
parents:
19510
diff
changeset
|
184 (" \\(From\\|Patch\\(es\\)? by\\|Report\\(ed by\\| from\\)\\|Suggest\\(ed by\\|ion from\\)\\)" |
19510
11cdee30cd02
(change-log-font-lock-keywords):
Richard M. Stallman <rms@gnu.org>
parents:
19477
diff
changeset
|
185 1 font-lock-comment-face)) |
9377
45228a0f6b78
(change-log-mode): Set font-lock-keywords locally.
Richard M. Stallman <rms@gnu.org>
parents:
9347
diff
changeset
|
186 "Additional expressions to highlight in Change Log mode.") |
45228a0f6b78
(change-log-mode): Set font-lock-keywords locally.
Richard M. Stallman <rms@gnu.org>
parents:
9347
diff
changeset
|
187 |
15889 | 188 (defvar change-log-mode-map nil |
189 "Keymap for Change Log major mode.") | |
190 (if change-log-mode-map | |
191 nil | |
192 (setq change-log-mode-map (make-sparse-keymap))) | |
193 | |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
194 (defvar change-log-time-zone-rule nil |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
195 "Time zone used for calculating change log time stamps. |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
196 It takes the same format as the TZ argument of `set-time-zone-rule'. |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
197 If nil, use local time.") |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
198 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
199 (defun add-log-iso8601-time-zone (time) |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
200 (let* ((utc-offset (or (car (current-time-zone time)) 0)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
201 (sign (if (< utc-offset 0) ?- ?+)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
202 (sec (abs utc-offset)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
203 (ss (% sec 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
204 (min (/ sec 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
205 (mm (% min 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
206 (hh (/ min 60))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
207 (format (cond ((not (zerop ss)) "%c%02d:%02d:%02d") |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
208 ((not (zerop mm)) "%c%02d:%02d") |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
209 (t "%c%02d")) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
210 sign hh mm ss))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
211 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
212 (defun add-log-iso8601-time-string () |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
213 (if change-log-time-zone-rule |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
214 (let ((tz (getenv "TZ")) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
215 (now (current-time))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
216 (unwind-protect |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
217 (progn |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
218 (set-time-zone-rule |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
219 change-log-time-zone-rule) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
220 (concat |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
221 (format-time-string "%Y-%m-%d " now) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
222 (add-log-iso8601-time-zone now))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
223 (set-time-zone-rule tz))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
224 (format-time-string "%Y-%m-%d"))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
225 |
661 | 226 (defun change-log-name () |
27240 | 227 "Return (system-dependent) default name for a change log file." |
661 | 228 (or change-log-default-name |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
229 (if (eq system-type 'vax-vms) |
16035
9d8b374b5bb1
(change-log-name): Don't treat MSDOS, NT specially.
Richard M. Stallman <rms@gnu.org>
parents:
15909
diff
changeset
|
230 "$CHANGE_LOG$.TXT" |
9d8b374b5bb1
(change-log-name): Don't treat MSDOS, NT specially.
Richard M. Stallman <rms@gnu.org>
parents:
15909
diff
changeset
|
231 "ChangeLog"))) |
661 | 232 |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
233 ;;;###autoload |
661 | 234 (defun prompt-for-change-log-name () |
235 "Prompt for a change log name." | |
12157
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
236 (let* ((default (change-log-name)) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
237 (name (expand-file-name |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
238 (read-file-name (format "Log file (default %s): " default) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
239 nil default)))) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
240 ;; Handle something that is syntactically a directory name. |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
241 ;; Look for ChangeLog or whatever in that directory. |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
242 (if (string= (file-name-nondirectory name) "") |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
243 (expand-file-name (file-name-nondirectory default) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
244 name) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
245 ;; Handle specifying a file that is a directory. |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
246 (if (file-directory-p name) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
247 (expand-file-name (file-name-nondirectory default) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
248 (file-name-as-directory name)) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
249 name)))) |
661 | 250 |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
251 (defun change-log-version-rcs (rcs-string &optional end) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
252 "Search for plain RCS-STRING from whole buffer up till END. |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
253 The surrounding $ characters fro RCS-STRING are added in this function; |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
254 provide argument e.g. as \"Id\"." |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
255 (let (str) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
256 (save-excursion |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
257 (goto-char (point-min)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
258 (when (re-search-forward |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
259 (concat "[$]" rcs-string ":[^\n$]+[$]") |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
260 end t) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
261 (setq str (match-string 0)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
262 (when (string-match "[0-9]+\.[0-9.]+" str) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
263 (match-string 0 str)))))) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
264 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
265 (defun change-log-version-number-search () |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
266 "Return version number for the file by searchin version control tags." |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
267 (let* ((size (buffer-size)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
268 (end |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
269 ;; The version number can be anywhere in the file, but restrict |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
270 ;; search to the file beginning: 10% should be enough to prevent |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
271 ;; some mishits. |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
272 ;; |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
273 ;; Apply percentage only if buffer size is bigger than approx 100 lines |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
274 (if (> size (* 100 80)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
275 (/ (* (buffer-size) 10) 100) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
276 size)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
277 version) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
278 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
279 ;; Search RCS, CVS version strings |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
280 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
281 (dolist (choice '("Revision" "Id")) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
282 (when (setq version (change-log-version-rcs choice end)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
283 (return))) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
284 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
285 (unless version |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
286 (dolist (regexp change-log-version-number-regexp-list) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
287 (save-excursion |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
288 (goto-char (point-min)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
289 (when (re-search-forward regexp end t) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
290 (setq version (match-string 1)) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
291 (return))))) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
292 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
293 version |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
294 )) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
295 |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
296 |
661 | 297 ;;;###autoload |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
298 (defun find-change-log (&optional file-name) |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
299 "Find a change log file for \\[add-change-log-entry] and return the name. |
8042
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
300 |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
301 Optional arg FILE-NAME specifies the file to use. |
9886
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
302 If FILE-NAME is nil, use the value of `change-log-default-name'. |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
303 If 'change-log-default-name' is nil, behave as though it were 'ChangeLog' |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
304 \(or whatever we use on this operating system). |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
305 |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
306 If 'change-log-default-name' contains a leading directory component, then |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
307 simply find it in the current directory. Otherwise, search in the current |
9886
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
308 directory and its successive parents for a file so named. |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
309 |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
310 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
|
311 current buffer to the complete file name." |
8042
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
312 ;; If user specified a file name or if this buffer knows which one to use, |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
313 ;; just use that. |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
314 (or file-name |
9886
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
315 (setq file-name (and change-log-default-name |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
316 (file-name-directory change-log-default-name) |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
317 change-log-default-name)) |
8042
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
318 (progn |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
319 ;; Chase links in the source file |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
320 ;; and use the change log in the dir where it points. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
321 (setq file-name (or (and buffer-file-name |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
322 (file-name-directory |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
323 (file-chase-links buffer-file-name))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
324 default-directory)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
325 (if (file-directory-p file-name) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
326 (setq file-name (expand-file-name (change-log-name) file-name))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
327 ;; Chase links before visiting the file. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
328 ;; This makes it easier to use a single change log file |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
329 ;; for several related directories. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
330 (setq file-name (file-chase-links file-name)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
331 (setq file-name (expand-file-name file-name)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
332 ;; Move up in the dir hierarchy till we find a change log file. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
333 (let ((file1 file-name) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
334 parent-dir) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
335 (while (and (not (or (get-file-buffer file1) (file-exists-p file1))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
336 (progn (setq parent-dir |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
337 (file-name-directory |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
338 (directory-file-name |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
339 (file-name-directory file1)))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
340 ;; Give up if we are already at the root dir. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
341 (not (string= (file-name-directory file1) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
342 parent-dir)))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
343 ;; Move up to the parent dir and try again. |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
344 (setq file1 (expand-file-name |
8042
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
345 (file-name-nondirectory (change-log-name)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
346 parent-dir))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
347 ;; If we found a change log in a parent, use that. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
348 (if (or (get-file-buffer file1) (file-exists-p file1)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
349 (setq file-name file1))))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
350 ;; Make a local variable in this buffer so we needn't search again. |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
351 (set (make-local-variable 'change-log-default-name) file-name) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
352 file-name) |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
353 |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
354 ;;;###autoload |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
355 (defun add-change-log-entry (&optional whoami file-name other-window new-entry) |
661 | 356 "Find change log file and add an entry for today. |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
357 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
358 name and site. |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
359 |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
360 Second arg is FILE-NAME of change log. If nil, uses `change-log-default-name'. |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
361 Third arg OTHER-WINDOW non-nil means visit in other window. |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
362 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
363 never append to an existing entry. Option `add-log-keep-changes-together' |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
364 otherwise affects whether a new entry is created. |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
365 |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
366 Today's date is calculated according to `change-log-time-zone-rule' if |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
367 non-nil, otherwise in local time." |
661 | 368 (interactive (list current-prefix-arg |
369 (prompt-for-change-log-name))) | |
13648
ce23ae11d3fa
(add-change-log-entry): Initialize add-log-full-name
Richard M. Stallman <rms@gnu.org>
parents:
13505
diff
changeset
|
370 (or add-log-full-name |
ce23ae11d3fa
(add-change-log-entry): Initialize add-log-full-name
Richard M. Stallman <rms@gnu.org>
parents:
13505
diff
changeset
|
371 (setq add-log-full-name (user-full-name))) |
ce23ae11d3fa
(add-change-log-entry): Initialize add-log-full-name
Richard M. Stallman <rms@gnu.org>
parents:
13505
diff
changeset
|
372 (or add-log-mailing-address |
ce23ae11d3fa
(add-change-log-entry): Initialize add-log-full-name
Richard M. Stallman <rms@gnu.org>
parents:
13505
diff
changeset
|
373 (setq add-log-mailing-address user-mail-address)) |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
374 (if whoami |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
375 (progn |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
376 (setq add-log-full-name (read-input "Full name: " add-log-full-name)) |
661 | 377 ;; Note that some sites have room and phone number fields in |
378 ;; full name which look silly when inserted. Rather than do | |
379 ;; anything about that here, let user give prefix argument so that | |
380 ;; s/he can edit the full name field in prompter if s/he wants. | |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
381 (setq add-log-mailing-address |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
382 (read-input "Mailing address: " add-log-mailing-address)))) |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
383 (let ((defun (funcall (or add-log-current-defun-function |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
384 'add-log-current-defun))) |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
385 (version (and change-log-version-info-enabled |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
386 (change-log-version-number-search))) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
387 bound |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
388 entry) |
1752
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
389 |
8136
9ad3db62f0e7
(add-change-log-entry): Apply expand-file-name to FILE-NAME.
Roland McGrath <roland@gnu.org>
parents:
8049
diff
changeset
|
390 (setq file-name (expand-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
|
391 |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
392 ;; 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
|
393 (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
|
394 ;; 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
|
395 (not (string= buffer-file-name file-name)) |
27240 | 396 (if add-log-file-name-function |
397 (setq entry | |
398 (funcall add-log-file-name-function buffer-file-name)) | |
399 (setq entry | |
24289
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
400 (if (string-match |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
401 (concat "^" (regexp-quote (file-name-directory |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
402 file-name))) |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
403 buffer-file-name) |
7917ac967ee5
(add-log-file-name-function): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
23215
diff
changeset
|
404 (substring buffer-file-name (match-end 0)) |
27240 | 405 (file-name-nondirectory buffer-file-name))) |
406 ;; If we have a backup file, it's presumably because we're | |
407 ;; comparing old and new versions (e.g. for deleted | |
408 ;; functions) and we'll want to use the original name. | |
409 (if (backup-file-name-p entry) | |
410 (setq entry (file-name-sans-versions entry))))) | |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
411 |
661 | 412 (if (and other-window (not (equal file-name buffer-file-name))) |
413 (find-file-other-window file-name) | |
414 (find-file file-name)) | |
5150
60fa14264c3b
(add-change-log-entry): put buffer in change-log-mode.
Richard M. Stallman <rms@gnu.org>
parents:
5038
diff
changeset
|
415 (or (eq major-mode 'change-log-mode) |
60fa14264c3b
(add-change-log-entry): put buffer in change-log-mode.
Richard M. Stallman <rms@gnu.org>
parents:
5038
diff
changeset
|
416 (change-log-mode)) |
661 | 417 (undo-boundary) |
418 (goto-char (point-min)) | |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
419 (let ((new-entry (concat (funcall add-log-time-format) |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
420 " " add-log-full-name |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
421 " <" add-log-mailing-address ">"))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
422 (if (looking-at (regexp-quote new-entry)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
423 (forward-line 1) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
424 (insert new-entry "\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
|
425 |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
426 (setq bound |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
427 (progn |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
428 (if (looking-at "\n*[^\n* \t]") |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
429 (skip-chars-forward "\n") |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
430 (if add-log-keep-changes-together |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
431 (forward-page) ; page delimits entries for date |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
432 (forward-paragraph))) ; paragraph delimits entries for file |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
433 (point))) |
661 | 434 (goto-char (point-min)) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
435 ;; Now insert the new line for this entry. |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
436 (cond ((re-search-forward "^\\s *\\*\\s *$" bound t) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
437 ;; 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
|
438 (if entry |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
439 (insert entry))) |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
440 ((and (not new-entry) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
441 (let (case-fold-search) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
442 (re-search-forward |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
443 (concat (regexp-quote (concat "* " entry)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
444 ;; Don't accept `foo.bar' when |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
445 ;; looking for `foo': |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
446 "\\(\\s \\|[(),:]\\)") |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
447 bound t))) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
448 ;; 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
|
449 (re-search-forward "^\\s *$\\|^\\s \\*") |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
450 (goto-char (match-beginning 0)) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
451 ;; Delete excess empty lines; make just 2. |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
452 (while (and (not (eobp)) (looking-at "^\\s *$")) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
453 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
454 (insert "\n\n") |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
455 (forward-line -2) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
456 (indent-relative-maybe)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
457 (t |
678 | 458 ;; Make a new entry. |
459 (forward-line 1) | |
460 (while (looking-at "\\sW") | |
461 (forward-line 1)) | |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
462 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
463 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
464 (insert "\n\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
465 (forward-line -2) |
678 | 466 (indent-to left-margin) |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
467 (insert "* " (or entry "")) |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
468 )) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
469 ;; 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
|
470 ;; Point is at the entry for this file, |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
471 ;; 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
|
472 (if defun |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
473 (progn |
678 | 474 ;; 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
|
475 (undo-boundary) |
678 | 476 (insert (if (save-excursion |
477 (beginning-of-line 1) | |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
478 (looking-at "\\s *$")) |
678 | 479 "" |
480 " ") | |
27003
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
481 "(" defun "): " |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
482 (if version |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
483 (concat version " ") |
f6f431fc901b
(change-log-version-number-regexp-list)
Gerd Moellmann <gerd@gnu.org>
parents:
26618
diff
changeset
|
484 ""))) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
485 ;; No function name, so put in a colon unless we have just a star. |
678 | 486 (if (not (save-excursion |
487 (beginning-of-line 1) | |
488 (looking-at "\\s *\\(\\*\\s *\\)?$"))) | |
27279
300415d17473
(add-change-log-entry): Insert version number
Gerd Moellmann <gerd@gnu.org>
parents:
27277
diff
changeset
|
489 (insert ": " |
300415d17473
(add-change-log-entry): Insert version number
Gerd Moellmann <gerd@gnu.org>
parents:
27277
diff
changeset
|
490 (if version |
27310
ed290e5a5b17
(add-change-log-entry): Fix error trying an `(insert nil)'.
Gerd Moellmann <gerd@gnu.org>
parents:
27281
diff
changeset
|
491 (concat version " ") "")))))) |
661 | 492 |
493 ;;;###autoload | |
494 (defun add-change-log-entry-other-window (&optional whoami file-name) | |
495 "Find change log file in other window and add an entry for today. | |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
496 Optional arg WHOAMI (interactive prefix) non-nil means prompt for user |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
497 name and site. |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
498 Second optional arg FILE-NAME is file name of change log. |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
499 If nil, use `change-log-default-name'. |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
500 |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
501 Affected by the same options as `add-change-log-entry'." |
661 | 502 (interactive (if current-prefix-arg |
503 (list current-prefix-arg | |
504 (prompt-for-change-log-name)))) | |
505 (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
|
506 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) |
661 | 507 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
508 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
509 (defun change-log-mode () |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3499
diff
changeset
|
510 "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
|
511 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
512 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window]. |
951 | 513 Each entry behaves as a paragraph, and the entries for one day as a page. |
514 Runs `change-log-mode-hook'." | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
515 (interactive) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
516 (kill-all-local-variables) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
517 (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
|
518 (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
|
519 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
|
520 left-margin 8 |
13706
ba34746d66fd
(change-log-mode): Defaults for `indent-tabs-mode'
Karl Heuer <kwzh@gnu.org>
parents:
13648
diff
changeset
|
521 fill-column 74 |
15887
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
522 indent-tabs-mode t |
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
523 tab-width 8) |
15889 | 524 (use-local-map change-log-mode-map) |
15887
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
525 (set (make-local-variable 'fill-paragraph-function) |
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
526 'change-log-fill-paragraph) |
21719
c888284a54f7
(change-log-mode): Add `* ' to paragraph-start.
Dave Love <fx@gnu.org>
parents:
21629
diff
changeset
|
527 ;; We really do want "^" in paragraph-start below: it is only the |
c888284a54f7
(change-log-mode): Add `* ' to paragraph-start.
Dave Love <fx@gnu.org>
parents:
21629
diff
changeset
|
528 ;; lines that begin at column 0 (despite the left-margin of 8) that |
c888284a54f7
(change-log-mode): Add `* ' to paragraph-start.
Dave Love <fx@gnu.org>
parents:
21629
diff
changeset
|
529 ;; we are looking for. Adding `* ' allows eliding the blank line |
c888284a54f7
(change-log-mode): Add `* ' to paragraph-start.
Dave Love <fx@gnu.org>
parents:
21629
diff
changeset
|
530 ;; between entries for different files. |
21749
84df514f7719
(change-log-mode): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents:
21719
diff
changeset
|
531 (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\<") |
21719
c888284a54f7
(change-log-mode): Add `* ' to paragraph-start.
Dave Love <fx@gnu.org>
parents:
21629
diff
changeset
|
532 (set (make-local-variable 'paragraph-separate) paragraph-start) |
1078
15b4ed20e524
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1062
diff
changeset
|
533 ;; 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
|
534 ;; is grouped with what follows. |
4380
0c7aefc58e0f
(change-log-mode): Use \f for formfeed, to avoid syntax error.
Richard M. Stallman <rms@gnu.org>
parents:
4157
diff
changeset
|
535 (set (make-local-variable 'page-delimiter) "^\\<\\|^\f") |
678 | 536 (set (make-local-variable 'version-control) 'never) |
537 (set (make-local-variable 'adaptive-fill-regexp) "\\s *") | |
9471
1b933ccf3c20
* add-log.el: (change-log-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9397
diff
changeset
|
538 (set (make-local-variable 'font-lock-defaults) |
1b933ccf3c20
* add-log.el: (change-log-mode): Set font-lock-defaults.
Simon Marshall <simon@gnu.org>
parents:
9397
diff
changeset
|
539 '(change-log-font-lock-keywords t)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
540 (run-hooks 'change-log-mode-hook)) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
541 |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
542 ;; It might be nice to have a general feature to replace this. The idea I |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
543 ;; have is a variable giving a regexp matching text which should not be |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
544 ;; moved from bol by filling. change-log-mode would set this to "^\\s *\\s(". |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
545 ;; But I don't feel up to implementing that today. |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
546 (defun change-log-fill-paragraph (&optional justify) |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
547 "Fill the paragraph, but preserve open parentheses at beginning of lines. |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
548 Prefix arg means justify as well." |
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
549 (interactive "P") |
16505
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
550 (let ((end (progn (forward-paragraph) (point))) |
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
551 (beg (progn (backward-paragraph) (point))) |
13505
86470b361571
(change-log-mode): Remove incorrect "^" anchors from
Richard M. Stallman <rms@gnu.org>
parents:
13282
diff
changeset
|
552 (paragraph-start (concat paragraph-start "\\|\\s *\\s("))) |
16505
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
553 (fill-region beg end justify) |
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
554 t)) |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
555 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
556 (defcustom add-log-current-defun-header-regexp |
6309
9217f29851c2
Don't use triple-hyphen in a character class.
Karl Heuer <kwzh@gnu.org>
parents:
5467
diff
changeset
|
557 "^\\([A-Z][A-Z_ ]*[A-Z_]\\|[-_a-zA-Z]+\\)[ \t]*[:=]" |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
558 "*Heuristic regexp used by `add-log-current-defun' for unknown major modes." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
559 :type 'regexp |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
560 :group 'change-log) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
561 |
6562
0541a368505c
(add-log-current-defun): Autoload this.
Roland McGrath <roland@gnu.org>
parents:
6309
diff
changeset
|
562 ;;;###autoload |
17912
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
563 (defvar add-log-lisp-like-modes |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
564 '(emacs-lisp-mode lisp-mode scheme-mode dsssl-mode lisp-interaction-mode) |
17912
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
565 "*Modes that look like Lisp to `add-log-current-defun'.") |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
566 |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
567 ;;;###autoload |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
568 (defvar add-log-c-like-modes |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
569 '(c-mode c++-mode c++-c-mode objc-mode) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
570 "*Modes that look like C to `add-log-current-defun'.") |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
571 |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
572 ;;;###autoload |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
573 (defvar add-log-tex-like-modes |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
574 '(TeX-mode plain-TeX-mode LaTeX-mode plain-tex-mode latex-mode) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
575 "*Modes that look like TeX to `add-log-current-defun'.") |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
576 |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
577 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
578 (defun add-log-current-defun () |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
579 "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
|
580 |
3499
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
581 Understands C, Lisp, LaTeX (\"functions\" are chapters, sections, ...), |
9347
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
582 Texinfo (@node titles), Perl, and Fortran. |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
583 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
584 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
|
585 point for uppercase headings starting in the first column or |
27277
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
586 identifiers followed by `:' or `=', see variables |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
587 `add-log-current-defun-header-regexp' and |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
588 `add-log-current-defun-function' |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
589 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
590 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
|
591 (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
592 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
593 (let ((location (point))) |
27281
8afd998ab3b2
(add-log-current-defun): Handle user-defined
Gerd Moellmann <gerd@gnu.org>
parents:
27279
diff
changeset
|
594 (cond ((and (functionp add-log-current-defun-function) |
8afd998ab3b2
(add-log-current-defun): Handle user-defined
Gerd Moellmann <gerd@gnu.org>
parents:
27279
diff
changeset
|
595 (funcall add-log-current-defun-function))) |
27277
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
596 ((memq major-mode add-log-lisp-like-modes) |
13086
1bc6075184d7
(add-log-current-defun): Ignore quotes before fcn name.
Richard M. Stallman <rms@gnu.org>
parents:
12551
diff
changeset
|
597 ;; If we are now precisely at the beginning of a defun, |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
598 ;; 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
|
599 ;; rather than the previous one. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
600 (or (eobp) (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
601 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
602 ;; Make sure we are really inside the defun found, not after it. |
21944
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
603 (when (and (looking-at "\\s(") |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
604 (progn (end-of-defun) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
605 (< location (point))) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
606 (progn (forward-sexp -1) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
607 (>= location (point)))) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
608 (if (looking-at "\\s(") |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
609 (forward-char 1)) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
610 ;; Skip the defining construct name, typically "defun" |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
611 ;; or "defvar". |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
612 (forward-sexp 1) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
613 ;; The second element is usually a symbol being defined. |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
614 ;; If it is not, use the first symbol in it. |
22018 | 615 (skip-chars-forward " \t\n'(") |
21944
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
616 (buffer-substring (point) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
617 (progn (forward-sexp 1) |
8e606f5208eb
(add-log-current-defun) <lisp>:
Richard M. Stallman <rms@gnu.org>
parents:
21943
diff
changeset
|
618 (point))))) |
17912
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
619 ((and (memq major-mode add-log-c-like-modes) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
620 (save-excursion |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
621 (beginning-of-line) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
622 ;; Use eq instead of = here to avoid |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
623 ;; error when at bob and char-after |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
624 ;; returns nil. |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
625 (while (eq (char-after (- (point) 2)) ?\\) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
626 (forward-line -1)) |
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
627 (looking-at "[ \t]*#[ \t]*define[ \t]"))) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
628 ;; Handle a C macro definition. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
629 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
630 (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
|
631 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
632 (search-forward "define") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
633 (skip-chars-forward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
634 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
635 (progn (forward-sexp 1) (point)))) |
17912
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
636 ((memq major-mode add-log-c-like-modes) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
637 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
638 ;; 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
|
639 ;; 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
|
640 (while (not (looking-at "{\\|\\(\\s *$\\)")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
641 (forward-line 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
642 (or (eobp) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
643 (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
644 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
645 (if (progn (end-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
646 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
647 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
648 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
649 (let (beg tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
650 |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
651 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
652 ;; 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
|
653 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
654 (looking-at "[ \t\n]")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
655 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
656 ;; 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
|
657 ;; 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
|
658 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
659 (and (save-excursion |
8313
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
660 (end-of-line) |
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
661 (while (= (preceding-char) ?\\) |
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
662 (end-of-line 2)) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
663 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
664 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
665 (setq tem (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
666 (looking-at "DEFUN\\b")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
667 (>= location tem)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
668 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
669 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
670 (goto-char tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
671 (down-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
672 (if (= (char-after (point)) ?\") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
673 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
674 (forward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
675 (skip-chars-forward " ,"))) |
953 | 676 (buffer-substring (point) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
677 (progn (forward-sexp 1) (point)))) |
11757
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
678 (if (looking-at "^[+-]") |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
679 (change-log-get-method-definition) |
11757
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
680 ;; Ordinary C function syntax. |
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
681 (setq beg (point)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
682 (if (and (condition-case nil |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
683 ;; Protect against "Unbalanced parens" error. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
684 (progn |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
685 (down-list 1) ; into arglist |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
686 (backward-up-list 1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
687 (skip-chars-backward " \t") |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
688 t) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
689 (error nil)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
690 ;; Verify initial pos was after |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
691 ;; real start of function. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
692 (save-excursion |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
693 (goto-char beg) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
694 ;; For this purpose, include the line |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
695 ;; that has the decl keywords. This |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
696 ;; may also include some of the |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
697 ;; comments before the function. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
698 (while (and (not (bobp)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
699 (save-excursion |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
700 (forward-line -1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
701 (looking-at "[^\n\f]"))) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
702 (forward-line -1)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
703 (>= location (point))) |
11757
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
704 ;; Consistency check: going down and up |
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
705 ;; shouldn't take us back before BEG. |
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
706 (> (point) beg)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
707 (let (end middle) |
25273
c8d2d5e80cc0
(add-log-current-defun): Exclude all trailing whitespace.
Karl Heuer <kwzh@gnu.org>
parents:
24940
diff
changeset
|
708 ;; Don't include any final whitespace |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
709 ;; in the name we use. |
25273
c8d2d5e80cc0
(add-log-current-defun): Exclude all trailing whitespace.
Karl Heuer <kwzh@gnu.org>
parents:
24940
diff
changeset
|
710 (skip-chars-backward " \t\n") |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
711 (setq end (point)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
712 (backward-sexp 1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
713 ;; Now find the right beginning of the name. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
714 ;; Include certain keywords if they |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
715 ;; precede the name. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
716 (setq middle (point)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
717 (forward-word -1) |
13255
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
718 ;; Ignore these subparts of a class decl |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
719 ;; and move back to the class name itself. |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
720 (while (looking-at "public \\|private ") |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
721 (skip-chars-backward " \t:") |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
722 (setq end (point)) |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
723 (backward-sexp 1) |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
724 (setq middle (point)) |
9e94f911f00c
(add-log-current-defun): Handle `private', `public' in C++ class definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13086
diff
changeset
|
725 (forward-word -1)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
726 (and (bolp) |
25273
c8d2d5e80cc0
(add-log-current-defun): Exclude all trailing whitespace.
Karl Heuer <kwzh@gnu.org>
parents:
24940
diff
changeset
|
727 (looking-at "enum \\|struct \\|union \\|class ") |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
728 (setq middle (point))) |
24940
ca83292ec6f2
(add-log-current-defun): Remove trailing -=' in C modes.
Richard M. Stallman <rms@gnu.org>
parents:
24289
diff
changeset
|
729 (goto-char end) |
ca83292ec6f2
(add-log-current-defun): Remove trailing -=' in C modes.
Richard M. Stallman <rms@gnu.org>
parents:
24289
diff
changeset
|
730 (when (eq (preceding-char) ?=) |
ca83292ec6f2
(add-log-current-defun): Remove trailing -=' in C modes.
Richard M. Stallman <rms@gnu.org>
parents:
24289
diff
changeset
|
731 (forward-char -1) |
ca83292ec6f2
(add-log-current-defun): Remove trailing -=' in C modes.
Richard M. Stallman <rms@gnu.org>
parents:
24289
diff
changeset
|
732 (skip-chars-backward " \t") |
ca83292ec6f2
(add-log-current-defun): Remove trailing -=' in C modes.
Richard M. Stallman <rms@gnu.org>
parents:
24289
diff
changeset
|
733 (setq end (point))) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
734 (buffer-substring middle end))))))))) |
17912
653987823f79
(add-log-lisp-like-modes, add-log-c-like-modes, add-log-tex-like-modes):
Erik Naggum <erik@naggum.no>
parents:
17413
diff
changeset
|
735 ((memq major-mode add-log-tex-like-modes) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
736 (if (re-search-backward |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
737 "\\\\\\(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
|
738 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
739 (goto-char (match-beginning 0)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
740 (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
|
741 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
742 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
743 (point)))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
744 ((eq major-mode 'texinfo-mode) |
9397
eba13d81ba0b
(add-log-current-defun): In texinfo-mode,
Richard M. Stallman <rms@gnu.org>
parents:
9377
diff
changeset
|
745 (if (re-search-backward "^@node[ \t]+\\([^,\n]+\\)" nil t) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
746 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
747 (match-end 1)))) |
9347
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
748 ((eq major-mode 'perl-mode) |
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
749 (if (re-search-backward "^sub[ \t]+\\([^ \t\n]+\\)" nil t) |
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
750 (buffer-substring (match-beginning 1) |
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
751 (match-end 1)))) |
27945
c11a0bbb5c88
(add-log-current-defun): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
27310
diff
changeset
|
752 ((eq major-mode 'autoconf-mode) |
c11a0bbb5c88
(add-log-current-defun): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
27310
diff
changeset
|
753 (if (re-search-backward "^\\(\\(m4_\\)?define\\|A._DEFUN\\)(\\[?\\([A-Za-z0-9_]+\\)" nil t) |
c11a0bbb5c88
(add-log-current-defun): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
27310
diff
changeset
|
754 (buffer-substring (match-beginning 3) |
c11a0bbb5c88
(add-log-current-defun): Add support for
Gerd Moellmann <gerd@gnu.org>
parents:
27310
diff
changeset
|
755 (match-end 3)))) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
756 ((or (eq major-mode 'fortran-mode) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
757 ;; Needs work for f90, but better than nothing. |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
758 (eq major-mode 'f90-mode)) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
759 ;; must be inside function body for this to work |
26618
d09cca4b3d50
(add-log-current-defun): Use fortran-{beginning,end}-of-subprogram.
Dave Love <fx@gnu.org>
parents:
26613
diff
changeset
|
760 (fortran-beginning-of-subprogram) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
761 (let ((case-fold-search t)) ; case-insensitive |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
762 ;; search for fortran subprogram start |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
763 (if (re-search-forward |
21943
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
764 "^[ \t]*\\(program\\|subroutine\\|function\ |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
765 \\|[ \ta-z0-9*()]*[ \t]+function\\|\\(block[ \t]*data\\)\\)" |
26618
d09cca4b3d50
(add-log-current-defun): Use fortran-{beginning,end}-of-subprogram.
Dave Love <fx@gnu.org>
parents:
26613
diff
changeset
|
766 (save-excursion (fortran-end-of-subprogram) |
21943
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
767 (point)) |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
768 t) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
769 (or (match-string 2) |
21943
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
770 (progn |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
771 ;; move to EOL or before first left paren |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
772 (if (re-search-forward "[(\n]" nil t) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
773 (progn (backward-char) |
21943
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
774 (skip-chars-backward " \t")) |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
775 (end-of-line)) |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
776 ;; Use the name preceding that. |
f702be237f91
(add-log-current-defun): Fix previous fortran change.
Richard M. Stallman <rms@gnu.org>
parents:
21926
diff
changeset
|
777 (buffer-substring (point) |
21629
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
778 (progn (backward-sexp) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
779 (point))))) |
2da609ac7ab1
(change-log-mode): Revert 1997-12-03 doc change.
Dave Love <fx@gnu.org>
parents:
21009
diff
changeset
|
780 "main"))) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
781 (t |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
782 ;; If all else fails, try heuristics |
27277
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
783 (let (case-fold-search |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
784 result) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
785 (end-of-line) |
27277
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
786 (when (re-search-backward |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
787 add-log-current-defun-header-regexp |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
788 (- (point) 10000) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
789 t) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
790 (setq result (or (buffer-substring (match-beginning 1) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
791 (match-end 1)) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
792 (buffer-substring (match-beginning 0) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
793 (match-end 0)))) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
794 ;; Strip whitespace away |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
795 (when (string-match "\\([^ \t\n\r\f].*[^ \t\n\r\f]\\)" |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
796 result) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
797 (setq result (match-string 1 result))) |
9fdcfef41c64
(add-log-current-defun): Call
Gerd Moellmann <gerd@gnu.org>
parents:
27240
diff
changeset
|
798 result)))))) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
799 (error nil))) |
999 | 800 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
801 (defvar change-log-get-method-definition-md) |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
802 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
803 ;; Subroutine used within change-log-get-method-definition. |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
804 ;; Add the last match in the buffer to the end of `md', |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
805 ;; followed by the string END; move to the end of that match. |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
806 (defun change-log-get-method-definition-1 (end) |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
807 (setq change-log-get-method-definition-md |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
808 (concat change-log-get-method-definition-md |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
809 (buffer-substring (match-beginning 1) (match-end 1)) |
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
810 end)) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
811 (goto-char (match-end 0))) |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
812 |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
813 (defun change-log-get-method-definition () |
27240 | 814 "For objective C, return the method name if we are in a method." |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
815 (let ((change-log-get-method-definition-md "[")) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
816 (save-excursion |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
817 (if (re-search-backward "^@implementation\\s-*\\([A-Za-z_]*\\)" nil t) |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
818 (change-log-get-method-definition-1 " "))) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
819 (save-excursion |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
820 (cond |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
821 ((re-search-forward "^\\([-+]\\)[ \t\n\f\r]*\\(([^)]*)\\)?\\s-*" nil t) |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
822 (change-log-get-method-definition-1 "") |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
823 (while (not (looking-at "[{;]")) |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
824 (looking-at |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
825 "\\([A-Za-z_]*:?\\)\\s-*\\(([^)]*)\\)?[A-Za-z_]*[ \t\n\f\r]*") |
20402
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
826 (change-log-get-method-definition-1 "")) |
108100aa1991
(change-log-add-make-room): New function.
Karl Heuer <kwzh@gnu.org>
parents:
19904
diff
changeset
|
827 (concat change-log-get-method-definition-md "]")))))) |
27240 | 828 |
829 (defun change-log-sortable-date-at () | |
830 "Return date of log entry in a consistent form for sorting. | |
831 Point is assumed to be at the start of the entry." | |
832 (require 'timezone) | |
833 (if (looking-at "^\\sw.........[0-9:+ ]*") | |
834 (let ((date (match-string-no-properties 0))) | |
835 (if date | |
836 (if (string-match "\\(....\\)-\\(..\\)-\\(..\\)\\s-+" date) | |
837 (concat (match-string 1 date) (match-string 2 date) | |
838 (match-string 3 date)) | |
839 (condition-case nil | |
840 (timezone-make-date-sortable date) | |
841 (error nil))))) | |
842 (error "Bad date"))) | |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
843 |
27240 | 844 ;;;###autoload |
845 (defun change-log-merge (other-log) | |
846 "Merge the contents of ChangeLog file OTHER-LOG with this buffer. | |
847 Both must be found in Change Log mode (since the merging depends on | |
848 the appropriate motion commands). | |
849 | |
850 Entries are inserted in chronological order. | |
851 | |
852 Both the current and old-style time formats for entries are supported, | |
853 so this command could be used to convert old-style logs by merging | |
854 with an empty log." | |
855 (interactive "*fLog file name to merge: ") | |
856 (if (not (eq major-mode 'change-log-mode)) | |
857 (error "Not in Change Log mode")) | |
858 (let ((other-buf (find-file-noselect other-log)) | |
859 (buf (current-buffer)) | |
860 date1 start end) | |
861 (save-excursion | |
862 (goto-char (point-min)) | |
863 (set-buffer other-buf) | |
864 (goto-char (point-min)) | |
865 (if (not (eq major-mode 'change-log-mode)) | |
866 (error "%s not found in Change Log mode" other-log)) | |
867 ;; Loop through all the entries in OTHER-LOG. | |
868 (while (not (eobp)) | |
869 (setq date1 (change-log-sortable-date-at)) | |
870 (setq start (point) | |
871 end (progn (forward-page) (point))) | |
872 ;; Look for an entry in original buffer that isn't later. | |
873 (with-current-buffer buf | |
874 (while (and (not (eobp)) | |
875 (string< date1 (change-log-sortable-date-at))) | |
876 (forward-page)) | |
877 (if (not (eobp)) | |
878 (insert-buffer-substring other-buf start end) | |
879 ;; At the end of the original buffer, insert a newline to | |
880 ;; separate entries and then the rest of the file being | |
881 ;; merged. Move to the end of it to terminate outer loop. | |
882 (insert "\n") | |
883 (insert-buffer-substring other-buf start | |
884 (with-current-buffer other-buf | |
885 (goto-char (point-max)) | |
886 (point))))))))) | |
999 | 887 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
888 (provide 'add-log) |
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
889 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
890 ;;; add-log.el ends here |