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