[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
copyright-fix-years problems.
From: |
Lute Kamstra |
Subject: |
copyright-fix-years problems. |
Date: |
Wed, 18 May 2005 13:51:19 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
When I use copyright-fix-years on something like this:
Copyright (C) 1980,82,87,2005 Free Software Foundation, Inc.
I get this:
Copyright (C) 1980,82, 1987, 2005 Free Software Foundation, Inc.
When I use copyright-fix-years on this:
Copyright (C) 1980,82,87-89,2005 Free Software Foundation, Inc.
I get:
Copyright (C) 1980,82, 1987- 1989, 2005 Free Software Foundation, Inc.
What about the patch below to fix this? It gives these results:
Copyright (C) 1980, 1982, 1987, 2005 Free Software Foundation, Inc.
Copyright (C) 1980, 1982, 1987-1989, 2005 Free Software Foundation, Inc.
Lute.
Index: lisp/emacs-lisp/copyright.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/emacs-lisp/copyright.el,v
retrieving revision 1.52
diff -c -r1.52 copyright.el
*** lisp/emacs-lisp/copyright.el 15 May 2005 22:02:39 -0000 1.52
--- lisp/emacs-lisp/copyright.el 18 May 2005 11:43:12 -0000
***************
*** 185,209 ****
(widen)
(goto-char (point-min))
(if (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
! (let ((s (match-beginning 2)) (e (make-marker))
last)
- (set-marker e (1+ (match-end 2)))
(goto-char s)
! ;; Back up one character so that our search can match the first year.
! (backward-char 1)
! (while (and (< (point) (marker-position e))
! (re-search-forward "\\([^0-9]\\)\\([0-9]+\\)[^0-9]"
! (marker-position e) t))
! (let ((p (point))
! (sep (match-string 1))
! (year (string-to-number (match-string 2))))
! (goto-char (1+ (match-beginning 0)))
! (unless (= (char-syntax (string-to-char sep)) ?\s)
(insert " "))
! (if (< year 100)
! (insert (if (>= year 50) "19" "20")))
! (goto-char p)
! (setq last p)))
(when last
(goto-char last)
;; Don't mess up whitespace after the years.
--- 185,208 ----
(widen)
(goto-char (point-min))
(if (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
! (let ((s (match-beginning 2))
! (e (copy-marker (1+ (match-end 2))))
! (p (make-marker))
last)
(goto-char s)
! (while (re-search-forward "[0-9]+" e t)
! (set-marker p (point))
! (goto-char (match-beginning 0))
! (let ((sep (char-before))
! (year (string-to-number (match-string 0))))
! (when (and sep
! (/= (char-syntax sep) ?\s)
! (/= sep ?-))
(insert " "))
! (when (< year 100)
! (insert (if (>= year 50) "19" "20"))))
! (goto-char p)
! (setq last p))
(when last
(goto-char last)
;; Don't mess up whitespace after the years.
***************
*** 211,222 ****
(save-restriction
(narrow-to-region (point-min) (point))
(let ((fill-prefix " "))
! (fill-region s last)))
! )
(set-marker e nil)
(copyright-update nil t))
! (message "No copyright message")
! (goto-char (point-min))))
;;;###autoload
(define-skeleton copyright
--- 210,220 ----
(save-restriction
(narrow-to-region (point-min) (point))
(let ((fill-prefix " "))
! (fill-region s last))))
(set-marker e nil)
+ (set-marker p nil)
(copyright-update nil t))
! (message "No copyright message")))
;;;###autoload
(define-skeleton copyright
- copyright-fix-years problems.,
Lute Kamstra <=