annotate lisp/packages/upd-copyr.el @ 119:d101af7320b8

Added tag r20-1b11 for changeset 7d55a9ba150c
author cvs
date Mon, 13 Aug 2007 09:24:19 +0200
parents 131b0175ea99
children 34a5b81f86ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; upd-copyr.el --- update the copyright notice in a GNU Emacs Lisp file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; Copyright (C) 1994, 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Roland McGrath <roland@gnu.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; hacked on by Jamie Zawinski.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; hacked upon by Jonathan Stigelman <Stig@hackvan.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; Keywords: maint
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 0
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; Synched up with: Not synched with FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Apparently mly synched this file with the version of upd-copyr.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; supplied with FSF 19.22 or 19.23. Since then, FSF renamed the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;; file to copyright.el and basically rewrote it, and Stig and Jamie
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; basically rewrote it, so there's not much in common any more.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; #### - this will break if you dump it into emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defconst copyright-year (substring (current-time-string) -4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "String representing the current year.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar copyright-do-not-disturb "Free Software Foundation, Inc."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "*If non-nil, the existing copyright holder is checked against this regexp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 If it does not match, then a new copyright line is added with the copyright
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 holder set to the value of `copyright-whoami'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar copyright-whoami nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 "*A string containing the name of the owner of new copyright notices.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defvar copyright-notice-file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "*If non-nil, replace copying notices with this file.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar copyright-files-to-ignore-regex "loaddefs.el$"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 "*Regular expression for files that should be ignored")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defvar current-gpl-version "2"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 "String representing the current version of the GPL.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defvar copyright-inhibit-update nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 "If nil, ask the user whether or not to update the copyright notice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 If the user has said no, we set this to t locally.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvar copyright-search-limit 2048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "Portion of file to search for copyright notices")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (defun update-copyright (&optional replace ask-upd ask-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 "Update the copyright notice at the beginning of the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 to indicate the current year. If optional arg REPLACE is given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 \(interactively, with prefix arg\) replace the years in the notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 rather than adding the current year after them.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 If `copyright-notice-file' is set, the copying permissions following the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 copyright are replaced as well.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 If optional third argument ASK is non-nil, the user is prompted for whether
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 or not to update the copyright. If optional fourth argument ASK-YEAR is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 non-nil, the user is prompted for whether or not to replace the year rather
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 than adding to it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (interactive "*P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (or (and ask-upd copyright-inhibit-update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (and buffer-file-truename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (string-match copyright-files-to-ignore-regex buffer-file-truename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (narrow-to-region (point-min)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (min copyright-search-limit (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Handle abbreviated year lists like "1800, 01, 02, 03"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; or "1900, '01, '02, '03".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 p-string holder add-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 mine current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 cw-current cw-mine last-cw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (cw-position '(lambda ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (cond (cw-mine (goto-char cw-mine))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ((or (and last-cw (goto-char last-cw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "copyright[^0-9\n]*\\([-, \t]*\\([0-9]+\\)\\)+"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (and add-new (beginning-of-line 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (t (goto-char (point-min)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; scan for all copyrights
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (while (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (concat "^\\(.*\\)copyright.*\\(" (substring copyright-year 0 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "\\)?" "\\([0-9][0-9]\\(, \t\\)+\\)*'?"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 "\\(\\(" (substring copyright-year 2) "\\)\\|[0-9][0-9]\\)\\s *\\(\\S .*\\)$")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (buffer-substring (match-beginning 0) (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (setq p-string (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 last-cw (match-end 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 holder (buffer-substring (match-beginning 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (match-end 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 current (match-beginning 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 mine (string-match copyright-do-not-disturb holder)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 cw-current (if mine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (or cw-current current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 cw-mine (or cw-mine (and mine last-cw))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; ok, now decide if a new copyright is needed...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (setq add-new (not cw-mine))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (or ask-upd add-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (message "Copyright notice already includes %s." copyright-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (cond ((and cw-current cw-mine)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (or ask-upd (message "The copyright is up to date"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (copyright-check-notice))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ((and (or add-new (not cw-current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; #### - doesn't bother to ask about non-GPL sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (or (not ask-upd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (search-forward "is free software" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (goto-char (point-min))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; adding a new copyright or one exists already...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (or add-new last-cw)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; adding a new copyright or the user wants to update...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (or (not ask-upd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (pop-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; Show user the copyright.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (funcall cw-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (or (y-or-n-p "Update copyright? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (set (make-local-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 'copyright-inhibit-update) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; The "XEmacs change" below effectively disabled this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; already, so I'm gonna comment it out entirely... --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; (setq replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; (or replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; (and ask-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;; (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; (pop-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; ;; Show the user the copyright.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; ;;XEmacs change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; ;; (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; ;; (y-or-n-p "Replace copyright year? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (cond (add-new
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; the cursor should already be at the beginning of a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; line here...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (funcall cw-position)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq holder (or copyright-whoami
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (read-string "New copyright holder: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if p-string (insert p-string) (indent-for-comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (insert "Copyright (C) ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (insert " " holder "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (replace
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; #### - check this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (re-search-forward "copyright\\([^0-9]*\\([-, \t]*\\([0-9]+\\)\\)+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (save-excursion (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (delete-region (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (t (insert ", ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; This did the wrong thing: "1990-1992" -> "1990, 1992"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; Perhaps "1990, 1991, 1992" would be an appropriate
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; substitution, but "1990-1992" is satisfactory. --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; XEmacs addition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; (if (looking-at "[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; (progn (forward-char 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; (insert ", "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (insert copyright-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;; XEmacs addition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; #### - this assumes lisp and shouldn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (if (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (>= (current-column) fill-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (if (= (char-syntax ?\;) ?<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (insert "\n;;;")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (insert "\n ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (message "Copyright updated to %s%s."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if replace "" "include ") copyright-year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (copyright-check-notice)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; show the newly-munged copyright.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (message "The copyright has been updated")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (sit-for 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ((not ask-upd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (error "This buffer does not contain a copyright notice!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun copyright-check-notice ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (if copyright-notice-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (let (beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; Find the beginning of the copyright.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (if (search-forward "copyright" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; Look for a blank line or a line with only comment chars.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (re-search-forward "^\\(\\s \\s<\\|\\s>\\)*$" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (princ (substitute-command-keys "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 I don't know where the copying notice begins.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 Put point there and hit \\[exit-recursive-edit]."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (setq beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (or (search-forward "02139, USA." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (with-output-to-temp-buffer "*Help*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (princ (substitute-command-keys "\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 I don't know where the copying notice ends.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 Put point there and hit \\[exit-recursive-edit]."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (delete-region beg (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (insert-file copyright-notice-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 "; either version \\(.+\\), or (at your option)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (goto-char (match-beginning 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (delete-region (point) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (insert current-gpl-version)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun ask-to-update-copyright ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "If the current buffer contains a copyright notice that is out of date,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ask the user if it should be updated with `update-copyright' (which see).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 Put this on write-file-hooks."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (update-copyright nil t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; Be sure return nil; if a write-file-hook return non-nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; the file is presumed to be already written.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (provide 'upd-copyr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;;; upd-copyr.el ends here