ergoemacs / ergoemacs-mode

ergoemacs-mode
ergoemacs.github.io/
GNU General Public License v3.0
293 stars 35 forks source link

Can't change keybinding for M-up in org mode #437

Closed calliecameron closed 3 years ago

calliecameron commented 7 years ago

I want M-up to always run windmove-up (and the other M-arrow combinations to run the other windmove commands). With the following code, it works everywhere except in org-mode, where it always runs ergoemacs-org-metaup:

    (ergoemacs-package dotfiles-keys-main
        :bind
        (("<M-left>" . windmove-left)
         ("<M-right>" . windmove-right)
         ("<M-up>" . windmove-up)
         ("<M-down>" . windmove-down)))

I have tried changing the bindings in org mode with bind-keys and local-set-key, which works for M-left, but not the others. I managed to forcibly override the bindings using overriding-terminal-local-map:

    (add-hook 'org-mode-hook
              (lambda ()
                (unless overriding-terminal-local-map
                  (setq overriding-terminal-local-map (make-keymap)))
                (bind-keys
                 :map overriding-terminal-local-map
                 ("<M-left>" . windmove-left)
                 ("<M-right>" . windmove-right)
                 ("<M-up>" . windmove-up)
                 ("<M-down>" . windmove-down))))

but this is horrible, and often stops working. What is the proper way to change these bindings?

Using latest stable ergoemacs-mode on Emacs 25.1.

mattfidler commented 7 years ago

In theory, you should be able to use:

    (ergoemacs-package dotfiles-keys-main
        :bind*
        (("<M-left>" . windmove-left)
         ("<M-right>" . windmove-right)
         ("<M-up>" . windmove-up)
         ("<M-down>" . windmove-down)))

Note the presence of the *.

mattfidler commented 7 years ago

I'm assuming you want this everywhere, not just org-mode. Sorry for the late reply.

mattfidler commented 7 years ago

I tried it and it didn't work. However by using f10eeccc1680390a07e6edf92899cbf55d7f0428 seemed to fix the issue for me. Now using the code above, the keys are bound everywhere.

calliecameron commented 7 years ago

It still doesn't work for me. Using :bind*, the keys don't get bound anywhere, even outside org-mode. Now M-left in e.g. lisp mode runs ergoemacs-backward-open-bracket.

Here's the minimal .emacs I'm using to test it:

(require 'package)
(setq
 package-enable-at-startup nil
 package-archives '(("melpa-stable" . "https://stable.melpa.org/packages/")
                    ("melpa" . "https://melpa.org/packages/")
                    ("gnu" . "https://elpa.gnu.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)

(use-package ergoemacs-mode
  :config
  (ergoemacs-mode))

(ergoemacs-package foo
  :bind*
  (("<M-left>" . windmove-left)
   ("<M-right>" . windmove-right)
   ("<M-up>" . windmove-up)
   ("<M-down>" . windmove-down)))
mattfidler commented 7 years ago

Did you upgrade ergoemacs?

mattfidler commented 7 years ago

Also you could try M-a ergoemacs-clear-cache

calliecameron commented 7 years ago

Yes, I'm using the latest ergoemacs from melpa. I've tried M-a ergoemacs-mode-clear-cache, and tried deleting .emacs.d altogether, and it still doesn't work. After experimenting a bit, it seems like :bind* doesn't work for me at all, not just for these particular bindings.

mattfidler commented 7 years ago

Hm. It was working for me for a bit, but it stopped working again. I will have to figure out why. I'm sorry, it should work. You could define the key directly to see if it works in the mean time:

(bind-keys
                 :map ergoemacs-override-keymap
                 ("<M-left>" . windmove-left)
                 ("<M-right>" . windmove-right)
                 ("<M-up>" . windmove-up)
                 ("<M-down>" . windmove-down))
calliecameron commented 7 years ago

This works in the meantime, thanks.

mattfidler commented 7 years ago

It seems to work for me. I made a test and it passes as well. If it doesn't work, let me know.

mattfidler commented 7 years ago

It didn't pass on travis, so I'm reopening the issue.