With 12 MB of text that got a huge amount of date input headers, so I would suggest that narrowing the buffer might still be a good way.
I am new to org-mode, so I may miss the easier way to achieve this, but the following will automatically narrow the buffer to entries made three months before the current date.
(defvar my-org-journal "/path/to/file.org") (add-hook 'org-mode-hook 'my-org-mode-hook) (defun my-org-mode-hook () (when (equal (expand-file-name (buffer-file-name)) (expand-file-name my-org-journal)) (my-org-narrow-to-month-of-entries))) (defun my-org-narrow-to-month-of-entries () "Narrow buffer to entries within the last three months." (interactive) (let ((minimum-date (with-temp-buffer (progn (org-insert-time-stamp (current-time) nil t) (org-timestamp-change -3 'month) (buffer-substring-no-properties (point-min) (point-max)))))) (save-excursion (while (search-forward-regexp org-tsr-regexp-both nil t) (let ((end (point))) (backward-sexp) (let ((datestamp (buffer-substring-no-properties (point) end))) (if (string< datestamp minimum-date) (narrow-to-region (point-min) (point)) (forward-sexp))))))))
And, of course, Cx n w to expand the buffer again to see all the records.
If you want to apply this based on a local variable, and not by file name, you can use this approach:
(defvar my-org-narrow-to-month-of-entries nil) (add-hook 'org-mode-hook 'my-org-mode-hook) (defun my-org-mode-hook () (add-hook 'hack-local-variables-hook (lambda () (when my-org-narrow-to-month-of-entries (my-org-narrow-to-month-of-entries))) nil t))
with the following at the end of the file:
;;; Local Variables: ;;; my-org-narrow-to-month-of-entries: t ;;; End:
Literature:
edit:
I'm not sure that, to be honest, this will do something with this long boot time. An example of an org file of comparable size is not deleted remotely, which takes a long time to load onto my machine, but I don’t know, because it is easier to process due to better hardware or my simple stub file.
If the above does not improve the situation, we could try to narrow down before initializing org-mode and see if it doesn't matter?
The following may not be the best way to do this, but it's worth a try for performance reasons just in case it matters.
This will be instead of binding org-mode and using the variable my-org-journal for the file name, as in the first example above.
(defadvice insert-file-contents (after my-insert-file-contents) (when (equal (expand-file-name (buffer-file-name)) (expand-file-name my-org-journal)) (require 'org) (my-org-narrow-to-month-of-entries))) (ad-activate 'insert-file-contents)