annotate lisp/progmodes/cap-words.el @ 99561:3ff54631d8b3

(x_draw_glyph_string): For stretch glyphs, don't call x_draw_glyph_string_background.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 15 Nov 2008 05:33:07 +0000
parents de1c8bf64340
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90746
8f03b3660640 *** empty log message ***
Juanma Barranquero <lekktu@gmail.com>
parents: 89911
diff changeset
1 ;;; cap-words.el --- minor mode for motion in CapitalizedWordIdentifiers
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
2
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
4 ;; Free Software Foundation, Inc.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
5
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Author: Dave Love <fx@gnu.org>
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
7 ;; Keywords: languages
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
8
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
9 ;; This file is part of GNU Emacs.
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
10
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; (at your option) any later version.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
15
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
20
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
23
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
25
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
26 ;; Provides Capitalized Words minor mode for word movement in
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;; identifiers CapitalizedLikeThis.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
28
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
29 ;; Note that the same effect could be obtained by frobbing the
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
30 ;; category of upper case characters to produce word boundaries, but
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; the necessary processing isn't done for ASCII characters.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
32
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
33 ;; Fixme: This doesn't work properly for mouse double clicks.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
34
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
35 ;;; Code:
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
36
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
37 (defun capitalized-find-word-boundary (pos limit)
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
38 "Function for use in `find-word-boundary-function-table'.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
39 Looks for word boundaries before capitals."
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
40 (save-excursion
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
41 (goto-char pos)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
42 (let (case-fold-search)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
43 (if (<= pos limit)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
44 ;; Fixme: Are these regexps the best?
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
45 (or (and (re-search-forward "\\=.\\w*[[:upper:]]"
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
46 limit t)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
47 (progn (backward-char)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
48 t))
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
49 (re-search-forward "\\>" limit t))
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
50 (or (re-search-backward "[[:upper:]]\\w*\\=" limit t)
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
51 (re-search-backward "\\<" limit t))))
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
52 (point)))
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
53
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
54
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
55 (defconst capitalized-find-word-boundary-function-table
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
56 (let ((tab (make-char-table nil)))
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
57 (set-char-table-range tab t #'capitalized-find-word-boundary)
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
58 tab)
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
59 "Assigned to `find-word-boundary-function-table' in Capitalized Words mode.")
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
60
89499
47e2e534b750 (capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents: 89311
diff changeset
61 ;;;###autoload
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
62 (define-minor-mode capitalized-words-mode
95265
de1c8bf64340 (capitalized-words-mode): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94673
diff changeset
63 "Toggle Capitalized Words mode.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
64
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
65 In this minor mode, a word boundary occurs immediately before an
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
66 uppercase letter in a symbol. This is in addition to all the normal
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
67 boundaries given by the syntax and category tables. There is no
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
68 restriction to ASCII.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
69
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
70 E.g. the beginning of words in the following identifier are as marked:
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
71
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
72 capitalizedWorDD
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
73 ^ ^ ^^
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
74
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
75 Note that these word boundaries only apply for word motion and
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
76 marking commands such as \\[forward-word]. This mode does not affect word
95265
de1c8bf64340 (capitalized-words-mode): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94673
diff changeset
77 boundaries found by regexp matching (`\\>', `\\w' &c).
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
78
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
79 This style of identifiers is common in environments like Java ones,
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
80 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
81 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
82 such a style. It is appropriate to add `capitalized-words-mode' to
95265
de1c8bf64340 (capitalized-words-mode): Fix typos in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 94673
diff changeset
83 the mode hook for programming language modes in which you encounter
89499
47e2e534b750 (capitalized-words-mode): Add autoload
Dave Love <fx@gnu.org>
parents: 89311
diff changeset
84 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
85 trouble if such identifiers aren't used.
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
86
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
87 See also `glasses-mode' and `studlify-word'.
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
88 Obsoletes `c-forward-into-nomenclature'."
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
89 nil " Caps" nil :group 'programming
91438
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
90 (set (make-local-variable 'find-word-boundary-function-table)
9341564706fb Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 90746
diff changeset
91 capitalized-find-word-boundary-function-table))
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
92
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
93 (provide 'cap-words)
89911
cce857c68ba2 Add arch taglines
Miles Bader <miles@gnu.org>
parents: 89499
diff changeset
94
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91438
diff changeset
95 ;; arch-tag: 46513b64-fe5a-4c0b-902c-ed235c22975f
89311
f81bc2f13a1b *** empty log message ***
Dave Love <fx@gnu.org>
parents:
diff changeset
96 ;;; cap-words.el ends here