summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2010-06-26 07:54:07 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2010-06-26 07:54:07 +0200
commitbcb7f7f1ef0d3e6bf1123d65537c5d177307e87e (patch)
treebfa7f2f38eb081e1e8618a2b990a2658b5568144
parentbbfca4a0e43fdc843375e5073a7cb10cf919d18e (diff)
downloadorg-mode-bcb7f7f1ef0d3e6bf1123d65537c5d177307e87e.tar.gz
Introduce a way to set a property to undefined.
* lisp/org-macs.el (org-not-nil): Return the value if not interpreted as nil. * lisp/org.el (org-entry-get): (org-entry-get-with-inheritance): Interpret the value "nil" as nil for properties. Bernt Hansen writes: > Carsten Dominik <carsten.dominik@gmail.com> writes: > > > On Jun 25, 2010, at 3:23 PM, Robert Goldman wrote: > > > > > Question: what is the proper way to get a NIL into a property? Are > > > we > > > to use () instead of "nil"? Or are property values always interpreted > > > as strings? > > > > > > Apologies in advance if this is a stupid question! > > > > Not a stupid question at all. > > > > There is no way, currently. Property values are string - the only > > way to make > > org-entry-get return nil is to not have the property defined at all. > > I've wanted a similar thing in the past for the LOGGING property where > the parent task has special logging set via the LOGGING property but I > want to undo that for some of the child tasks so they use the default > logging setup. > > Having a way to undefine a property would be good in general I think. -Bernt
-rw-r--r--lisp/org-macs.el5
-rw-r--r--lisp/org.el23
2 files changed, 18 insertions, 10 deletions
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index ad1fab5..2043045 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -44,8 +44,9 @@
`(and (boundp (quote ,var)) ,var))
(defun org-not-nil (v)
- "Is V not nil, and also not the string \"nil\"?"
- (and v (not (equal v "nil"))))
+ "If V not nil, and also not the string \"nil\", then return V.
+Otherwise return nil."
+ (and v (not (equal v "nil")) v))
(defmacro org-unmodified (&rest body)
"Execute body without changing `buffer-modified-p'.
diff --git a/lisp/org.el b/lisp/org.el
index 517f782..31cc94c 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -13352,14 +13352,18 @@ things up because then unnecessary parsing is avoided."
(push (cons "CATEGORY" value) props))
(append sum-props (nreverse props)))))))
-(defun org-entry-get (pom property &optional inherit)
+(defun org-entry-get (pom property &optional inherit literal-nil)
"Get value of PROPERTY for entry at point-or-marker POM.
If INHERIT is non-nil and the entry does not have the property,
then also check higher levels of the hierarchy.
If INHERIT is the symbol `selective', use inheritance only if the setting
in `org-use-property-inheritance' selects PROPERTY for inheritance.
If the property is present but empty, the return value is the empty string.
-If the property is not present at all, nil is returned."
+If the property is not present at all, nil is returned.
+
+If LITERAL-NIL is set, return the string value \"nil\" as a string,
+do not interpret it as the list atom nil. This is used for inheritance
+when a \"nil\" value can supercede a non-nil value higher up the hierarchy."
(org-with-point-at pom
(if (and inherit (if (eq inherit 'selective)
(org-property-inherit-p property)
@@ -13377,7 +13381,9 @@ If the property is not present at all, nil is returned."
(cdr range) t))
;; Found the property, return it.
(if (match-end 1)
- (org-match-string-no-properties 1)
+ (if literal-nil
+ (org-match-string-no-properties 1)
+ (org-not-nil (org-match-string-no-properties 1)))
"")))))))
(defun org-property-or-variable-value (var &optional inherit)
@@ -13481,15 +13487,16 @@ is set.")
(widen)
(catch 'ex
(while t
- (when (setq tmp (org-entry-get nil property))
+ (when (setq tmp (org-entry-get nil property nil 'literal-nil))
(org-back-to-heading t)
(move-marker org-entry-property-inherited-from (point))
(throw 'ex tmp))
(or (org-up-heading-safe) (throw 'ex nil)))))
- (or tmp
- (cdr (assoc property org-file-properties))
- (cdr (assoc property org-global-properties))
- (cdr (assoc property org-global-properties-fixed))))))
+ (org-not-nil
+ (or tmp
+ (cdr (assoc property org-file-properties))
+ (cdr (assoc property org-global-properties))
+ (cdr (assoc property org-global-properties-fixed)))))))
(defvar org-property-changed-functions nil
"Hook called when the value of a property has changed.