Mercurial > emacs
annotate lisp/play/studly.el @ 38469:38c0279a4af4
(display-images-p): New function.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Tue, 17 Jul 2001 12:58:19 +0000 |
parents | 67b464da13ec |
children | 01c7199c0ee7 |
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) |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
665
diff
changeset
|
2 |
665
f9274ecd9acd
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
664
diff
changeset
|
3 ;;; This is in the public domain, since it was distributed |
f9274ecd9acd
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
664
diff
changeset
|
4 ;;; by its author without a copyright notice in 1986. |
2 | 5 |
38414
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32297
diff
changeset
|
6 ;; This file is part of GNU Emacs. |
67b464da13ec
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
32297
diff
changeset
|
7 |
841 | 8 ;; Keywords: games |
9 | |
2315
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
10 ;;; Commentary: |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
11 |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
12 ;; Functions to studlycapsify a region, word, or buffer. Possibly the |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
13 ;; esoteric significance of studlycapsification escapes you; that is, |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
14 ;; you suffer from autostudlycapsifibogotification. Too bad. |
9e7ec92a4fdf
Added or corrected Commentary headers
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
841
diff
changeset
|
15 |
787
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
665
diff
changeset
|
16 ;;; Code: |
3cece0106722
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
665
diff
changeset
|
17 |
32297
5a9159a46fe5
(studlify-region, studlify-word): Add autoload
Dave Love <fx@gnu.org>
parents:
18383
diff
changeset
|
18 ;;;###autoload |
2 | 19 (defun studlify-region (begin end) |
20 "Studlify-case the region" | |
21 (interactive "*r") | |
22 (save-excursion | |
23 (goto-char begin) | |
24 (setq begin (point)) | |
25 (while (and (<= (point) end) | |
26 (not (looking-at "\\W*\\'"))) | |
27 (forward-word 1) | |
28 (backward-word 1) | |
29 (setq begin (max (point) begin)) | |
30 (forward-word 1) | |
31 (let ((offset 0) | |
32 (word-end (min (point) end)) | |
33 c) | |
34 (goto-char begin) | |
35 (while (< (point) word-end) | |
36 (setq offset (+ offset (following-char))) | |
37 (forward-char 1)) | |
38 (setq offset (+ offset (following-char))) | |
39 (goto-char begin) | |
40 (while (< (point) word-end) | |
41 (setq c (following-char)) | |
42 (if (and (= (% (+ c offset) 4) 2) | |
43 (let ((ch (following-char))) | |
44 (or (and (>= ch ?a) (<= ch ?z)) | |
45 (and (>= ch ?A) (<= ch ?Z))))) | |
46 (progn | |
47 (delete-char 1) | |
48 (insert (logxor c ? )))) | |
49 (forward-char 1)) | |
50 (setq begin (point)))))) | |
51 | |
32297
5a9159a46fe5
(studlify-region, studlify-word): Add autoload
Dave Love <fx@gnu.org>
parents:
18383
diff
changeset
|
52 ;;;###autoload |
2 | 53 (defun studlify-word (count) |
54 "Studlify-case the current word, or COUNT words if given an argument" | |
55 (interactive "*p") | |
56 (let ((begin (point)) end rb re) | |
57 (forward-word count) | |
58 (setq end (point)) | |
59 (setq rb (min begin end) re (max begin end)) | |
60 (studlify-region rb re))) | |
61 | |
62 (defun studlify-buffer () | |
63 "Studlify-case the current buffer" | |
64 (interactive "*") | |
65 (studlify-region (point-min) (point-max))) | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
66 |
18383 | 67 (provide 'studly) |
68 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2
diff
changeset
|
69 ;;; studly.el ends here |