Annotation of 43BSD/contrib/emacs/lisp/dissociate.el, revision 1.1

1.1     ! root        1: ;; Scramble text amusingly for Emacs.
        !             2: ;; Copyright (C) 1985 Richard M. Stallman.
        !             3: 
        !             4: ;; This file is part of GNU Emacs.
        !             5: 
        !             6: ;; GNU Emacs is distributed in the hope that it will be useful,
        !             7: ;; but WITHOUT ANY WARRANTY.  No author or distributor
        !             8: ;; accepts responsibility to anyone for the consequences of using it
        !             9: ;; or for whether it serves any particular purpose or works at all,
        !            10: ;; unless he says so in writing.  Refer to the GNU Emacs General Public
        !            11: ;; License for full details.
        !            12: 
        !            13: ;; Everyone is granted permission to copy, modify and redistribute
        !            14: ;; GNU Emacs, but only under the conditions described in the
        !            15: ;; GNU Emacs General Public License.   A copy of this license is
        !            16: ;; supposed to have been given to you along with GNU Emacs so you
        !            17: ;; can know your rights and responsibilities.  It should be in a
        !            18: ;; file named COPYING.  Among other things, the copyright notice
        !            19: ;; and this notice must be preserved on all copies.
        !            20: 
        !            21: 
        !            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.
        !            29: Default is 2."
        !            30:   (interactive "P")
        !            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))
        !            37:         (last-query-point 0))
        !            38:     (switch-to-buffer outbuf)
        !            39:     (erase-buffer)
        !            40:     (while
        !            41:       (save-excursion
        !            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? "))
        !            47:                 (progn
        !            48:                   (message "")
        !            49:                   (recenter 1)
        !            50:                   (setq last-query-point (point-max))
        !            51:                   t))))
        !            52:       (let (start end)
        !            53:        (save-excursion
        !            54:         (set-buffer inbuf)
        !            55:         (setq start (point))
        !            56:         (if (eq move-function 'forward-char)
        !            57:             (progn
        !            58:               (setq end (+ start (+ move-amount (logand 15 (random)))))
        !            59:               (if (> end (point-max))
        !            60:                   (setq end (+ 1 move-amount (logand 15 (random)))))
        !            61:               (goto-char end))
        !            62:           (funcall move-function
        !            63:                    (+ move-amount (logand 15 (random)))))
        !            64:         (setq end (point)))
        !            65:        (let ((opoint (point)))
        !            66:          (insert-buffer-substring inbuf start end)
        !            67:          (save-excursion
        !            68:           (goto-char opoint)
        !            69:           (end-of-line)
        !            70:           (and (> (current-column) fill-column)
        !            71:                (do-auto-fill)))))
        !            72:       (save-excursion
        !            73:        (set-buffer inbuf)
        !            74:        (if (eobp)
        !            75:           (goto-char (point-min))
        !            76:         (let ((overlap
        !            77:                (buffer-substring (prog1 (point)
        !            78:                                         (funcall move-function
        !            79:                                                  (- move-amount)))
        !            80:                                  (point))))
        !            81:           (let (ranval)
        !            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)))
        !            86:                 (goto-char 1)
        !            87:                 (funcall search-function overlap opoint t))))))
        !            88:       (sit-for 0))))

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.