Function: copyright-update

copyright-update is an autoloaded, interactive and byte-compiled function defined in copyright.el.gz.

Signature

(copyright-update &optional ARG INTERACTIVEP)

Documentation

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 following the copyright are updated as well. If non-nil, INTERACTIVEP tells the function to behave as when it's called interactively.

Probably introduced at or before Emacs version 19.30.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/copyright.el.gz
;;;###autoload
(defun copyright-update (&optional arg interactivep)
  "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
following the copyright are updated as well.
If non-nil, INTERACTIVEP tells the function to behave as when it's called
interactively."
  (interactive "*P\nd")
  (when (or copyright-update interactivep)
    (let ((noquery (or (not copyright-query)
		       (and (eq copyright-query 'function) interactivep))))
      (save-excursion
	(save-restriction
	  ;; If names-regexp doesn't match, we should not mess with
	  ;; the years _or_ the GPL version.
	  ;; TODO there may be multiple copyrights we should update.
	  (when (copyright-find-copyright)
	    (copyright-update-year arg noquery)
	    (goto-char (copyright-start-point))
	    (and copyright-current-gpl-version
		 ;; Match the GPL version comment in .el files.
		 ;; This is sensitive to line-breaks. :(
		 (copyright-re-search
		  "the Free Software Foundation[,;\n].*either version \
\\([0-9]+\\)\\(?: of the License\\)?, or[ \n].*any later version"
		  (copyright-limit) t)
		 ;; Don't update if the file is already using a more recent
		 ;; version than the "current" one.
		 (< (string-to-number (match-string 1))
		    (string-to-number copyright-current-gpl-version))
		 (or noquery
		     (save-match-data
		       (goto-char (match-end 1))
		       (save-window-excursion
			 (switch-to-buffer (current-buffer))
			 (y-or-n-p
			  (format "Replace GPL version %s with version %s? "
				  (match-string-no-properties 1)
				  copyright-current-gpl-version)))))
		 (replace-match copyright-current-gpl-version t t nil 1))))
        (setq-local copyright-update nil)))
    ;; If a write-file-hook returns non-nil, the file is presumed to be written.
    nil))