Browse Source

Merge branch 'maint'

Nicolas Goaziou 8 years ago
parent
commit
ecf20715e2
2 changed files with 59 additions and 14 deletions
  1. 15 14
      lisp/org.el
  2. 44 0
      testing/lisp/test-org.el

+ 15 - 14
lisp/org.el

@@ -7942,20 +7942,21 @@ When NO-TAGS is non-nil, don't include tags.
 When NO-TODO is non-nil, don't include TODO keywords."
   (save-excursion
     (org-back-to-heading t)
-    (cond
-     ((and no-tags no-todo)
-      (looking-at org-complex-heading-regexp)
-      (match-string 4))
-     (no-tags
-      (looking-at (concat org-outline-regexp
-			  "\\(.*?\\)"
-			  "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$"))
-      (match-string 1))
-     (no-todo
-      (looking-at org-todo-line-regexp)
-      (match-string 3))
-     (t (looking-at org-heading-regexp)
-	(match-string 2)))))
+    (let ((case-fold-search nil))
+      (cond
+       ((and no-tags no-todo)
+	(looking-at org-complex-heading-regexp)
+	(match-string 4))
+       (no-tags
+	(looking-at (concat org-outline-regexp
+			    "\\(.*?\\)"
+			    "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$"))
+	(match-string 1))
+       (no-todo
+	(looking-at org-todo-line-regexp)
+	(match-string 3))
+       (t (looking-at org-heading-regexp)
+	  (match-string 2))))))
 
 (defvar orgstruct-mode)   ; defined below
 

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

@@ -1346,6 +1346,50 @@
 
 ;;; Headline
 
+(ert-deftest test-org/get-heading ()
+  "Test `org-get-heading' specifications."
+  ;; Return current heading, even if point is not on it.
+  (should
+   (equal "H"
+	  (org-test-with-temp-text "* H"
+	    (org-get-heading))))
+  (should
+   (equal "H"
+	  (org-test-with-temp-text "* H\nText<point>"
+	    (org-get-heading))))
+  ;; Without any optional argument, return TODO keywords and tags.
+  (should
+   (equal "TODO H"
+	  (org-test-with-temp-text "#+TODO: TODO | DONE\n* TODO H<point>"
+	    (org-get-heading))))
+  (should
+   (equal "H :tag:"
+	  (org-test-with-temp-text "* H :tag:"
+	    (org-get-heading))))
+  ;; With NO-TAGS argument, ignore tags.
+  (should
+   (equal "TODO H"
+	  (org-test-with-temp-text "#+TODO: TODO | DONE\n* TODO H<point>"
+	    (org-get-heading t))))
+  (should
+   (equal "H"
+	  (org-test-with-temp-text "* H :tag:"
+	    (org-get-heading t))))
+  ;; With NO-TODO, ignore TODO keyword.
+  (should
+   (equal "H"
+	  (org-test-with-temp-text "#+TODO: TODO | DONE\n* TODO H<point>"
+	    (org-get-heading nil t))))
+  (should
+   (equal "H :tag:"
+	  (org-test-with-temp-text "* H :tag:"
+	    (org-get-heading nil t))))
+  ;; TODO keywords are case-sensitive.
+  (should
+   (equal "Todo H"
+	  (org-test-with-temp-text "#+TODO: TODO | DONE\n* Todo H<point>"
+	    (org-get-heading nil t)))))
+
 (ert-deftest test-org/in-commented-heading-p ()
   "Test `org-in-commented-heading-p' specifications."
   ;; Commented headline.