Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lazy loading of only the first N lines in emacs org-mode

Tags:

emacs

org-mode

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.

like image 919
719016 Avatar asked Jun 22 '11 19:06

719016


People also ask

How to use Org mode in Emacs?

Emacs does not actually understand you are editing an Org document, yet. To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores.

How do I turn off line numbers in Emacs?

By default, Emacs displays the current line number of the point in the mode line. You can toggle this feature off or on with the command M-x line-number-mode , or by setting the variable line-number-mode .

Why use Org mode?

Org Mode facilitates this by allowing items to be subdivided into simple steps (nested to-dos and/or checklists), and given tags and properties such as priorities and deadlines. An agenda for the items to be done this week or day can then be automatically generated from date tags. Plain text outlines.


2 Answers

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.

like image 168
Dave Bacher Avatar answered Sep 20 '22 12:09

Dave Bacher


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.

like image 40
phils Avatar answered Sep 20 '22 12:09

phils