/[emacs]/emacs/lisp/emacs-lisp/copyright.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/copyright.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37 by rms, Fri Jan 4 20:21:31 2002 UTC revision 1.38 by rms, Sun Jan 13 20:17:06 2002 UTC
# Line 1  Line 1 
1  ;;; copyright.el --- update the copyright notice in current buffer  ;;; copyright.el --- update the copyright notice in current buffer
2    
3  ;; Copyright (C) 1991, 92, 93, 94, 95, 1998 Free Software Foundation, Inc.  ;; Copyright (C) 1991, 92, 93, 94, 95, 98, 2001 Free Software Foundation, Inc.
4    
5  ;; Author: Daniel Pfeiffer <occitan@esperanto.org>  ;; Author: Daniel Pfeiffer <occitan@esperanto.org>
6  ;; Keywords: maint, tools  ;; Keywords: maint, tools
# Line 35  Line 35 
35    
36  (defcustom copyright-limit 2000  (defcustom copyright-limit 2000
37    "*Don't try to update copyright beyond this position unless interactive.    "*Don't try to update copyright beyond this position unless interactive.
38  `nil' means to search whole buffer."  A value of nil means to search whole buffer."
39    :group 'copyright    :group 'copyright
40    :type '(choice (integer :tag "Limit")    :type '(choice (integer :tag "Limit")
41                   (const :tag "No limit")))                   (const :tag "No limit")))
42    
43  ;; Cleaner to specify Latin-1 coding for this file, and not use both  ;; Would it be cleaner to specify Latin-1 coding for this file,
44  ;; unibyte and multibyte copyright symbol characters?  ;; and not use both unibyte and multibyte copyright symbol characters?
45    
46    ;; The character classes include the unibyte (C) sign,
47    ;; the Latin-1 version, and the Latin-9 version.
48  (defcustom copyright-regexp  (defcustom copyright-regexp
49    "\\([\251]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *(C)\    "\\([\251]\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\((C)\\)?\
50  \\|[Cc]opyright\\s *:?\\s *[\251]\\)\  \\|[Cc]opyright\\s *:?\\s *[\251]\\)\
51  \\s *\\([1-9][-0-9, ';\n\t]*[0-9]+\\)"  \\s *\\([1-9]\\([-0-9, ';\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
52    "*What your copyright notice looks like.    "*What your copyright notice looks like.
53  The second \\( \\) construct must match the years."  The second \\( \\) construct must match the years."
54    :group 'copyright    :group 'copyright
# Line 53  The second \\( \\) construct must match Line 56  The second \\( \\) construct must match
56    
57    
58  (defcustom copyright-query 'function  (defcustom copyright-query 'function
59    "*If non-`nil', ask user before changing copyright.    "*If non-nil, ask user before changing copyright.
60  When this is `function', only ask when called non-interactively."  When this is `function', only ask when called non-interactively."
61    :group 'copyright    :group 'copyright
62    :type '(choice (const :tag "Do not ask")    :type '(choice (const :tag "Do not ask")
# Line 63  When this is `function', only ask when c Line 66  When this is `function', only ask when c
66    
67  ;; when modifying this, also modify the comment generated by autoinsert.el  ;; when modifying this, also modify the comment generated by autoinsert.el
68  (defconst copyright-current-gpl-version "2"  (defconst copyright-current-gpl-version "2"
69    "String representing the current version of the GPL or `nil'.")    "String representing the current version of the GPL or nil.")
70    
71  (defvar copyright-update t)  (defvar copyright-update t)
72    
73  ;; This is a defvar rather than a defconst, because the year can  ;; This is a defvar rather than a defconst, because the year can
74  ;; change during the Emacs session.  ;; change during the Emacs session.
75  (defvar copyright-current-year "2001"  (defvar copyright-current-year (substring (current-time-string) -4)
76    "String representing the current year.")    "String representing the current year.")
77    
78    
79  ;;;###autoload  ;;;###autoload
80  (defun copyright-update (&optional arg)  (defun copyright-update (&optional arg)
81    "Update the copyright notice at the beginning of the buffer to indicate    "Update copyright notice at beginning of buffer to indicate the current year.
82  the current year.  If optional prefix ARG is given replace the years in the  With prefix ARG, replace the years in the notice rather than adding
83  notice rather than adding the current year after them.  If necessary and  the current year after them.  If necessary, and
84  `copyright-current-gpl-version' is set, the copying permissions following the  `copyright-current-gpl-version' is set, any copying permissions
85  copyright, if any, are updated as well."  following the copyright are updated as well."
86    (interactive "*P")    (interactive "*P")
87    (if copyright-update    (if copyright-update
88        (save-excursion        (save-excursion
89          (save-restriction          (save-restriction
90            (widen)            (widen)
91            (goto-char (point-min))            (goto-char (point-min))
92              ;; Note that `current-time-string' isn't locale-sensitive.
93            (setq copyright-current-year (substring (current-time-string) -4))            (setq copyright-current-year (substring (current-time-string) -4))
94            (if (re-search-forward copyright-regexp copyright-limit t)            (if (re-search-forward copyright-regexp copyright-limit t)
95                (if (string= (buffer-substring (- (match-end 2) 2) (match-end 2))                (if (string= (buffer-substring (- (match-end 2) 2) (match-end 2))
# Line 98  copyright, if any, are updated as well." Line 102  copyright, if any, are updated as well."
102                                        (concat "Replace copyright year(s) by "                                        (concat "Replace copyright year(s) by "
103                                                copyright-current-year "? ")                                                copyright-current-year "? ")
104                                      (concat "Add " copyright-current-year                                      (concat "Add " copyright-current-year
105                                              " to copyright? "))))                                              " to copyright? "))))
106                      (if arg                      (if arg
107                          (progn                          (progn
108                            (delete-region (match-beginning 1) (match-end 1))                            (delete-region (match-beginning 1) (match-end 1))
# Line 122  copyright, if any, are updated as well." Line 126  copyright, if any, are updated as well."
126            (and copyright-current-gpl-version            (and copyright-current-gpl-version
127                 ;; match the GPL version comment in .el files, including the                 ;; match the GPL version comment in .el files, including the
128                 ;; bilingual Esperanto one in two-column, and in texinfo.tex                 ;; bilingual Esperanto one in two-column, and in texinfo.tex
129                 (re-search-forward "\\(the Free Software Foundation; either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via  \\)version \\([0-9]+\\), or (at"                 (re-search-forward "\\(the Free Software Foundation;\
130     either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via     \\)\
131    version \\([0-9]+\\), or (at"
132                                    copyright-limit t)                                    copyright-limit t)
133                 (not (string= (buffer-substring (match-beginning 3) (match-end 3))                 (not (string= (match-string 3) copyright-current-gpl-version))
                              copyright-current-gpl-version))  
134                 (or (not copyright-query)                 (or (not copyright-query)
135                     (and (eq copyright-query 'function)                     (and (eq copyright-query 'function)
136                          (eq this-command 'copyright-update))                          (eq this-command 'copyright-update))

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26