summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustav Wikström <p950gsw@fspa.myntet.se>2020-11-05 00:42:01 +0100
committerGustav Wikström <p950gsw@fspa.myntet.se>2020-11-05 00:49:23 +0100
commitdad436c60bb9fe92382cf43921fada4bd75d5414 (patch)
tree59a0df895672c6bd64a3da0f9ea119b96fe8f25c
parent8d7a9b4ce9a2642afa951866e0e2550cb3062eef (diff)
downloadorg-mode-dad436c60bb9fe92382cf43921fada4bd75d5414.tar.gz
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.
-rw-r--r--etc/ORG-NEWS12
-rw-r--r--lisp/org.el6
2 files changed, 15 insertions, 3 deletions
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 7f935bf..60bff52 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 875044a..9a13f03 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))))