1 ;;; studly.el --- StudlyCaps (tm)(r)(c)(xxx)
3 ;; Copyright (C) 1992 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 1, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 (defun studlify-region (begin end)
22 "Studlify-case the region"
27 (while (and (<= (point) end)
28 (not (looking-at "\\W*\\'")))
31 (setq begin (max (point) begin))
34 (word-end (min (point) end))
37 (while (< (point) word-end)
38 (setq offset (+ offset (following-char)))
40 (setq offset (+ offset (following-char)))
42 (while (< (point) word-end)
43 (setq c (following-char))
44 (if (and (= (% (+ c offset) 4) 2)
45 (let ((ch (following-char)))
46 (or (and (>= ch ?a) (<= ch ?z))
47 (and (>= ch ?A) (<= ch ?Z)))))
50 (insert (logxor c ? ))))
52 (setq begin (point))))))
54 (defun studlify-word (count)
55 "Studlify-case the current word, or COUNT words if given an argument"
57 (let ((begin (point)) end rb re)
60 (setq rb (min begin end) re (max begin end))
61 (studlify-region rb re)))
63 (defun studlify-buffer ()
64 "Studlify-case the current buffer"
66 (studlify-region (point-min) (point-max)))
68 ;;; studly.el ends here