* lisp/org.el (org-map-entries): Check that buffer-file-name is non-nil
before passing to org-agenda-prepare-buffers.
This is a backport of commit
44c8cd7136e3fcd1e6bfa08895cac437b7a691fa
from upstream org-mode. Addresses bug #23365.
(if (not scope)
(progn
(org-agenda-prepare-buffers
- (list (buffer-file-name (current-buffer))))
+ (and buffer-file-name (list buffer-file-name)))
(setq res (org-scan-tags func matcher todo-only start-level)))
;; Get the right scope
(cond
(setq scope (org-agenda-files t))
(setq scope (org-add-archive-files scope)))
((eq scope 'file)
- (setq scope (list (buffer-file-name))))
+ (setq scope (and buffer-file-name (list buffer-file-name))))
((eq scope 'file-with-archives)
(setq scope (org-add-archive-files (list (buffer-file-name))))))
(org-agenda-prepare-buffers scope)