Questions tagged [narrowing]

Questions related to narrowing (restricting) the editable area of a buffer.

Narrowing a buffer temporarily focuses editing on a portion of the content.

Emacs provides the narrow-to-region command (and several related commands) for setting the buffer restriction. These commands temporarily make content outside of the specified region inaccessible and hidden. The restriction can be removed using widen.

36 questions
20
votes
3 answers

Can I have two views on a file - one narrowed one not?

I am editing some file, abc.org, and call org-narrow-to-block to narrow to a code block that I want to edit. For the editing process I have to access another part of abc.org and just want to show it in another window. So I do "C-x 2" and find that…
Matthias
  • 745
  • 3
  • 14
8
votes
5 answers

How do I search in search results

When I C-s I can search. How should I do a function which I could bind for example to C-r which would let me search in the results of some predefined search query? Like contents of window would be: function xyz(a, b) return a + b end I can C-M-s…
lukas.pukenis
  • 677
  • 6
  • 11
8
votes
2 answers

Narrow to previous restriction

Is there a convenient way to restore the previous restriction? So after the following sequence of events: Mark a region Call narrow-to-region and do some work. Call widen to jump around and look for something I'd like to narrow to the original…
glucas
  • 20,175
  • 1
  • 51
  • 83
6
votes
1 answer

How to save a desktop with narrowed indirect buffers?

I am unable to figure out a way to save my narrowed indirect buffer window, and restore it as it was. Say I have a frame with several windows containing several indirect buffers, each narrowed to a different subtree (org mode) or region. What I…
Novus
  • 107
  • 4
6
votes
3 answers

How to narrow to python class?

How can I narrow a buffer to the python class at point? narrow-to-region works but requires first selecting the class as a region, and it seems python-mode has moved on since this was…
Croad Langshan
  • 3,192
  • 14
  • 42
6
votes
3 answers

How can I hide indentation on a narrowed defun?

When I'm in the middle of implementing a new function, I like to narrow my source buffer to just that function (C-x n d). However, this leaves the function indented as it was. I would like to have the function aligned to the left, but returned to…
J David Smith
  • 2,635
  • 1
  • 16
  • 27
5
votes
1 answer

Syntax highlight narrowed python string literals as code

I have some python code, that has some long string literals containing more python code. These strings should most of the time be uniformly colored, as happens by default. However, I would like to be able to some times narrow my buffer to any of…
jmlorenzi
  • 283
  • 1
  • 5
4
votes
1 answer

Frame specific narrowing

I'm using make-frame-on-display for collaborative editing with a colleague. Everything seems to work OK, but to avoid confusion we tend not to edit the exact part of the same file at the same time. As a part of my workflow, I like to…
Daniel
  • 3,563
  • 16
  • 41
4
votes
2 answers

How to show part of buffer in different buffer?

I have a buffer with some data. I want to select part of buffer and open the selection in different buffer (and window) to make it easier to read for me. Is there some function that does it? I am looking for something like…
MatthewRock
  • 1,453
  • 13
  • 27
4
votes
1 answer

Preserve original line numbering for a narrowed region

I noticed that whenever I narrow a region in emacs, the line numbering is relative to the narrowed region rather than being relative to the original file. Is there any way I can preserve the line numbering from the original buffer ?
Chakravarthy Raghunandan
  • 3,132
  • 2
  • 18
  • 42
3
votes
1 answer

Put “save-excursion” Outermost When Using Both “save-excursion” And “save-restriction”

I'm reading Emacs Lisp Intro by Robert J. Chassell. In 6.1 The ‘save-restriction’ Special Form when you use both ‘save-excursion’ and ‘save-restriction’, one right after the other, you should use ‘save-excursion’ outermost. If you write them in…
shynur
  • 4,065
  • 1
  • 3
  • 23
3
votes
1 answer

Why advice won't work if the function is called from another compiled function?

Let's consider a minimal example, I take org-narrow-to-subtree as a compiled function, under the hood it calls narrow-to-region, I add simple advice to it: (defun bark (START END) (message "Bark!")) (advice-add 'narrow-to-region :before #'bark) If…
3
votes
1 answer

Centering within comment blocks or ASCII art

I have C comments like this: /****************************************************************************** * Includes * …
Vercingatorix
  • 201
  • 1
  • 6
3
votes
2 answers

Delighting narrow-to-region possible?

I want to delight narrow-to-region. When I call org-toggle-narrow-to-subtree it calls org-narrow-to-subtree which calls narrow-to-region. When this is called the modeline shows "Narrow". Is there a way to delight that? I would like to replace that…
Jens Lange
  • 463
  • 2
  • 13
2
votes
1 answer

How to create buffer for custom source code region (e.g for each function)?

Objective : Frame some areas in a source code file, with custom pattern (e.g "# - Name of Region - #"), and then having the choice to type the name of region to directly open a buffer containing only the region's inside text. Could someone puts the…
Guest4314
  • 23
  • 3
1
2 3