Browse Source

Merge branch 'maint'

Nicolas Goaziou 7 years ago
parent
commit
44e3745c78
2 changed files with 11 additions and 6 deletions
  1. 6 6
      lisp/org.el
  2. 5 0
      testing/lisp/test-org.el

+ 6 - 6
lisp/org.el

@@ -24221,10 +24221,11 @@ convenience:
 	(backward-char)
 	(org-backward-paragraph))
        ((<= (point) post-affiliated) (goto-char begin))
+       ;; Special behavior: on a table or a property drawer, move to
+       ;; its beginning.
        ((memq type '(node-property table-row))
 	(goto-char (org-element-property
 		    :post-affiliated (org-element-property :parent element))))
-       ((memq type '(property-drawer table)) (goto-char begin))
        (special?
 	(if (<= (point) contents-begin) (goto-char post-affiliated)
 	  ;; Inside a verse block, see blank lines as paragraph
@@ -24235,8 +24236,7 @@ convenience:
 	      (skip-chars-forward " \r\t\n" origin)
 	      (if (= (point) origin) (goto-char contents-begin)
 		(beginning-of-line))))))
-       ((eq type 'paragraph)
-	(goto-char contents-begin)
+       ((eq type 'paragraph) (goto-char contents-begin)
 	;; When at first paragraph in an item or a footnote definition,
 	;; move directly to beginning of line.
 	(let ((parent-contents
@@ -24244,9 +24244,9 @@ convenience:
 		:contents-begin (org-element-property :parent element))))
 	  (when (and parent-contents (= parent-contents contents-begin))
 	    (beginning-of-line))))
-       ;; At the end of a greater element, move to the beginning of the
-       ;; last element within.
-       ((>= (point) contents-end)
+       ;; At the end of a greater element, move to the beginning of
+       ;; the last element within.
+       ((and contents-end (>= (point) contents-end))
 	(goto-char (1- contents-end))
 	(org-backward-paragraph))
        (t (goto-char (or post-affiliated begin))))

+ 5 - 0
testing/lisp/test-org.el

@@ -3606,6 +3606,11 @@ SCHEDULED: <2017-05-06 Sat>
   ;; beginning of block.
   (should
    (org-test-with-temp-text "#+BEGIN_<point>EXAMPLE\nL1\n#+END_EXAMPLE"
+     (org-backward-paragraph)
+     (bobp)))
+  ;; Pathological case: on an empty heading, move to its beginning.
+  (should
+   (org-test-with-temp-text "* <point>H"
      (org-backward-paragraph)
      (bobp))))