[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Preferred way to add commands to a foreign keymap?
From: |
Sean McAfee |
Subject: |
Preferred way to add commands to a foreign keymap? |
Date: |
Wed, 08 Dec 2010 15:28:47 -0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (darwin) |
I want to add the following command to Dired mode:
(defun mac-open-files (arg)
(interactive "P")
(dired-do-shell-command "/usr/bin/open" arg (dired-get-marked-files)))
I can think of two ways to do it:
1. Twiddle dired-mode's keymap directly:
(define-key dired-mode-map [(super o)] 'mac-open-files)
2. Use local-set-key in a hook:
(add-hook 'dired-mode-hook
(lambda () (local-set-key [(super o)] 'mac-open-files)
#1 seems like the (very, very slightly) more efficient appoach, but I
worry that I'm potentially trampling on a dired-mode implementation
detail.
Is there any practical reason to prefer one approach over the other? Or
is there another way?
- Preferred way to add commands to a foreign keymap?,
Sean McAfee <=