Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stomps all over the local keymap if outline-minor-mode is enabled (or disabled) #36

Open
phil-s opened this issue Jul 7, 2020 · 5 comments
Labels

Comments

@phil-s
Copy link

phil-s commented Jul 7, 2020

(add-hook 'outline-minor-mode-hook 'mediawiki-outline-magic-keys) is really bad.

mediawiki-outline-magic-keys calls local-set-key for a bunch of key sequences. That's usually the major mode keymap, which is shared amongst all buffers in that mode whether or not outline-minor-mode (let alone mediawiki-mode) is enabled in any given buffer, and which persists for future buffers using that major mode as well.

And because the global outline-minor-mode-hook was used, this clobbering happens again in future, even if you'd re-bound the keys manually, until you figure out what was causing it.

And this all happens from simply loading mediawiki.el.

I suggest creating a new buffer-local minor mode for the desired key bindings, and then only enabling that mode in the specific buffers where you want it.

@phil-s phil-s changed the title Stomps all over the local keymap if outline-minor-mode is enabled Stomps all over the local keymap if outline-minor-mode is enabled (or disabled) Jul 7, 2020
@hexmode
Copy link
Owner

hexmode commented Jul 7, 2020

Excellent points. I'll look at fixing this soon.

@hexmode
Copy link
Owner

hexmode commented Jul 11, 2020

Could you see if this is fixed in the latest master?

@phil-s
Copy link
Author

phil-s commented Jul 11, 2020

No, the current master is commit 05aab5c and we can see that nothing has changed:

mediawiki-el/mediawiki.el

Lines 1917 to 1932 in 05aab5c

(defun mediawiki-outline-magic-keys ()
"Set up outline magic keys.
See https://www.emacswiki.org/emacs/OutlineMagic"
(interactive)
(unless (featurep 'xemacs)
(local-set-key [(shift iso-lefttab)] 'outline-cycle)
(local-set-key [iso-left-tab] 'outline-cycle))
(local-set-key [(meta left)] 'outline-promote)
(local-set-key [(meta right)] 'outline-demote)
(local-set-key [(shift return)] 'newline-and-indent)
(local-set-key [(control left)] 'mediawiki-simple-outline-promote)
(local-set-key [(control right)] 'mediawiki-simple-outline-demote)
(local-set-key [(control up)] 'outline-move-subtree-up)
(local-set-key [(control down)] 'outline-move-subtree-down))
(add-hook 'mediawiki-mode-hook (lambda () (outline-minor-mode nil)))
(add-hook 'outline-minor-mode-hook 'mediawiki-outline-magic-keys)

@hexmode
Copy link
Owner

hexmode commented Jul 11, 2020

ah, thanks for showing me.

@aspiers
Copy link

aspiers commented Aug 25, 2020

Ouch, this is really bad. It just bit me by breaking outshine-mode, and confused the hell out of me until I traced it to this package. I suggest simply removing that add-hook line as a quick fix, but yeah, these keys absolutely must be moved to their own map. In the mean time I'm going to have to uninstall this package unfortunately.

jonmoore added a commit to jonmoore/JMEmacs that referenced this issue Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants