1 ;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
3 ;; This is in the public domain, since it was distributed
4 ;; by its author without a copyright notice in 1986.
8 ;; This file is part of XEmacs.
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)
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.
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
25 ;;; Synched up with: Not in FSF
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.
35 (defun studlify-region (begin end)
36 "Studlify-case the region"
41 (while (re-search-forward "\\w+" end t)
42 (let ((rnd (loop for pos from (match-beginning 0) to (match-end 0)
43 sum (or (char-after pos) 0))))
44 (loop for pos from (match-beginning 0) to (1- (match-end 0)) do
45 (let ((c (char-after pos)))
46 (when (= (% (+ c rnd) 4) 2)
48 (downcase-region pos (1+ pos))
49 (upcase-region pos (1+ pos)))
52 (defun studlify-word (count)
53 "Studlify-case the current word, or COUNT words if given an argument"
55 (let ((begin (point)) end rb re)
58 (setq rb (min begin end) re (max begin end))
59 (studlify-region rb re)))
61 (defun studlify-buffer ()
62 "Studlify-case the current buffer"
64 (studlify-region (point-min) (point-max)))
66 ;;; studly.el ends here