Skip to content

[feature request] Jump to an existing field given its outline path #29

@rodrigo-morales-1

Description

@rodrigo-morales-1

In Org Mode, it is possible to jump to a given headline by speciying its outline. See minimal working example below.

(with-temp-buffer
  (org-mode)
  (insert
   (concat
    "* 1\n"
    "* 2\n"
    "** 2.1\n"
    "*** 2.1.1\n"
    "*** 2.1.2\n"
    "* 3\n"))
  (goto-char (point-min))
  (goto-char (org-find-olp '("2" "2.1" "2.1.1") t))
  (thing-at-point 'line t))
*** 2.1.1

Given the similarity between YAML and Org Mode documents, I believe that such function would come in handy when editing YAML files.

The function could be called yaml-find-olp and it would work the same way as org-find-olp. Consider the YAML document shown below, after executing (yaml-find-olp '("2" "2.1" "2.1.1") t), the point would be at <point>.

1:
2:
  2.1:
    2.1.1:
    2.1.2: <point>

The function would also complain when there are two fields with the same outline path just as org-find-olp does (see minimal working example below).

(with-temp-buffer
  (org-mode)
  (insert
   (concat
    "* 1\n"
    "* 2\n"
    "** 2.1\n"
    "*** 2.1.1\n"
    "*** 2.1.1\n"
    "* 3\n"))
  (goto-char (point-min))
  (condition-case err
      (org-find-olp '("2" "2.1" "2.1.1") t)
    ('error (error-message-string err))))
Heading not unique on level 3: 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions