浏览代码

org-map-entries: Do not demand file buffer when SCOPE is nil

* lisp/org.el (org-map-entries): Avoid calling
`org-agenda-prepare-buffers' for non-file buffers.
`org-agenda-prepare-buffers' expects a file buffer and gives
unexpected dialogue otherwise.  Since `org-agenda-prepare-buffer' only
contains optional cache calculations and things only useful for agenda
generation, not calling it should be reasonably safe.

Reported-by: Rodrigo Morales <moralesrodrigo1100@gmail.com>
Link: https://orgmode.org/list/871r54m6xm.fsf@gmail.com
Ihor Radchenko 2 年之前
父节点
当前提交
88c85d620b
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      lisp/org.el

+ 5 - 2
lisp/org.el

@@ -12187,8 +12187,11 @@ a *different* entry, you cannot use these techniques."
 
 
 	  (if (not scope)
 	  (if (not scope)
 	      (progn
 	      (progn
-		(org-agenda-prepare-buffers
-		 (and buffer-file-name (list buffer-file-name)))
+                ;; Agenda expects a file buffer.  Skip over refreshing
+                ;; agenda cache for non-file buffers.
+                (when buffer-file-name
+		  (org-agenda-prepare-buffers
+		   (and buffer-file-name (list buffer-file-name))))
 		(setq res
 		(setq res
 		      (org-scan-tags
 		      (org-scan-tags
 		       func matcher org--matcher-tags-todo-only start-level)))
 		       func matcher org--matcher-tags-todo-only start-level)))