Mercurial > hg > xemacs-beta
comparison lisp/utils/hide-copyleft.el @ 149:538048ae2ab8 r20-3b1
Import from CVS: tag r20-3b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:36:16 +0200 |
parents | 376386a54a3c |
children |
comparison
equal
deleted
inserted
replaced
148:f659db2a1f73 | 149:538048ae2ab8 |
---|---|
1 ;;; -*- Mode:Emacs-Lisp -*- | 1 ;;; hide-copyleft.el --- hide obnoxious copyright prologs |
2 | 2 |
3 ;;; "hide-copyleft.el" by Jamie Zawinski <jwz@lucid.com>, 19-jan-91. | 3 ;; Copyright (C) 1997 Sun Microsystems. |
4 ;;; Last modified 7-sep-91. | 4 |
5 ;;; | 5 ;; This file is part of XEmacs. |
6 ;;; I sometimes find it tiresome to have fifteen lines of copyright notice at | 6 |
7 ;;; the beginning of each file. Meta-< does not take you to the beginning of | 7 ;; XEmacs is free software; you can redistribute it and/or modify it |
8 ;;; the code, it takes you a windowfull or two away, which can be tedious on | 8 ;; under the terms of the GNU General Public License as published by |
9 ;;; slow terminal lines. | 9 ;; the Free Software Foundation; either version 2, or (at your option) |
10 ;;; | 10 ;; any later version. |
11 ;;; I know what the copyright notice says; so this code makes all but the first | 11 |
12 ;;; line of it be invisible, by using Emacs's selective-display feature. The | 12 ;; XEmacs is distributed in the hope that it will be useful, but |
13 ;;; text is still present and unmodified, but it is invisible. | 13 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
14 ;;; | 14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 ;;; Elide the copyright notice with "Meta-X hide-copyleft-region". Make it | 15 ;; General Public License for more details. |
16 ;;; visible again with "Control-U Meta-X hide-copyleft-region". Or, if you're | 16 |
17 ;;; sure you're not gonna get sued, you can do something like this in your | 17 ;; You should have received a copy of the GNU General Public License |
18 ;;; .emacs file: | 18 ;; along with XEmacs; see the file COPYING. If not, write to the Free |
19 ;;; | 19 ;; Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA |
20 ;;; (autoload 'hide-copyleft-region "hide-copyleft" nil t) | 20 ;; 02111-1307, USA. |
21 ;;; (autoload 'unhide-copyleft-region "hide-copyleft" nil t) | 21 |
22 ;;; (setq emacs-lisp-mode-hook 'hide-copyleft-region | 22 ;;; Commentary: |
23 ;;; c-mode-hook 'hide-copyleft-region) | 23 |
24 ;;; | 24 ;; Written by Jamie Zawinski <jwz@netscape.com>, 19-jan-91. |
25 ;;; This code (obviously) has quite specific knowledge of the wording of the | 25 ;; Minor fixes by Martin Buchholz, 14-may-97. |
26 ;;; various copyrights I've run across. Let me know if you find one on which | 26 ;; Last modified 14-may-97. |
27 ;;; it fails. | 27 ;; |
28 ;; I sometimes find it tiresome to have fifteen lines of copyright notice at | |
29 ;; the beginning of each file. Meta-< does not take you to the beginning of | |
30 ;; the code, it takes you a windowfull or two away, which can be tedious on | |
31 ;; slow terminal lines. | |
32 ;; | |
33 ;; I know what the copyright notice says; so this code makes all but the first | |
34 ;; line of it be invisible, by using Emacs's selective-display feature. The | |
35 ;; text is still present and unmodified, but it is invisible. | |
36 ;; | |
37 ;; Elide the copyright notice with "Meta-X hide-copyleft-region". Make it | |
38 ;; visible again with "Control-U Meta-X hide-copyleft-region". Or, if you're | |
39 ;; sure you're not gonna get sued, you can do something like this in your | |
40 ;; .emacs file: | |
41 ;; | |
42 ;; (autoload 'hide-copyleft-region "hide-copyleft" nil t) | |
43 ;; (autoload 'unhide-copyleft-region "hide-copyleft" nil t) | |
44 ;; (add-hook 'emacs-lisp-mode-hook 'hide-copyleft-region) | |
45 ;; (add-hook 'c-mode-hook 'hide-copyleft-region) | |
46 ;; | |
47 ;; This code (obviously) has quite specific knowledge of the wording of the | |
48 ;; various copyrights I've run across. Let me know if you find one on which | |
49 ;; it fails. | |
28 | 50 |
29 (defvar copylefts-to-hide | 51 (defvar copylefts-to-hide |
30 ;; There are some extra backslashes in these strings to prevent this code | 52 ;; There are some extra backslashes in these strings to prevent this code |
31 ;; from matching the definition of this list as the copyright notice! | 53 ;; from matching the definition of this list as the copyright notice! |
32 '(;; GNU | 54 '(;; GNU |
33 ("free software\; you can redistribute it" . | 55 ("free software\; you can redistribute it" . |
34 "notice must be preserved on all") | 56 "notice must be\ preserved on all") |
35 ("free software\; you can redistribute it" . | 57 ("free software\; you can redistribute it" . |
36 "copy of the GNU General Public License.*\n?.*\n?.*\n?.*\n?02139,") | 58 "copy of the GNU General Public License.*\n?.*\n?.*\n?.*\n?.*\\(02139,\\|02111-1307\\)") |
37 ("distributed in the hope that it will be useful\," . | 59 ("distributed in the hope that it will be useful\," . |
38 "notice must be preserved on all") | 60 "notice must be\ preserved on all") |
39 ("free software\; you can redistribute it" . | 61 ("free software\; you can redistribute it" . |
40 "General Public License for more details\\.") | 62 "General Public License for more details\\.") |
41 ;; X11 | 63 ;; X11 |
42 ("Permission to use\, copy, modify," . | 64 ("Permission to use\, copy, modify," . |
43 "WITH THE USE OR PERFORMANCE") | 65 "WITH THE USE OR PERFORMANCE") |
60 ) | 82 ) |
61 "An alist of pairs of regexps which delimit copyright notices to hide. | 83 "An alist of pairs of regexps which delimit copyright notices to hide. |
62 The first one found is hidden, so order is significant.") | 84 The first one found is hidden, so order is significant.") |
63 | 85 |
64 | 86 |
87 ;;;###autoload | |
65 (defun hide-copyleft-region (&optional arg) | 88 (defun hide-copyleft-region (&optional arg) |
66 "Make the legal drivel at the front of this file invisible. Unhide it again | 89 "Make the legal drivel at the front of this file invisible. Unhide it again |
67 with C-u \\[hide-copyleft-region]." | 90 with C-u \\[hide-copyleft-region]." |
68 (interactive "P") | 91 (interactive "P") |
69 (if arg | 92 (if arg |
73 (if selective-display (error "selective-display is already on.")) | 96 (if selective-display (error "selective-display is already on.")) |
74 (catch 'Abort | 97 (catch 'Abort |
75 (let ((mod-p (buffer-modified-p)) | 98 (let ((mod-p (buffer-modified-p)) |
76 (buffer-read-only nil) | 99 (buffer-read-only nil) |
77 (rest copylefts-to-hide) | 100 (rest copylefts-to-hide) |
78 pair start end max) | 101 pair start end) |
79 (widen) | 102 (widen) |
80 (goto-char (point-min)) | 103 (goto-char (point-min)) |
81 (while (and rest (not pair)) | 104 (while (and rest (not pair)) |
82 (save-excursion | 105 (save-excursion |
83 (and (re-search-forward (car (car rest)) nil t) | 106 (and (re-search-forward (car (car rest)) nil t) |
105 (insert "\^M") | 128 (insert "\^M") |
106 (forward-line 1)) | 129 (forward-line 1)) |
107 (setq selective-display t) | 130 (setq selective-display t) |
108 (set-buffer-modified-p mod-p))))))) | 131 (set-buffer-modified-p mod-p))))))) |
109 | 132 |
133 ;;;###autoload | |
110 (defun unhide-copyleft-region () | 134 (defun unhide-copyleft-region () |
111 "If the legal nonsense at the top of this file is elided, make it visible again." | 135 "If the legal nonsense at the top of this file is elided, make it visible again." |
112 (save-excursion | 136 (save-excursion |
113 (save-restriction | 137 (save-restriction |
114 (widen) | 138 (widen) |