0

In org mode, say I'm on a headline, and just below that is a PROPERTIES drawer:

*** this is my headline, I want to move past the closed PROPERTIES drawer
:PROPERTIES:
:CREATED:  [2024-01-31T10:54:33-0600]
:SOMEPROP: value here
:END:

I want to move past the drawer, to the start of the line below :END:. Is there some motion command that will do that? Something better than just C-n several times? Frustratingly, M-} in that situation says "cannot move further down".

1
  • You can do C-n TAB C-n to move to the drawer, fold it and then move past it. Or C-n M-}.
    – NickD
    Jan 31 at 22:16

2 Answers 2

0

I don't know of any out of the box solution. However, you could advise org-forward-element as follows

(defun org-forward-element-ad (orig-fun &rest args)
  (condition-case nil
      (apply orig-fun args)
    (error (forward-line)
           (apply orig-fun args))))

(advice-add 'org-forward-element :around #'org-forward-element-ad)

and then simply use M-}.

1
  • That's not too bad, but still not quite what I was hoping for. Thank you, though! What I think we really need here are motion functions that work with drawers in the same way that, say, org-forward-heading-same-level and org-previous-visible-heading and friends work with headings, and that org-next-block works with blocks. I want stuff like that for drawers.
    – Dan Drake
    Feb 3 at 12:50
0

Digging through org source code, I found something that works. Hooray, I guess, for obscure, undocumented functions buried in lisp code... :)

This uses org-end-of-meta-data:

"Skip planning line and properties drawer in current entry.

When optional argument FULL is t, also skip planning information,
clocking lines and any kind of drawer.

When the heading is closed, though, it just moves point to the end of the visible line. For what I'm doing here, I want to open/unfold the heading. So I just need org-fold-show-entry first. The following two-line function is basically what I was hoping for here:

(defun org-open-and-put-point-past-drawers()
  "Show/unfold current entry and position POINT past entry's metadata.

The 'metadata' is defined by `org-end-of-meta-data', and we skip
past planning lines, clocking lines, and any kind of drawer."
  (interactive)
  (org-fold-show-entry)
  (org-end-of-meta-data t))

And then you add in some kind of UI for that. I've used C-c M-n, which reminds me of C-c C-n, C-c C-x C-n, and others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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