Jelajahi Sumber

org: Fix tags extraction

* lisp/org.el (org-get-tags-at): Use non-greedy match up to colon to
  match all tags (and not just the last.)
* testing/lisp/test-org.el (test-org/tags-at): One test to cover the
  issue.
Marco Wahl 8 tahun lalu
induk
melakukan
7e57cf5d40
2 mengubah file dengan 8 tambahan dan 1 penghapusan
  1. 1 1
      lisp/org.el
  2. 7 0
      testing/lisp/test-org.el

+ 1 - 1
lisp/org.el

@@ -14870,7 +14870,7 @@ ignore inherited ones."
 		    (org-back-to-heading t)
 		    (while (not (equal lastpos (point)))
 		      (setq lastpos (point))
-		      (when (looking-at ".+:\\([[:alnum:]_@#%:]+\\):[ \t]*$")
+		      (when (looking-at ".+?:\\([[:alnum:]_@#%:]+\\):[ \t]*$")
 			(setq ltags (org-split-string
 				     (match-string-no-properties 1) ":"))
 			(when parent

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

@@ -4509,6 +4509,13 @@ Paragraph<point>"
 	     (org-fix-tags-on-the-fly))
 	    (buffer-string)))))
 
+(ert-deftest test-org/tags-at ()
+  (should
+   (equal '("foo" "bar")
+	  (org-test-with-temp-text
+	   "* T<point>est :foo:bar:"
+	   (org-get-tags-at)))))
+
 
 ;;; Timestamps API