comparison lisp/progmodes/cc-subword.el @ 70238:1be7d556ba69

(c-subword-mode-map): Use command remapping.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 26 Apr 2006 20:21:56 +0000
parents dc49655f57ae
children ad23aa667a59
comparison
equal deleted inserted replaced
70237:1cc4411c326c 70238:1be7d556ba69
105 (error 105 (error
106 "c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!")) 106 "c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!"))
107 107
108 (defvar c-subword-mode-map 108 (defvar c-subword-mode-map
109 (let ((map (make-sparse-keymap))) 109 (let ((map (make-sparse-keymap)))
110 (substitute-key-definition 'forward-word 110 (dolist (cmd '(forward-word backward-word mark-word
111 'c-forward-subword 111 kill-word backward-kill-word
112 map global-map) 112 transpose-words
113 (substitute-key-definition 'backward-word 113 capitalize-word upcase-word downcase-word))
114 'c-backward-subword 114 (let ((othercmd (let ((name (symbol-name cmd)))
115 map global-map) 115 (string-match "\\(.*-\\)\\(word.*\\)" name)
116 (substitute-key-definition 'mark-word 116 (intern (concat "c-"
117 'c-mark-subword 117 (match-string 1 name)
118 map global-map) 118 "sub"
119 119 (match-string 2 name))))))
120 (substitute-key-definition 'kill-word 120 (if (fboundp 'command-remapping)
121 'c-kill-subword 121 (define-key map (vector 'remap cmd) othercmd)
122 map global-map) 122 (substitute-key-definition cmd othercmd map global-map))))
123 (substitute-key-definition 'backward-kill-word
124 'c-backward-kill-subword
125 map global-map)
126
127 (substitute-key-definition 'transpose-words
128 'c-transpose-subwords
129 map global-map)
130
131 (substitute-key-definition 'capitalize-word
132 'c-capitalize-subword
133 map global-map)
134 (substitute-key-definition 'upcase-word
135 'c-upcase-subword
136 map global-map)
137 (substitute-key-definition 'downcase-word
138 'c-downcase-subword
139 map global-map)
140 map) 123 map)
141 "Keymap used in command `c-subword-mode' minor mode.") 124 "Keymap used in command `c-subword-mode' minor mode.")
142 125
143 (define-minor-mode c-subword-mode 126 (define-minor-mode c-subword-mode
144 "Mode enabling subword movement and editing keys. 127 "Mode enabling subword movement and editing keys.
306 (backward-word 1))) 289 (backward-word 1)))
307 290
308 291
309 (cc-provide 'cc-subword) 292 (cc-provide 'cc-subword)
310 293
311 ;;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3 294 ;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
312 ;;; cc-subword.el ends here 295 ;;; cc-subword.el ends here