(read_minibuf): Clean up the binding stack if
[bpt/emacs.git] / lisp / play / studly.el
1 ;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
2
3 ;;; This is in the public domain, since it was distributed
4 ;;; by its author without a copyright notice in 1986.
5
6 ;; Keywords: games
7
8 ;;; Commentary:
9
10 ;; Functions to studlycapsify a region, word, or buffer. Possibly the
11 ;; esoteric significance of studlycapsification escapes you; that is,
12 ;; you suffer from autostudlycapsifibogotification. Too bad.
13
14 ;;; Code:
15
16 ;;;###autoload
17 (defun studlify-region (begin end)
18 "Studlify-case the region"
19 (interactive "*r")
20 (save-excursion
21 (goto-char begin)
22 (setq begin (point))
23 (while (and (<= (point) end)
24 (not (looking-at "\\W*\\'")))
25 (forward-word 1)
26 (backward-word 1)
27 (setq begin (max (point) begin))
28 (forward-word 1)
29 (let ((offset 0)
30 (word-end (min (point) end))
31 c)
32 (goto-char begin)
33 (while (< (point) word-end)
34 (setq offset (+ offset (following-char)))
35 (forward-char 1))
36 (setq offset (+ offset (following-char)))
37 (goto-char begin)
38 (while (< (point) word-end)
39 (setq c (following-char))
40 (if (and (= (% (+ c offset) 4) 2)
41 (let ((ch (following-char)))
42 (or (and (>= ch ?a) (<= ch ?z))
43 (and (>= ch ?A) (<= ch ?Z)))))
44 (progn
45 (delete-char 1)
46 (insert (logxor c ? ))))
47 (forward-char 1))
48 (setq begin (point))))))
49
50 ;;;###autoload
51 (defun studlify-word (count)
52 "Studlify-case the current word, or COUNT words if given an argument"
53 (interactive "*p")
54 (let ((begin (point)) end rb re)
55 (forward-word count)
56 (setq end (point))
57 (setq rb (min begin end) re (max begin end))
58 (studlify-region rb re)))
59
60 (defun studlify-buffer ()
61 "Studlify-case the current buffer"
62 (interactive "*")
63 (studlify-region (point-min) (point-max)))
64
65 (provide 'studly)
66
67 ;;; studly.el ends here