From 1de825df319e1386faf69bb0f871327b8dc73b64 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 11 Mar 2015 17:12:49 +0100 Subject: [PATCH] Fix CATEGORY property * doc/org.texi (Special properties): Remove "CATEGORY" * lisp/org.el (org-special-properties): Remove "CATEGORY". (org-property-get-allowed-values): Ignore "CATEGORY". (org-entry-get): Make sure to get CATEGORY value using `org-entry-properties'. * testing/lisp/test-org.el (test-org/entry-put): Add test. "CATEGORY" is not a special property as it can also be set using a properties drawer. --- doc/org.texi | 6 ++---- lisp/org.el | 8 ++++---- testing/lisp/test-org.el | 12 +++++++++--- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index d92263910..0369eecb6 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -5352,12 +5352,11 @@ Special properties provide an alternative access method to Org mode features, like the TODO state or the priority of an entry, discussed in the previous chapters. This interface exists so that you can include these states in a column view (@pxref{Column view}), or to use them in queries. The -following property names are special and (except for @code{:CATEGORY:}) -should not be used as keys in the properties drawer: +following property names are special and should not be used as keys in the +properties drawer: @cindex property, special, ALLTAGS @cindex property, special, BLOCKED -@cindex property, special, CATEGORY @cindex property, special, CLOCKSUM @cindex property, special, CLOCKSUM_T @cindex property, special, CLOSED @@ -5373,7 +5372,6 @@ should not be used as keys in the properties drawer: @example ALLTAGS @r{All tags, including inherited ones.} BLOCKED @r{"t" if task is currently blocked by children or siblings.} -CATEGORY @r{The category of an entry.} CLOCKSUM @r{The sum of CLOCK intervals in the subtree. @code{org-clock-sum}} @r{must be run first to compute the values in the current buffer.} CLOCKSUM_T @r{The sum of CLOCK intervals in the subtree for today.} diff --git a/lisp/org.el b/lisp/org.el index c566152e8..6dd247559 100755 --- a/lisp/org.el +++ b/lisp/org.el @@ -15367,9 +15367,8 @@ a *different* entry, you cannot use these techniques." ;;; Properties API (defconst org-special-properties - '("ALLTAGS" "BLOCKED" "CATEGORY" "CLOCKSUM" "CLOCKSUM_T" "CLOSED" "DEADLINE" - "FILE" "ITEM" "PRIORITY" "SCHEDULED" "TAGS" "TIMESTAMP" "TIMESTAMP_IA" - "TODO") + '("ALLTAGS" "BLOCKED" "CLOCKSUM" "CLOCKSUM_T" "CLOSED" "DEADLINE" "FILE" + "ITEM" "PRIORITY" "SCHEDULED" "TAGS" "TIMESTAMP" "TIMESTAMP_IA" "TODO") "The special properties valid in Org mode. These are properties that are not defined in the property drawer, but in some other way.") @@ -15718,7 +15717,7 @@ value higher up the hierarchy." ((and inherit (or (not (eq inherit 'selective)) (org-property-inherit-p property))) (org-entry-get-with-inheritance property literal-nil)) - ((member-ignore-case property org-special-properties) + ((member-ignore-case property (cons "CATEGORY" org-special-properties)) ;; We need a special property. Use `org-entry-properties' to ;; retrieve it, but specify the wanted property. (cdr (assoc-string property (org-entry-properties nil property)))) @@ -16270,6 +16269,7 @@ completion." (while (>= n org-highest-priority) (push (char-to-string n) vals) (setq n (1- n))))) + ((equal property "CATEGORY")) ((member property org-special-properties)) ((setq vals (run-hook-with-args-until-success 'org-property-allowed-value-functions property))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 5c10dd43c..3d4f050a9 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -2951,6 +2951,12 @@ Text. (org-test-with-temp-text "* H\nDEADLINE: <2014-03-04 tue.>" (org-entry-put (point) "DEADLINE" "later") (buffer-string)))) + ;; Set "CATEGORY" property + (should + (string-match "^ *:CATEGORY: cat" + (org-test-with-temp-text "* H" + (org-entry-put (point) "CATEGORY" "cat") + (buffer-string)))) ;; Regular properties, with or without pre-existing drawer. (should (string-match "^ *:A: +2$" @@ -2965,9 +2971,9 @@ Text. ;; Special case: two consecutive headlines. (should (string-match "\\* A\n *:PROPERTIES:" - (org-test-with-temp-text "* A\n** B" - (org-entry-put (point) "A" "1") - (buffer-string))))) + (org-test-with-temp-text "* A\n** B" + (org-entry-put (point) "A" "1") + (buffer-string))))) ;;; Radio Targets -- 2.11.4.GIT