aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2005-10-25 08:40:16 +0000
committerEli Zaretskii2005-10-25 08:40:16 +0000
commit35b1f2e99bc673fcb9a5edf11559cbeba987e256 (patch)
tree458ef85fa07c670a04c046f2effed7d3ef58b56b
parent05f7d868db12381a1fd077dc39b221f166c90825 (diff)
downloademacs-35b1f2e99bc673fcb9a5edf11559cbeba987e256.tar.gz
emacs-35b1f2e99bc673fcb9a5edf11559cbeba987e256.zip
(blackbox-redefine-key): New function.
(blackbox-mode-map): Use it to remap existing bindings for cursor motion instead of binding literal keys.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/play/blackbox.el27
2 files changed, 21 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index fdecb9afe29..d95571394d5 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12005-10-25 Michael Cadilhac <michael.cadilhac-@t-lrde.epita.fr> (tiny change)
2
3 * play/blackbox.el (blackbox-redefine-key): New function.
4 (blackbox-mode-map): Use it to remap existing bindings for cursor
5 motion instead of binding literal keys.
6
12005-10-25 Glenn Morris <rgm@gnu.org> 72005-10-25 Glenn Morris <rgm@gnu.org>
2 8
3 * calendar/diary-lib.el (diary-list-entries): Prevent infloop when 9 * calendar/diary-lib.el (diary-list-entries): Prevent infloop when
diff --git a/lisp/play/blackbox.el b/lisp/play/blackbox.el
index ffde5c46021..f6194bda5f9 100644
--- a/lisp/play/blackbox.el
+++ b/lisp/play/blackbox.el
@@ -89,23 +89,26 @@
89(defvar bb-balls-placed nil 89(defvar bb-balls-placed nil
90 "List of already placed balls.") 90 "List of already placed balls.")
91 91
92;; This is used below to remap existing bindings for cursor motion to
93;; blackbox-specific bindings in blackbox-mode-map. This is so that
94;; users who prefer non-default key bindings for cursor motion don't
95;; lose that when they play Blackbox.
96(defun blackbox-redefine-key (oldfun newfun)
97 "Redefine keys that run the function OLDFUN to run NEWFUN instead."
98 (define-key blackbox-mode-map (vector 'remap oldfun) newfun))
99
92(unless blackbox-mode-map 100(unless blackbox-mode-map
93 (setq blackbox-mode-map (make-keymap)) 101 (setq blackbox-mode-map (make-keymap))
94 (suppress-keymap blackbox-mode-map t) 102 (suppress-keymap blackbox-mode-map t)
95 (define-key blackbox-mode-map "\C-f" 'bb-right) 103 (blackbox-redefine-key 'backward-char 'bb-left)
96 (define-key blackbox-mode-map [right] 'bb-right) 104 (blackbox-redefine-key 'forward-char 'bb-right)
97 (define-key blackbox-mode-map "\C-b" 'bb-left) 105 (blackbox-redefine-key 'previous-line 'bb-up)
98 (define-key blackbox-mode-map [left] 'bb-left) 106 (blackbox-redefine-key 'next-line 'bb-down)
99 (define-key blackbox-mode-map "\C-p" 'bb-up) 107 (blackbox-redefine-key 'move-end-of-line 'bb-eol)
100 (define-key blackbox-mode-map [up] 'bb-up) 108 (blackbox-redefine-key 'move-beginning-of-line 'bb-bol)
101 (define-key blackbox-mode-map "\C-n" 'bb-down)
102 (define-key blackbox-mode-map [down] 'bb-down)
103 (define-key blackbox-mode-map "\C-e" 'bb-eol)
104 (define-key blackbox-mode-map "\C-a" 'bb-bol)
105 (define-key blackbox-mode-map " " 'bb-romp) 109 (define-key blackbox-mode-map " " 'bb-romp)
106 (define-key blackbox-mode-map [insert] 'bb-romp) 110 (define-key blackbox-mode-map [insert] 'bb-romp)
107 (define-key blackbox-mode-map "\C-m" 'bb-done) 111 (blackbox-redefine-key 'newline 'bb-done))
108 (define-key blackbox-mode-map [kp-enter] 'bb-done))
109 112
110;; Blackbox mode is suitable only for specially formatted data. 113;; Blackbox mode is suitable only for specially formatted data.
111(put 'blackbox-mode 'mode-class 'special) 114(put 'blackbox-mode 'mode-class 'special)