diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 7f935bf52..60bff5268 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -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 diff --git a/lisp/org.el b/lisp/org.el index 875044a3e..9a13f03d6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -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))))