From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: programmatic jump to headline Date: Sat, 26 Mar 2011 15:07:52 +0800 Message-ID: <87oc4y2wc7.fsf@ericabrahamsen.net> References: <87vcz7o7zn.fsf@ericabrahamsen.net> <87ipv7o20h.fsf@norang.ca> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=42000 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q3Nda-0007Io-8n for emacs-orgmode@gnu.org; Sat, 26 Mar 2011 03:10:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q3NbS-0003yj-8e for emacs-orgmode@gnu.org; Sat, 26 Mar 2011 03:08:11 -0400 Received: from lo.gmane.org ([80.91.229.12]:33609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q3NbS-0003yd-21 for emacs-orgmode@gnu.org; Sat, 26 Mar 2011 03:08:06 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q3NbR-0007O5-9j for emacs-orgmode@gnu.org; Sat, 26 Mar 2011 08:08:05 +0100 Received: from 123.121.233.140 ([123.121.233.140]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 Mar 2011 08:08:05 +0100 Received: from eric by 123.121.233.140 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 26 Mar 2011 08:08:05 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Bernt Hansen writes: > Eric Abrahamsen 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