aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier2015-11-30 08:02:55 -0500
committerStefan Monnier2015-11-30 08:02:55 -0500
commitc77b816bc3d8fc242b95c04859803ffff5bb8210 (patch)
treed282ac5f87df939cc94836bda3d239731342ca96 /lisp
parentf248292ede3940dde5e4ac29d96f8a0294788b0a (diff)
downloademacs-c77b816bc3d8fc242b95c04859803ffff5bb8210.tar.gz
emacs-c77b816bc3d8fc242b95c04859803ffff5bb8210.zip
* lisp/calculator.el (calculator-define-key): Silence warning
...about unknown calculator-mode-map.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/calculator.el64
1 files changed, 32 insertions, 32 deletions
diff --git a/lisp/calculator.el b/lisp/calculator.el
index f2e6a888c09..1d3715b75b8 100644
--- a/lisp/calculator.el
+++ b/lisp/calculator.el
@@ -379,38 +379,6 @@ Used for repeating operations in calculator-repR/L.")
379;;;--------------------------------------------------------------------- 379;;;---------------------------------------------------------------------
380;;; Key bindings 380;;; Key bindings
381 381
382(defun calculator-define-key (key cmd &optional map)
383 ;; arranges for unbound alphabetic keys to be used as their un/shifted
384 ;; versions if those are bound (mimics the usual Emacs global
385 ;; bindings)
386 (let* ((key (if (stringp key) (kbd key) key))
387 (map (or map calculator-mode-map))
388 (omap (keymap-parent map)))
389 (define-key map key cmd)
390 ;; "other" map, used for case-flipped bindings
391 (unless omap
392 (setq omap (make-sparse-keymap))
393 (suppress-keymap omap t)
394 (set-keymap-parent map omap))
395 (let ((m omap))
396 ;; bind all case-flipped versions
397 (dotimes (i (length key))
398 (let* ((c (aref key i))
399 (k (vector c))
400 (b (lookup-key m k))
401 (defkey (lambda (x)
402 (define-key m k x)
403 (when (and (characterp c)
404 (or (<= ?A c ?Z) (<= ?a c ?z)))
405 (define-key m (vector (logxor 32 c)) x)))))
406 (cond ((= i (1- (length key)))
407 ;; prefer longer sequences
408 (unless (keymapp b) (funcall defkey cmd)))
409 ((keymapp b) (setq m b))
410 (t (let ((sub (make-sparse-keymap)))
411 (funcall defkey sub)
412 (setq m sub)))))))))
413
414(defvar calculator-mode-map 382(defvar calculator-mode-map
415 (let ((map (make-sparse-keymap))) 383 (let ((map (make-sparse-keymap)))
416 (suppress-keymap map t) 384 (suppress-keymap map t)
@@ -594,6 +562,38 @@ Used for repeating operations in calculator-repR/L.")
594 map) 562 map)
595 "The calculator key map.") 563 "The calculator key map.")
596 564
565(defun calculator-define-key (key cmd &optional map)
566 ;; Arranges for unbound alphabetic keys to be used as their un/shifted
567 ;; versions if those are bound (mimics the usual Emacs global
568 ;; bindings).
569 (let* ((key (if (stringp key) (kbd key) key))
570 (map (or map calculator-mode-map))
571 (omap (keymap-parent map)))
572 (define-key map key cmd)
573 ;; "other" map, used for case-flipped bindings
574 (unless omap
575 (setq omap (make-sparse-keymap))
576 (suppress-keymap omap t)
577 (set-keymap-parent map omap))
578 (let ((m omap))
579 ;; Bind all case-flipped versions.
580 (dotimes (i (length key))
581 (let* ((c (aref key i))
582 (k (vector c))
583 (b (lookup-key m k))
584 (defkey (lambda (x)
585 (define-key m k x)
586 (when (and (characterp c)
587 (or (<= ?A c ?Z) (<= ?a c ?z)))
588 (define-key m (vector (logxor 32 c)) x)))))
589 (cond ((= i (1- (length key)))
590 ;; Prefer longer sequences.
591 (unless (keymapp b) (funcall defkey cmd)))
592 ((keymapp b) (setq m b))
593 (t (let ((sub (make-sparse-keymap)))
594 (funcall defkey sub)
595 (setq m sub)))))))))
596
597;;;--------------------------------------------------------------------- 597;;;---------------------------------------------------------------------
598;;; Startup and mode stuff 598;;; Startup and mode stuff
599 599