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 <[EMAIL PROTECTED]>

;; Author: Benjamin Drieu <[EMAIL PROTECTED]>
;; 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/  |  <[EMAIL PROTECTED]>
   `-    
_______________________________________________
Gnu-emacs-sources mailing list
Gnu-emacs-sources@gnu.org
http://lists.gnu.org/mailman/listinfo/gnu-emacs-sources

Reply via email to