~bzg/worg

ref: 559025d3195c39306b5a5546c06a4e375fe4ff7f worg/agenda-optimization.org -rw-r--r-- 5.5 KiB
559025d3Bastien org-contribute.org: Add a note to maintainers 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#+TITLE: Agenda speedup and optimization
#+AUTHOR: Bastien Guerry
#+STARTUP:    align fold nodlcheck hidestars oddeven
#+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
#+LANGUAGE:   en
#+CATEGORY:   worg
#+OPTIONS:    H:3 num:nil toc:t \n:nil ::t |:t ^:t -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc
#+LINK:       doc https://orgmode.org/worg/doc.html#%s

# This file is released by its authors and contributors under the GNU
# Free Documentation license v1.3 or later, code examples are released
# under the GNU General Public License v3 or later.

When your Org files grow, agenda generation may slow down.

Here are some tips on how to speed up the agenda generation.  For those
tips that depend on a specific version of Org, we mention this version.

#+INDEX: Agenda speedup

* Reduce the number of Org agenda files

The more agenda files, the more time it takes to check all of them before
producing an agenda command.  The older your hardrive is, the longer it
takes to visit a file.  Don't buy a new harddrive now!  Just reduce the
number of agenda files.

Also, don't forget that you can define the set of agenda files for each
agenda custom command like this:

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-custom-commands
        '((" " "Aujourd'hui" agenda "List of rendez-vous and tasks for today"
           ((org-agenda-files '("~/org/rdv.org" "~/org/bzg.org"))))))
#+END_SRC

* Reduce the number of DONE and archived headlines

When matching against TODO-type tasks, Org will skip the ones marked as
DONE or archived.  If you have many DONE tasks and archived tasks in your
file, better to store them in another file.

* Inhibit the dimming of blocked tasks

#+INDEX: Dim blocked tasks
#+INDEX: org-agenda-dim-blocked-tasks

By default [[doc::org-agenda-dim-blocked-tasks][org-agenda-dim-blocked-tasks]] is set to t, which will dim blocked
tasks.  For the agenda to get the relevant information, it needs to check
against the headline up, and this takes time.  If you don't need this
feature globally or for a specific agenda, turning it off will speed up
agenda generation.

* Inhibit agenda files startup options (Org > 8.0)

#+INDEX: org-startup-folded

When you run an agenda command, Org visits agenda files that are not yet
visited.  When finding a file for the first time, Org checks the startup
options and apply them to the buffer: those options are either globally set
through the =org-startup-*= variables or on a per-file basis through the
=#+STARTUP= keyword.

Especially, Org will honor the startup visibility status, as set by
[[doc::org-startup-folded][org-startup-folded]] or =#+STARTUP: folded=.

This may slow down the operation of visiting a file very much, and the
process of selecting agenda entries consequently.

To prevent agenda commands to honor startup options when visiting an agenda
file for the first time, use this:

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-inhibit-startup t)
#+END_SRC

The side-effect is that newly visited file will have all their headlines
visible, but this speeds up agenda generation /a lot/ when those files have
many nested headlines.

* Disable tag inheritance in agendas (Org > 8.0)

#+INDEX: Tag inheritance
#+INDEX: org-use-tag-inheritance
#+INDEX: org-agenda-use-tag-inheritance
#+INDEX: org-agenda-show-inherited-tags

Defining inherited tags for a headline in the agenda takes time, because
Org needs will grab inherited tags from higher level headlines.

Whether the agenda knows about inherited tags for each task depends on
[[doc::org-use-tag-inheritance][org-use-tag-inheritance]] and [[doc::org-agenda-use-tag-inheritance][org-agenda-use-tag-inheritance]]:

- [[doc::org-use-tag-inheritance][org-use-tag-inheritance]] controls whether tags are inherited for tags-type
  agenda commands: =tags=, =tags-todo= and =tags-tree=.  This variable also
  controls whether tags are inherited when running the command =M-x
  org-sparse-tree RET= in an Org buffer (hence the name of this variable,
  without the =org-agenda-= prefix.)

- [[doc::org-agenda-use-tag-inheritance][org-agenda-use-tag-inheritance]] controls whether tags are inherited for
  other agenda types too: =todo=, =search=, =timeline=, =agenda=.

  Generally, you want this variable to be nil, because the headlines on
  those agenda types don't depend on tags (and /a fortiori/ on inherited
  ones.)  Still, the default is to use tags in all agenda types, because
  [[doc::org-agenda-show-inherited-tags][org-agenda-show-inherited-tags]] needs to do the right thing by default.

What to do?  If you don't need inherited tags in
todo/search/timeline/agenda, just use this setting:

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-use-tag-inheritance nil)
#+END_SRC

If you need tags in todo agendas only:

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-use-tag-inheritance '(search timeline agenda))
#+END_SRC

You can also set this on a per-command basis:

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-custom-commands
        '((" " "Aujourd'hui" agenda "List of rendez-vous and tasks for today"
           ((org-agenda-files '("~/org/rdv.org" "~/org/bzg.org"))
            (org-agenda-use-tag-inheritance nil)))))
#+END_SRC

* Disable parsing for some drawer properties

Text properties are used to prepare buffers for effort estimates,
appointments, and subtree-local categories in the agenda.  If you
don't use some of these agenda features, you can turn them off.
Since using such drawer properties require a special scan before each
new agenda command, this can lead to a speedup. For example

#+BEGIN_SRC emacs-lisp
  (setq org-agenda-ignore-drawer-properties '(effort appt category))
#+END_SRC