Mercurial > emacs
annotate lisp/play/studly.el @ 696:904853a03d9a
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 07 Jun 1992 04:20:03 +0000 |
parents | f9274ecd9acd |
children | 3cece0106722 |
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) |
665
f9274ecd9acd
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
664
diff
changeset
|
2 ;;; This is in the public domain, since it was distributed |
f9274ecd9acd
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
664
diff
changeset
|
3 ;;; by its author without a copyright notice in 1986. |
2 | 4 |
5 (defun studlify-region (begin end) | |
6 "Studlify-case the region" | |
7 (interactive "*r") | |
8 (save-excursion | |
9 (goto-char begin) | |
10 (setq begin (point)) | |
11 (while (and (<= (point) end) | |
12 (not (looking-at "\\W*\\'"))) | |
13 (forward-word 1) | |
14 (backward-word 1) | |
15 (setq begin (max (point) begin)) | |
16 (forward-word 1) | |
17 (let ((offset 0) | |
18 (word-end (min (point) end)) | |
19 c) | |
20 (goto-char begin) | |
21 (while (< (point) word-end) | |
22 (setq offset (+ offset (following-char))) | |
23 (forward-char 1)) | |
24 (setq offset (+ offset (following-char))) | |
25 (goto-char begin) | |
26 (while (< (point) word-end) | |
27 (setq c (following-char)) | |
28 (if (and (= (% (+ c offset) 4) 2) | |
29 (let ((ch (following-char))) | |
30 (or (and (>= ch ?a) (<= ch ?z)) | |
31 (and (>= ch ?A) (<= ch ?Z))))) | |
32 (progn | |
33 (delete-char 1) | |
34 (insert (logxor c ? )))) | |
35 (forward-char 1)) | |
36 (setq begin (point)))))) | |
37 | |
38 (defun studlify-word (count) | |
39 "Studlify-case the current word, or COUNT words if given an argument" | |
40 (interactive "*p") | |
41 (let ((begin (point)) end rb re) | |
42 (forward-word count) | |
43 (setq end (point)) | |
44 (setq rb (min begin end) re (max begin end)) | |
45 (studlify-region rb re))) | |
46 | |
47 (defun studlify-buffer () | |
48 "Studlify-case the current buffer" | |
49 (interactive "*") | |
50 (studlify-region (point-min) (point-max))) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
51 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
52 ;;; studly.el ends here |