X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/7ad8fe5e2876518a8f33b80050f98dab4ff78398..af7c7572ce8d87f51817d0f518d1b0aced074a41:/lisp/emacs-lisp/copyright.el diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index f8894a7975..6f7a43af84 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -1,7 +1,7 @@ ;;; copyright.el --- update the copyright notice in current buffer ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1998, 2001, 2002, 2003, -;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. ;; Author: Daniel Pfeiffer ;; Keywords: maint, tools @@ -51,7 +51,8 @@ This is useful for ChangeLogs." (defcustom copyright-regexp "\\(©\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\ \\|[Cc]opyright\\s *:?\\s *©\\)\ -\\s *\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" +\\s *\\(?:[^0-9\n]*\\s *\\)?\ +\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" "What your copyright notice looks like. The second \\( \\) construct must match the years." :group 'copyright @@ -86,7 +87,8 @@ When this is `function', only ask when called non-interactively." (defconst copyright-current-gpl-version "3" "String representing the current version of the GPL or nil.") -(defvar copyright-update t) +(defvar copyright-update t + "The function `copyright-update' sets this to nil after updating a buffer.") ;; This is a defvar rather than a defconst, because the year can ;; change during the Emacs session. @@ -156,11 +158,13 @@ When this is `function', only ask when called non-interactively." (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3)) (substring copyright-current-year -2)) (if (or noquery - (y-or-n-p (if replace - (concat "Replace copyright year(s) by " - copyright-current-year "? ") - (concat "Add " copyright-current-year - " to copyright? ")))) + ;; Fixes some point-moving oddness (bug#2209). + (save-excursion + (y-or-n-p (if replace + (concat "Replace copyright year(s) by " + copyright-current-year "? ") + (concat "Add " copyright-current-year + " to copyright? "))))) (if replace (replace-match copyright-current-year t t nil 3) (let ((size (save-excursion (skip-chars-backward "0-9")))) @@ -189,7 +193,7 @@ When this is `function', only ask when called non-interactively." ;;;###autoload (defun copyright-update (&optional arg interactivep) - "Update copyright notice at beginning of buffer to indicate the current year. + "Update copyright notice to indicate the current year. With prefix ARG, replace the years in the notice rather than adding the current year after them. If necessary, and `copyright-current-gpl-version' is set, any copying permissions @@ -219,8 +223,9 @@ version \\([0-9]+\\), or (at" (< (string-to-number (match-string 3)) (string-to-number copyright-current-gpl-version)) (or noquery - (y-or-n-p (format "Replace GPL version by %s? " - copyright-current-gpl-version))) + (save-match-data + (y-or-n-p (format "Replace GPL version by %s? " + copyright-current-gpl-version)))) (progn (if (match-end 2) ;; Esperanto bilingual comment in two-column.el @@ -231,6 +236,7 @@ version \\([0-9]+\\), or (at" nil)) +;; FIXME should be within 50 years of present (cf calendar). ;;;###autoload (defun copyright-fix-years () "Convert 2 digit years to 4 digit years. @@ -282,10 +288,12 @@ Uses heuristic: year >= 50 means 19xx, < 50 means 20xx." (message "Copyright extends beyond `copyright-limit' and won't be updated automatically.")) comment-end \n) +;;;###autoload (defun copyright-update-directory (directory match) "Update copyright notice for all files in DIRECTORY matching MATCH." - (interactive "DDirectory: \nMFilenames matching: ") + (interactive "DDirectory: \nMFilenames matching (regexp): ") (dolist (file (directory-files directory t match nil)) + (message "Updating file `%s'" file) (find-file file) (let ((copyright-query nil)) (copyright-update))