From agenda view, is it possible to execute functions on specific .org files?
Example setup: foo.org
and 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.
However, when 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.
edit
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?
foo.org
(which I'm sure you can), you also need to somehow tell it WHERE in that buffer to execute the function. You have added nothing here to specify that crucial piece of information.