*** empty log message ***
[bpt/emacs.git] / lisp / play / studly.el
CommitLineData
d501f516 1;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
630cc463
ER
2
3;; Maintainer: FSF
4
0560661c
RS
5;;; This is in the public domain, since it was distributed
6;;; by its author without a copyright notice in 1986.
47bdd84a 7
630cc463
ER
8;;; Code:
9
47bdd84a
JB
10(defun studlify-region (begin end)
11 "Studlify-case the region"
12 (interactive "*r")
13 (save-excursion
14 (goto-char begin)
15 (setq begin (point))
16 (while (and (<= (point) end)
17 (not (looking-at "\\W*\\'")))
18 (forward-word 1)
19 (backward-word 1)
20 (setq begin (max (point) begin))
21 (forward-word 1)
22 (let ((offset 0)
23 (word-end (min (point) end))
24 c)
25 (goto-char begin)
26 (while (< (point) word-end)
27 (setq offset (+ offset (following-char)))
28 (forward-char 1))
29 (setq offset (+ offset (following-char)))
30 (goto-char begin)
31 (while (< (point) word-end)
32 (setq c (following-char))
33 (if (and (= (% (+ c offset) 4) 2)
34 (let ((ch (following-char)))
35 (or (and (>= ch ?a) (<= ch ?z))
36 (and (>= ch ?A) (<= ch ?Z)))))
37 (progn
38 (delete-char 1)
39 (insert (logxor c ? ))))
40 (forward-char 1))
41 (setq begin (point))))))
42
43(defun studlify-word (count)
44 "Studlify-case the current word, or COUNT words if given an argument"
45 (interactive "*p")
46 (let ((begin (point)) end rb re)
47 (forward-word count)
48 (setq end (point))
49 (setq rb (min begin end) re (max begin end))
50 (studlify-region rb re)))
51
52(defun studlify-buffer ()
53 "Studlify-case the current buffer"
54 (interactive "*")
55 (studlify-region (point-min) (point-max)))
d501f516
ER
56
57;;; studly.el ends here