summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2005-10-25 08:40:16 +0000
committerEli Zaretskii <eliz@gnu.org>2005-10-25 08:40:16 +0000
commit35b1f2e99bc673fcb9a5edf11559cbeba987e256 (patch)
tree458ef85fa07c670a04c046f2effed7d3ef58b56b /lisp
parent05f7d868db12381a1fd077dc39b221f166c90825 (diff)
downloademacs-35b1f2e99bc673fcb9a5edf11559cbeba987e256.tar.gz
(blackbox-redefine-key): New function.
(blackbox-mode-map): Use it to remap existing bindings for cursor motion instead of binding literal keys.
Diffstat (limited to 'lisp')
-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 @@
+2005-10-25 Michael Cadilhac <michael.cadilhac-@t-lrde.epita.fr> (tiny change)
+
+ * play/blackbox.el (blackbox-redefine-key): New function.
+ (blackbox-mode-map): Use it to remap existing bindings for cursor
+ motion instead of binding literal keys.
+
2005-10-25 Glenn Morris <rgm@gnu.org>
* 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 @@
(defvar bb-balls-placed nil
"List of already placed balls.")
+;; This is used below to remap existing bindings for cursor motion to
+;; blackbox-specific bindings in blackbox-mode-map. This is so that
+;; users who prefer non-default key bindings for cursor motion don't
+;; lose that when they play Blackbox.
+(defun blackbox-redefine-key (oldfun newfun)
+ "Redefine keys that run the function OLDFUN to run NEWFUN instead."
+ (define-key blackbox-mode-map (vector 'remap oldfun) newfun))
+
(unless blackbox-mode-map
(setq blackbox-mode-map (make-keymap))
(suppress-keymap blackbox-mode-map t)
- (define-key blackbox-mode-map "\C-f" 'bb-right)
- (define-key blackbox-mode-map [right] 'bb-right)
- (define-key blackbox-mode-map "\C-b" 'bb-left)
- (define-key blackbox-mode-map [left] 'bb-left)
- (define-key blackbox-mode-map "\C-p" 'bb-up)
- (define-key blackbox-mode-map [up] 'bb-up)
- (define-key blackbox-mode-map "\C-n" 'bb-down)
- (define-key blackbox-mode-map [down] 'bb-down)
- (define-key blackbox-mode-map "\C-e" 'bb-eol)
- (define-key blackbox-mode-map "\C-a" 'bb-bol)
+ (blackbox-redefine-key 'backward-char 'bb-left)
+ (blackbox-redefine-key 'forward-char 'bb-right)
+ (blackbox-redefine-key 'previous-line 'bb-up)
+ (blackbox-redefine-key 'next-line 'bb-down)
+ (blackbox-redefine-key 'move-end-of-line 'bb-eol)
+ (blackbox-redefine-key 'move-beginning-of-line 'bb-bol)
(define-key blackbox-mode-map " " 'bb-romp)
(define-key blackbox-mode-map [insert] 'bb-romp)
- (define-key blackbox-mode-map "\C-m" 'bb-done)
- (define-key blackbox-mode-map [kp-enter] 'bb-done))
+ (blackbox-redefine-key 'newline 'bb-done))
;; Blackbox mode is suitable only for specially formatted data.
(put 'blackbox-mode 'mode-class 'special)