emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] FR: headline iteration API


From: Max Mikhanosha
Subject: Re: [Orgmode] FR: headline iteration API
Date: Wed, 16 Jul 2008 11:06:04 -0400
User-agent: Wanderlust/2.15.3 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shij┼Ź) APEL/10.6 Emacs/22.0.51 (x86_64-unknown-linux-gnu) MULE/5.0 (SAKAKI)

At Wed, 11 Jun 2008 12:15:11 -0500,
Eddward DeVilla wrote:

>  - doc traversal
>     - first-item
>       Go to the first item in the file.
>     - current-item
>       Go to the beginning of the item containing the cursor.
>     - next-item
>       Go to the item after the current one.
>     - previous-item
>       Go to item before the current one

Some time ago I wrote the following for myself, and I find that I use
these bindings several times a day.

(defun my-org-skip-forward (arg)
  "Move forward to the next visible 2nd or greater level heading,
skipping headings of the same level as the starting position"
  (interactive "p")
  (let ((initial-level (org-outline-level))
        (done nil))
    (while (not done)
      (outline-next-visible-heading arg)
      (let ((level (org-outline-level)))
        (when (and (> initial-level 1) (= level 1))
           (setq initial-level -1))
        (setq done (or
                    (and (< arg 0) (bobp)) 
                    (and (> arg 0) (eobp))
                    (and (not (= level initial-level)))))))))

(defun my-org-skip-backward (arg)
  (interactive "p")
  (my-org-skip-forward (- arg)))

The idea is that point is moved to the next visible boundary where
outline level changes. This is useful when you have your file in
collapsed state with only a few trees expanded. Above command allows
one to quickly jump between such trees.

Also useful for navigating result of a sparse tree search in the same
manner.

Regards,
  Max





reply via email to

[Prev in Thread] Current Thread [Next in Thread]