annotate lisp/progmodes/cc-subword.el @ 85100:c04703192cb6

(diff-hunk-style): New fun. (diff-end-of-hunk): Use it. (diff-context->unified): Use the new `apply' undo element, if applicable, so as to save undo-log space. (diff-fine-change): New face. (diff-fine-highlight-preproc): New function. (diff-fine-highlight): New command.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 09 Oct 2007 04:12:24 +0000
parents c1ec1c8a8d2e
children a1342e6e097a 5405672da978
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
1 ;;; cc-subword.el --- Handling capitalized subwords in a nomenclature
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
2
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 70649
diff changeset
3 ;; Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
4
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
5 ;; Author: Masatake YAMATO
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
6
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
7 ;; This program is free software; you can redistribute it and/or modify
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
78234
c1ec1c8a8d2e Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77083
diff changeset
9 ;; the Free Software Foundation; either version 3, or (at your option)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
10 ;; any later version.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
11
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
12 ;; This program is distributed in the hope that it will be useful,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
15 ;; GNU General Public License for more details.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
16
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
18 ;; along with this program; see the file COPYING. If not, write to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
19 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
20 ;; Boston, MA 02110-1301, USA.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
21
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
22 ;;; Commentary:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
23
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
24 ;; This package provides `subword' oriented commands and a minor mode
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
25 ;; (`c-subword-mode') that substitutes the common word handling
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
26 ;; functions with them.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
27
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
28 ;; In spite of GNU Coding Standards, it is popular to name a symbol by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
29 ;; mixing uppercase and lowercase letters, e.g. "GtkWidget",
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
30 ;; "EmacsFrameClass", "NSGraphicsContext", etc. Here we call these
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
31 ;; mixed case symbols `nomenclatures'. Also, each capitalized (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
32 ;; completely uppercase) part of a nomenclature is called a `subword'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
33 ;; Here are some examples:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
34
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
35 ;; Nomenclature Subwords
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
36 ;; ===========================================================
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
37 ;; GtkWindow => "Gtk" and "Window"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
38 ;; EmacsFrameClass => "Emacs", "Frame" and "Class"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
39 ;; NSGraphicsContext => "NS", "Graphics" and "Context"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
40
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
41 ;; The subword oriented commands defined in this package recognize
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
42 ;; subwords in a nomenclature to move between them and to edit them as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
43 ;; words.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
44
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
45 ;; In the minor mode, all common key bindings for word oriented
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
46 ;; commands are overridden by the subword oriented commands:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
47
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
48 ;; Key Word oriented command Subword oriented command
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
49 ;; ============================================================
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
50 ;; M-f `forward-word' `c-forward-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
51 ;; M-b `backward-word' `c-backward-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
52 ;; M-@ `mark-word' `c-mark-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
53 ;; M-d `kill-word' `c-kill-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
54 ;; M-DEL `backward-kill-word' `c-backward-kill-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
55 ;; M-t `transpose-words' `c-transpose-subwords'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
56 ;; M-c `capitalize-word' `c-capitalize-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
57 ;; M-u `upcase-word' `c-upcase-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
58 ;; M-l `downcase-word' `c-downcase-subword'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
59 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
60 ;; Note: If you have changed the key bindings for the word oriented
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
61 ;; commands in your .emacs or a similar place, the keys you've changed
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
62 ;; to are also used for the corresponding subword oriented commands.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
63
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
64 ;; To make the mode turn on automatically, put the following code in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
65 ;; your .emacs:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
66 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
67 ;; (add-hook 'c-mode-common-hook
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
68 ;; (lambda () (c-subword-mode 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
69 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
70
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
71 ;; Acknowledgment:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
72 ;; The regular expressions to detect subwords are mostly based on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
73 ;; the old `c-forward-into-nomenclature' originally contributed by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
74 ;; Terry_Glanfield dot Southern at rxuk dot xerox dot com.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
75
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
76 ;; TODO: ispell-word and subword oriented C-w in isearch.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
77
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
78 ;;; Code:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
79
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
80 (eval-when-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
81 (let ((load-path
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
82 (if (and (boundp 'byte-compile-dest-file)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
83 (stringp byte-compile-dest-file))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
84 (cons (file-name-directory byte-compile-dest-file) load-path)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
85 load-path)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
86 (load "cc-bytecomp" nil t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
87
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
88 (cc-require 'cc-defs)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
89 (cc-require 'cc-cmds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
90
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
91 ;; Don't complain about the `define-minor-mode' form if it isn't defined.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
92 (cc-bytecomp-defvar c-subword-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
93
70239
ad23aa667a59 Fixup commenting convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70238
diff changeset
94 ;; Autoload directives must be on the top level, so we construct an
ad23aa667a59 Fixup commenting convention.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70238
diff changeset
95 ;; autoload form instead.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
96 ;;;###autoload (autoload 'c-subword-mode "cc-subword" "Mode enabling subword movement and editing keys." t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
97
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
98 (if (not (fboundp 'define-minor-mode))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
99 (defun c-subword-mode ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
100 "(Missing) mode enabling subword movement and editing keys.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
101 This mode is not (yet) available in this version of (X)Emacs. Sorry! If
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
102 you really want it, please send a request to <bug-gnu-emacs@gnu.org>,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
103 telling us which (X)Emacs version you're using."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
104 (interactive)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
105 (error
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
106 "c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
107
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
108 (defvar c-subword-mode-map
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
109 (let ((map (make-sparse-keymap)))
70238
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
110 (dolist (cmd '(forward-word backward-word mark-word
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
111 kill-word backward-kill-word
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
112 transpose-words
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
113 capitalize-word upcase-word downcase-word))
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
114 (let ((othercmd (let ((name (symbol-name cmd)))
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
115 (string-match "\\(.*-\\)\\(word.*\\)" name)
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
116 (intern (concat "c-"
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
117 (match-string 1 name)
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
118 "sub"
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
119 (match-string 2 name))))))
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
120 (if (fboundp 'command-remapping)
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
121 (define-key map (vector 'remap cmd) othercmd)
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
122 (substitute-key-definition cmd othercmd map global-map))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
123 map)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
124 "Keymap used in command `c-subword-mode' minor mode.")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
125
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
126 (define-minor-mode c-subword-mode
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
127 "Mode enabling subword movement and editing keys.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
128 In spite of GNU Coding Standards, it is popular to name a symbol by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
129 mixing uppercase and lowercase letters, e.g. \"GtkWidget\",
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
130 \"EmacsFrameClass\", \"NSGraphicsContext\", etc. Here we call these
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
131 mixed case symbols `nomenclatures'. Also, each capitalized (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
132 completely uppercase) part of a nomenclature is called a `subword'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
133 Here are some examples:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
134
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
135 Nomenclature Subwords
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
136 ===========================================================
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
137 GtkWindow => \"Gtk\" and \"Window\"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
138 EmacsFrameClass => \"Emacs\", \"Frame\" and \"Class\"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
139 NSGraphicsContext => \"NS\", \"Graphics\" and \"Context\"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
140
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
141 The subword oriented commands activated in this minor mode recognize
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
142 subwords in a nomenclature to move between subwords and to edit them
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
143 as words.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
144
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
145 \\{c-subword-mode-map}"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
146 nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
147 nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
148 c-subword-mode-map
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
149 (c-update-modeline))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
150
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
151 )
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
152
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
153 (defun c-forward-subword (&optional arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
154 "Do the same as `forward-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
155 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
156 Optional argument ARG is the same as for `forward-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
157 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
158 (unless arg (setq arg 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
159 (c-keep-region-active)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
160 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
161 ((< 0 arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
162 (dotimes (i arg (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
163 (c-forward-subword-internal)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
164 ((> 0 arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
165 (dotimes (i (- arg) (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
166 (c-backward-subword-internal)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
167 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
168 (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
169
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
170 (put 'c-forward-subword 'CUA 'move)
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
171
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
172 (defun c-backward-subword (&optional arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
173 "Do the same as `backward-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
174 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
175 Optional argument ARG is the same as for `backward-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
176 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
177 (c-forward-subword (- (or arg 1))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
178
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
179 (defun c-mark-subword (arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
180 "Do the same as `mark-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
181 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
182 Optional argument ARG is the same as for `mark-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
183 ;; This code is almost copied from `mark-word' in GNU Emacs.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
184 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
185 (cond ((and (eq last-command this-command) (mark t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
186 (set-mark
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
187 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
188 (goto-char (mark))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
189 (c-forward-subword arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
190 (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
191 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
192 (push-mark
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
193 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
194 (c-forward-subword arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
195 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
196 nil t))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
197
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
198 (put 'c-backward-subword 'CUA 'move)
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
199
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
200 (defun c-kill-subword (arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
201 "Do the same as `kill-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
202 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
203 Optional argument ARG is the same as for `kill-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
204 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
205 (kill-region (point) (c-forward-subword arg)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
206
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
207 (defun c-backward-kill-subword (arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
208 "Do the same as `backward-kill-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
209 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
210 Optional argument ARG is the same as for `backward-kill-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
211 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
212 (c-kill-subword (- arg)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
213
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
214 (defun c-transpose-subwords (arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
215 "Do the same as `transpose-words' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
216 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
217 Optional argument ARG is the same as for `transpose-words'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
218 (interactive "*p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
219 (transpose-subr 'c-forward-subword arg))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
220
77082
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
221
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
222
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
223 (defun c-downcase-subword (arg)
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
224 "Do the same as `downcase-word' but on subwords.
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
225 See the command `c-subword-mode' for a description of subwords.
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
226 Optional argument ARG is the same as for `downcase-word'."
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
227 (interactive "p")
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
228 (let ((start (point)))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
229 (downcase-region (point) (c-forward-subword arg))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
230 (when (< arg 0)
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
231 (goto-char start))))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
232
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
233 (defun c-upcase-subword (arg)
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
234 "Do the same as `upcase-word' but on subwords.
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
235 See the command `c-subword-mode' for a description of subwords.
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
236 Optional argument ARG is the same as for `upcase-word'."
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
237 (interactive "p")
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
238 (let ((start (point)))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
239 (upcase-region (point) (c-forward-subword arg))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
240 (when (< arg 0)
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
241 (goto-char start))))
c783ccac00cf Install a patch from Paul Curry.
Masatake YAMATO <jet@gyve.org>
parents: 75347
diff changeset
242
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
243 (defun c-capitalize-subword (arg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
244 "Do the same as `capitalize-word' but on subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
245 See the command `c-subword-mode' for a description of subwords.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
246 Optional argument ARG is the same as for `capitalize-word'."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
247 (interactive "p")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
248 (let ((count (abs arg))
77083
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
249 (start (point))
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
250 (advance (if (< arg 0) nil t)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
251 (dotimes (i count)
77083
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
252 (if advance
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
253 (progn (re-search-forward
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
254 (concat "[" c-alpha "]")
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
255 nil t)
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
256 (goto-char (match-beginning 0)))
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
257 (c-backward-subword))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
258 (let* ((p (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
259 (pp (1+ p))
77083
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
260 (np (c-forward-subword)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
261 (upcase-region p pp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
262 (downcase-region pp np)
77083
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
263 (goto-char (if advance np p))))
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
264 (unless advance
304a180098d2 (c-capitalize-subword): Implement
Masatake YAMATO <jet@gyve.org>
parents: 77082
diff changeset
265 (goto-char start))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
266
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
267
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
268
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
269 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
270 ;; Internal functions
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
271 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
272 (defun c-forward-subword-internal ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
273 (if (and
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
274 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
275 (let ((case-fold-search nil))
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
276 (re-search-forward
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
277 (concat "\\W*\\(\\([" c-upper "]*\\W?\\)[" c-lower c-digit "]*\\)")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
278 nil t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
279 (> (match-end 0) (point))) ; So we don't get stuck at a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
280 ; "word-constituent" which isn't c-upper,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
281 ; c-lower or c-digit
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
282 (goto-char
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
283 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
284 ((< 1 (- (match-end 2) (match-beginning 2)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
285 (1- (match-end 2)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
286 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
287 (match-end 0))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
288 (forward-word 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
289
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
290
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
291 (defun c-backward-subword-internal ()
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
292 (if (save-excursion
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
293 (let ((case-fold-search nil))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
294 (re-search-backward
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
295 (concat
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
296 "\\(\\(\\W\\|[" c-lower c-digit "]\\)\\([" c-upper "]+\\W*\\)"
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
297 "\\|\\W\\w+\\)")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
298 nil t)))
70649
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
299 (goto-char
4cc85f377783 (c-forward-subword, c-backward-subword):
Kim F. Storm <storm@cua.dk>
parents: 70239
diff changeset
300 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
301 ((and (match-end 3)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
302 (< 1 (- (match-end 3) (match-beginning 3)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
303 (not (eq (point) (match-end 3))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
304 (1- (match-end 3)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
305 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
306 (1+ (match-beginning 0)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
307 (backward-word 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
308
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
309
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
310 (cc-provide 'cc-subword)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
311
70238
1be7d556ba69 (c-subword-mode-map): Use command remapping.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
312 ;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents:
diff changeset
313 ;;; cc-subword.el ends here