Function: org-entry-properties
org-entry-properties is a byte-compiled function defined in org.el.gz.
Signature
(org-entry-properties &optional EPOM WHICH)
Documentation
Get all properties of the current entry.
When EPOM is a buffer position, marker, or element, get all properties from the entry there instead.
This includes the TODO keyword, the tags, time strings for deadline, scheduled, and clocking, and any additional properties defined in the entry.
If WHICH is nil or all, get all properties. If WHICH is
special or standard, only get that subclass. If WHICH is
a string, only get that property.
Return value is an alist. Keys are properties, as upcased strings.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org.el.gz
(defun org-entry-properties (&optional epom which)
"Get all properties of the current entry.
When EPOM is a buffer position, marker, or element, get all properties
from the entry there instead.
This includes the TODO keyword, the tags, time strings for
deadline, scheduled, and clocking, and any additional properties
defined in the entry.
If WHICH is nil or `all', get all properties. If WHICH is
`special' or `standard', only get that subclass. If WHICH is
a string, only get that property.
Return value is an alist. Keys are properties, as upcased
strings."
(org-with-point-at epom
(when (and (derived-mode-p 'org-mode)
(org-back-to-heading-or-point-min t))
(catch 'exit
(let* ((beg (point))
(specific (and (stringp which) (upcase which)))
(which (cond ((not specific) which)
((member specific org-special-properties) 'special)
(t 'standard)))
props)
;; Get the special properties, like TODO and TAGS.
(when (memq which '(nil all special))
(when (or (not specific) (string= specific "CLOCKSUM"))
(let ((clocksum (get-text-property (point) :org-clock-minutes)))
(when clocksum
(push (cons "CLOCKSUM" (org-duration-from-minutes clocksum))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "CLOCKSUM_T"))
(let ((clocksumt (get-text-property (point)
:org-clock-minutes-today)))
(when clocksumt
(push (cons "CLOCKSUM_T"
(org-duration-from-minutes clocksumt))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ITEM"))
(let ((case-fold-search nil))
(when (looking-at org-complex-heading-regexp)
(push (cons "ITEM"
(let ((title (match-string-no-properties 4)))
(if (org-string-nw-p title)
(org-remove-tabs title)
"")))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "TODO"))
(let ((case-fold-search nil))
(when (and (looking-at org-todo-line-regexp) (match-end 2))
(push (cons "TODO" (match-string-no-properties 2)) props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "PRIORITY"))
(push (cons "PRIORITY"
(if (looking-at org-priority-regexp)
(match-string-no-properties 2)
(char-to-string org-priority-default)))
props)
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "FILE"))
(push (cons "FILE" (buffer-file-name (buffer-base-buffer)))
props)
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "TAGS"))
(let ((tags (org-get-tags nil t)))
(when tags
(push (cons "TAGS" (org-make-tag-string tags))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "ALLTAGS"))
(let ((tags (org-get-tags)))
(when tags
(push (cons "ALLTAGS" (org-make-tag-string tags))
props)))
(when specific (throw 'exit props)))
(when (or (not specific) (string= specific "BLOCKED"))
(push (cons "BLOCKED" (if (org-entry-blocked-p) "t" "")) props)
(when specific (throw 'exit props)))
(when (or (not specific)
(member specific '("CLOSED" "DEADLINE" "SCHEDULED")))
(forward-line)
(when (looking-at-p org-planning-line-re)
(end-of-line)
(let ((bol (line-beginning-position))
;; Backward compatibility: time keywords used to
;; be configurable (before 8.3). Make sure we
;; get the correct keyword.
(key-assoc `(("CLOSED" . ,org-closed-string)
("DEADLINE" . ,org-deadline-string)
("SCHEDULED" . ,org-scheduled-string))))
(dolist (pair (if specific (list (assoc specific key-assoc))
key-assoc))
(save-excursion
(when (search-backward (cdr pair) bol t)
(goto-char (match-end 0))
(skip-chars-forward " \t")
(and (looking-at org-ts-regexp-both)
(push (cons (car pair)
(match-string-no-properties 0))
props)))))))
(when specific (throw 'exit props)))
(when (or (not specific)
(member specific '("TIMESTAMP" "TIMESTAMP_IA")))
(let ((find-ts
(lambda (end ts)
;; Fix next timestamp before END. TS is the
;; list of timestamps found so far.
(let ((ts ts)
(regexp (cond
((string= specific "TIMESTAMP")
org-ts-regexp)
((string= specific "TIMESTAMP_IA")
org-ts-regexp-inactive)
((assoc "TIMESTAMP_IA" ts)
org-ts-regexp)
((assoc "TIMESTAMP" ts)
org-ts-regexp-inactive)
(t org-ts-regexp-both))))
(catch 'next
(while (re-search-forward regexp end t)
(backward-char)
(let ((object (org-element-context)))
;; Accept to match timestamps in node
;; properties, too.
(when (org-element-type-p
object '(node-property timestamp))
(let ((type
(org-element-property :type object)))
(cond
((and (memq type '(active active-range))
(not (equal specific "TIMESTAMP_IA")))
(unless (assoc "TIMESTAMP" ts)
(push (cons "TIMESTAMP"
(org-element-property
:raw-value object))
ts)
(when specific (throw 'exit ts))))
((and (memq type '(inactive inactive-range))
(not (string= specific "TIMESTAMP")))
(unless (assoc "TIMESTAMP_IA" ts)
(push (cons "TIMESTAMP_IA"
(org-element-property
:raw-value object))
ts)
(when specific (throw 'exit ts))))))
;; Both timestamp types are found,
;; move to next part.
(when (= (length ts) 2) (throw 'next ts)))))
ts)))))
(goto-char beg)
;; First look for timestamps within headline.
(let ((ts (funcall find-ts (line-end-position) nil)))
(if (= (length ts) 2) (setq props (nconc ts props))
;; Then find timestamps in the section, skipping
;; planning line.
(let ((end (save-excursion (outline-next-heading))))
(forward-line)
(when (looking-at-p org-planning-line-re) (forward-line))
(setq props (nconc (funcall find-ts end ts) props))))))))
;; Get the standard properties, like :PROP:.
(when (memq which '(nil all standard))
;; If we are looking after a specific property, delegate
;; to `org-entry-get', which is faster. However, make an
;; exception for "CATEGORY", since it can be also set
;; through keywords (i.e. #+CATEGORY).
(if (and specific (not (equal specific "CATEGORY")))
(let ((value (org-entry-get beg specific nil t)))
(throw 'exit (and value (list (cons specific value)))))
(let ((range (org-get-property-block beg)))
(when range
(let ((end (cdr range)) seen-base)
(goto-char (car range))
;; Unlike to `org--update-property-plist', we
;; handle the case where base values is found
;; after its extension. We also forbid standard
;; properties to be named as special properties.
(while (re-search-forward org-property-re end t)
(let* ((key (upcase (match-string-no-properties 2)))
(extendp (string-match-p "\\+\\'" key))
(key-base (if extendp (substring key 0 -1) key))
(value (match-string-no-properties 3)))
(cond
((member-ignore-case key-base org-special-properties))
(extendp
(setq props
(org--update-property-plist key value props)))
((member key seen-base))
(t (push key seen-base)
(let ((p (assoc-string key props t)))
(if p (setcdr p (concat value " " (cdr p)))
(push (cons key value) props))))))))))))
(unless (assoc "CATEGORY" props)
(push (cons "CATEGORY" (org-get-category beg)) props)
(when (string= specific "CATEGORY") (throw 'exit props)))
;; Return value.
props)))))