* Use of command remapping in cc-subword.el
@ 2006-04-03 22:09 Stefan Monnier
0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2006-04-03 22:09 UTC (permalink / raw)
Any objection to the patch below?
Stefan
--- cc-subword.el 17 Feb 2006 10:49:16 -0500 1.2
+++ cc-subword.el 03 Apr 2006 18:05:46 -0400
@@ -91,6 +91,24 @@
;; Don't complain about the `define-minor-mode' form if it isn't defined.
(cc-bytecomp-defvar c-subword-mode)
+(defvar c-subword-mode-map
+ (let ((map (make-sparse-keymap)))
+ (dolist (cmd '(forward-word backward-word mark-word
+ kill-word backward-kill-word
+ transpose-words
+ capitalize-word upcase-word downcase-word))
+ (let ((othercmd (if (consp cmd) (prog1 (cdr cmd) (setq cmd (car cmd)))
+ (let ((name (symbol-name cmd)))
+ (string-match "\\(.*-\\)\\(word.*\\)" name)
+ (intern (concat "c-"
+ (match-string 1 name)
+ "sub"
+ (match-string 2 name)))))))
+ (if (fboundp 'command-remapping)
+ (define-key map (vector 'remap cmd) othercmd)
+ (substitute-key-definition cmd othercmd map global-map)))))
+ "Keymap used in command `c-subword-mode' minor mode.")
+
;;; Autoload directives must be on the top level, so we construct an
;;; autoload form instead.
;;;###autoload (autoload 'c-subword-mode "cc-subword" "Mode enabling subword movement and editing keys." t)
@@ -105,41 +123,6 @@
(error
"c-subword-mode is not (yet) available in this version of (X)Emacs. Sorry!"))
- (defvar c-subword-mode-map
- (let ((map (make-sparse-keymap)))
- (substitute-key-definition 'forward-word
- 'c-forward-subword
- map global-map)
- (substitute-key-definition 'backward-word
- 'c-backward-subword
- map global-map)
- (substitute-key-definition 'mark-word
- 'c-mark-subword
- map global-map)
-
- (substitute-key-definition 'kill-word
- 'c-kill-subword
- map global-map)
- (substitute-key-definition 'backward-kill-word
- 'c-backward-kill-subword
- map global-map)
-
- (substitute-key-definition 'transpose-words
- 'c-transpose-subwords
- map global-map)
-
- (substitute-key-definition 'capitalize-word
- 'c-capitalize-subword
- map global-map)
- (substitute-key-definition 'upcase-word
- 'c-upcase-subword
- map global-map)
- (substitute-key-definition 'downcase-word
- 'c-downcase-subword
- map global-map)
- map)
- "Keymap used in command `c-subword-mode' minor mode.")
-
(define-minor-mode c-subword-mode
"Mode enabling subword movement and editing keys.
In spite of GNU Coding Standards, it is popular to name a symbol by
@@ -308,5 +291,5 @@
\f
(cc-provide 'cc-subword)
-;;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
+;; arch-tag: 2be9d294-7f30-4626-95e6-9964bb93c7a3
;;; cc-subword.el ends here
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-04-03 22:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-03 22:09 Use of command remapping in cc-subword.el Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.