Emacs narrow-or-widen-dwim29 Jul 2014, by Artur Malabarba.
Mnemonic Keymaps post series
Narrowing is one of those features you won’t even hear about in a more mundane editor, but Emacs has an entire keymap for it. While I wouldn’t want to be without this feature, I’m all for simplification.
Michael Fogleman (the same justicier who took matters to his own hands on Hungry Delete Mode) mentioned the following gem on the The Toggle-Map and Wizardry post. I took the liberty of adding a bit of functionality. To use it, you’ll also need the endless/inside-org-code-block-p function.
If you’re the kind of person who knows how to use
this command might not be for you. Meanwhile, for us mortals, it more
than fits the bill.
Sacha Chua’s comment below gave me a glimpse of inspiration.
I’ve never liked org’s default keybind for editing a source code
block, C-c ', and have been looking for a better
one. But if you meditate on it for a minute, the effect of
C-c ' is a narrow command with some bells
attached. So it fits perfectly into
Now that I’m no longer using C-c ' to edit code blocks, I also need a better key to finish editing code blocks, and C-x C-s makes perfect sense.
Now it should also work with any type of org-block supported by
LaTeX-mode-hook instead of
eval-after-load, as suggested by Omar in the