I wonder what is wrong with the following code?
(defvar my-forward-word-map (let ((map (make-sparse-keymap))) (define-key map (kbd "n") 'forward-word) (define-key map (kbd "p") 'my-backward-word) map)) (defvar my-backward-word-map (let ((map (make-sparse-keymap))) (define-key map (kbd "p") 'backward-word) (define-key map (kbd "n") 'my-forward-word) map)) (defun my-forward-word () (interactive) (set-transient-map my-forward-word-map t)) (defun my-backward-word () (interactive) (set-transient-map my-backward-word-map t)) (global-set-key (kbd "M-n") 'my-forward-word) (global-set-key (kbd "M-p") 'my-backward-word)
There is a buffer with the text: |Hello world
. |
- this is cursor.
I press M-n
, n
. I get Hello| world
as I expected.
Then I press p
, p
. I get |Hello world
as was previously. And that's fine.
But when I press n
again nothing happens i.e. cursor doesn't change its position no matter how many time I press n
.
After n
and n
I expected to get Hello| world
.
What's wrong?
$ emacs --version GNU Emacs 24.4.1