annotate lisp/play/studly.el @ 1371:d8be1fdf53aa

Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Fri, 09 Oct 1992 05:29:15 +0000
parents 2cdce064065f
children 9e7ec92a4fdf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2
diff changeset
1 ;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 665
diff changeset
2
665
f9274ecd9acd *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 664
diff changeset
3 ;;; This is in the public domain, since it was distributed
f9274ecd9acd *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 664
diff changeset
4 ;;; by its author without a copyright notice in 1986.
2
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
6 ;; Keywords: games
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
7
787
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 665
diff changeset
8 ;;; Code:
3cece0106722 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 665
diff changeset
9
2
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 (defun studlify-region (begin end)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 "Studlify-case the region"
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 (interactive "*r")
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 (save-excursion
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 (goto-char begin)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 (setq begin (point))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 (while (and (<= (point) end)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 (not (looking-at "\\W*\\'")))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 (forward-word 1)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 (backward-word 1)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 (setq begin (max (point) begin))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 (forward-word 1)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 (let ((offset 0)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 (word-end (min (point) end))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 c)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 (goto-char begin)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 (while (< (point) word-end)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 (setq offset (+ offset (following-char)))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 (forward-char 1))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 (setq offset (+ offset (following-char)))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 (goto-char begin)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 (while (< (point) word-end)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (setq c (following-char))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 (if (and (= (% (+ c offset) 4) 2)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (let ((ch (following-char)))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 (or (and (>= ch ?a) (<= ch ?z))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (and (>= ch ?A) (<= ch ?Z)))))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 (progn
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 (delete-char 1)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 (insert (logxor c ? ))))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 (forward-char 1))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 (setq begin (point))))))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 (defun studlify-word (count)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 "Studlify-case the current word, or COUNT words if given an argument"
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (interactive "*p")
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 (let ((begin (point)) end rb re)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (forward-word count)
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (setq end (point))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (setq rb (min begin end) re (max begin end))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 (studlify-region rb re)))
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 (defun studlify-buffer ()
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 "Studlify-case the current buffer"
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (interactive "*")
9b11cd9e3ba8 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (studlify-region (point-min) (point-max)))
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2
diff changeset
56
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2
diff changeset
57 ;;; studly.el ends here