gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fix-copyright.el - Automatically update copyright in source files


From: Benjamin Drieu
Subject: fix-copyright.el - Automatically update copyright in source files
Date: Mon, 16 Jan 2006 19:07:30 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

This snippet updates dates in copyright lines, based on occurences of
your name (that is, user-full-name).

;;; fix-copyright.el --- Fix copyright year in C source

;; Copyright (C) 2006  Benjamin Drieu <address@hidden>

;; Author: Benjamin Drieu <address@hidden>
;; Keywords: c

;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:

;; Will replace all occurences of ``year1-year2 username'' to
;; ``year2-currentyear username'' in current buffer.
;;
;; Just add the following in your .emacs file to use it in C mode :
;;   (add-hook 'c-mode-hook 'update-copyright)

;;; History:
;; 2006/01/16: First version.

;;; Code:

(defun update-copyright ()
  "Update copyright in current buffer."
  (interactive)
  (save-excursion
    (let ((year (substring (current-time-string (current-time)) 20 24))
          (user user-full-name))
      (replace-regexp
       (concat "     \\(200.\\) *" user)
       (concat "\\1-" year " " user))
      (replace-regexp
       (concat "\\(200.-\\)?200. *" user)
       (concat "\\1" year " " user)))))

(provide 'fix-copyright)
;;; fix-copyright.el ends here


-- 
  .''`.
 ; ;' ;      Debian GNU/Linux     |   Benjamin Drieu
 `. `'    http://www.debian.org/  |  <address@hidden>
   `-    


reply via email to

[Prev in Thread] Current Thread [Next in Thread]