1 ;; Scramble text amusingly for Emacs.
2 ;; Copyright (C) 1985 Free Software Foundation, Inc.
4 ;; This file is part of GNU Emacs.
6 ;; GNU Emacs is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 1, or (at your option)
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GNU Emacs; see the file COPYING. If not, write to
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 (defun dissociated-press (&optional arg
)
23 "Dissociate the text of the current buffer.
24 Output goes in buffer named *Dissociation*,
25 which is redisplayed each time text is added to it.
26 Every so often the user must say whether to continue.
27 If ARG is positive, require ARG chars of continuity.
28 If ARG is negative, require -ARG words of continuity.
31 (setq arg
(if arg
(prefix-numeric-value arg
) 2))
32 (let* ((inbuf (current-buffer))
33 (outbuf (get-buffer-create "*Dissociation*"))
34 (move-function (if (> arg
0) 'forward-char
'forward-word
))
35 (move-amount (if (> arg
0) arg
(- arg
)))
36 (search-function (if (> arg
0) 'search-forward
'word-search-forward
))
38 (switch-to-buffer outbuf
)
42 (goto-char last-query-point
)
43 (vertical-motion (- (window-height) 4))
44 (or (= (point) (point-max))
45 (and (progn (goto-char (point-max))
46 (y-or-n-p "Continue dissociation? "))
50 (setq last-query-point
(point-max))
56 (if (eq move-function
'forward-char
)
58 (setq end
(+ start
(+ move-amount
(random 16))))
59 (if (> end
(point-max))
60 (setq end
(+ 1 move-amount
(random 16))))
62 (funcall move-function
63 (+ move-amount
(random 16))))
65 (let ((opoint (point)))
66 (insert-buffer-substring inbuf start end
)
70 (and (> (current-column) fill-column
)
75 (goto-char (point-min))
77 (buffer-substring (prog1 (point)
78 (funcall move-function
82 (while (< (setq ranval
(random)) 0))
83 (goto-char (1+ (% ranval
(1- (point-max))))))
84 (or (funcall search-function overlap nil t
)
85 (let ((opoint (point)))
87 (funcall search-function overlap opoint t
))))))