aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorDave Love2002-12-01 12:19:36 +0000
committerDave Love2002-12-01 12:19:36 +0000
commitf7ab7a26d62e07f38fd1447cd45cb4ed360f8d00 (patch)
tree821ff79e5020d4c72e13dc4ba66fbc89b890125f /lisp
parent8395d85077eae6904e37bdee1b97e44561a7d47d (diff)
downloademacs-f7ab7a26d62e07f38fd1447cd45cb4ed360f8d00.tar.gz
emacs-f7ab7a26d62e07f38fd1447cd45cb4ed360f8d00.zip
*** empty log message ***
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/progmodes/cap-words.el91
2 files changed, 95 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bb797871554..0b60fdad54c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12002-12-01 Dave Love <fx@gnu.org>
2
3 * progmodes/cap-words.el: New file.
4
12002-11-07 Kenichi Handa <handa@m17n.org> 52002-11-07 Kenichi Handa <handa@m17n.org>
2 6
3 The following changes are to make character composition happen 7 The following changes are to make character composition happen
diff --git a/lisp/progmodes/cap-words.el b/lisp/progmodes/cap-words.el
new file mode 100644
index 00000000000..eb6da529371
--- /dev/null
+++ b/lisp/progmodes/cap-words.el
@@ -0,0 +1,91 @@
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'.
38Looks 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
59(define-minor-mode capitalized-words-mode
60 "Toggle Capitalized- Words mode.
61
62In this minor mode, a word boundary occurs immediately before an
63uppercase letter in a symbol. This is in addition to all the normal
64boundaries given by the syntax and category tables. There is no
65restriction to ASCII.
66
67E.g. the beginning of words in the following identifier are as marked:
68
69 capitalizedWorDD
70 ^ ^ ^^
71
72Note that these word boundaries only apply for word motion and
73marking commands such as \\[forward-word]. This mode does not affect word
74boundaries in found by regexp matching (`\\>', `\\w' &c).
75
76This style of identifiers is common in environments like Java ones,
77where underscores aren't trendy enough. Capitalization rules are
78sometimes part of the language, e.g. Haskell, which may encourage such
79a style. It is appropriate to add `capitalized-words-mode' to the
80mode hook for programming langauge modes in which you encounter such
81variables, e.g. `java-mode-hook', since it's unlikely to cause trouble
82if such identifiers aren't used.
83
84See also `glasses-mode' and `studlify-word'.
85Obsoletes `c-forward-into-nomenclature'."
86 nil " Caps" nil :group 'programming
87 (set (make-local-variable 'next-word-boundary-function-table)
88 capitalized-next-word-boundary-function-table))
89
90(provide 'cap-words)
91;;; cap-words.el ends here