summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kangas <stefan@marxist.se>2021-12-24 17:29:05 +0100
committerStefan Kangas <stefan@marxist.se>2021-12-24 17:35:42 +0100
commit992bb3a9aef973447bc369e389c8f7228672f82c (patch)
tree5f48479f5849d4c414d4fd9b864bc2140f9fbb59
parentb6ea93c62cb0b54bf90a954227f6d8603bdbaf80 (diff)
downloademacs-992bb3a9aef973447bc369e389c8f7228672f82c.tar.gz
Simplify command remapping in play/blackbox.el
* lisp/play/blackbox.el (blackbox-redefine-key): Make obsolete. (blackbox-mode-map): Simplify.
-rw-r--r--lisp/play/blackbox.el34
1 files changed, 15 insertions, 19 deletions
diff --git a/lisp/play/blackbox.el b/lisp/play/blackbox.el
index 13bcdcc8595..1b82d1a4259 100644
--- a/lisp/play/blackbox.el
+++ b/lisp/play/blackbox.el
@@ -85,31 +85,22 @@
(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 (map oldfun newfun)
- "Redefine keys that run the function OLDFUN to run NEWFUN instead."
- (define-key map (vector 'remap oldfun) newfun))
-
-
(defvar blackbox-mode-map
- (let ((map (make-keymap)))
+ (let ((map (make-sparse-keymap)))
(suppress-keymap map t)
- (blackbox-redefine-key map 'backward-char 'bb-left)
- (blackbox-redefine-key map 'left-char 'bb-left)
- (blackbox-redefine-key map 'forward-char 'bb-right)
- (blackbox-redefine-key map 'right-char 'bb-right)
- (blackbox-redefine-key map 'previous-line 'bb-up)
- (blackbox-redefine-key map 'next-line 'bb-down)
- (blackbox-redefine-key map 'move-end-of-line 'bb-eol)
- (blackbox-redefine-key map 'move-beginning-of-line 'bb-bol)
(define-key map " " 'bb-romp)
(define-key map "q" 'bury-buffer)
(define-key map [insert] 'bb-romp)
(define-key map [return] 'bb-done)
- (blackbox-redefine-key map 'newline 'bb-done)
+ (define-key map [remap backward-char] #'bb-left)
+ (define-key map [remap left-char] #'bb-left)
+ (define-key map [remap forward-char] #'bb-right)
+ (define-key map [remap right-char] #'bb-right)
+ (define-key map [remap previous-line] #'bb-up)
+ (define-key map [remap next-line] #'bb-down)
+ (define-key map [remap move-end-of-line] #'bb-eol)
+ (define-key map [remap move-beginning-of-line] #'bb-bol)
+ (define-key map [remap newline] #'bb-done)
map))
;; Blackbox mode is suitable only for specially formatted data.
@@ -426,6 +417,11 @@ a reflection."
(insert c)
(backward-char 1)))
+(defun blackbox-redefine-key (map oldfun newfun)
+ "Redefine keys that run the function OLDFUN to run NEWFUN instead."
+ (declare (obsolete define-key "29.1"))
+ (define-key map (vector 'remap oldfun) newfun))
+
(provide 'blackbox)
;;; blackbox.el ends here