Mercurial > emacs
annotate lisp/emacs-lisp/copyright.el @ 55144:ab3d5c605cad
(ielm-prompt-read-only, ielm-prompt): Expand docstring.
(ielm): Only go to the end of the buffer when starting a new process.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Mon, 26 Apr 2004 02:41:40 +0000 |
parents | edbcb3c5d4e3 |
children | 22f1ac802ffd |
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 |
53499
837280979573
allow % and # as well as ; in copyright notice
Karl Berry <karl@gnu.org>
parents:
52401
diff
changeset
|
3 ;; Copyright (C) 1991, 92, 93, 94, 95, 1998, 2001, 2003, 2004 |
51564
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 | 5 |
23869 | 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 | 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 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
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. |
53504
f657faa17ea1
Fix comment to recommend
Simon Josefsson <jas@extundo.com>
parents:
53499
diff
changeset
|
30 ;; Do (add-hook 'before-save-hook 'copyright-update), or use |
f657faa17ea1
Fix comment to recommend
Simon Josefsson <jas@extundo.com>
parents:
53499
diff
changeset
|
31 ;; M-x customize-variable RET before-save-hook RET. |
288 | 32 |
773
9c89fd7ddd41
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
718
diff
changeset
|
33 ;;; Code: |
9c89fd7ddd41
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
718
diff
changeset
|
34 |
21328 | 35 (defgroup copyright nil |
36 "Update the copyright notice in current buffer." | |
37 :group 'tools) | |
38 | |
39 (defcustom copyright-limit 2000 | |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
40 "*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
|
41 A value of nil means to search whole buffer." |
21328 | 42 :group 'copyright |
43 :type '(choice (integer :tag "Limit") | |
44 (const :tag "No limit"))) | |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
45 |
52286 | 46 ;; The character classes have the Latin-1 version and the Latin-9 |
47 ;; version, which is probably enough. | |
21328 | 48 (defcustom copyright-regexp |
43169
717543e790e1
(copyright-regexp): Delete the unibyte copyright symbol; it's redundant.
Richard M. Stallman <rms@gnu.org>
parents:
42892
diff
changeset
|
49 "\\([]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\ |
717543e790e1
(copyright-regexp): Delete the unibyte copyright symbol; it's redundant.
Richard M. Stallman <rms@gnu.org>
parents:
42892
diff
changeset
|
50 \\|[Cc]opyright\\s *:?\\s *[]\\)\ |
53507 | 51 \\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
|
52 "*What your copyright notice looks like. |
21328 | 53 The second \\( \\) construct must match the years." |
54 :group 'copyright | |
55 :type 'regexp) | |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
56 |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
57 |
21328 | 58 (defcustom copyright-query 'function |
42732
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
59 "*If non-nil, ask user before changing copyright. |
21328 | 60 When this is `function', only ask when called non-interactively." |
61 :group 'copyright | |
62 :type '(choice (const :tag "Do not ask") | |
22580
a191ee97be00
(copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
21754
diff
changeset
|
63 (const :tag "Ask unless interactive" function) |
a191ee97be00
(copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents:
21754
diff
changeset
|
64 (other :tag "Ask" t))) |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
65 |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
66 |
14040 | 67 ;; 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
|
68 (defconst copyright-current-gpl-version "2" |
42732
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
69 "String representing the current version of the GPL or nil.") |
288 | 70 |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
71 (defvar copyright-update t) |
718 | 72 |
35129
9f38c893ea39
(copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents:
27329
diff
changeset
|
73 ;; 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
|
74 ;; change during the Emacs session. |
42732
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
75 (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
|
76 "String representing the current year.") |
9f38c893ea39
(copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents:
27329
diff
changeset
|
77 |
51564
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
78 (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
|
79 (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
|
80 ;; 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
|
81 (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
|
82 (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
|
83 (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
|
84 (if (or noquery |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
85 (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
|
86 (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
|
87 copyright-current-year "? ") |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
88 (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
|
89 " to copyright? ")))) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
90 (if replace |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
91 (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
|
92 (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
|
93 (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
|
94 (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
|
95 (+ (point) size) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
96 (point)))) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
97 100) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
98 1) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
99 (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
|
100 (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
|
101 ;; 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
|
102 (delete-char size) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
103 ;; 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
|
104 ;; (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
|
105 (if (and |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
106 ;; 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
|
107 (eq size -4) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
108 (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
|
109 (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
|
110 ;; 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
|
111 (save-excursion |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
112 (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
|
113 (line-beginning-position) t)) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
114 ;; 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
|
115 (save-excursion |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
116 (forward-char size) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
117 (re-search-backward |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
118 (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
|
119 "[0-9][0-9]") |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
120 (line-beginning-position) t))) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
121 ;; 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
|
122 (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
|
123 ;; 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
|
124 (insert |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
125 (save-excursion |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
126 (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
|
127 (line-beginning-position) t) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
128 (match-string 1) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
129 ", "))) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
130 ;; 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
|
131 (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
|
132 (insert ?'))) |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
133 ;; 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
|
134 (insert (substring copyright-current-year size)))))))) |
35129
9f38c893ea39
(copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents:
27329
diff
changeset
|
135 |
288 | 136 ;;;###autoload |
51564
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
137 (defun copyright-update (&optional arg interactivep) |
42732
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
138 "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
|
139 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
|
140 the current year after them. If necessary, and |
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
141 `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
|
142 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
|
143 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
|
144 interactively." |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
145 (interactive "*P\nd") |
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
146 (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
|
147 (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
|
148 (and (eq copyright-query 'function) interactivep)))) |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
149 (save-excursion |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
150 (save-restriction |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
151 (widen) |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
152 (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
|
153 (copyright-update-year arg noquery) |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
154 (goto-char (point-min)) |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
155 (and copyright-current-gpl-version |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
156 ;; 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
|
157 ;; 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
|
158 (re-search-forward "\\(the Free Software Foundation;\ |
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
159 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
|
160 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
|
161 (+ (point) copyright-limit) t) |
42732
7db08aae2e67
(copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents:
42533
diff
changeset
|
162 (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
|
163 (or noquery |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
164 (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
|
165 copyright-current-gpl-version "? "))) |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
166 (progn |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
167 (if (match-end 2) |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
168 ;; 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
|
169 (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
|
170 (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
|
171 (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
|
172 ;; 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
|
173 nil)) |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
174 |
581 | 175 |
176 ;;;###autoload | |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
177 (define-skeleton copyright |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
178 "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
|
179 "Company: " |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
180 comment-start |
35129
9f38c893ea39
(copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents:
27329
diff
changeset
|
181 "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
|
182 (or (getenv "ORGANIZATION") |
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
183 str) |
51564
09736ff1baa6
(copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
43169
diff
changeset
|
184 '(if (> (point) (+ (point-min) copyright-limit)) |
12503
f77164f5bc6b
New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents:
10510
diff
changeset
|
185 (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
|
186 comment-end \n) |
288 | 187 |
18383 | 188 (provide 'copyright) |
189 | |
27229 | 190 ;; For the copyright sign: |
191 ;; Local Variables: | |
192 ;; coding: emacs-mule | |
193 ;; End: | |
194 | |
52401 | 195 ;;; arch-tag: b4991afb-b6b1-4590-bebe-e076d9d4aee8 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
35129
diff
changeset
|
196 ;;; copyright.el ends here |