Mercurial > emacs
annotate lisp/play/studly.el @ 658:7cbd4fcd8b0f
*** empty log message ***
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Sat, 30 May 1992 21:11:25 +0000 |
parents | fec3f9a1e3e5 |
children | 9b0e666dfdf8 |
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) |
2 | 2 |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
3 ;; Copyright (C) 1992 Free Software Foundation, Inc. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
4 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; This file is part of GNU Emacs. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
7 ;; GNU Emacs is free software; you can redistribute it and/or modify |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
8 ;; it under the terms of the GNU General Public License as published by |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
9 ;; the Free Software Foundation; either version 1, or (at your option) |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
10 ;; any later version. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
11 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
12 ;; GNU Emacs is distributed in the hope that it will be useful, |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
15 ;; GNU General Public License for more details. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
16 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
17 ;; You should have received a copy of the GNU General Public License |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
18 ;; along with GNU Emacs; see the file COPYING. If not, write to |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
20 |
2 | 21 (defun studlify-region (begin end) |
22 "Studlify-case the region" | |
23 (interactive "*r") | |
24 (save-excursion | |
25 (goto-char begin) | |
26 (setq begin (point)) | |
27 (while (and (<= (point) end) | |
28 (not (looking-at "\\W*\\'"))) | |
29 (forward-word 1) | |
30 (backward-word 1) | |
31 (setq begin (max (point) begin)) | |
32 (forward-word 1) | |
33 (let ((offset 0) | |
34 (word-end (min (point) end)) | |
35 c) | |
36 (goto-char begin) | |
37 (while (< (point) word-end) | |
38 (setq offset (+ offset (following-char))) | |
39 (forward-char 1)) | |
40 (setq offset (+ offset (following-char))) | |
41 (goto-char begin) | |
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))))) | |
48 (progn | |
49 (delete-char 1) | |
50 (insert (logxor c ? )))) | |
51 (forward-char 1)) | |
52 (setq begin (point)))))) | |
53 | |
54 (defun studlify-word (count) | |
55 "Studlify-case the current word, or COUNT words if given an argument" | |
56 (interactive "*p") | |
57 (let ((begin (point)) end rb re) | |
58 (forward-word count) | |
59 (setq end (point)) | |
60 (setq rb (min begin end) re (max begin end)) | |
61 (studlify-region rb re))) | |
62 | |
63 (defun studlify-buffer () | |
64 "Studlify-case the current buffer" | |
65 (interactive "*") | |
66 (studlify-region (point-min) (point-max))) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
67 |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
68 ;;; studly.el ends here |