emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Years in copyright notices


From: Kim F. Storm
Subject: Re: Years in copyright notices
Date: 17 Jun 2004 15:13:47 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

Richard Stallman <address@hidden> writes:

> The latest legal advice I got is that we should not drop the 19 or 20
> from year numbers in copyright notices.  There is no need to change
> all the existing notices, but the year numbers we add should be
> written in 4 digits.

Why not do it properly if we are going to fix 04 -> 2004 anyway?


This function seems to do the job (could be added to copyright.el):

(require 'copyright)

;;;###autoload
(defun copyright-fix-years (&optional arg)
  "Convert 2 digit years to 4 digit years in copyright.
With prefix arg, also update copyright.
Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
  (interactive "P")
  (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)
        (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)
          (fill-region s last)
          )
        (set-marker e nil)
        (if arg
            (copyright-update nil t)))
    (message "No copyright message")
    (goto-char (point-min))))


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]