/[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.41.2.2 by handa, Fri Apr 16 12:50:13 2004 UTC revision 1.41.2.3 by miles, Fri Aug 27 07:00:26 2004 UTC
# Line 52  The second \\( \\) construct must match Line 52  The second \\( \\) construct must match
52    :group 'copyright    :group 'copyright
53    :type 'regexp)    :type 'regexp)
54    
55    (defcustom copyright-years-regexp
56     "\\(\\s *\\)\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
57      "*Match additional copyright notice years.
58    The second \\( \\) construct must match the years."
59      :group 'copyright
60      :type 'regexp)
61    
62    
63  (defcustom copyright-query 'function  (defcustom copyright-query 'function
64    "*If non-nil, ask user before changing copyright.    "*If non-nil, ask user before changing copyright.
# Line 75  When this is `function', only ask when c Line 82  When this is `function', only ask when c
82    
83  (defun copyright-update-year (replace noquery)  (defun copyright-update-year (replace noquery)
84    (when (re-search-forward copyright-regexp (+ (point) copyright-limit) t)    (when (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
85        ;; If the years are continued onto multiple lined
86        ;; that are marked as comments, skip to the end of the years anyway.
87        (while (save-excursion
88                 (and (eq (following-char) ?,)
89                      (progn (forward-char 1) t)
90                      (progn (skip-chars-forward " \t") (eolp))
91                      comment-start-skip
92                      (save-match-data
93                        (forward-line 1)
94                        (and (looking-at comment-start-skip)
95                             (goto-char (match-end 0))))
96                      (save-match-data
97                        (looking-at copyright-years-regexp))))
98          (forward-line 1)
99          (re-search-forward comment-start-skip)
100          (re-search-forward copyright-years-regexp))
101    
102      ;; Note that `current-time-string' isn't locale-sensitive.      ;; Note that `current-time-string' isn't locale-sensitive.
103      (setq copyright-current-year (substring (current-time-string) -4))      (setq copyright-current-year (substring (current-time-string) -4))
104      (unless (string= (buffer-substring (- (match-end 2) 2) (match-end 2))      (unless (string= (buffer-substring (- (match-end 2) 2) (match-end 2))
# Line 98  When this is `function', only ask when c Line 122  When this is `function', only ask when c
122                             (eq (char-after (+ (point) size -2)) ?-)))                             (eq (char-after (+ (point) size -2)) ?-)))
123                    ;; This is a range so just replace the end part.                    ;; This is a range so just replace the end part.
124                    (delete-char size)                    (delete-char size)
                 ;; Detect if this is using the following shorthand:  
                 ;; (C) 1993, 94, 95, 1998, 2000, 01, 02, 2003  
                 (if (and  
                      ;; Check that the last year was 4-chars and same century.  
                      (eq size -4)  
                      (equal (buffer-substring (- (point) 4) (- (point) 2))  
                             (substring copyright-current-year 0 2))  
                      ;; Check that there are 2-char years as well.  
                      (save-excursion  
                        (re-search-backward "[^0-9][0-9][0-9][^0-9]"  
                                            (line-beginning-position) t))  
                      ;; Make sure we don't remove the first century marker.  
                      (save-excursion  
                        (forward-char size)  
                        (re-search-backward  
                         (concat (buffer-substring (point) (+ (point) 2))  
                                 "[0-9][0-9]")  
                         (line-beginning-position) t)))  
                     ;; Remove the century marker of the last entry.  
                     (delete-region (- (point) 4) (- (point) 2)))  
125                  ;; Insert a comma with the preferred number of spaces.                  ;; Insert a comma with the preferred number of spaces.
126                  (insert                  (insert
127                   (save-excursion                   (save-excursion

Legend:
Removed from v.1.41.2.2  
changed lines
  Added in v.1.41.2.3

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