aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLute Kamstra2005-05-19 08:13:31 +0000
committerLute Kamstra2005-05-19 08:13:31 +0000
commit07b41c42758f74cd1f0737595a73de6af870f823 (patch)
tree5baa8e32734e0252b8f42c0dc5c037c5ee0ceec4
parent34e99b2e36e39fc5199dba83c87e6cfc10cde23c (diff)
downloademacs-07b41c42758f74cd1f0737595a73de6af870f823.tar.gz
emacs-07b41c42758f74cd1f0737595a73de6af870f823.zip
(copyright-fix-years): Make sure all years are fixed. Don't insert a
space after a dash.
-rw-r--r--lisp/emacs-lisp/copyright.el38
1 files changed, 18 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 30c76b8769a..c2e394bf15b 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -185,25 +185,24 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
185 (widen) 185 (widen)
186 (goto-char (point-min)) 186 (goto-char (point-min))
187 (if (re-search-forward copyright-regexp (+ (point) copyright-limit) t) 187 (if (re-search-forward copyright-regexp (+ (point) copyright-limit) t)
188 (let ((s (match-beginning 2)) (e (make-marker)) 188 (let ((s (match-beginning 2))
189 (e (copy-marker (1+ (match-end 2))))
190 (p (make-marker))
189 last) 191 last)
190 (set-marker e (1+ (match-end 2)))
191 (goto-char s) 192 (goto-char s)
192 ;; Back up one character so that our search can match the first year. 193 (while (re-search-forward "[0-9]+" e t)
193 (backward-char 1) 194 (set-marker p (point))
194 (while (and (< (point) (marker-position e)) 195 (goto-char (match-beginning 0))
195 (re-search-forward "\\([^0-9]\\)\\([0-9]+\\)[^0-9]" 196 (let ((sep (char-before))
196 (marker-position e) t)) 197 (year (string-to-number (match-string 0))))
197 (let ((p (point)) 198 (when (and sep
198 (sep (match-string 1)) 199 (/= (char-syntax sep) ?\s)
199 (year (string-to-number (match-string 2)))) 200 (/= sep ?-))
200 (goto-char (1+ (match-beginning 0)))
201 (unless (= (char-syntax (string-to-char sep)) ?\s)
202 (insert " ")) 201 (insert " "))
203 (if (< year 100) 202 (when (< year 100)
204 (insert (if (>= year 50) "19" "20"))) 203 (insert (if (>= year 50) "19" "20"))))
205 (goto-char p) 204 (goto-char p)
206 (setq last p))) 205 (setq last p))
207 (when last 206 (when last
208 (goto-char last) 207 (goto-char last)
209 ;; Don't mess up whitespace after the years. 208 ;; Don't mess up whitespace after the years.
@@ -211,12 +210,11 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx."
211 (save-restriction 210 (save-restriction
212 (narrow-to-region (point-min) (point)) 211 (narrow-to-region (point-min) (point))
213 (let ((fill-prefix " ")) 212 (let ((fill-prefix " "))
214 (fill-region s last))) 213 (fill-region s last))))
215 )
216 (set-marker e nil) 214 (set-marker e nil)
215 (set-marker p nil)
217 (copyright-update nil t)) 216 (copyright-update nil t))
218 (message "No copyright message") 217 (message "No copyright message")))
219 (goto-char (point-min))))
220 218
221;;;###autoload 219;;;###autoload
222(define-skeleton copyright 220(define-skeleton copyright