From 3a10d3934f10b5e69815fe78e1daa902ac1f0c1a Mon Sep 17 00:00:00 2001 From: deb0ch Date: Sat, 14 Jan 2017 16:01:51 +0100 Subject: [PATCH] readme: improve code examples the way the key bindings were overriden in these examples didn't update the winum-keymap variable itself, leading to problems such as not being able to use define-key on winum-keymap afterwards --- README.org | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.org b/README.org index 081e3a0..3fd506a 100644 --- a/README.org +++ b/README.org @@ -139,9 +139,7 @@ If you prefer no to use a prefix and have even shorter bindings, you can also override =winum-keymap= in the minor mode bindings table: #+BEGIN_SRC emacs-lisp - (require 'winum) - - (setcdr (assoc 'winum-mode minor-mode-map-alist) + (setq winum-keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "C-`") 'winum-select-window-by-number) (define-key map (kbd "C-²") 'winum-select-window-by-number) @@ -156,9 +154,13 @@ override =winum-keymap= in the minor mode bindings table: (define-key map (kbd "M-8") 'winum-select-window-8) map)) + (require 'winum) + (winum-mode) #+END_SRC +Note that it is important to set =winum-keymap= /before/ the =require=. + You can also use the more conventional =define-key= on =winum-keymap=: #+BEGIN_SRC emacs-lisp @@ -249,9 +251,7 @@ Here is an example that you could put in your =.emacs=, which includes all available winum options. #+BEGIN_SRC emacs-lisp - (require 'winum) - - (setcdr (assoc 'winum-mode minor-mode-map-alist) + (setq winum-keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "C-`") 'winum-select-window-by-number) (define-key map (kbd "C-²") 'winum-select-window-by-number) @@ -266,6 +266,8 @@ available winum options. (define-key map (kbd "M-8") 'winum-select-window-8) map)) + (require 'winum) + (defun my-winum-assign-func () (cond ((equal (buffer-name) "*Calculator*")