annotate lisp/emacs-lisp/copyright.el @ 89483:2f877ed80fa6

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Sep 2003 12:53:41 +0000
parents 375f2633d815 ef4c8f452558
children 68c22ea6027c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
1 ;;; copyright.el --- update the copyright notice in current buffer
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 611
diff changeset
2
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
3 ;; Copyright (C) 1991, 92, 93, 94, 95, 1998, 2001, 2003
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
4 ;; Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
5
23869
8d2bb5d1416a Update comment.
Karl Heuer <kwzh@gnu.org>
parents: 22580
diff changeset
6 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
7 ;; Keywords: maint, tools
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
8
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
9 ;; This file is part of GNU Emacs.
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 718
diff changeset
10
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
14 ;; any later version.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
15
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
19 ;; GNU General Public License for more details.
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
20
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14040
diff changeset
24 ;; Boston, MA 02111-1307, USA.
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
25
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
26 ;;; Commentary:
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
27
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
28 ;; Allows updating the copyright year and above mentioned GPL version manually
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
29 ;; or when saving a file.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
30 ;; Do (add-hook 'write-file-functions 'copyright-update).
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
31
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 718
diff changeset
32 ;;; Code:
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 718
diff changeset
33
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
34 (defgroup copyright nil
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
35 "Update the copyright notice in current buffer."
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
36 :group 'tools)
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
37
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
38 (defcustom copyright-limit 2000
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
39 "*Don't try to update copyright beyond this position unless interactive.
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
40 A value of nil means to search whole buffer."
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
41 :group 'copyright
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
42 :type '(choice (integer :tag "Limit")
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
43 (const :tag "No limit")))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
44
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
45 (defcustom copyright-regexp
89483
2f877ed80fa6 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 88123 88916
diff changeset
46 "\\(©\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\
88916
ef4c8f452558 (copyright-regexp): Remove redundancy.
Dave Love <fx@gnu.org>
parents: 43169
diff changeset
47 \\|[Cc]opyright\\s *:?\\s *©\\)\
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
48 \\s *\\([1-9]\\([-0-9, ';\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
49 "*What your copyright notice looks like.
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
50 The second \\( \\) construct must match the years."
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
51 :group 'copyright
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
52 :type 'regexp)
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
53
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
54
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
55 (defcustom copyright-query 'function
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
56 "*If non-nil, ask user before changing copyright.
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
57 When this is `function', only ask when called non-interactively."
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
58 :group 'copyright
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
59 :type '(choice (const :tag "Do not ask")
22580
a191ee97be00 (copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents: 21754
diff changeset
60 (const :tag "Ask unless interactive" function)
a191ee97be00 (copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents: 21754
diff changeset
61 (other :tag "Ask" t)))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
62
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
63
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13684
diff changeset
64 ;; when modifying this, also modify the comment generated by autoinsert.el
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
65 (defconst copyright-current-gpl-version "2"
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
66 "String representing the current version of the GPL or nil.")
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
67
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
68 (defvar copyright-update t)
718
2011f5e67975 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 657
diff changeset
69
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
70 ;; This is a defvar rather than a defconst, because the year can
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
71 ;; change during the Emacs session.
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
72 (defvar copyright-current-year (substring (current-time-string) -4)
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
73 "String representing the current year.")
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
74
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
75 (defun copyright-update-year (replace noquery)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
76 (when (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
77 ;; Note that `current-time-string' isn't locale-sensitive.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
78 (setq copyright-current-year (substring (current-time-string) -4))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
79 (unless (string= (buffer-substring (- (match-end 2) 2) (match-end 2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
80 (substring copyright-current-year -2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
81 (if (or noquery
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
82 (y-or-n-p (if replace
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
83 (concat "Replace copyright year(s) by "
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
84 copyright-current-year "? ")
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
85 (concat "Add " copyright-current-year
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
86 " to copyright? "))))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
87 (if replace
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
88 (replace-match copyright-current-year t t nil 1)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
89 (let ((size (save-excursion (skip-chars-backward "0-9"))))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
90 (if (and (eq (% (- (string-to-number copyright-current-year)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
91 (string-to-number (buffer-substring
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
92 (+ (point) size)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
93 (point))))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
94 100)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
95 1)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
96 (or (eq (char-after (+ (point) size -1)) ?-)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
97 (eq (char-after (+ (point) size -2)) ?-)))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
98 ;; This is a range so just replace the end part.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
99 (delete-char size)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
100 ;; Detect if this is using the following shorthand:
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
101 ;; (C) 1993, 94, 95, 1998, 2000, 01, 02, 2003
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
102 (if (and
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
103 ;; Check that the last year was 4-chars and same century.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
104 (eq size -4)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
105 (equal (buffer-substring (- (point) 4) (- (point) 2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
106 (substring copyright-current-year 0 2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
107 ;; Check that there are 2-char years as well.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
108 (save-excursion
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
109 (re-search-backward "[^0-9][0-9][0-9][^0-9]"
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
110 (line-beginning-position) t))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
111 ;; Make sure we don't remove the first century marker.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
112 (save-excursion
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
113 (forward-char size)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
114 (re-search-backward
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
115 (concat (buffer-substring (point) (+ (point) 2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
116 "[0-9][0-9]")
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
117 (line-beginning-position) t)))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
118 ;; Remove the century marker of the last entry.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
119 (delete-region (- (point) 4) (- (point) 2)))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
120 ;; Insert a comma with the preferred number of spaces.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
121 (insert
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
122 (save-excursion
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
123 (if (re-search-backward "[0-9]\\( *, *\\)[0-9]"
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
124 (line-beginning-position) t)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
125 (match-string 1)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
126 ", ")))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
127 ;; If people use the '91 '92 '93 scheme, do that as well.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
128 (if (eq (char-after (+ (point) size -3)) ?')
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
129 (insert ?')))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
130 ;; Finally insert the new year.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
131 (insert (substring copyright-current-year size))))))))
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
132
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
133 ;;;###autoload
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
134 (defun copyright-update (&optional arg interactivep)
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
135 "Update copyright notice at beginning of buffer to indicate the current year.
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
136 With prefix ARG, replace the years in the notice rather than adding
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
137 the current year after them. If necessary, and
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
138 `copyright-current-gpl-version' is set, any copying permissions
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
139 following the copyright are updated as well.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
140 If non-nil, INTERACTIVEP tells the function to behave as when it's called
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
141 interactively."
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
142 (interactive "*P\nd")
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
143 (when (or copyright-update interactivep)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
144 (let ((noquery (or (not copyright-query)
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
145 (and (eq copyright-query 'function) interactivep))))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
146 (save-excursion
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
147 (save-restriction
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
148 (widen)
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
149 (goto-char (point-min))
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
150 (copyright-update-year arg noquery)
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
151 (goto-char (point-min))
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
152 (and copyright-current-gpl-version
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
153 ;; match the GPL version comment in .el files, including the
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
154 ;; bilingual Esperanto one in two-column, and in texinfo.tex
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
155 (re-search-forward "\\(the Free Software Foundation;\
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
156 either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
157 version \\([0-9]+\\), or (at"
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
158 (+ (point) copyright-limit) t)
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
159 (not (string= (match-string 3) copyright-current-gpl-version))
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
160 (or noquery
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
161 (y-or-n-p (concat "Replace GPL version by "
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
162 copyright-current-gpl-version "? ")))
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
163 (progn
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
164 (if (match-end 2)
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
165 ;; Esperanto bilingual comment in two-column.el
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
166 (replace-match copyright-current-gpl-version t t nil 2))
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
167 (replace-match copyright-current-gpl-version t t nil 3))))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
168 (set (make-local-variable 'copyright-update) nil)))
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
169 ;; If a write-file-hook returns non-nil, the file is presumed to be written.
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
170 nil))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
171
581
e7dd969ff98b *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 291
diff changeset
172
e7dd969ff98b *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 291
diff changeset
173 ;;;###autoload
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
174 (define-skeleton copyright
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
175 "Insert a copyright by $ORGANIZATION notice at cursor."
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
176 "Company: "
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
177 comment-start
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
178 "Copyright (C) " `(substring (current-time-string) -4) " by "
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
179 (or (getenv "ORGANIZATION")
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
180 str)
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
181 '(if (> (point) (+ (point-min) copyright-limit))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
182 (message "Copyright extends beyond `copyright-limit' and won't be updated automatically."))
39764
fb28cd06b2f6 (copyright): Add final \n.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38436
diff changeset
183 comment-end \n)
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
184
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
185 (provide 'copyright)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
186
27229
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
187 ;; For the copyright sign:
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
188 ;; Local Variables:
88916
ef4c8f452558 (copyright-regexp): Remove redundancy.
Dave Love <fx@gnu.org>
parents: 43169
diff changeset
189 ;; coding: utf-8
27229
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
190 ;; End:
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
191
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 35129
diff changeset
192 ;;; copyright.el ends here