From agenda view, is it possible to execute functions on specific .org files?
bar.org are source files for agenda
Example working function from : Sort entire hierarchy in an Org mode buffer
(defun sort-all-org-entries () (interactive) (let ((fun #'(lambda nil (condition-case nil (org-sort-entries nil ?d) (user-error t))))) (org-map-entries fun))) (add-hook 'org-agenda-mode-hook (lambda() (local-set-key (kbd "g") 'sort-all-org-entries)))
The example function
sort-all-org-entries works correctly if
M-x sort-all-org-entries is activated in the buffer for either foo.org or bar.org.
g is pressed in the agenda buffer, the function is presumably executed only in the agenda as it presumably does not have a target .org file.
Is there a way to define
g to execute
sort-all-org-entries at the beginning of
foo.org, even though
g is activated from the agenda buffer?