mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-25 07:27:57 +00:00
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
This commit is contained in:
parent
bbfca4a0e4
commit
bcb7f7f1ef
@ -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'.
|
||||
|
23
lisp/org.el
23
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.
|
||||
|
Loading…
Reference in New Issue
Block a user