diff options
| -rw-r--r-- | lisp/ChangeLog | 27 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 20 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 4 | ||||
| -rw-r--r-- | lisp/subword.el (renamed from lisp/progmodes/cc-subword.el) | 157 |
5 files changed, 113 insertions, 101 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a05579268bf..6c3cab24033 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,30 @@ | |||
| 1 | 2009-11-20 Tassilo Horn <tassilo@member.fsf.org> | ||
| 2 | |||
| 3 | * progmodes/cc-cmds.el (c-update-modeline) | ||
| 4 | (c-forward-into-nomenclature, c-backward-into-nomenclature): Refer | ||
| 5 | to subword.el functions instead of cc-subword.el. | ||
| 6 | |||
| 7 | * progmodes/cc-mode.el (subword-mode, c-mode-base-map): Refer to | ||
| 8 | subword.el functions instead of cc-subword.el. | ||
| 9 | |||
| 10 | * progmodes/cc-subword.el: Renamed to subword.el. | ||
| 11 | * subword.el: Renamed from progmodes/cc-subword.el. | ||
| 12 | (subword-mode-map): Renamed from c-subword-mode-map. | ||
| 13 | (subword-mode): Renamed from c-subword-mode. | ||
| 14 | (global-subword-mode): New global minor mode. | ||
| 15 | (forward-subword): Renamed from c-forward-subword. | ||
| 16 | (backward-subword): Renamed from c-backward-subword. | ||
| 17 | (mark-subword): Renamed from c-mark-subword. | ||
| 18 | (kill-subword): Renamed from c-kill-subword. | ||
| 19 | (backward-kill-subword): Renamed from c-backward-kill-subword. | ||
| 20 | (transpose-subwords): Renamed from c-tranpose-subword. | ||
| 21 | (downcase-subword): Renamed from c-downcase-subword. | ||
| 22 | (capitalize-subword): Renamed from c-capitalize-subword. | ||
| 23 | (forward-subword-internal): Renamed from | ||
| 24 | c-forward-subword-internal. | ||
| 25 | (backward-subword-internal): Renamed from | ||
| 26 | c-backward-subword-internal. | ||
| 27 | |||
| 1 | 2009-11-20 Dan Nicolaescu <dann@ics.uci.edu> | 28 | 2009-11-20 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 29 | ||
| 3 | * vc.el (vc-deduce-fileset): Allow non-state changing operations | 30 | * vc.el (vc-deduce-fileset): Allow non-state changing operations |
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index bd41e1c7c87..e356089d4ad 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -50,8 +50,6 @@ | |||
| 50 | (cc-bytecomp-defun delete-forward-p) ; XEmacs | 50 | (cc-bytecomp-defun delete-forward-p) ; XEmacs |
| 51 | (cc-bytecomp-defvar filladapt-mode) ; c-fill-paragraph contains a kludge | 51 | (cc-bytecomp-defvar filladapt-mode) ; c-fill-paragraph contains a kludge |
| 52 | ; which looks at this. | 52 | ; which looks at this. |
| 53 | (cc-bytecomp-defun c-forward-subword) | ||
| 54 | (cc-bytecomp-defun c-backward-subword) | ||
| 55 | 53 | ||
| 56 | ;; Indentation / Display syntax functions | 54 | ;; Indentation / Display syntax functions |
| 57 | (defvar c-fix-backslashes t) | 55 | (defvar c-fix-backslashes t) |
| @@ -263,9 +261,9 @@ With universal argument, inserts the analysis as a comment on that line." | |||
| 263 | "a" "") | 261 | "a" "") |
| 264 | (if c-hungry-delete-key "h" "") | 262 | (if c-hungry-delete-key "h" "") |
| 265 | (if (and | 263 | (if (and |
| 266 | ;; cc-subword might not be loaded. | 264 | ;; subword might not be loaded. |
| 267 | (boundp 'c-subword-mode) | 265 | (boundp 'subword-mode) |
| 268 | (symbol-value 'c-subword-mode)) | 266 | (symbol-value 'subword-mode)) |
| 269 | "w" | 267 | "w" |
| 270 | ""))) | 268 | ""))) |
| 271 | (bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name) | 269 | (bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name) |
| @@ -1328,16 +1326,16 @@ keyword on the line, the keyword is not inserted inside a literal, and | |||
| 1328 | (defun c-forward-into-nomenclature (&optional arg) | 1326 | (defun c-forward-into-nomenclature (&optional arg) |
| 1329 | "Compatibility alias for `c-forward-subword'." | 1327 | "Compatibility alias for `c-forward-subword'." |
| 1330 | (interactive "p") | 1328 | (interactive "p") |
| 1331 | (require 'cc-subword) | 1329 | (require 'subword) |
| 1332 | (c-forward-subword arg)) | 1330 | (forward-subword arg)) |
| 1333 | (make-obsolete 'c-forward-into-nomenclature 'c-forward-subword "22.1") | 1331 | (make-obsolete 'c-forward-into-nomenclature 'forward-subword "23.2") |
| 1334 | 1332 | ||
| 1335 | (defun c-backward-into-nomenclature (&optional arg) | 1333 | (defun c-backward-into-nomenclature (&optional arg) |
| 1336 | "Compatibility alias for `c-backward-subword'." | 1334 | "Compatibility alias for `c-backward-subword'." |
| 1337 | (interactive "p") | 1335 | (interactive "p") |
| 1338 | (require 'cc-subword) | 1336 | (require 'subword) |
| 1339 | (c-backward-subword arg)) | 1337 | (backward-subword arg)) |
| 1340 | (make-obsolete 'c-backward-into-nomenclature 'c-backward-subword "22.1") | 1338 | (make-obsolete 'c-backward-into-nomenclature 'backward-subword "23.2") |
| 1341 | 1339 | ||
| 1342 | (defun c-scope-operator () | 1340 | (defun c-scope-operator () |
| 1343 | "Insert a double colon scope operator at point. | 1341 | "Insert a double colon scope operator at point. |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 0e0eca228bc..e6fcd2f85e2 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -306,9 +306,9 @@ the evaluated constant value at compile time." | |||
| 306 | :style toggle :selected c-auto-newline] | 306 | :style toggle :selected c-auto-newline] |
| 307 | ["Hungry delete" c-toggle-hungry-state | 307 | ["Hungry delete" c-toggle-hungry-state |
| 308 | :style toggle :selected c-hungry-delete-key] | 308 | :style toggle :selected c-hungry-delete-key] |
| 309 | ["Subword mode" c-subword-mode | 309 | ["Subword mode" subword-mode |
| 310 | :style toggle :selected (and (boundp 'c-subword-mode) | 310 | :style toggle :selected (and (boundp 'subword-mode) |
| 311 | c-subword-mode)]))) | 311 | subword-mode)]))) |
| 312 | 312 | ||
| 313 | 313 | ||
| 314 | ;;; Syntax tables. | 314 | ;;; Syntax tables. |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index 8d7ac9241f6..2bf725f1bc3 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -113,7 +113,7 @@ | |||
| 113 | 113 | ||
| 114 | ;; Autoload directive for emacsen that doesn't have an older CC Mode | 114 | ;; Autoload directive for emacsen that doesn't have an older CC Mode |
| 115 | ;; version in the dist. | 115 | ;; version in the dist. |
| 116 | (autoload 'c-subword-mode "cc-subword" | 116 | (autoload 'subword-mode "subword" |
| 117 | "Mode enabling subword movement and editing keys." t) | 117 | "Mode enabling subword movement and editing keys." t) |
| 118 | 118 | ||
| 119 | ;; Load cc-fonts first after font-lock is loaded, since it isn't | 119 | ;; Load cc-fonts first after font-lock is loaded, since it isn't |
| @@ -379,7 +379,7 @@ control). See \"cc-mode.el\" for more info." | |||
| 379 | ;; conflicts with OOBR | 379 | ;; conflicts with OOBR |
| 380 | ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) | 380 | ;;(define-key c-mode-base-map "\C-c\C-v" 'c-version) |
| 381 | ;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22. | 381 | ;; (define-key c-mode-base-map "\C-c\C-y" 'c-toggle-hungry-state) Commented out by ACM, 2005-11-22. |
| 382 | (define-key c-mode-base-map "\C-c\C-w" 'c-subword-mode) | 382 | (define-key c-mode-base-map "\C-c\C-w" 'subword-mode) |
| 383 | ) | 383 | ) |
| 384 | 384 | ||
| 385 | ;; We don't require the outline package, but we configure it a bit anyway. | 385 | ;; We don't require the outline package, but we configure it a bit anyway. |
diff --git a/lisp/progmodes/cc-subword.el b/lisp/subword.el index 01ad937f516..0b22c135701 100644 --- a/lisp/progmodes/cc-subword.el +++ b/lisp/subword.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; cc-subword.el --- Handling capitalized subwords in a nomenclature | 1 | ;;; subword.el --- Handling capitalized subwords in a nomenclature |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -21,8 +21,11 @@ | |||
| 21 | 21 | ||
| 22 | ;;; Commentary: | 22 | ;;; Commentary: |
| 23 | 23 | ||
| 24 | ;; This package was cc-submode.el before it was recognized being | ||
| 25 | ;; useful in general and not tied to C and c-mode at all. | ||
| 26 | |||
| 24 | ;; This package provides `subword' oriented commands and a minor mode | 27 | ;; This package provides `subword' oriented commands and a minor mode |
| 25 | ;; (`c-subword-mode') that substitutes the common word handling | 28 | ;; (`subword-mode') that substitutes the common word handling |
| 26 | ;; functions with them. | 29 | ;; functions with them. |
| 27 | 30 | ||
| 28 | ;; In spite of GNU Coding Standards, it is popular to name a symbol by | 31 | ;; In spite of GNU Coding Standards, it is popular to name a symbol by |
| @@ -47,15 +50,15 @@ | |||
| 47 | 50 | ||
| 48 | ;; Key Word oriented command Subword oriented command | 51 | ;; Key Word oriented command Subword oriented command |
| 49 | ;; ============================================================ | 52 | ;; ============================================================ |
| 50 | ;; M-f `forward-word' `c-forward-subword' | 53 | ;; M-f `forward-word' `forward-subword' |
| 51 | ;; M-b `backward-word' `c-backward-subword' | 54 | ;; M-b `backward-word' `backward-subword' |
| 52 | ;; M-@ `mark-word' `c-mark-subword' | 55 | ;; M-@ `mark-word' `mark-subword' |
| 53 | ;; M-d `kill-word' `c-kill-subword' | 56 | ;; M-d `kill-word' `kill-subword' |
| 54 | ;; M-DEL `backward-kill-word' `c-backward-kill-subword' | 57 | ;; M-DEL `backward-kill-word' `backward-kill-subword' |
| 55 | ;; M-t `transpose-words' `c-transpose-subwords' | 58 | ;; M-t `transpose-words' `transpose-subwords' |
| 56 | ;; M-c `capitalize-word' `c-capitalize-subword' | 59 | ;; M-c `capitalize-word' `capitalize-subword' |
| 57 | ;; M-u `upcase-word' `c-upcase-subword' | 60 | ;; M-u `upcase-word' `upcase-subword' |
| 58 | ;; M-l `downcase-word' `c-downcase-subword' | 61 | ;; M-l `downcase-word' `downcase-subword' |
| 59 | ;; | 62 | ;; |
| 60 | ;; Note: If you have changed the key bindings for the word oriented | 63 | ;; Note: If you have changed the key bindings for the word oriented |
| 61 | ;; commands in your .emacs or a similar place, the keys you've changed | 64 | ;; commands in your .emacs or a similar place, the keys you've changed |
| @@ -65,7 +68,7 @@ | |||
| 65 | ;; your .emacs: | 68 | ;; your .emacs: |
| 66 | ;; | 69 | ;; |
| 67 | ;; (add-hook 'c-mode-common-hook | 70 | ;; (add-hook 'c-mode-common-hook |
| 68 | ;; (lambda () (c-subword-mode 1))) | 71 | ;; (lambda () (subword-mode 1))) |
| 69 | ;; | 72 | ;; |
| 70 | 73 | ||
| 71 | ;; Acknowledgment: | 74 | ;; Acknowledgment: |
| @@ -77,37 +80,22 @@ | |||
| 77 | 80 | ||
| 78 | ;;; Code: | 81 | ;;; Code: |
| 79 | 82 | ||
| 80 | (eval-when-compile | 83 | (defvar subword-mode-map |
| 81 | (let ((load-path | ||
| 82 | (if (and (boundp 'byte-compile-dest-file) | ||
| 83 | (stringp byte-compile-dest-file)) | ||
| 84 | (cons (file-name-directory byte-compile-dest-file) load-path) | ||
| 85 | load-path))) | ||
| 86 | (load "cc-bytecomp" nil t))) | ||
| 87 | |||
| 88 | (cc-require 'cc-defs) | ||
| 89 | (cc-require 'cc-cmds) | ||
| 90 | |||
| 91 | (defvar c-subword-mode-map | ||
| 92 | (let ((map (make-sparse-keymap))) | 84 | (let ((map (make-sparse-keymap))) |
| 93 | (dolist (cmd '(forward-word backward-word mark-word | 85 | (dolist (cmd '(forward-word backward-word mark-word kill-word |
| 94 | kill-word backward-kill-word | 86 | backward-kill-word transpose-words |
| 95 | transpose-words | ||
| 96 | capitalize-word upcase-word downcase-word)) | 87 | capitalize-word upcase-word downcase-word)) |
| 97 | (let ((othercmd (let ((name (symbol-name cmd))) | 88 | (let ((othercmd (let ((name (symbol-name cmd))) |
| 98 | (string-match "\\(.*-\\)\\(word.*\\)" name) | 89 | (string-match "\\(.*-\\)\\(word.*\\)" name) |
| 99 | (intern (concat "c-" | 90 | (intern (concat (match-string 1 name) |
| 100 | (match-string 1 name) | ||
| 101 | "sub" | 91 | "sub" |
| 102 | (match-string 2 name)))))) | 92 | (match-string 2 name)))))) |
| 103 | (if (fboundp 'command-remapping) | 93 | (define-key map (vector 'remap cmd) othercmd))) |
| 104 | (define-key map (vector 'remap cmd) othercmd) | ||
| 105 | (substitute-key-definition cmd othercmd map global-map)))) | ||
| 106 | map) | 94 | map) |
| 107 | "Keymap used in command `c-subword-mode' minor mode.") | 95 | "Keymap used in `subword-mode' minor mode.") |
| 108 | 96 | ||
| 109 | ;;;###autoload | 97 | ;;;###autoload |
| 110 | (define-minor-mode c-subword-mode | 98 | (define-minor-mode subword-mode |
| 111 | "Mode enabling subword movement and editing keys. | 99 | "Mode enabling subword movement and editing keys. |
| 112 | In spite of GNU Coding Standards, it is popular to name a symbol by | 100 | In spite of GNU Coding Standards, it is popular to name a symbol by |
| 113 | mixing uppercase and lowercase letters, e.g. \"GtkWidget\", | 101 | mixing uppercase and lowercase letters, e.g. \"GtkWidget\", |
| @@ -126,41 +114,45 @@ The subword oriented commands activated in this minor mode recognize | |||
| 126 | subwords in a nomenclature to move between subwords and to edit them | 114 | subwords in a nomenclature to move between subwords and to edit them |
| 127 | as words. | 115 | as words. |
| 128 | 116 | ||
| 129 | \\{c-subword-mode-map}" | 117 | \\{subword-mode-map}" |
| 130 | nil | 118 | nil |
| 131 | nil | 119 | nil |
| 132 | c-subword-mode-map | 120 | subword-mode-map) |
| 133 | (c-update-modeline)) | 121 | |
| 122 | (define-obsolete-function-alias 'c-subword-mode 'subword-mode "23.2") | ||
| 134 | 123 | ||
| 135 | (defun c-forward-subword (&optional arg) | 124 | ;;;###autoload |
| 125 | (define-global-minor-mode global-subword-mode subword-mode | ||
| 126 | (lambda () (subword-mode 1))) | ||
| 127 | |||
| 128 | (defun forward-subword (&optional arg) | ||
| 136 | "Do the same as `forward-word' but on subwords. | 129 | "Do the same as `forward-word' but on subwords. |
| 137 | See the command `c-subword-mode' for a description of subwords. | 130 | See the command `subword-mode' for a description of subwords. |
| 138 | Optional argument ARG is the same as for `forward-word'." | 131 | Optional argument ARG is the same as for `forward-word'." |
| 139 | (interactive "p") | 132 | (interactive "p") |
| 140 | (unless arg (setq arg 1)) | 133 | (unless arg (setq arg 1)) |
| 141 | (c-keep-region-active) | ||
| 142 | (cond | 134 | (cond |
| 143 | ((< 0 arg) | 135 | ((< 0 arg) |
| 144 | (dotimes (i arg (point)) | 136 | (dotimes (i arg (point)) |
| 145 | (c-forward-subword-internal))) | 137 | (forward-subword-internal))) |
| 146 | ((> 0 arg) | 138 | ((> 0 arg) |
| 147 | (dotimes (i (- arg) (point)) | 139 | (dotimes (i (- arg) (point)) |
| 148 | (c-backward-subword-internal))) | 140 | (backward-subword-internal))) |
| 149 | (t | 141 | (t |
| 150 | (point)))) | 142 | (point)))) |
| 151 | 143 | ||
| 152 | (put 'c-forward-subword 'CUA 'move) | 144 | (put 'forward-subword 'CUA 'move) |
| 153 | 145 | ||
| 154 | (defun c-backward-subword (&optional arg) | 146 | (defun backward-subword (&optional arg) |
| 155 | "Do the same as `backward-word' but on subwords. | 147 | "Do the same as `backward-word' but on subwords. |
| 156 | See the command `c-subword-mode' for a description of subwords. | 148 | See the command `subword-mode' for a description of subwords. |
| 157 | Optional argument ARG is the same as for `backward-word'." | 149 | Optional argument ARG is the same as for `backward-word'." |
| 158 | (interactive "p") | 150 | (interactive "p") |
| 159 | (c-forward-subword (- (or arg 1)))) | 151 | (forward-subword (- (or arg 1)))) |
| 160 | 152 | ||
| 161 | (defun c-mark-subword (arg) | 153 | (defun mark-subword (arg) |
| 162 | "Do the same as `mark-word' but on subwords. | 154 | "Do the same as `mark-word' but on subwords. |
| 163 | See the command `c-subword-mode' for a description of subwords. | 155 | See the command `subword-mode' for a description of subwords. |
| 164 | Optional argument ARG is the same as for `mark-word'." | 156 | Optional argument ARG is the same as for `mark-word'." |
| 165 | ;; This code is almost copied from `mark-word' in GNU Emacs. | 157 | ;; This code is almost copied from `mark-word' in GNU Emacs. |
| 166 | (interactive "p") | 158 | (interactive "p") |
| @@ -168,63 +160,61 @@ Optional argument ARG is the same as for `mark-word'." | |||
| 168 | (set-mark | 160 | (set-mark |
| 169 | (save-excursion | 161 | (save-excursion |
| 170 | (goto-char (mark)) | 162 | (goto-char (mark)) |
| 171 | (c-forward-subword arg) | 163 | (forward-subword arg) |
| 172 | (point)))) | 164 | (point)))) |
| 173 | (t | 165 | (t |
| 174 | (push-mark | 166 | (push-mark |
| 175 | (save-excursion | 167 | (save-excursion |
| 176 | (c-forward-subword arg) | 168 | (forward-subword arg) |
| 177 | (point)) | 169 | (point)) |
| 178 | nil t)))) | 170 | nil t)))) |
| 179 | 171 | ||
| 180 | (put 'c-backward-subword 'CUA 'move) | 172 | (put 'backward-subword 'CUA 'move) |
| 181 | 173 | ||
| 182 | (defun c-kill-subword (arg) | 174 | (defun kill-subword (arg) |
| 183 | "Do the same as `kill-word' but on subwords. | 175 | "Do the same as `kill-word' but on subwords. |
| 184 | See the command `c-subword-mode' for a description of subwords. | 176 | See the command `subword-mode' for a description of subwords. |
| 185 | Optional argument ARG is the same as for `kill-word'." | 177 | Optional argument ARG is the same as for `kill-word'." |
| 186 | (interactive "p") | 178 | (interactive "p") |
| 187 | (kill-region (point) (c-forward-subword arg))) | 179 | (kill-region (point) (forward-subword arg))) |
| 188 | 180 | ||
| 189 | (defun c-backward-kill-subword (arg) | 181 | (defun backward-kill-subword (arg) |
| 190 | "Do the same as `backward-kill-word' but on subwords. | 182 | "Do the same as `backward-kill-word' but on subwords. |
| 191 | See the command `c-subword-mode' for a description of subwords. | 183 | See the command `subword-mode' for a description of subwords. |
| 192 | Optional argument ARG is the same as for `backward-kill-word'." | 184 | Optional argument ARG is the same as for `backward-kill-word'." |
| 193 | (interactive "p") | 185 | (interactive "p") |
| 194 | (c-kill-subword (- arg))) | 186 | (kill-subword (- arg))) |
| 195 | 187 | ||
| 196 | (defun c-transpose-subwords (arg) | 188 | (defun transpose-subwords (arg) |
| 197 | "Do the same as `transpose-words' but on subwords. | 189 | "Do the same as `transpose-words' but on subwords. |
| 198 | See the command `c-subword-mode' for a description of subwords. | 190 | See the command `subword-mode' for a description of subwords. |
| 199 | Optional argument ARG is the same as for `transpose-words'." | 191 | Optional argument ARG is the same as for `transpose-words'." |
| 200 | (interactive "*p") | 192 | (interactive "*p") |
| 201 | (transpose-subr 'c-forward-subword arg)) | 193 | (transpose-subr 'forward-subword arg)) |
| 202 | |||
| 203 | |||
| 204 | 194 | ||
| 205 | (defun c-downcase-subword (arg) | 195 | (defun downcase-subword (arg) |
| 206 | "Do the same as `downcase-word' but on subwords. | 196 | "Do the same as `downcase-word' but on subwords. |
| 207 | See the command `c-subword-mode' for a description of subwords. | 197 | See the command `subword-mode' for a description of subwords. |
| 208 | Optional argument ARG is the same as for `downcase-word'." | 198 | Optional argument ARG is the same as for `downcase-word'." |
| 209 | (interactive "p") | 199 | (interactive "p") |
| 210 | (let ((start (point))) | 200 | (let ((start (point))) |
| 211 | (downcase-region (point) (c-forward-subword arg)) | 201 | (downcase-region (point) (forward-subword arg)) |
| 212 | (when (< arg 0) | 202 | (when (< arg 0) |
| 213 | (goto-char start)))) | 203 | (goto-char start)))) |
| 214 | 204 | ||
| 215 | (defun c-upcase-subword (arg) | 205 | (defun upcase-subword (arg) |
| 216 | "Do the same as `upcase-word' but on subwords. | 206 | "Do the same as `upcase-word' but on subwords. |
| 217 | See the command `c-subword-mode' for a description of subwords. | 207 | See the command `subword-mode' for a description of subwords. |
| 218 | Optional argument ARG is the same as for `upcase-word'." | 208 | Optional argument ARG is the same as for `upcase-word'." |
| 219 | (interactive "p") | 209 | (interactive "p") |
| 220 | (let ((start (point))) | 210 | (let ((start (point))) |
| 221 | (upcase-region (point) (c-forward-subword arg)) | 211 | (upcase-region (point) (forward-subword arg)) |
| 222 | (when (< arg 0) | 212 | (when (< arg 0) |
| 223 | (goto-char start)))) | 213 | (goto-char start)))) |
| 224 | 214 | ||
| 225 | (defun c-capitalize-subword (arg) | 215 | (defun capitalize-subword (arg) |
| 226 | "Do the same as `capitalize-word' but on subwords. | 216 | "Do the same as `capitalize-word' but on subwords. |
| 227 | See the command `c-subword-mode' for a description of subwords. | 217 | See the command `subword-mode' for a description of subwords. |
| 228 | Optional argument ARG is the same as for `capitalize-word'." | 218 | Optional argument ARG is the same as for `capitalize-word'." |
| 229 | (interactive "p") | 219 | (interactive "p") |
| 230 | (let ((count (abs arg)) | 220 | (let ((count (abs arg)) |
| @@ -233,13 +223,13 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 233 | (dotimes (i count) | 223 | (dotimes (i count) |
| 234 | (if advance | 224 | (if advance |
| 235 | (progn (re-search-forward | 225 | (progn (re-search-forward |
| 236 | (concat "[" c-alpha "]") | 226 | (concat "[[:alpha:]]") |
| 237 | nil t) | 227 | nil t) |
| 238 | (goto-char (match-beginning 0))) | 228 | (goto-char (match-beginning 0))) |
| 239 | (c-backward-subword)) | 229 | (backward-subword)) |
| 240 | (let* ((p (point)) | 230 | (let* ((p (point)) |
| 241 | (pp (1+ p)) | 231 | (pp (1+ p)) |
| 242 | (np (c-forward-subword))) | 232 | (np (forward-subword))) |
| 243 | (upcase-region p pp) | 233 | (upcase-region p pp) |
| 244 | (downcase-region pp np) | 234 | (downcase-region pp np) |
| 245 | (goto-char (if advance np p)))) | 235 | (goto-char (if advance np p)))) |
| @@ -251,16 +241,14 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 251 | ;; | 241 | ;; |
| 252 | ;; Internal functions | 242 | ;; Internal functions |
| 253 | ;; | 243 | ;; |
| 254 | (defun c-forward-subword-internal () | 244 | (defun forward-subword-internal () |
| 255 | (if (and | 245 | (if (and |
| 256 | (save-excursion | 246 | (save-excursion |
| 257 | (let ((case-fold-search nil)) | 247 | (let ((case-fold-search nil)) |
| 258 | (re-search-forward | 248 | (re-search-forward |
| 259 | (concat "\\W*\\(\\([" c-upper "]*\\W?\\)[" c-lower c-digit "]*\\)") | 249 | (concat "\\W*\\(\\([[:upper:]]*\\W?\\)[[:lower:][:digit:]]*\\)") |
| 260 | nil t))) | 250 | nil t))) |
| 261 | (> (match-end 0) (point))) ; So we don't get stuck at a | 251 | (> (match-end 0) (point))) |
| 262 | ; "word-constituent" which isn't c-upper, | ||
| 263 | ; c-lower or c-digit | ||
| 264 | (goto-char | 252 | (goto-char |
| 265 | (cond | 253 | (cond |
| 266 | ((< 1 (- (match-end 2) (match-beginning 2))) | 254 | ((< 1 (- (match-end 2) (match-beginning 2))) |
| @@ -270,12 +258,12 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 270 | (forward-word 1))) | 258 | (forward-word 1))) |
| 271 | 259 | ||
| 272 | 260 | ||
| 273 | (defun c-backward-subword-internal () | 261 | (defun backward-subword-internal () |
| 274 | (if (save-excursion | 262 | (if (save-excursion |
| 275 | (let ((case-fold-search nil)) | 263 | (let ((case-fold-search nil)) |
| 276 | (re-search-backward | 264 | (re-search-backward |
| 277 | (concat | 265 | (concat |
| 278 | "\\(\\(\\W\\|[" c-lower c-digit "]\\)\\([" c-upper "]+\\W*\\)" | 266 | "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)" |
| 279 | "\\|\\W\\w+\\)") | 267 | "\\|\\W\\w+\\)") |
| 280 | nil t))) | 268 | nil t))) |
| 281 | (goto-char | 269 | (goto-char |
| @@ -289,7 +277,6 @@ Optional argument ARG is the same as for `capitalize-word'." | |||
| 289 | (backward-word 1))) | 277 | (backward-word 1))) |
| 290 | 278 | ||
| 291 | 279 | ||
| 292 | (cc-provide 'cc-subword) | 280 | (provide 'subword) |
| 293 | 281 | ||
| 294 | ;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3 | 282 | ;;; subword.el ends here |
| 295 | ;;; cc-subword.el ends here | ||