all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: Use of command remapping in cc-subword.el
Date: Mon, 03 Apr 2006 18:09:19 -0400	[thread overview]
Message-ID: <jwvirpqtisy.fsf-monnier+emacs@gnu.org> (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

                 reply	other threads:[~2006-04-03 22:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvirpqtisy.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.