Make `org-goto-first-child' behave intuitively before first heading

* lisp/org.el (org-goto-first-child): Make it understand outline
level 0 as well.  The function now behaves intuitively also before
first heading.
This commit is contained in:
Gustav Wikström 2020-11-05 00:42:01 +01:00
parent 8d7a9b4ce9
commit dad436c60b
2 changed files with 15 additions and 3 deletions

View File

@ -88,6 +88,18 @@ package, to convert pandas Dataframes into orgmode tables:
| 2 | 3 | 6 |
#+end_src
** Miscellaneous
*** =org-goto-first-child= now works before first heading
When point is before first heading =org-goto-first-child= will move
point to the first child heading, or return nil if no heading exist
in buffer. This is in line with the fact that everything before first
heading is regarded as outline level 0, i.e. the parent level of all
headings in the buffer.
Previously =org-goto-first-child= would do nothing before first
heading, except return nil.
* Version 9.4
** Incompatible changes
*** Possibly broken internal file links: please check and fix

View File

@ -20427,10 +20427,10 @@ move point."
Return t when a child was found. Otherwise don't move point and
return nil."
(let (level (pos (point)) (re org-outline-regexp-bol))
(when (ignore-errors (org-back-to-heading t))
(setq level (outline-level))
(when (org-back-to-heading-or-point-min t)
(setq level (org-outline-level))
(forward-char 1)
(if (and (re-search-forward re nil t) (> (outline-level) level))
(if (and (re-search-forward re nil t) (> (org-outline-level) level))
(progn (goto-char (match-beginning 0)) t)
(goto-char pos) nil))))