Browse Source

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.
Nicolas Goaziou 10 years ago
parent
commit
1de825df31
3 changed files with 15 additions and 11 deletions
  1. 2 4
      doc/org.texi
  2. 4 4
      lisp/org.el
  3. 9 3
      testing/lisp/test-org.el

+ 2 - 4
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.}

+ 4 - 4
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)))

+ 9 - 3
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