diff --git a/lisp/org-element.el b/lisp/org-element.el index 2f2fc45b8..83c6557fd 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -760,11 +760,14 @@ Assume point is at beginning of the headline." (point))))) ;; Clean RAW-VALUE from any quote or comment string. (when (or quotedp commentedp) - (setq raw-value - (replace-regexp-in-string - (concat "\\(" org-quote-string "\\|" org-comment-string "\\) +") - "" - raw-value))) + (let ((case-fold-search nil)) + (setq raw-value + (replace-regexp-in-string + (concat + (regexp-opt (list org-quote-string org-comment-string)) + "\\(?: \\|$\\)") + "" + raw-value)))) ;; Clean TAGS from archive tag, if any. (when archivedp (setq tags (delete org-archive-tag tags))) (let ((headline diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index be4103006..6716a61a4 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -739,23 +739,31 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01" (should-not (org-element-property :quotedp (org-element-at-point))))) ;; Standard position. (org-test-with-temp-text "* QUOTE Headline" - (let ((org-quote-string "QUOTE")) - (let ((headline (org-element-at-point))) - (should (org-element-property :quotedp headline)) - ;; Test removal from raw value. - (should (equal (org-element-property :raw-value headline) "Headline")))) - ;; Case sensitivity. - (let ((org-quote-string "Quote")) - (should-not (org-element-property :quotedp (org-element-at-point))))) + (let* ((org-quote-string "QUOTE") + (headline (org-element-at-point))) + (should (org-element-property :quotedp headline)) + ;; Test removal from raw value. + (should (equal (org-element-property :raw-value headline) "Headline")))) + ;; Case sensitivity. + (org-test-with-temp-text "* QUOTE Headline" + (let* ((org-quote-string "Quote") + (headline (org-element-at-point))) + (should-not (org-element-property :quotedp headline)) + (should (equal (org-element-property :raw-value headline) + "QUOTE Headline")))) ;; With another keyword. (org-test-with-temp-text "* TODO QUOTE Headline" - (let ((org-quote-string "QUOTE") - (org-todo-keywords '((sequence "TODO" "DONE")))) - (should (org-element-property :quotedp (org-element-at-point))))) + (let* ((org-quote-string "QUOTE") + (org-todo-keywords '((sequence "TODO" "DONE"))) + (headline (org-element-at-point))) + (should (org-element-property :quotedp headline)) + (should (equal (org-element-property :raw-value headline) "Headline")))) ;; With the keyword only. (org-test-with-temp-text "* QUOTE" - (let ((org-quote-string "QUOTE")) - (should (org-element-property :quotedp (org-element-at-point)))))) + (let* ((org-quote-string "QUOTE") + (headline (org-element-at-point))) + (should (org-element-property :quotedp headline)) + (should (equal (org-element-property :raw-value headline) ""))))) (ert-deftest test-org-element/headline-comment-keyword () "Test COMMENT keyword recognition." @@ -765,23 +773,30 @@ CLOCK: [2012-01-01 sun. 00:01]--[2012-01-01 sun. 00:02] => 0:01" (should-not (org-element-property :commentedp (org-element-at-point))))) ;; Standard position. (org-test-with-temp-text "* COMMENT Headline" - (let ((org-comment-string "COMMENT")) - (let ((headline (org-element-at-point))) - (should (org-element-property :commentedp headline)) - ;; Test removal from raw value. - (should (equal (org-element-property :raw-value headline) "Headline")))) - ;; Case sensitivity. - (let ((org-comment-string "Comment")) - (should-not (org-element-property :commentedp (org-element-at-point))))) + (let ((org-comment-string "COMMENT") + (headline (org-element-at-point))) + (should (org-element-property :commentedp headline)) + (should (equal (org-element-property :raw-value headline) "Headline")))) + ;; Case sensitivity. + (org-test-with-temp-text "* COMMENT Headline" + (let* ((org-comment-string "Comment") + (headline (org-element-at-point))) + (should-not (org-element-property :commentedp headline)) + (should (equal (org-element-property :raw-value headline) + "COMMENT Headline")))) ;; With another keyword. (org-test-with-temp-text "* TODO COMMENT Headline" - (let ((org-comment-string "COMMENT") - (org-todo-keywords '((sequence "TODO" "DONE")))) - (should (org-element-property :commentedp (org-element-at-point))))) + (let* ((org-comment-string "COMMENT") + (org-todo-keywords '((sequence "TODO" "DONE"))) + (headline (org-element-at-point))) + (should (org-element-property :commentedp headline)) + (should (equal (org-element-property :raw-value headline) "Headline")))) ;; With the keyword only. (org-test-with-temp-text "* COMMENT" - (let ((org-comment-string "COMMENT")) - (should (org-element-property :commentedp (org-element-at-point)))))) + (let* ((org-comment-string "COMMENT") + (headline (org-element-at-point))) + (should (org-element-property :commentedp headline)) + (should (equal (org-element-property :raw-value headline) ""))))) (ert-deftest test-org-element/headline-archive-tag () "Test ARCHIVE tag recognition."