annotate lisp/games/studly.el @ 39:06f275776fba

Added tag r19-15b102 for changeset 1a767b41a199
author cvs
date Mon, 13 Aug 2007 08:54:02 +0200
parents b82b59fe008d
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
3 ;; This is in the public domain, since it was distributed
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
4 ;; by its author without a copyright notice in 1986.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: games
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
8 ;; This file is part of XEmacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
9
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
11 ;; under the terms of the GNU General Public License as published by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
13 ;; any later version.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
14
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
18 ;; General Public License for more details.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
19
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
24
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
25 ;;; Synched up with: Not in FSF
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
26
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; Functions to studlycapsify a region, word, or buffer. Possibly the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; esoteric significance of studlycapsification escapes you; that is,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; you suffer from autostudlycapsifibogotification. Too bad.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defun studlify-region (begin end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "Studlify-case the region"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (interactive "*r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (setq begin (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (while (and (<= (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (not (looking-at "\\W*\\'")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (backward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (setq begin (max (point) begin))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (forward-word 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let ((offset 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (word-end (min (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (while (< (point) word-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (setq offset (+ offset (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq offset (+ offset (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (goto-char begin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (while (< (point) word-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (setq c (following-char))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (if (and (= (% (+ c offset) 4) 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (let ((ch (following-char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (or (and (>= ch ?a) (<= ch ?z))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (and (>= ch ?A) (<= ch ?Z)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (delete-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (insert (logxor c ? ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (forward-char 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (setq begin (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun studlify-word (count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "Studlify-case the current word, or COUNT words if given an argument"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (interactive "*p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (let ((begin (point)) end rb re)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (forward-word count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (setq rb (min begin end) re (max begin end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (studlify-region rb re)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defun studlify-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "Studlify-case the current buffer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (interactive "*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (studlify-region (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;;; studly.el ends here