annotate lisp/emacs-lisp/copyright.el @ 112453:06719a229a46 default tip

* calc/calc.el (calc-default-power-reference-level) (calc-default-field-reference-level): New variables. * calc/calc-units.el (math-standard-units): Add dB and Np. (math-logunits): New variable. (math-extract-logunits, math-logcombine, calcFunc-luplus) (calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level) (calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New functions. (math-find-base-units-rec): Add entry for ln(10). * calc/calc-help.el (calc-u-prefix-help): Add logarithmic help. (calc-ul-prefix-help): New function. * calc/calc-ext.el (calc-init-extensions): Autoload new units functions. Add keybindings for new units functions.
author Jay Belanger <jay.p.belanger@gmail.com>
date Sun, 23 Jan 2011 23:08:04 -0600
parents 7a578da192b9
children
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
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2002, 2003,
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
5 ;; Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
6
23869
8d2bb5d1416a Update comment.
Karl Heuer <kwzh@gnu.org>
parents: 22580
diff changeset
7 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
8 ;; Keywords: maint, tools
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
9
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
10 ;; This file is part of GNU Emacs.
773
9c89fd7ddd41 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 718
diff changeset
11
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94224
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94224
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94224
diff changeset
15 ;; (at your option) any later version.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
16
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
17 ;; 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
18 ;; 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
19 ;; 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
20 ;; GNU General Public License for more details.
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
21
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
22 ;; You should have received a copy of the GNU General Public License
94655
90a2847062be Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94224
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
24
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
25 ;;; Commentary:
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
26
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
27 ;; 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
28 ;; or when saving a file.
53504
f657faa17ea1 Fix comment to recommend
Simon Josefsson <jas@extundo.com>
parents: 53499
diff changeset
29 ;; Do (add-hook 'before-save-hook 'copyright-update), or use
f657faa17ea1 Fix comment to recommend
Simon Josefsson <jas@extundo.com>
parents: 53499
diff changeset
30 ;; M-x customize-variable RET before-save-hook RET.
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
78358
9b7f2e8baaeb (copyright-update-year, copyright-update, copyright-fix-years, copyright):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78217
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
94224
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
45 (defcustom copyright-at-end-flag nil
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
46 "Non-nil means to search backwards from the end of the buffer for copyright.
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
47 This is useful for ChangeLogs."
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
48 :group 'copyright
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
49 :type 'boolean
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
50 :version "23.1")
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
51
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
52 (defcustom copyright-regexp
90998
539530fa389c Merge from emacs--devo--0
Miles Bader <miles@gnu.org>
parents: 90996 82221
diff changeset
53 "\\(©\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\
88916
ef4c8f452558 (copyright-regexp): Remove redundancy.
Dave Love <fx@gnu.org>
parents: 43169
diff changeset
54 \\|[Cc]opyright\\s *:?\\s *©\\)\
102068
e22cfe7e0065 Tweak copyright-regexp
Miles Bader <miles@gnu.org>
parents: 102066
diff changeset
55 \\s *\\(?:[^0-9\n]*\\s *\\)?\
e22cfe7e0065 Tweak copyright-regexp
Miles Bader <miles@gnu.org>
parents: 102066
diff changeset
56 \\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
78358
9b7f2e8baaeb (copyright-update-year, copyright-update, copyright-fix-years, copyright):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78217
diff changeset
57 "What your copyright notice looks like.
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
58 The second \\( \\) construct must match the years."
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
59 :group 'copyright
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
60 :type 'regexp)
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
61
81079
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
62 (defcustom copyright-names-regexp ""
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
63 "Regexp matching the names which correspond to the user.
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
64 Only copyright lines where the name matches this regexp will be updated.
84511
729600607616 (copyright-names-regexp): Doc fix: typo.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 82449
diff changeset
65 This allows you to avoid adding years to a copyright notice belonging to
81079
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
66 someone else or to a group for which you do not work."
82408
50d1581f2548 (copyright-names-regexp): Add custom group.
Richard M. Stallman <rms@gnu.org>
parents: 82221
diff changeset
67 :group 'copyright
81079
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
68 :type 'regexp)
506d3398a966 (copyright-names-regexp): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 75346
diff changeset
69
56685
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
70 (defcustom copyright-years-regexp
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
71 "\\(\\s *\\)\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
78358
9b7f2e8baaeb (copyright-update-year, copyright-update, copyright-fix-years, copyright):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78217
diff changeset
72 "Match additional copyright notice years.
56685
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
73 The second \\( \\) construct must match the years."
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
74 :group 'copyright
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
75 :type 'regexp)
22f1ac802ffd (copyright-years-regexp): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 53507
diff changeset
76
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
77
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
78 (defcustom copyright-query 'function
78358
9b7f2e8baaeb (copyright-update-year, copyright-update, copyright-fix-years, copyright):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 78217
diff changeset
79 "If non-nil, ask user before changing copyright.
21328
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
80 When this is `function', only ask when called non-interactively."
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
81 :group 'copyright
d5ffccfcea21 Customized.
Andreas Schwab <schwab@suse.de>
parents: 19108
diff changeset
82 :type '(choice (const :tag "Do not ask")
22580
a191ee97be00 (copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents: 21754
diff changeset
83 (const :tag "Ask unless interactive" function)
a191ee97be00 (copyright-query): Use `other' widget
Andreas Schwab <schwab@suse.de>
parents: 21754
diff changeset
84 (other :tag "Ask" t)))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
85
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
86
14040
187735b53d52 Comment fixes.
Karl Heuer <kwzh@gnu.org>
parents: 13684
diff changeset
87 ;; when modifying this, also modify the comment generated by autoinsert.el
78100
4535acabc388 (copyright-current-gpl-version): Set to 3.
Nick Roberts <nickrob@snap.net.nz>
parents: 75346
diff changeset
88 (defconst copyright-current-gpl-version "3"
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
89 "String representing the current version of the GPL or nil.")
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
90
101116
cdcfed3dd3f9 (copyright-update): Add doc-string.
Glenn Morris <rgm@gnu.org>
parents: 100869
diff changeset
91 (defvar copyright-update t
cdcfed3dd3f9 (copyright-update): Add doc-string.
Glenn Morris <rgm@gnu.org>
parents: 100869
diff changeset
92 "The function `copyright-update' sets this to nil after updating a buffer.")
718
2011f5e67975 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 657
diff changeset
93
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
94 ;; 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
95 ;; change during the Emacs session.
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
96 (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
97 "String representing the current year.")
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
98
82447
7206375cd8a6 (copyright-limit): New defsubst.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 82445
diff changeset
99 (defsubst copyright-limit () ; re-search-forward BOUND
94224
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
100 (and copyright-limit
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
101 (if copyright-at-end-flag
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
102 (- (point) copyright-limit)
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
103 (+ (point) copyright-limit))))
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
104
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
105 (defun copyright-re-search (regexp &optional bound noerror count)
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
106 "Re-search forward or backward depending on `copyright-at-end-flag'."
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
107 (if copyright-at-end-flag
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
108 (re-search-backward regexp bound noerror count)
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
109 (re-search-forward regexp bound noerror count)))
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
110
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
111 (defun copyright-start-point ()
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
112 "Return point-min or point-max, depending on `copyright-at-end-flag'."
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
113 (if copyright-at-end-flag
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
114 (point-max)
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
115 (point-min)))
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
116
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
117 (defun copyright-offset-too-large-p ()
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
118 "Return non-nil if point is too far from the edge of the buffer."
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
119 (when copyright-limit
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
120 (if copyright-at-end-flag
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
121 (< (point) (- (point-max) copyright-limit))
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
122 (> (point) (+ (point-min) copyright-limit)))))
82447
7206375cd8a6 (copyright-limit): New defsubst.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 82445
diff changeset
123
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
124 (defun copyright-find-copyright ()
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
125 "Return non-nil if a copyright header suitable for updating is found.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
126 The header must match `copyright-regexp' and `copyright-names-regexp', if set.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
127 This function sets the match-data that `copyright-update-year' uses."
112431
7a578da192b9 Tweak previous copyright.el change.
Glenn Morris <rgm@gnu.org>
parents: 112430
diff changeset
128 (widen)
7a578da192b9 Tweak previous copyright.el change.
Glenn Morris <rgm@gnu.org>
parents: 112430
diff changeset
129 (goto-char (copyright-start-point))
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
130 (condition-case err
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
131 ;; (1) Need the extra \\( \\) around copyright-regexp because we
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
132 ;; goto (match-end 1) below. See note (2) below.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
133 (copyright-re-search (concat "\\(" copyright-regexp
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
134 "\\)\\([ \t]*\n\\)?.*\\(?:"
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
135 copyright-names-regexp "\\)")
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
136 (copyright-limit)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
137 t)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
138 ;; In case the regexp is rejected. This is useful because
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
139 ;; copyright-update is typically called from before-save-hook where
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
140 ;; such an error is very inconvenient for the user.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
141 (error (message "Can't update copyright: %s" err) nil)))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
142
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
143 (defun copyright-update-year (replace noquery)
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
144 ;; This uses the match-data from copyright-find-copyright.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
145 (goto-char (match-end 1))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
146 ;; If the years are continued onto multiple lines
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
147 ;; that are marked as comments, skip to the end of the years anyway.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
148 (while (save-excursion
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
149 (and (eq (following-char) ?,)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
150 (progn (forward-char 1) t)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
151 (progn (skip-chars-forward " \t") (eolp))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
152 comment-start-skip
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
153 (save-match-data
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
154 (forward-line 1)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
155 (and (looking-at comment-start-skip)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
156 (goto-char (match-end 0))))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
157 (looking-at-p copyright-years-regexp)))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
158 (forward-line 1)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
159 (re-search-forward comment-start-skip)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
160 ;; (2) Need the extra \\( \\) so that the years are subexp 3, as
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
161 ;; they are at note (1) above.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
162 (re-search-forward (format "\\(%s\\)" copyright-years-regexp)))
56706
15d087a81874 (copyright-update-year): Delete code that replaces 20xy with xy.
Luc Teirlinck <teirllm@auburn.edu>
parents: 56685
diff changeset
163
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
164 ;; Note that `current-time-string' isn't locale-sensitive.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
165 (setq copyright-current-year (substring (current-time-string) -4))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
166 (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
167 (substring copyright-current-year -2))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
168 (if (or noquery
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
169 (save-window-excursion
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
170 (switch-to-buffer (current-buffer))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
171 ;; Fixes some point-moving oddness (bug#2209).
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
172 (save-excursion
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
173 (y-or-n-p (if replace
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
174 (concat "Replace copyright year(s) by "
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
175 copyright-current-year "? ")
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
176 (concat "Add " copyright-current-year
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
177 " to copyright? "))))))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
178 (if replace
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
179 (replace-match copyright-current-year t t nil 3)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
180 (let ((size (save-excursion (skip-chars-backward "0-9"))))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
181 (if (and (eq (% (- (string-to-number copyright-current-year)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
182 (string-to-number (buffer-substring
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
183 (+ (point) size)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
184 (point))))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
185 100)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
186 1)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
187 (or (eq (char-after (+ (point) size -1)) ?-)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
188 (eq (char-after (+ (point) size -2)) ?-)))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
189 ;; This is a range so just replace the end part.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
190 (delete-char size)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
191 ;; Insert a comma with the preferred number of spaces.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
192 (insert
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
193 (save-excursion
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
194 (if (re-search-backward "[0-9]\\( *, *\\)[0-9]"
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
195 (line-beginning-position) t)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
196 (match-string 1)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
197 ", ")))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
198 ;; If people use the '91 '92 '93 scheme, do that as well.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
199 (if (eq (char-after (+ (point) size -3)) ?')
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
200 (insert ?')))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
201 ;; Finally insert the new year.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
202 (insert (substring copyright-current-year size)))))))
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
203
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
204 ;;;###autoload
51564
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
205 (defun copyright-update (&optional arg interactivep)
101224
9346c2b4e4eb (copyright-update): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 101116
diff changeset
206 "Update copyright notice to indicate the current year.
42732
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
207 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
208 the current year after them. If necessary, and
7db08aae2e67 (copyright-regexp): Make (C) optional.
Richard M. Stallman <rms@gnu.org>
parents: 42533
diff changeset
209 `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
210 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
211 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
212 interactively."
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
213 (interactive "*P\nd")
09736ff1baa6 (copyright-update-year): New function extracted from copyright-update.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43169
diff changeset
214 (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
215 (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
216 (and (eq copyright-query 'function) interactivep))))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
217 (save-excursion
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
218 (save-restriction
112429
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
219 ;; If names-regexp doesn't match, we should not mess with
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
220 ;; the years _or_ the GPL version.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
221 (when (copyright-find-copyright)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
222 (copyright-update-year arg noquery)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
223 (goto-char (copyright-start-point))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
224 (and copyright-current-gpl-version
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
225 ;; Match the GPL version comment in .el files.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
226 ;; This is sensitive to line-breaks. :(
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
227 (copyright-re-search
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
228 "the Free Software Foundation[,;\n].*either version \
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
229 \\([0-9]+\\)\\(?: of the License\\)?, or[ \n].*any later version"
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
230 (copyright-limit) t)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
231 ;; Don't update if the file is already using a more recent
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
232 ;; version than the "current" one.
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
233 (< (string-to-number (match-string 1))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
234 (string-to-number copyright-current-gpl-version))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
235 (or noquery
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
236 (save-match-data
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
237 (goto-char (match-end 1))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
238 (save-window-excursion
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
239 (switch-to-buffer (current-buffer))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
240 (y-or-n-p
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
241 (format "Replace GPL version %s with version %s? "
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
242 (match-string-no-properties 1)
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
243 copyright-current-gpl-version)))))
6e50030da731 Some copyright.el updates.
Glenn Morris <rgm@gnu.org>
parents: 112278
diff changeset
244 (replace-match copyright-current-gpl-version t t nil 1))))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
245 (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
246 ;; 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
247 nil))
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
248
581
e7dd969ff98b *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 291
diff changeset
249
101116
cdcfed3dd3f9 (copyright-update): Add doc-string.
Glenn Morris <rgm@gnu.org>
parents: 100869
diff changeset
250 ;; FIXME should be within 50 years of present (cf calendar).
581
e7dd969ff98b *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 291
diff changeset
251 ;;;###autoload
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
252 (defun copyright-fix-years ()
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
253 "Convert 2 digit years to 4 digit years.
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
254 Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
255 (interactive)
112430
78c4c9559156 * lisp/emacs-lisp/copyright.el (copyright-fix-years): Use copyright-find-copyright.
Glenn Morris <rgm@gnu.org>
parents: 112429
diff changeset
256 (if (copyright-find-copyright)
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
257 (let ((s (match-beginning 2))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
258 (e (copy-marker (1+ (match-end 2))))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
259 (p (make-marker))
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
260 last)
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
261 (goto-char s)
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
262 (while (re-search-forward "[0-9]+" e t)
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
263 (set-marker p (point))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
264 (goto-char (match-beginning 0))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
265 (let ((sep (char-before))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
266 (year (string-to-number (match-string 0))))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
267 (when (and sep
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
268 (/= (char-syntax sep) ?\s)
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
269 (/= sep ?-))
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
270 (insert " "))
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
271 (when (< year 100)
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
272 (insert (if (>= year 50) "19" "20"))))
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
273 (goto-char p)
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
274 (setq last p))
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
275 (when last
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
276 (goto-char last)
62375
6a8938e81aa7 (copyright-fix-years): Match properly if the first year is 2-digit.
Richard M. Stallman <rms@gnu.org>
parents: 61330
diff changeset
277 ;; Don't mess up whitespace after the years.
6a8938e81aa7 (copyright-fix-years): Match properly if the first year is 2-digit.
Richard M. Stallman <rms@gnu.org>
parents: 61330
diff changeset
278 (skip-chars-backward " \t")
6a8938e81aa7 (copyright-fix-years): Match properly if the first year is 2-digit.
Richard M. Stallman <rms@gnu.org>
parents: 61330
diff changeset
279 (save-restriction
94224
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
280 (narrow-to-region (copyright-start-point) (point))
62375
6a8938e81aa7 (copyright-fix-years): Match properly if the first year is 2-digit.
Richard M. Stallman <rms@gnu.org>
parents: 61330
diff changeset
281 (let ((fill-prefix " "))
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
282 (fill-region s last))))
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
283 (set-marker e nil)
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
284 (set-marker p nil)
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
285 (copyright-update nil t))
62508
39dc00cd1f8a (copyright-fix-years): Make sure all years are fixed. Don't insert a
Lute Kamstra <lute@gnu.org>
parents: 62375
diff changeset
286 (message "No copyright message")))
60319
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
287
68fb18eab7a7 (copyright-fix-years): New command.
Kim F. Storm <storm@cua.dk>
parents: 56706
diff changeset
288 ;;;###autoload
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
289 (define-skeleton copyright
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
290 "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
291 "Company: "
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
292 comment-start
35129
9f38c893ea39 (copyright-current-year): Now a defvar.
Eli Zaretskii <eliz@gnu.org>
parents: 27329
diff changeset
293 "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
294 (or (getenv "ORGANIZATION")
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
295 str)
94224
6743069007ec (copyright-at-end-flag): New option.
Glenn Morris <rgm@gnu.org>
parents: 94043
diff changeset
296 '(if (copyright-offset-too-large-p)
12503
f77164f5bc6b New name for generalized upd-copyr.el
Karl Heuer <kwzh@gnu.org>
parents: 10510
diff changeset
297 (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
298 comment-end \n)
288
5c0f837c0287 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
299
100869
3d95444199e1 (copyright-update-directory): Autoload.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 94655
diff changeset
300 ;;;###autoload
94043
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
301 (defun copyright-update-directory (directory match)
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
302 "Update copyright notice for all files in DIRECTORY matching MATCH."
100869
3d95444199e1 (copyright-update-directory): Autoload.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 94655
diff changeset
303 (interactive "DDirectory: \nMFilenames matching (regexp): ")
94043
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
304 (dolist (file (directory-files directory t match nil))
100869
3d95444199e1 (copyright-update-directory): Autoload.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 94655
diff changeset
305 (message "Updating file `%s'" file)
94043
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
306 (find-file file)
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
307 (let ((copyright-query nil))
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
308 (copyright-update))
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
309 (save-buffer)
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
310 (kill-buffer (current-buffer))))
3901934685f5 (copyright-update-directory): New command.
Reiner Steib <Reiner.Steib@gmx.de>
parents: 93852
diff changeset
311
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
312 (provide 'copyright)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
313
27229
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
314 ;; For the copyright sign:
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
315 ;; Local Variables:
88916
ef4c8f452558 (copyright-regexp): Remove redundancy.
Dave Love <fx@gnu.org>
parents: 43169
diff changeset
316 ;; coding: utf-8
27229
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
317 ;; End:
fdaa887d0f8f Tag as emacs-mule coding.
Dave Love <fx@gnu.org>
parents: 23869
diff changeset
318
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 35129
diff changeset
319 ;;; copyright.el ends here