Skip to content

Commit 4080938

Browse files
committed
org-agenda-prepare-buffers: Avoid repetitive updates of agenda menu
* lisp/org.el (org-agenda-file-menu-enabled): New variable controlling whether `org-mode' updates the agenda file list in the menu. (org-mode): Honor the new variable. (org-agenda-prepare-buffers): Suppress `org-install-agenda-files-menu' when opening the agenda files. Run it once at the end. This commit reduces performance overheads when the number of agenda files is large.
1 parent d3a9c42 commit 4080938

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lisp/org.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,7 +4713,8 @@ The following commands are available:
47134713
\\{org-mode-map}"
47144714
(setq-local org-mode-loading t)
47154715
(org-load-modules-maybe)
4716-
(org-install-agenda-files-menu)
4716+
(when org-agenda-file-menu-enabled
4717+
(org-install-agenda-files-menu))
47174718
(when (and org-link-descriptive
47184719
(eq org-fold-core-style 'overlays))
47194720
(add-to-invisibility-spec '(org-link)))
@@ -15167,7 +15168,10 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
1516715168
"Create buffers for all agenda files, protect archived trees and comments."
1516815169
(interactive)
1516915170
(let ((inhibit-read-only t)
15170-
(org-inhibit-startup org-agenda-inhibit-startup))
15171+
(org-inhibit-startup org-agenda-inhibit-startup)
15172+
;; Do not refresh list of agenda files in the menu when
15173+
;; opening every new file.
15174+
(org-agenda-file-menu-enabled nil))
1517115175
(setq org-tag-alist-for-agenda nil
1517215176
org-tag-groups-alist-for-agenda nil)
1517315177
(dolist (file files)
@@ -15210,6 +15214,9 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
1521015214
(org-uniquify org-todo-keywords-for-agenda))
1521115215
(setq org-todo-keyword-alist-for-agenda
1521215216
(org-uniquify org-todo-keyword-alist-for-agenda))))
15217+
;; Refresh the menu once after loading all the agenda buffers.
15218+
(when org-agenda-file-menu-enabled
15219+
(org-install-agenda-files-menu))))
1521315220

1521415221

1521515222
;;;; CDLaTeX minor mode
@@ -18000,6 +18007,8 @@ Your bug report will be posted to the Org mailing list.
1800018007
(when (re-search-backward "^\\(Subject: \\)Org mode version \\(.*?\\);[ \t]*\\(.*\\)" nil t)
1800118008
(replace-match "\\1[BUG] \\3 [\\2]")))))
1800218009

18010+
(defvar org-agenda-file-menu-enabled t
18011+
"When non-nil, refresh Agenda files in Org menu when loading Org.")
1800318012

1800418013
(defun org-install-agenda-files-menu ()
1800518014
"Install agenda file menu."

0 commit comments

Comments
 (0)