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.
If you’re the kind of person who knows how to use narrow-to-page,
this command might not be for you. Meanwhile, for us mortals, it more
than fits the bill.
Update 05 Sep 2014
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 narrow-or-widen-dwim (updated
above).
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.
Update 23 Sep 2014
I’ve updated it to no longer use the org-in-src-block-p function and
just try calling org-edit-src-code instead. org-in-src-block-p
has proven quite unreliable.
Update 05 Dec 2015
Now it should also work with any type of org-block supported by
org-narrow-to-block.
Update 07 Dec 2015
Use LaTeX-mode-hook instead of eval-after-load, as suggested by Omar in the
comments.
Emacs narrow-or-widen-dwim
29 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
narrow-to-page
, this command might not be for you. Meanwhile, for us mortals, it more than fits the bill.Update 05 Sep 2014
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
narrow-or-widen-dwim
(updated above).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.
Update 23 Sep 2014
I’ve updated it to no longer use the
org-in-src-block-p
function and just try callingorg-edit-src-code
instead.org-in-src-block-p
has proven quite unreliable.Update 05 Dec 2015
Now it should also work with any type of org-block supported by
org-narrow-to-block
.Update 07 Dec 2015
Use
LaTeX-mode-hook
instead ofeval-after-load
, as suggested by Omar in the comments.Tags: narrow, intuitive, keybind, init.el, emacs,
Banishing the Shift Key with Key-Chord in Emacs »
« Hungry Delete Mode
Related Posts
A few paredit keys that take over the world in keybind
Fill and unfill paragraphs with a single key in keybind
Disable Mouse only inside Emacs in keybind
Content © 2019, All rights reserved. Icons under CC3.0.