do not define keymap if winum-keymap-prefix is nil

This commit is contained in:
deb0ch 2016-12-15 18:22:20 +01:00
parent 84de252877
commit 0ba8f4ba74

View file

@ -94,31 +94,32 @@ numbers in the mode-line.")
:group 'winum :group 'winum
:type '(repeat string)) :type '(repeat string))
(defface winum-face '()
"Face used for the number in the mode-line."
:group 'winum)
(defcustom winum-keymap-prefix (kbd "C-x w") (defcustom winum-keymap-prefix (kbd "C-x w")
"Prefix key sequence for keybindings." "Prefix key sequence for keybindings."
:group 'winum :group 'winum
:type 'string) :type 'string)
(defface winum-face '()
"Face used for the number in the mode-line."
:group 'winum)
(defvar winum-keymap (defvar winum-keymap
(let ((map (make-sparse-keymap))) (when winum-keymap-prefix
(let ((prefix-map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(define-key prefix-map (kbd "`") 'winum-select-window-by-number) (let ((prefix-map (make-sparse-keymap)))
(define-key prefix-map (kbd "0") 'winum-select-window-0-or-10) (define-key prefix-map (kbd "`") 'winum-select-window-by-number)
(define-key prefix-map (kbd "1") 'winum-select-window-1) (define-key prefix-map (kbd "0") 'winum-select-window-0-or-10)
(define-key prefix-map (kbd "2") 'winum-select-window-2) (define-key prefix-map (kbd "1") 'winum-select-window-1)
(define-key prefix-map (kbd "3") 'winum-select-window-3) (define-key prefix-map (kbd "2") 'winum-select-window-2)
(define-key prefix-map (kbd "4") 'winum-select-window-4) (define-key prefix-map (kbd "3") 'winum-select-window-3)
(define-key prefix-map (kbd "5") 'winum-select-window-5) (define-key prefix-map (kbd "4") 'winum-select-window-4)
(define-key prefix-map (kbd "6") 'winum-select-window-6) (define-key prefix-map (kbd "5") 'winum-select-window-5)
(define-key prefix-map (kbd "7") 'winum-select-window-7) (define-key prefix-map (kbd "6") 'winum-select-window-6)
(define-key prefix-map (kbd "8") 'winum-select-window-8) (define-key prefix-map (kbd "7") 'winum-select-window-7)
(define-key prefix-map (kbd "9") 'winum-select-window-9) (define-key prefix-map (kbd "8") 'winum-select-window-8)
(define-key map winum-keymap-prefix prefix-map)) (define-key prefix-map (kbd "9") 'winum-select-window-9)
map) (define-key map winum-keymap-prefix prefix-map))
map))
"Keymap used for `winum-mode'.") "Keymap used for `winum-mode'.")
;; Internal variables ---------------------------------------------------------- ;; Internal variables ----------------------------------------------------------