Mercurial > emacs
annotate lisp/add-log.el @ 20129:a68db1ead5cf
(set-scroll-bar-mode): Take just one arg.
(set-scroll-bar-mode-1): Take 2 args, as set-scroll-bar-mode used to.
(scroll-bar-mode variable): Use set-scroll-bar-mode-1.
(scroll-bar-mode command): Pass 1 arg to set-scroll-bar-mode.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 23 Oct 1997 06:44:15 +0000 |
parents | 1e0f71fd673c |
children | 108100aa1991 |
rev | line source |
---|---|
661 | 1 ;;; add-log.el --- change log maintenance commands for Emacs |
2 | |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
3 ;; Copyright (C) 1985, 86, 88, 93, 94, 1997 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 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
30 (defgroup change-log nil |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
31 "Change log maintenance" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
32 :group 'tools |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
33 :prefix "change-log-" |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
34 :prefix "add-log-") |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
35 |
661 | 36 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
37 (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
|
38 "*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
|
39 :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
|
40 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
41 :group 'change-log) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
42 |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
43 (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
|
44 "\ |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
45 *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
|
46 \\[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
|
47 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
|
48 :type 'function |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
49 :group 'change-log) |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
50 |
14856
f64fa743c80f
(add-log-full-name, add-log-mailing-address): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
14528
diff
changeset
|
51 ;;;###autoload |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
52 (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
|
53 "*Full name 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
|
54 This defaults to the value returned by the `user-full-name' function." |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
55 :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
|
56 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
57 :group 'change-log) |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
58 |
14856
f64fa743c80f
(add-log-full-name, add-log-mailing-address): Add autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
14528
diff
changeset
|
59 ;;;###autoload |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
60 (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
|
61 "*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
|
62 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
|
63 :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
|
64 string) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
65 :group 'change-log) |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
66 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
67 (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
|
68 "*Function that defines the time format. |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
69 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
|
70 date in international ISO 8601 format, |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
71 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
|
72 :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
|
73 add-log-iso8601-time-string) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
74 (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
|
75 current-time-string) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
76 (function :tag "Other")) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
77 :group 'change-log) |
4741
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
78 |
9377
45228a0f6b78
(change-log-mode): Set font-lock-keywords locally.
Richard M. Stallman <rms@gnu.org>
parents:
9347
diff
changeset
|
79 (defvar change-log-font-lock-keywords |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
80 '(;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
81 ;; Date lines, new and old styles. |
17923
986fa91361cc
(change-log-font-lock-keywords): Tweak font-lock-keywords.
Erik Naggum <erik@naggum.no>
parents:
17912
diff
changeset
|
82 ("^\\sw.........[0-9: ]*" |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
83 (0 font-lock-string-face) |
17923
986fa91361cc
(change-log-font-lock-keywords): Tweak font-lock-keywords.
Erik Naggum <erik@naggum.no>
parents:
17912
diff
changeset
|
84 ("\\([^<]+\\)<\\([A-Za-z0-9_.-]+@[A-Za-z0-9_.-]+\\)>" nil nil |
986fa91361cc
(change-log-font-lock-keywords): Tweak font-lock-keywords.
Erik Naggum <erik@naggum.no>
parents:
17912
diff
changeset
|
85 (1 font-lock-reference-face) |
986fa91361cc
(change-log-font-lock-keywords): Tweak font-lock-keywords.
Erik Naggum <erik@naggum.no>
parents:
17912
diff
changeset
|
86 (2 font-lock-variable-name-face))) |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
87 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
88 ;; File names. |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
89 ("^\t\\* \\([^ ,:([\n]+\\)" |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
90 (1 font-lock-function-name-face) |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
91 ("\\=, \\([^ ,:([\n]+\\)" nil nil (1 font-lock-function-name-face))) |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
92 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
93 ;; Function or variable names. |
19325
db1b53ad6c80
(change-log-font-lock-keywords): Don't consider
Richard M. Stallman <rms@gnu.org>
parents:
18277
diff
changeset
|
94 ("(\\([^) ,:\n]+\\)" |
16450
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
95 (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
|
96 ("\\=, *\\([^) ,:\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
|
97 ;; |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
98 ;; Conditionals. |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
99 ("\\[!?\\([^]\n]+\\)\\]\\(:\\| (\\)" (1 font-lock-variable-name-face)) |
82b0566ece27
Tweak change-log-font-lock-keywords
Simon Marshall <simon@gnu.org>
parents:
16035
diff
changeset
|
100 ;; |
19439 | 101 ;; Acknowledgements. |
19632
eb2d6de004b1
(change-log-font-lock-keywords): Add more to prev change.
Richard M. Stallman <rms@gnu.org>
parents:
19510
diff
changeset
|
102 ("^\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
|
103 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
|
104 (" \\(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
|
105 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
|
106 "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
|
107 |
15889 | 108 (defvar change-log-mode-map nil |
109 "Keymap for Change Log major mode.") | |
110 (if change-log-mode-map | |
111 nil | |
112 (setq change-log-mode-map (make-sparse-keymap))) | |
113 | |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
114 (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
|
115 "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
|
116 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
|
117 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
|
118 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
119 (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
|
120 (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
|
121 (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
|
122 (sec (abs utc-offset)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
123 (ss (% sec 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
124 (min (/ sec 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
125 (mm (% min 60)) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
126 (hh (/ min 60))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
127 (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
|
128 ((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
|
129 (t "%c%02d")) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
130 sign hh mm ss))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
131 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
132 (defun add-log-iso8601-time-string () |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
133 (if change-log-time-zone-rule |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
134 (let ((tz (getenv "TZ")) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
135 (now (current-time))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
136 (unwind-protect |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
137 (progn |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
138 (set-time-zone-rule |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
139 change-log-time-zone-rule) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
140 (concat |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
141 (format-time-string "%Y-%m-%d " now) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
142 (add-log-iso8601-time-zone now))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
143 (set-time-zone-rule tz))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
144 (format-time-string "%Y-%m-%d"))) |
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
145 |
661 | 146 (defun change-log-name () |
147 (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
|
148 (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
|
149 "$CHANGE_LOG$.TXT" |
9d8b374b5bb1
(change-log-name): Don't treat MSDOS, NT specially.
Richard M. Stallman <rms@gnu.org>
parents:
15909
diff
changeset
|
150 "ChangeLog"))) |
661 | 151 |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
152 ;;;###autoload |
661 | 153 (defun prompt-for-change-log-name () |
154 "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
|
155 (let* ((default (change-log-name)) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
156 (name (expand-file-name |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
157 (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
|
158 nil default)))) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
159 ;; 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
|
160 ;; 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
|
161 (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
|
162 (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
|
163 name) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
164 ;; 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
|
165 (if (file-directory-p name) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
166 (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
|
167 (file-name-as-directory name)) |
f4a8265756e7
(prompt-for-change-log-name): Handle the case where
Karl Heuer <kwzh@gnu.org>
parents:
11816
diff
changeset
|
168 name)))) |
661 | 169 |
170 ;;;###autoload | |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
171 (defun find-change-log (&optional file-name) |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
172 "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
|
173 |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 \(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
|
178 |
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 |
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
183 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
|
184 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
|
185 ;; 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
|
186 ;; just use that. |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
187 (or file-name |
9886
f54af6fe889e
(find-change-log): If change-log-default-name
Richard M. Stallman <rms@gnu.org>
parents:
9774
diff
changeset
|
188 (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
|
189 (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
|
190 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
|
191 (progn |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
192 ;; 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
|
193 ;; 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
|
194 (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
|
195 (file-name-directory |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
196 (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
|
197 default-directory)) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
198 (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
|
199 (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
|
200 ;; 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
|
201 ;; 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
|
202 ;; 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
|
203 (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
|
204 (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
|
205 ;; 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
|
206 (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
|
207 parent-dir) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
208 (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
|
209 (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
|
210 (file-name-directory |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
211 (directory-file-name |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
212 (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
|
213 ;; 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
|
214 (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
|
215 parent-dir)))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
216 ;; 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
|
217 (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
|
218 (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
|
219 parent-dir))) |
0495d3085f00
(find-change-log): If file name specified, just use it.
Richard M. Stallman <rms@gnu.org>
parents:
6562
diff
changeset
|
220 ;; 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
|
221 (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
|
222 (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
|
223 ;; 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
|
224 (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
|
225 file-name) |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
226 |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
227 |
2463
d3c9f0ad5964
(find-change-log): New function.
Roland McGrath <roland@gnu.org>
parents:
2307
diff
changeset
|
228 ;;;###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
|
229 (defun add-change-log-entry (&optional whoami file-name other-window new-entry) |
661 | 230 "Find change log file and add an entry for today. |
231 Optional arg (interactive prefix) non-nil means prompt for user name and site. | |
232 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
|
233 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
|
234 Fourth arg NEW-ENTRY non-nil means always create a new entry at the front; |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
235 never append to an existing entry. Today's date is calculated according to |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
236 `change-log-time-zone-rule' if non-nil, otherwise in local time." |
661 | 237 (interactive (list current-prefix-arg |
238 (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
|
239 (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
|
240 (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
|
241 (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
|
242 (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
|
243 (if whoami |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
244 (progn |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
245 (setq add-log-full-name (read-input "Full name: " add-log-full-name)) |
661 | 246 ;; Note that some sites have room and phone number fields in |
247 ;; full name which look silly when inserted. Rather than do | |
248 ;; anything about that here, let user give prefix argument so that | |
249 ;; 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
|
250 (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
|
251 (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
|
252 (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
|
253 'add-log-current-defun))) |
c0ea0009268a
add-log-full-name, add-log-mailing-address: new varialbes
Brian Fox <bfox@gnu.org>
parents:
4380
diff
changeset
|
254 paragraph-end entry) |
1752
b2af3186e7a7
(add-change-log-entry): Search for existing ChangeLog
Richard M. Stallman <rms@gnu.org>
parents:
1727
diff
changeset
|
255 |
8136
9ad3db62f0e7
(add-change-log-entry): Apply expand-file-name to FILE-NAME.
Roland McGrath <roland@gnu.org>
parents:
8049
diff
changeset
|
256 (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
|
257 |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
258 ;; 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
|
259 (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
|
260 ;; 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
|
261 (not (string= buffer-file-name file-name)) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
262 (setq entry (if (string-match |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
263 (concat "^" (regexp-quote (file-name-directory |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
264 file-name))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
265 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
|
266 (substring buffer-file-name (match-end 0)) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
267 (file-name-nondirectory buffer-file-name)))) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
268 |
661 | 269 (if (and other-window (not (equal file-name buffer-file-name))) |
270 (find-file-other-window file-name) | |
271 (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
|
272 (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
|
273 (change-log-mode)) |
661 | 274 (undo-boundary) |
275 (goto-char (point-min)) | |
18277
7509948b0121
(add-log-time-format): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
17923
diff
changeset
|
276 (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
|
277 " " add-log-full-name |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
278 " <" add-log-mailing-address ">"))) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
279 (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
|
280 (forward-line 1) |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
281 (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
|
282 |
1847
63af9f715bd3
(add-change-log-entry): Undo Jan 25 change. It worked for buffers in
Roland McGrath <roland@gnu.org>
parents:
1813
diff
changeset
|
283 ;; Search only within the first paragraph. |
1999
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
284 (if (looking-at "\n*[^\n* \t]") |
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
285 (skip-chars-forward "\n") |
ced6a5b2519d
(add-change-log-entry): Never move past second hdr line.
Richard M. Stallman <rms@gnu.org>
parents:
1956
diff
changeset
|
286 (forward-paragraph 1)) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
287 (setq paragraph-end (point)) |
661 | 288 (goto-char (point-min)) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
289 |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
290 ;; Now insert the new line for this entry. |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
291 (cond ((re-search-forward "^\\s *\\*\\s *$" paragraph-end t) |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
292 ;; 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
|
293 (if entry |
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
294 (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
|
295 ((and (not new-entry) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
296 (let (case-fold-search) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
297 (re-search-forward |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
298 (concat (regexp-quote (concat "* " entry)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
299 ;; Don't accept `foo.bar' when |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
300 ;; looking for `foo': |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
301 "\\(\\s \\|[(),:]\\)") |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
302 paragraph-end t))) |
1727
d6cc12c97a59
(add-change-log-entry): Notice when ENTRY is equal to FILE-NAME,
Roland McGrath <roland@gnu.org>
parents:
1644
diff
changeset
|
303 ;; 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
|
304 (re-search-forward "^\\s *$\\|^\\s \\*") |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
305 (goto-char (match-beginning 0)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
306 ;; Delete excess empty lines; make just 2. |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
307 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
308 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
309 (insert "\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
310 (forward-line -2) |
678 | 311 (indent-relative-maybe)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
312 (t |
678 | 313 ;; Make a new entry. |
314 (forward-line 1) | |
315 (while (looking-at "\\sW") | |
316 (forward-line 1)) | |
912
1c37c99856de
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
846
diff
changeset
|
317 (while (and (not (eobp)) (looking-at "^\\s *$")) |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
318 (delete-region (point) (save-excursion (forward-line 1) (point)))) |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
319 (insert "\n\n\n") |
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
320 (forward-line -2) |
678 | 321 (indent-to left-margin) |
322 (insert "* " (or entry "")))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
323 ;; 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
|
324 ;; Point is at the entry for this file, |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
325 ;; 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
|
326 (if defun |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
327 (progn |
678 | 328 ;; 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
|
329 (undo-boundary) |
678 | 330 (insert (if (save-excursion |
331 (beginning-of-line 1) | |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
332 (looking-at "\\s *$")) |
678 | 333 "" |
334 " ") | |
335 "(" defun "): ")) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
336 ;; No function name, so put in a colon unless we have just a star. |
678 | 337 (if (not (save-excursion |
338 (beginning-of-line 1) | |
339 (looking-at "\\s *\\(\\*\\s *\\)?$"))) | |
837
a8aef92e0025
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
811
diff
changeset
|
340 (insert ": "))))) |
661 | 341 |
342 ;;;###autoload | |
343 (defun add-change-log-entry-other-window (&optional whoami file-name) | |
344 "Find change log file in other window and add an entry for today. | |
4154
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
345 Optional arg (interactive prefix) non-nil means prompt for user name and site. |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
346 Second arg is file name of change log. \ |
20a0593431b7
(add-log-current-defun-function): New defvar.
Roland McGrath <roland@gnu.org>
parents:
3897
diff
changeset
|
347 If nil, uses `change-log-default-name'." |
661 | 348 (interactive (if current-prefix-arg |
349 (list current-prefix-arg | |
350 (prompt-for-change-log-name)))) | |
351 (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
|
352 ;;;###autoload (define-key ctl-x-4-map "a" 'add-change-log-entry-other-window) |
661 | 353 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
354 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
355 (defun change-log-mode () |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3499
diff
changeset
|
356 "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
|
357 Prevents numeric backups and sets `left-margin' to 8 and `fill-column' to 74. |
951 | 358 New log entries are usually made with \\[add-change-log-entry] or \\[add-change-log-entry-other-window]. |
359 Each entry behaves as a paragraph, and the entries for one day as a page. | |
360 Runs `change-log-mode-hook'." | |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
361 (interactive) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
362 (kill-all-local-variables) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
363 (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
|
364 (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
|
365 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
|
366 left-margin 8 |
13706
ba34746d66fd
(change-log-mode): Defaults for `indent-tabs-mode'
Karl Heuer <kwzh@gnu.org>
parents:
13648
diff
changeset
|
367 fill-column 74 |
15887
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
368 indent-tabs-mode t |
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
369 tab-width 8) |
15889 | 370 (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
|
371 (set (make-local-variable 'fill-paragraph-function) |
18c1dcf40139
(change-log-mode): Set fill-paragraph-function.
Karl Heuer <kwzh@gnu.org>
parents:
15299
diff
changeset
|
372 'change-log-fill-paragraph) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
373 ;; Let each entry behave as one paragraph: |
13505
86470b361571
(change-log-mode): Remove incorrect "^" anchors from
Richard M. Stallman <rms@gnu.org>
parents:
13282
diff
changeset
|
374 ;; We really do want "^" in paragraph-start below: it is only the lines that |
86470b361571
(change-log-mode): Remove incorrect "^" anchors from
Richard M. Stallman <rms@gnu.org>
parents:
13282
diff
changeset
|
375 ;; begin at column 0 (despite the left-margin of 8) that we are looking for. |
15909
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
376 (set (make-local-variable 'paragraph-start) "\\s *$\\|\f\\|^\\<") |
088510eef043
Change to ISO 8601 date formats, without time of day.
Erik Naggum <erik@naggum.no>
parents:
15889
diff
changeset
|
377 (set (make-local-variable 'paragraph-separate) "\\s *$\\|\f\\|^\\<") |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
378 ;; Let all entries for one day behave as one page. |
1078
15b4ed20e524
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
1062
diff
changeset
|
379 ;; 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
|
380 ;; 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
|
381 (set (make-local-variable 'page-delimiter) "^\\<\\|^\f") |
678 | 382 (set (make-local-variable 'version-control) 'never) |
383 (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
|
384 (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
|
385 '(change-log-font-lock-keywords t)) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
386 (run-hooks 'change-log-mode-hook)) |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
387 |
4157
d2316090d029
(prompt-for-change-log-name): Autoload this (for vc-comment-to-change-log).
Roland McGrath <roland@gnu.org>
parents:
4154
diff
changeset
|
388 ;; 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
|
389 ;; 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
|
390 ;; 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
|
391 ;; 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
|
392 (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
|
393 "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
|
394 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
|
395 (interactive "P") |
16505
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
396 (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
|
397 (beg (progn (backward-paragraph) (point))) |
13505
86470b361571
(change-log-mode): Remove incorrect "^" anchors from
Richard M. Stallman <rms@gnu.org>
parents:
13282
diff
changeset
|
398 (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
|
399 (fill-region beg end justify) |
39efcea11aad
(change-log-fill-paragraph): Return non-nil so
Richard M. Stallman <rms@gnu.org>
parents:
16450
diff
changeset
|
400 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
|
401 |
17413
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
402 (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
|
403 "^\\([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
|
404 "*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
|
405 :type 'regexp |
9fa0ed8da0b1
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16505
diff
changeset
|
406 :group 'change-log) |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
407 |
6562
0541a368505c
(add-log-current-defun): Autoload this.
Roland McGrath <roland@gnu.org>
parents:
6309
diff
changeset
|
408 ;;;###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
|
409 (defvar add-log-lisp-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
|
410 '(emacs-lisp-mode lisp-mode scheme-mode lisp-interaction-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
|
411 "*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
|
412 |
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
|
413 ;;;###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
|
414 (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
|
415 '(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
|
416 "*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
|
417 |
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
|
418 ;;;###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
|
419 (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
|
420 '(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
|
421 "*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
|
422 |
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
|
423 ;;;###autoload |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
424 (defun add-log-current-defun () |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
425 "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
|
426 |
3499
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
427 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
|
428 Texinfo (@node titles), Perl, and Fortran. |
666
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
429 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
430 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
|
431 point for uppercase headings starting in the first column or |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
432 identifiers followed by `:' or `=', see variable |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
433 `add-log-current-defun-header-regexp'. |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
434 |
7fa6b835da67
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
661
diff
changeset
|
435 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
|
436 (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
437 (save-excursion |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
438 (let ((location (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
|
439 (cond ((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
|
440 ;; 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
|
441 ;; 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
|
442 ;; rather than the previous one. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
443 (or (eobp) (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
444 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
445 ;; Make sure we are really inside the defun found, not after it. |
14528
09351147da04
(add-log-current-defun): In Lisp, if we don't find a
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
446 (if (and (looking-at "\\s(") |
09351147da04
(add-log-current-defun): In Lisp, if we don't find a
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
447 (progn (end-of-defun) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
448 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
449 (progn (forward-sexp -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
450 (>= location (point)))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
451 (progn |
3853
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
452 (if (looking-at "\\s(") |
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
453 (forward-char 1)) |
d771acf8f6ef
* add-log.el (add-log-current-defun): To find the name of the
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
454 (forward-sexp 1) |
13086
1bc6075184d7
(add-log-current-defun): Ignore quotes before fcn name.
Richard M. Stallman <rms@gnu.org>
parents:
12551
diff
changeset
|
455 (skip-chars-forward " '") |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
456 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
457 (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
|
458 ((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
|
459 (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
|
460 (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
|
461 ;; 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
|
462 ;; 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
|
463 ;; 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
|
464 (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
|
465 (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
|
466 (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
|
467 ;; Handle a C macro definition. |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
468 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
469 (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
|
470 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
471 (search-forward "define") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
472 (skip-chars-forward " \t") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
473 (buffer-substring (point) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
474 (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
|
475 ((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
|
476 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
477 ;; 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
|
478 ;; 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
|
479 (while (not (looking-at "{\\|\\(\\s *$\\)")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
480 (forward-line 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
481 (or (eobp) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
482 (forward-char 1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
483 (beginning-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
484 (if (progn (end-of-defun) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
485 (< location (point))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
486 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
487 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
488 (let (beg tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
489 |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
490 (forward-line -1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
491 ;; 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
|
492 (while (and (not (bobp)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
493 (looking-at "[ \t\n]")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
494 (forward-line -1)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
495 ;; 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
|
496 ;; 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
|
497 (if (condition-case nil |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
498 (and (save-excursion |
8313
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
499 (end-of-line) |
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
500 (while (= (preceding-char) ?\\) |
589abdc989e1
(add-log-current-defun): Skip doc string
Richard M. Stallman <rms@gnu.org>
parents:
8261
diff
changeset
|
501 (end-of-line 2)) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
502 (backward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
503 (beginning-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
504 (setq tem (point)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
505 (looking-at "DEFUN\\b")) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
506 (>= location tem)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
507 (error nil)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
508 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
509 (goto-char tem) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
510 (down-list 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
511 (if (= (char-after (point)) ?\") |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
512 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
513 (forward-sexp 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
514 (skip-chars-forward " ,"))) |
953 | 515 (buffer-substring (point) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
516 (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
|
517 (if (looking-at "^[+-]") |
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
518 (get-method-definition) |
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
519 ;; 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
|
520 (setq beg (point)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
521 (if (and (condition-case nil |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
522 ;; Protect against "Unbalanced parens" error. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
523 (progn |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
524 (down-list 1) ; into arglist |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
525 (backward-up-list 1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
526 (skip-chars-backward " \t") |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
527 t) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
528 (error nil)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
529 ;; Verify initial pos was after |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
530 ;; real start of function. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
531 (save-excursion |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
532 (goto-char beg) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
533 ;; For this purpose, include the line |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
534 ;; that has the decl keywords. This |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
535 ;; may also include some of the |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
536 ;; comments before the function. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
537 (while (and (not (bobp)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
538 (save-excursion |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
539 (forward-line -1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
540 (looking-at "[^\n\f]"))) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
541 (forward-line -1)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
542 (>= location (point))) |
11757
108646bbd84f
(add-log-current-defun): Handle objc-mode like c-mode;
Richard M. Stallman <rms@gnu.org>
parents:
11749
diff
changeset
|
543 ;; 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
|
544 ;; 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
|
545 (> (point) beg)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
546 (let (end middle) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
547 ;; Don't include any final newline |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
548 ;; in the name we use. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
549 (if (= (preceding-char) ?\n) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
550 (forward-char -1)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
551 (setq end (point)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
552 (backward-sexp 1) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
553 ;; 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
|
554 ;; Include certain keywords if they |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
555 ;; precede the name. |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
556 (setq middle (point)) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
557 (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
|
558 ;; 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
|
559 ;; 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
|
560 (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
|
561 (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
|
562 (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
|
563 (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
|
564 (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
|
565 (forward-word -1)) |
12551
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
566 (and (bolp) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
567 (looking-at "struct \\|union \\|class ") |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
568 (setq middle (point))) |
572a8ef6b1f4
(add-log-current-defun): Handle C struct definitions.
Karl Heuer <kwzh@gnu.org>
parents:
12157
diff
changeset
|
569 (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
|
570 ((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
|
571 (if (re-search-backward |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
572 "\\\\\\(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
|
573 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
574 (goto-char (match-beginning 0)) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
575 (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
|
576 (progn |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
577 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
578 (point)))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
579 ((eq major-mode 'texinfo-mode) |
9397
eba13d81ba0b
(add-log-current-defun): In texinfo-mode,
Richard M. Stallman <rms@gnu.org>
parents:
9377
diff
changeset
|
580 (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
|
581 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
582 (match-end 1)))) |
9347
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
583 ((eq major-mode 'perl-mode) |
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
584 (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
|
585 (buffer-substring (match-beginning 1) |
1a69634e3477
(add-log-current-defun): Handle Perl specially.
Richard M. Stallman <rms@gnu.org>
parents:
9008
diff
changeset
|
586 (match-end 1)))) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
587 ((eq major-mode 'fortran-mode) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
588 ;; must be inside function body for this to work |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
589 (beginning-of-fortran-subprogram) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
590 (let ((case-fold-search t)) ; case-insensitive |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
591 ;; search for fortran subprogram start |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
592 (if (re-search-forward |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
593 "^[ \t]*\\(program\\|subroutine\\|function\ |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
594 \\|[ \ta-z0-9*]*[ \t]+function\\)" |
3499
6428162f137c
(add-log-current-defun): Fix typos in last change.
Richard M. Stallman <rms@gnu.org>
parents:
3486
diff
changeset
|
595 nil t) |
3486
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
596 (progn |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
597 ;; move to EOL or before first left paren |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
598 (if (re-search-forward "[(\n]" nil t) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
599 (progn (forward-char -1) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
600 (skip-chars-backward " \t")) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
601 (end-of-line)) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
602 ;; Use the name preceding that. |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
603 (buffer-substring (point) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
604 (progn (forward-sexp -1) |
a4b23b25b671
(add-log-current-defun): Handle Fortran.
Richard M. Stallman <rms@gnu.org>
parents:
3261
diff
changeset
|
605 (point))))))) |
1447
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
606 (t |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
607 ;; If all else fails, try heuristics |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
608 (let (case-fold-search) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
609 (end-of-line) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
610 (if (re-search-backward add-log-current-defun-header-regexp |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
611 (- (point) 10000) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
612 t) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
613 (buffer-substring (match-beginning 1) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
614 (match-end 1)))))))) |
75fa9ad982a5
(add-log-current-defun): Add condition-case around
Richard M. Stallman <rms@gnu.org>
parents:
1369
diff
changeset
|
615 (error nil))) |
999 | 616 |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
617 (defvar get-method-definition-md) |
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
618 |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
619 ;; Subroutine used within get-method-definition. |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
620 ;; 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
|
621 ;; followed by the string END; move to the end of that match. |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
622 (defun get-method-definition-1 (end) |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
623 (setq get-method-definition-md |
19477
a9629283bc4c
(change-log-font-lock-keywords): Recognize "Patch by".
Richard M. Stallman <rms@gnu.org>
parents:
19439
diff
changeset
|
624 (concat get-method-definition-md |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
625 (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
|
626 end)) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
627 (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
|
628 |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
629 ;; For objective C, return the method name if we are in a method. |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
630 (defun get-method-definition () |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
631 (let ((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
|
632 (save-excursion |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
633 (if (re-search-backward "^@implementation\\s-*\\([A-Za-z_]*\\)" nil t) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
634 (get-method-definition-1 " "))) |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
635 (save-excursion |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
636 (cond |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
637 ((re-search-forward "^\\([-+]\\)[ \t\n\f\r]*\\(([^)]*)\\)?\\s-*" nil t) |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
638 (get-method-definition-1 "") |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
639 (while (not (looking-at "[{;]")) |
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
640 (looking-at |
11816
2a8e1b01bc15
(get-method-definition): Fix regexps.
Karl Heuer <kwzh@gnu.org>
parents:
11757
diff
changeset
|
641 "\\([A-Za-z_]*:?\\)\\s-*\\(([^)]*)\\)?[A-Za-z_]*[ \t\n\f\r]*") |
11749
8da04214faed
(get-method-definition, get-method-definition-1): New functions.
Richard M. Stallman <rms@gnu.org>
parents:
11517
diff
changeset
|
642 (get-method-definition-1 "")) |
13282
69fe836d7f02
(get-method-definition, get-method-definition-1):
Richard M. Stallman <rms@gnu.org>
parents:
13255
diff
changeset
|
643 (concat 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
|
644 |
999 | 645 |
980
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
646 (provide 'add-log) |
b62886fbf2a7
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
953
diff
changeset
|
647 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
678
diff
changeset
|
648 ;;; add-log.el ends here |