I have a large journal file with date entries like this:
[2011-06-23 Thu] some text [2011-06-22 Wed] some more text [... 12MB of text later ...] [2000-01-01 Sat] first entry
I would like to be able to configure org-mode so that only the last 3 months are visible, whereas older entries are collapsed, and are only expanded when I need to. Is there a way of setting this up automatically so that every new day makes the 3 month + 1 day old entry be collapsed next time?
As it is now, it's impossible for me to use, because it takes more than a minute to load the document.
Create an agenda view with
C-[
then look at the daily/weekly agenda withC-u 90 C-c a a
. You can customise this and bind it to something, see http://www.gnu.org/software/emacs/manual/html_node/org/Custom-agenda-views.html#Custom-agenda-views .[EDIT] Actually, this doesn't answer the question about collapsing older entries, but does allow you to view only the relevant entries.
You have three options:
VISIBILITY
property tofolded
for all older entries. You can use C-c a < a to get the agenda restricted to the current file followed by marking the entries and setting the above property en masse.I don't have a completely automated way to do what you're asking. I'm sure someone with some elisp/org-mode chops could automate it.
Here are some org-mode features that might help:
One annoyance that I found when trying this on my system is that the search result ended up with a flat list of all heading levels. The way I organize entries, it would be better to limit the search to top-level headings (that's what I use for daily entries in my journal). I'm sure you could work around it by setting some property, or perhaps org-mode can filter searches at a particular level.
With 12MB of text, that's got to be a huge number of date entry headings, so I would imagine buffer narrowing might still be a good way to go.
I'm an org-mode novice, so I may be missing an easier way to achieve this, but the following will automatically narrow the buffer to the entries made since three months prior to the current date.
And, of course, C-xnw to widen the buffer again to see all the entries.
If you wanted to apply this based on a Local Variable rather than by file name, you could use this approach instead:
with the following at the end of your file:
References:
edit:
I'm not sure if that will do anything about that long load time, to be honest. A sample org file of comparable size doesn't take remotely that long to load on my machine, but I don't know whether that's due to better hardware, or my simple dummy file being easier to process.
If the above doesn't improve things, we could look at making the narrowing happen before org-mode is initialised, and see if that makes any difference?
The following may not be the best way of doing this, but it should be worth trying out for performance reasons, just in case it makes a difference.
This would be in place of the org-mode-hook, and using the
my-org-journal
variable for the filename, as with the first example above.