summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorKim F. Storm <storm@cua.dk>2005-03-01 10:14:48 +0000
committerKim F. Storm <storm@cua.dk>2005-03-01 10:14:48 +0000
commit422032f0ca216ecc279cf8e1733e1d661c8bfd78 (patch)
tree998ddc2c5909986b35f0fed514782d3942ac626f /lisp/emacs-lisp
parent5582d76d7dc04a184279531db1e55d6d6969ebb6 (diff)
downloademacs-422032f0ca216ecc279cf8e1733e1d661c8bfd78.tar.gz
emacs-422032f0ca216ecc279cf8e1733e1d661c8bfd78.tar.bz2
emacs-422032f0ca216ecc279cf8e1733e1d661c8bfd78.zip
(copyright-fix-years): New command.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/copyright.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 3d160f54606..dcb68188383 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -178,6 +178,41 @@ version \\([0-9]+\\), or (at"
;;;###autoload
+(defun copyright-fix-years ()
+ "Convert 2 digit years to 4 digit years.
+Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
+ (interactive)
+ (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)
+ (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
"Insert a copyright by $ORGANIZATION notice at cursor."
"Company: "