Bläddra i källkod

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.
Gustav Wikström 4 år sedan
förälder
incheckning
dad436c60b
2 ändrade filer med 15 tillägg och 3 borttagningar
  1. 12 0
      etc/ORG-NEWS
  2. 3 3
      lisp/org.el

+ 12 - 0
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

+ 3 - 3
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))))