3

I wan't to be able to programmatically open a file in org mode and scroll to a specific header. the file is quite big, so opening the file at a certain place is qhat I am looking for.

Any idea how to do that from the terminal via Bash?

5

Perhaps something along the following lines:

emacs -Q --eval='(progn (find-file "/path/to/file") (goto-char (org-find-exact-headline-in-buffer "org-headline")))'

2
  • 1
    You might want to skip the -Q though: it depends on whether one wants to do something quick and exit, in which case the -Q is useful, since it avoids the potentially long user initialization; or whether one wants to continue working in that emacs session, in which case the user initialization, although long, is useful and amortized over the life of the session. If there is an emacs server running, the emacsclient invocation of the above might be even more useful. – NickD Jun 2 at 16:25
  • Great, thanks. It works even with nested headings. – kipkipe Jun 3 at 6:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.