Browse Source

Fix `org-beginning-of-line'

* lisp/org.el (org-beginning-of-line): Prevent an error when buffer
  contains only a single star.

* testing/lisp/test-org.el (test-org/beginning-of-line): Add tests.
Nicolas Goaziou 9 years ago
parent
commit
6e1d7bc8fe
2 changed files with 10 additions and 2 deletions
  1. 1 1
      lisp/org.el
  2. 9 1
      testing/lisp/test-org.el

+ 1 - 1
lisp/org.el

@@ -23816,7 +23816,7 @@ beyond the end of the headline."
     (when special
       (cond
        ((and (looking-at org-complex-heading-regexp)
-	     (= (char-after (match-end 1)) ?\ ))
+	     (eq (char-after (match-end 1)) ?\s))
 	(setq refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
 			  (point-at-eol)))
 	(goto-char

+ 9 - 1
testing/lisp/test-org.el

@@ -1815,7 +1815,15 @@ drops support for Emacs 24.1 and 24.2."
        (org-end-of-line)
        (and (progn (org-beginning-of-line) (looking-at "Headline"))
 	    (progn (org-beginning-of-line) (bolp))
-	    (progn (org-beginning-of-line) (looking-at "Headline")))))))
+	    (progn (org-beginning-of-line) (looking-at "Headline"))))))
+  ;; Special case: Do not error when the buffer contains only a single
+  ;; asterisk.
+  (should
+   (org-test-with-temp-text "*<point>"
+     (let ((org-special-ctrl-a/e t)) (org-beginning-of-line))))
+  (should
+   (org-test-with-temp-text "*<point>"
+     (let ((org-special-ctrl-a/e nil)) (org-beginning-of-line)))))
 
 (ert-deftest test-org/end-of-line ()
   "Test `org-end-of-line' specifications."