annotate lisp/play/bruce.el @ 86024:1027550b68ba

Add query-replace-show-replacement and match-substitute-replacement.
author Juri Linkov <juri@jurta.org>
date Sat, 10 Nov 2007 21:52:06 +0000
parents 527f752989fc
children 54006a859bcc f55f9811f5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47726
33d53d287ee4 Add "no-byte-compile: t" in first line.
Juanma Barranquero <lekktu@gmail.com>
parents: 42041
diff changeset
1 ;;; bruce.el --- bruce phrase utility for overloading the Communications -*- no-byte-compile: t -*-
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2 ;;; Decency Act snoops, if any.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
3
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68634
diff changeset
4 ;; Copyright (C) 1988, 1993, 1997, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74509
diff changeset
5 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
6
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
7 ;; Maintainer: FSF
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; Keywords: games
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9 ;; Created: Jan 1997
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
78227
527f752989fc Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
15 ;; the Free Software Foundation; either version 3, or (at your option)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
16 ;; any later version.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
26 ;; Boston, MA 02110-1301, USA.
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; This program was written to protest the miss-named "Communications
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; Decency Act of 1996. This Act bans "indecent speech", whatever that is,
42041
b4eeb5fd09f9 Fix typos.
Pavel Janík <Pavel@Janik.cz>
parents: 21363
diff changeset
32 ;; from the Internet. For more on the CDA, see Richard Stallman's essay on
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; censorship, included in the etc directory of emacs distributions 19.34
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;; and up. See also http://www.eff.org/blueribbon.html.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 ;; For many years, emacs has included a program called Spook. This program
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 ;; adds a series of "keywords" to email just before it goes out. On the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
38 ;; theory that the NSA monitors people's email, the keywords would be
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 ;; picked up by the NSA's snoop computers, causing them to waste time
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 ;; reading your meeting schedule notices or other email boring to everyone
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;; but you and (you hope) the recipient. See below (I left in the original
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;; writeup when I made this conversion), or the emacs documentation at
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 ;; ftp://prep.ai.mit.edu/pub/gnu/emacs-manual*.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;; Bruce is a direct copy of spook, with the word "spook" replaced with
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;; the word "bruce". Thanks to "esr", whoever he, she or it may be, this
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 ;; conversion was an extremely easy piece of editing, suitable for a first
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 ;; essay at elisp programming.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 ;; You may think of the name as having been derived from a certain Monty
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 ;; Python routine. Or from Lenny Bruce, who opposed censorship in his own
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 ;; inimitable way. Bruce does exactly what Spook does: it throws keywords
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 ;; into your email messages or other documents.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 ;; However, in order to comply with the CDA as interpreted by Richard
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 ;; Stallman (see the essay on censorship), bruce is distributed without a
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 ;; data file from which to select words at random. Sorry about that. I
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 ;; believe the average user will be able to come up with a few words on
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 ;; his or her own. If that is a problem, feel free to ask any American
42041
b4eeb5fd09f9 Fix typos.
Pavel Janík <Pavel@Janik.cz>
parents: 21363
diff changeset
60 ;; teenager, preferably one who attends a government school. Failing
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ;; that, you might write to Mr. Clinton or Ms Reno or their successors and
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 ;; ask them for suggestions. Think of it as a public spirited act: the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ;; time they spend answering you is time not spent persecuting someone
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 ;; else. However, do ask them to respond by snail mail, where their
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 ;; suggestions would be legal.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ;; To build the data file, just start a file called bruce.lines in the etc
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 ;; directory of your emacs distribution. Note that each phrase or word has
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 ;; to be followed by an ascii 0, control-@. See the file spook.lines in
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 ;; the etc directory for an example. In emacs, use c-q c-@ to insert the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 ;; ascii 0s.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 ;; Once you have edited up a data file, you have to tell emacs how to find
42041
b4eeb5fd09f9 Fix typos.
Pavel Janík <Pavel@Janik.cz>
parents: 21363
diff changeset
74 ;; the program bruce. Add the following two lines to your .emacs file. Be
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 ;; sure to uncomment the second line.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 ;; for bruce mode
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 ;; (autoload 'bruce "bruce" "Use the Bruce program to protest the CDA" t)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ;; Shut down emacs and fire it up again. Then "M-x bruce" should put some
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 ;; shocking words in the current buffer.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 ;; Please note that I am not suggesting that you actually use this program
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 ;; to add "illegal" words to your email, or any other purpose. First, you
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;; don't really need a program to do it, and second, it would be illegal
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; for me to suggest or advise that you actually break the law. This
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; program was written as a demonstration only, and as an act of political
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 ;; protest and free expression protected by the First Amendment, or
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90 ;; whatever is left of it.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 ;; We now return to the original writeup for spook:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 ;; Steve Strassmann <straz@media-lab.media.mit.edu> didn't write the
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 ;; program spook, from which this was adapted, and even if he did, he
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 ;; really didn't mean for you to use it in an anarchistic way.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 ;;
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 ;; To use this:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 ;; Just before sending mail, do M-x spook.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 ;; A number of phrases will be inserted into your buffer, to help
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 ;; give your message that extra bit of attractiveness for automated
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 ;; keyword scanners. Help defeat the NSA trunk trawler!
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 ;;; Code:
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107 (require 'cookie1)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
109 ; Variables
21363
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
110 (defgroup bruce nil
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
111 "Insert phrases selected at random from a file into a buffer."
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
112 :prefix "bruce-"
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
113 :group 'games)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114
21363
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
115 (defcustom bruce-phrases-file "~/bruce.lines"
42041
b4eeb5fd09f9 Fix typos.
Pavel Janík <Pavel@Janik.cz>
parents: 21363
diff changeset
116 "Keep your favourite phrases here."
21363
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
117 :type 'file
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
118 :group 'bruce)
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
119
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
120 (defcustom bruce-phrase-default-count 15
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
121 "Default number of phrases to insert."
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
122 :type 'integer
f1fc193b6958 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20323
diff changeset
123 :group 'bruce)
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 ;;;###autoload
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 (defun bruce ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 "Adds that special touch of class to your outgoing mail."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 (interactive)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 (or (file-exists-p bruce-phrases-file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 (error "You need to create %s" bruce-phrases-file))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 (cookie-insert bruce-phrases-file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 bruce-phrase-default-count
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 "Checking authorization..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 "Checking authorization...Approved"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 ;;;###autoload
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 (defun snarf-bruces ()
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 "Return a vector containing the lines from `bruce-phrases-file'."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 (or (file-exists-p bruce-phrases-file)
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (error "You need to create %s" bruce-phrases-file))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 (cookie-snarf bruce-phrases-file
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 "Checking authorization..."
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 "Checking authorization...Approved"))
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 ;; Note: the implementation that used to take up most of this file has been
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 ;; cleaned up, generalized, gratuitously broken by esr, and now resides in
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 ;; cookie1.el.
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148
48341
595c4a350a47 Add provide call.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47726
diff changeset
149 (provide 'bruce)
595c4a350a47 Add provide call.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47726
diff changeset
150
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48341
diff changeset
151 ;;; arch-tag: b83ded51-4ccb-41ef-8bd6-3b521e81dd9b
20323
eae9c49831e4 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 ;;; bruce.el ends here