Browse Source

Fix `org-return' on non-keyword

* lisp/org.el (org-return): Recognize non-keywords and split text
  accordingly.
* testing/lisp/test-org.el (test-org/return): Add test.

Reported-by: Samuel Wales <samologist@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/109929>
Nicolas Goaziou 8 years ago
parent
commit
e8b4eeb482
2 changed files with 8 additions and 5 deletions
  1. 3 5
      lisp/org.el
  2. 5 0
      testing/lisp/test-org.el

+ 3 - 5
lisp/org.el

@@ -21369,7 +21369,8 @@ object (e.g., within a comment).  In these case, you need to use
      ;; Insert newline in heading, but preserve tags.
      ((and (not (bolp))
 	   (save-excursion (beginning-of-line)
-			   (looking-at org-complex-heading-regexp)))
+			   (let ((case-fold-search nil))
+			     (looking-at org-complex-heading-regexp))))
       ;; At headline.  Split line.  However, if point is on keyword,
       ;; priority cookie or tags, do not break any of them: add
       ;; a newline after the headline instead.
@@ -21377,10 +21378,7 @@ object (e.g., within a comment).  In these case, you need to use
 			      (save-excursion (goto-char (match-beginning 5))
 					      (current-column))))
 	    (string
-	     (when (and (match-end 4)
-			(>= (point)
-			    (or (match-end 3) (match-end 2) (1+ (match-end 1))))
-			(<= (point) (match-end 4)))
+	     (when (and (match-end 4) (org-point-in-group (point) 4))
 	       (delete-and-extract-region (point) (match-end 4)))))
 	;; Adjust tag alignment.
 	(cond

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

@@ -1092,6 +1092,11 @@
 	  (org-test-with-temp-text "* TODO<point> [#B] H :tag:"
 	    (org-return)
 	    (buffer-string))))
+  (should				;TODO are case-sensitive
+   (equal "* \nTodo"
+	  (org-test-with-temp-text "* <point>Todo"
+	    (org-return)
+	    (buffer-string))))
   ;; At headline text, break headline text but preserve tags.
   (should
    (equal "* TODO [#B] foo    :tag:\nbar"