[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] Re: programmatic jump to headline
From: |
Eric Abrahamsen |
Subject: |
[O] Re: programmatic jump to headline |
Date: |
Sat, 26 Mar 2011 15:07:52 +0800 |
User-agent: |
Gnus/5.110016 (No Gnus v0.16) Emacs/23.2 (gnu/linux) |
Bernt Hansen <address@hidden> writes:
> Eric Abrahamsen <address@hidden> 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