Mercurial > emacs
annotate lisp/progmodes/cap-words.el @ 89573:6b5d42f51038
(x_get_font_repertory): Handle the case that the
encoding of font is other than Unicode.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 06 Oct 2003 11:23:25 +0000 |
parents | 47e2e534b750 |
children | cce857c68ba2 |
rev | line source |
---|---|
89311 | 1 ;;; cap-words.el --- minor mode for motion in CapsitalizedWordIdentifiers |
2 | |
3 ;; Copyright (C) 2002 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Dave Love <fx@gnu.org> | |
6 ;; Keywords: languages | |
7 | |
8 ;; This file is free software; you can redistribute it and/or modify | |
9 ;; it under the terms of the GNU General Public License as published by | |
10 ;; the Free Software Foundation; either version 2, or (at your option) | |
11 ;; any later version. | |
12 | |
13 ;; This file is distributed in the hope that it will be useful, | |
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 ;; GNU General Public License for more details. | |
17 | |
18 ;; You should have received a copy of the GNU General Public License | |
19 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
20 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 ;; Boston, MA 02111-1307, USA. | |
22 | |
23 ;;; Commentary: | |
24 | |
25 ;; Provides Capitalized Words minor mode for word movement in | |
26 ;; identifiers CapitalizedLikeThis. | |
27 | |
28 ;; Note that the same effect could be obtained by frobbing the | |
29 ;; category of upper case characters to produce word boundaries, but | |
30 ;; the necessary processing isn't done for ASCII characters. | |
31 | |
32 ;; Fixme: This doesn't work properly for mouse double clicks. | |
33 | |
34 ;;; Code: | |
35 | |
36 (defun capitalized-next-word-boundary (pos limit) | |
37 "Function for use in `next-word-boundary-function-table'. | |
38 Looks for word boundaries before capitals." | |
39 (save-excursion | |
40 (goto-char pos) | |
41 (let (case-fold-search) | |
42 (if (<= pos limit) | |
43 ;; Fixme: Are these regexps the best? | |
44 (or (and (re-search-forward "\\=.\\w*[[:upper:]]" | |
45 limit t) | |
46 (progn (backward-char) | |
47 t)) | |
48 (re-search-forward "\\>" limit t)) | |
49 (or (re-search-backward "[[:upper:]]\\w*\\=" limit t) | |
50 (re-search-backward "\\<" limit t)))) | |
51 (point))) | |
52 | |
53 (defconst capitalized-next-word-boundary-function-table | |
54 (let ((tab (make-char-table nil))) | |
55 (set-char-table-range tab t #'capitalized-next-word-boundary) | |
56 tab) | |
57 "Assigned to `next-word-boundary-function-table' in Capitalized Words mode.") | |
58 | |
89499
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
59 ;;;###autoload |
89311 | 60 (define-minor-mode capitalized-words-mode |
61 "Toggle Capitalized- Words mode. | |
62 | |
63 In this minor mode, a word boundary occurs immediately before an | |
64 uppercase letter in a symbol. This is in addition to all the normal | |
65 boundaries given by the syntax and category tables. There is no | |
66 restriction to ASCII. | |
67 | |
68 E.g. the beginning of words in the following identifier are as marked: | |
69 | |
70 capitalizedWorDD | |
71 ^ ^ ^^ | |
72 | |
73 Note that these word boundaries only apply for word motion and | |
74 marking commands such as \\[forward-word]. This mode does not affect word | |
75 boundaries in found by regexp matching (`\\>', `\\w' &c). | |
76 | |
77 This style of identifiers is common in environments like Java ones, | |
78 where underscores aren't trendy enough. Capitalization rules are | |
89499
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
79 sometimes part of the language, e.g. Haskell, which may thus encourage |
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
80 such a style. It is appropriate to add `capitalized-words-mode' to |
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
81 the mode hook for programming langauge modes in which you encounter |
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
82 variables like this, e.g. `java-mode-hook'. It's unlikely to cause |
47e2e534b750
(capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents:
89311
diff
changeset
|
83 trouble if such identifiers aren't used. |
89311 | 84 |
85 See also `glasses-mode' and `studlify-word'. | |
86 Obsoletes `c-forward-into-nomenclature'." | |
87 nil " Caps" nil :group 'programming | |
88 (set (make-local-variable 'next-word-boundary-function-table) | |
89 capitalized-next-word-boundary-function-table)) | |
90 | |
91 (provide 'cap-words) | |
92 ;;; cap-words.el ends here |