annotate lisp/packages/upd-copyr.el @ 24:4103f0995bd7 r19-15b95

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