Bernt Hansen <[email protected]> writes:
> Eric Abrahamsen <[email protected]> writes:
>
>> I'm writing a little helper function for use when I'm starting work on a
>> particular long-term writing project. Basically I found myself doing the
>> same little ritual of commands two or three times a day, and I got tired
>> of it. Here's what I've got so far, it's pretty self-explanatory. The "my-"
>> variables are set elsewhere.
[...]
> Hi Eric,
>
> If your chapters are always level 1 headings you can do something like
> this:
>
> (defun bh/jump-to-last-level-1-heading ()
> (interactive)
> (goto-char (point-max))
> (while (org-up-heading-safe)))
Thanks for the pointers! A =while= form with no body wasn't
something that had occured to me, that's pretty useful. The final
command, which does just what I want, is below.
Eric
#+begin_src emacs-lisp
(defun my-project-start ()
(interactive)
(delete-other-windows)
(find-file my-project-file)
(goto-char (point-max))
(while (org-up-heading-safe))
(while (not (looking-at "\\* Chapter"))
(org-backward-same-level 1))
(org-narrow-to-subtree)
(split-window-horizontally)
(other-window 1)
(show-subtree)
(goto-char (point-max))
(abbrev-mode 1)
(read-abbrev-file my-project-abbrev-file)
)
#+end_src