Mercurial > emacs
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 |
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 | 5 |
841 | 6 ;; Keywords: games |
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 | 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))) | |
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 |