6

Is there a way to tell org-mode to load only the first N lines of a long text file? I would like to keep the whole file open to be able to search through it, but have org-mode display on the first N lines of my file, which is where I edit new content.

719016
  • 9,922
  • 20
  • 85
  • 158
  • 1
    I suspect that this is agnostic to org-mode, but I'd love to hear a good solution. – jdd Jun 22 '11 at 20:27
  • 1
    You could just split the window and re-size the org mode buffer to as many rows as you want. Not a perfect solution, but it works. – yarian Jun 23 '11 at 01:46
  • how can I resize the org mode buffer? Manually with a cut+paste? – 719016 Jun 23 '11 at 06:16

2 Answers2

6

If you have a structured outline in org-mode, you can set the global file visibility with the #+STARTUP markup, or the visibility of any heading with the VISIBILITY property, see Visibility Cycling for details. The benefit of using the built-in org-mode properties is that it's easy to have a file open up in exactly the state you want.

I have my journal file set up to accomplish something similar what I think you're asking for using these org-mode properties. The "Today" section is opened so I can see everything, but older archives are collapsed.

Dave Bacher
  • 15,652
  • 3
  • 63
  • 86
  • Sounds good. So I now can turn my question into: how can I collapse all entries older than 3 months in my org-mode journal file? http://stackoverflow.com/questions/6451044/how-can-i-collapse-all-entries-older-than-3-months-in-my-emacs-org-mode-journal-f – 719016 Jun 23 '11 at 08:03
5

I'm not sure the title really fits the description?

I think you just want use buffer narrowing, which lets you hide everything outside of the specified region for as long as necessary.

You can manually narrow the buffer by marking the region and typing C-xnn

Widen the display back to the full buffer with C-xnw

I guess you could use an eval Local Variable to automate this to a pre-defined region, if you really wanted to.

There's also narrow-to-defun (C-xnd) and narrow-to-page (C-xnp). If you throw a page break into your org file (C-qC-l), the latter might prove handy.

phils
  • 71,335
  • 11
  • 153
  • 198
  • Ahh, I thought he was asking about loading n lines from a file with a lot of lines – jdd Jun 22 '11 at 23:48