Some copyright.el updates.
* lisp/emacs-lisp/copyright.el (copyright-find-copyright): New function, split out from copyright-update-year. (copyright-update): Don't mess with the GPL version if we don't own the copyright. Update license regexp, and remove no longer needed Esperanto stuff.
This commit is contained in:
parent
e7c1dca85c
commit
0412a5a4de
2 changed files with 112 additions and 97 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-01-22 Glenn Morris <rgm@gnu.org>
|
||||||
|
|
||||||
|
* emacs-lisp/copyright.el (copyright-find-copyright): New function,
|
||||||
|
split out from copyright-update-year.
|
||||||
|
(copyright-update): Don't mess with the GPL version if we don't own the
|
||||||
|
copyright. Update license regexp, and remove no longer needed
|
||||||
|
Esperanto stuff.
|
||||||
|
|
||||||
2011-01-22 Chong Yidong <cyd@stupidchicken.com>
|
2011-01-22 Chong Yidong <cyd@stupidchicken.com>
|
||||||
|
|
||||||
* vc/diff.el (diff-sentinel): Doc fix (Bug#7682).
|
* vc/diff.el (diff-sentinel): Doc fix (Bug#7682).
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
;;; copyright.el --- update the copyright notice in current buffer
|
;;; copyright.el --- update the copyright notice in current buffer
|
||||||
|
|
||||||
;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2002, 2003,
|
;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2002, 2003,
|
||||||
;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
;; 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
||||||
|
;; Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
|
;; Author: Daniel Pfeiffer <occitan@esperanto.org>
|
||||||
;; Keywords: maint, tools
|
;; Keywords: maint, tools
|
||||||
|
@ -120,8 +121,10 @@ When this is `function', only ask when called non-interactively."
|
||||||
(< (point) (- (point-max) copyright-limit))
|
(< (point) (- (point-max) copyright-limit))
|
||||||
(> (point) (+ (point-min) copyright-limit)))))
|
(> (point) (+ (point-min) copyright-limit)))))
|
||||||
|
|
||||||
(defun copyright-update-year (replace noquery)
|
(defun copyright-find-copyright ()
|
||||||
(when
|
"Return non-nil if a copyright header suitable for updating is found.
|
||||||
|
The header must match `copyright-regexp' and `copyright-names-regexp', if set.
|
||||||
|
This function sets the match-data that `copyright-update-year' uses."
|
||||||
(condition-case err
|
(condition-case err
|
||||||
;; (1) Need the extra \\( \\) around copyright-regexp because we
|
;; (1) Need the extra \\( \\) around copyright-regexp because we
|
||||||
;; goto (match-end 1) below. See note (2) below.
|
;; goto (match-end 1) below. See note (2) below.
|
||||||
|
@ -133,7 +136,10 @@ When this is `function', only ask when called non-interactively."
|
||||||
;; In case the regexp is rejected. This is useful because
|
;; In case the regexp is rejected. This is useful because
|
||||||
;; copyright-update is typically called from before-save-hook where
|
;; copyright-update is typically called from before-save-hook where
|
||||||
;; such an error is very inconvenient for the user.
|
;; such an error is very inconvenient for the user.
|
||||||
(error (message "Can't update copyright: %s" err) nil))
|
(error (message "Can't update copyright: %s" err) nil)))
|
||||||
|
|
||||||
|
(defun copyright-update-year (replace noquery)
|
||||||
|
;; This uses the match-data from copyright-find-copyright.
|
||||||
(goto-char (match-end 1))
|
(goto-char (match-end 1))
|
||||||
;; If the years are continued onto multiple lines
|
;; If the years are continued onto multiple lines
|
||||||
;; that are marked as comments, skip to the end of the years anyway.
|
;; that are marked as comments, skip to the end of the years anyway.
|
||||||
|
@ -191,7 +197,7 @@ When this is `function', only ask when called non-interactively."
|
||||||
(if (eq (char-after (+ (point) size -3)) ?')
|
(if (eq (char-after (+ (point) size -3)) ?')
|
||||||
(insert ?')))
|
(insert ?')))
|
||||||
;; Finally insert the new year.
|
;; Finally insert the new year.
|
||||||
(insert (substring copyright-current-year size))))))))
|
(insert (substring copyright-current-year size)))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun copyright-update (&optional arg interactivep)
|
(defun copyright-update (&optional arg interactivep)
|
||||||
|
@ -210,31 +216,32 @@ interactively."
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(widen)
|
(widen)
|
||||||
(goto-char (copyright-start-point))
|
(goto-char (copyright-start-point))
|
||||||
|
;; If names-regexp doesn't match, we should not mess with
|
||||||
|
;; the years _or_ the GPL version.
|
||||||
|
(when (copyright-find-copyright)
|
||||||
(copyright-update-year arg noquery)
|
(copyright-update-year arg noquery)
|
||||||
(goto-char (copyright-start-point))
|
(goto-char (copyright-start-point))
|
||||||
(and copyright-current-gpl-version
|
(and copyright-current-gpl-version
|
||||||
;; match the GPL version comment in .el files, including the
|
;; Match the GPL version comment in .el files.
|
||||||
;; bilingual Esperanto one in two-column, and in texinfo.tex
|
;; This is sensitive to line-breaks. :(
|
||||||
(copyright-re-search
|
(copyright-re-search
|
||||||
"\\(the Free Software Foundation;\
|
"the Free Software Foundation[,;\n].*either version \
|
||||||
either \\|; a\\^u eldono \\([0-9]+\\)a, ? a\\^u (la\\^u via \\)\
|
\\([0-9]+\\)\\(?: of the License\\)?, or[ \n].*any later version"
|
||||||
version \\([0-9]+\\), or (at"
|
|
||||||
(copyright-limit) t)
|
(copyright-limit) t)
|
||||||
;; Don't update if the file is already using a more recent
|
;; Don't update if the file is already using a more recent
|
||||||
;; version than the "current" one.
|
;; version than the "current" one.
|
||||||
(< (string-to-number (match-string 3))
|
(< (string-to-number (match-string 1))
|
||||||
(string-to-number copyright-current-gpl-version))
|
(string-to-number copyright-current-gpl-version))
|
||||||
(or noquery
|
(or noquery
|
||||||
(save-match-data
|
(save-match-data
|
||||||
|
(goto-char (match-end 1))
|
||||||
(save-window-excursion
|
(save-window-excursion
|
||||||
(switch-to-buffer (current-buffer))
|
(switch-to-buffer (current-buffer))
|
||||||
(y-or-n-p (format "Replace GPL version by %s? "
|
(y-or-n-p
|
||||||
|
(format "Replace GPL version %s with version %s? "
|
||||||
|
(match-string-no-properties 1)
|
||||||
copyright-current-gpl-version)))))
|
copyright-current-gpl-version)))))
|
||||||
(progn
|
(replace-match copyright-current-gpl-version t t nil 1))))
|
||||||
(if (match-end 2)
|
|
||||||
;; Esperanto bilingual comment in two-column.el
|
|
||||||
(replace-match copyright-current-gpl-version t t nil 2))
|
|
||||||
(replace-match copyright-current-gpl-version t t nil 3))))
|
|
||||||
(set (make-local-variable 'copyright-update) nil)))
|
(set (make-local-variable 'copyright-update) nil)))
|
||||||
;; If a write-file-hook returns non-nil, the file is presumed to be written.
|
;; If a write-file-hook returns non-nil, the file is presumed to be written.
|
||||||
nil))
|
nil))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue