;;; update-gpl.el --- update FSF address and GPL location in copyleft notices ;; Author: Noah Friedman ;; Created: 1991 ;; Public domain. ;;; $Id: update-gpl.el,v 1.1 2017/09/18 05:14:11 friedman Exp $ ;;; Commentary: ;; For obvious irony-related reasons, this file is public domain. ;; To use, put this in your .emacs: ;; ;; (require 'update-gpl) ;; (add-hook 'before-save-hook 'update-gpl-notice) ;;; Code: (defvar update-gpl-notice-asked nil "Indicates whether user has been queried to update FSF address in current buffer before saving. User will not be asked again even if answered no the first time, upon subsequent saves of the same buffer. This variable is buffer-local.") (make-variable-buffer-local 'update-gpl-notice-asked) (defvar update-gpl-notice-ignored-major-modes '(vm-mode fundamental-mode hexl-mode) "Major modes for which FSF copyright addresses will never be updated.") ;;;###autoload (defun update-gpl-notice () "Update obsolete GPL notices. This function should go on `before-save-hook'." (interactive) (unless (or update-gpl-notice-asked buffer-read-only (memq major-mode update-gpl-notice-ignored-major-modes)) (save-excursion (save-restriction (widen) (let ((case-fold-search t)) (goto-char (point-min)) (query-replace-regexp "^\\(.*\\)you should have.*license\\s-*\n\\(\\1.*\n\\)*\\1.*,\\s-+usa.\\s-*\n" (mapconcat (lambda (s) (concat "\\1" s "\n")) '("You should have received a copy of the GNU General Public License" "along with this program. If not, see .") ""))) (setq update-gpl-notice-asked nil)))) nil) (provide 'update-gpl) ;; update-gpl.el ends here