|
@@ -153,12 +153,8 @@
|
|
|
"-\\{5,\\}[ \t]*$" "\\|"
|
|
|
;; LaTeX environments.
|
|
|
"\\\\begin{\\([A-Za-z0-9]+\\*?\\)}" "\\|"
|
|
|
- ;; Planning and Clock lines.
|
|
|
- (regexp-opt (list org-scheduled-string
|
|
|
- org-deadline-string
|
|
|
- org-closed-string
|
|
|
- org-clock-string))
|
|
|
- "\\|"
|
|
|
+ ;; Clock lines.
|
|
|
+ (regexp-quote org-clock-string) "\\|"
|
|
|
;; Lists.
|
|
|
(let ((term (case org-plain-list-ordered-item-terminator
|
|
|
(?\) ")") (?. "\\.") (otherwise "[.)]")))
|
|
@@ -847,7 +843,7 @@ Assume point is at beginning of the headline."
|
|
|
;; Read time properties on the line below the headline.
|
|
|
(save-excursion
|
|
|
(forward-line)
|
|
|
- (when (looking-at org-planning-or-clock-line-re)
|
|
|
+ (when (looking-at org-planning-line-re)
|
|
|
(let ((end (line-end-position)) plist)
|
|
|
(while (re-search-forward
|
|
|
org-keyword-time-not-clock-regexp end t)
|
|
@@ -1006,8 +1002,7 @@ Assume point is at beginning of the inline task."
|
|
|
;; opening string.
|
|
|
(when task-end
|
|
|
(save-excursion
|
|
|
- (when (progn (forward-line)
|
|
|
- (looking-at org-planning-or-clock-line-re))
|
|
|
+ (when (progn (forward-line) (looking-at org-planning-line-re))
|
|
|
(let ((end (line-end-position)) plist)
|
|
|
(while (re-search-forward
|
|
|
org-keyword-time-not-clock-regexp end t)
|
|
@@ -1396,34 +1391,34 @@ containing `:begin', `:end', `:contents-begin', `:contents-end',
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
|
|
|
|
|
Assume point is at the beginning of the property drawer."
|
|
|
- (save-excursion
|
|
|
- (let ((case-fold-search t))
|
|
|
- (if (not (save-excursion
|
|
|
- (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
|
|
|
- ;; Incomplete drawer: parse it as a paragraph.
|
|
|
- (org-element-paragraph-parser limit affiliated)
|
|
|
- (save-excursion
|
|
|
- (let* ((drawer-end-line (match-beginning 0))
|
|
|
- (begin (car affiliated))
|
|
|
- (post-affiliated (point))
|
|
|
- (contents-begin (progn (forward-line)
|
|
|
- (and (< (point) drawer-end-line)
|
|
|
- (point))))
|
|
|
- (contents-end (and contents-begin drawer-end-line))
|
|
|
- (pos-before-blank (progn (goto-char drawer-end-line)
|
|
|
- (forward-line)
|
|
|
- (point)))
|
|
|
- (end (progn (skip-chars-forward " \r\t\n" limit)
|
|
|
- (if (eobp) (point) (line-beginning-position)))))
|
|
|
- (list 'property-drawer
|
|
|
- (nconc
|
|
|
- (list :begin begin
|
|
|
- :end end
|
|
|
- :contents-begin contents-begin
|
|
|
- :contents-end contents-end
|
|
|
- :post-blank (count-lines pos-before-blank end)
|
|
|
- :post-affiliated post-affiliated)
|
|
|
- (cdr affiliated)))))))))
|
|
|
+ (let ((case-fold-search t))
|
|
|
+ (if (not (save-excursion (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
|
|
|
+ ;; Incomplete drawer: parse it as a paragraph.
|
|
|
+ (org-element-paragraph-parser limit affiliated)
|
|
|
+ (save-excursion
|
|
|
+ (let* ((drawer-end-line (match-beginning 0))
|
|
|
+ (begin (car affiliated))
|
|
|
+ (post-affiliated (point))
|
|
|
+ (contents-begin
|
|
|
+ (progn
|
|
|
+ (forward-line)
|
|
|
+ (and (re-search-forward org-property-re drawer-end-line t)
|
|
|
+ (line-beginning-position))))
|
|
|
+ (contents-end (and contents-begin drawer-end-line))
|
|
|
+ (pos-before-blank (progn (goto-char drawer-end-line)
|
|
|
+ (forward-line)
|
|
|
+ (point)))
|
|
|
+ (end (progn (skip-chars-forward " \r\t\n" limit)
|
|
|
+ (if (eobp) (point) (line-beginning-position)))))
|
|
|
+ (list 'property-drawer
|
|
|
+ (nconc
|
|
|
+ (list :begin begin
|
|
|
+ :end end
|
|
|
+ :contents-begin contents-begin
|
|
|
+ :contents-end contents-end
|
|
|
+ :post-blank (count-lines pos-before-blank end)
|
|
|
+ :post-affiliated post-affiliated)
|
|
|
+ (cdr affiliated))))))))
|
|
|
|
|
|
(defun org-element-property-drawer-interpreter (property-drawer contents)
|
|
|
"Interpret PROPERTY-DRAWER element as Org syntax.
|
|
@@ -2105,29 +2100,30 @@ LIMIT bounds the search.
|
|
|
Return a list whose CAR is `node-property' and CDR is a plist
|
|
|
containing `:key', `:value', `:begin', `:end', `:post-blank' and
|
|
|
`:post-affiliated' keywords."
|
|
|
- (save-excursion
|
|
|
- (looking-at org-property-re)
|
|
|
- (let ((case-fold-search t)
|
|
|
- (begin (point))
|
|
|
- (key (org-match-string-no-properties 2))
|
|
|
- (value (org-match-string-no-properties 3))
|
|
|
- (pos-before-blank (progn (forward-line) (point)))
|
|
|
- (end (progn (skip-chars-forward " \r\t\n" limit)
|
|
|
- (if (eobp) (point) (point-at-bol)))))
|
|
|
- (list 'node-property
|
|
|
- (list :key key
|
|
|
- :value value
|
|
|
- :begin begin
|
|
|
- :end end
|
|
|
- :post-blank (count-lines pos-before-blank end)
|
|
|
- :post-affiliated begin)))))
|
|
|
+ (looking-at org-property-re)
|
|
|
+ (let ((case-fold-search t)
|
|
|
+ (begin (point))
|
|
|
+ (key (org-match-string-no-properties 2))
|
|
|
+ (value (org-match-string-no-properties 3))
|
|
|
+ (end (save-excursion
|
|
|
+ (end-of-line)
|
|
|
+ (if (re-search-forward org-property-re limit t)
|
|
|
+ (line-beginning-position)
|
|
|
+ limit))))
|
|
|
+ (list 'node-property
|
|
|
+ (list :key key
|
|
|
+ :value value
|
|
|
+ :begin begin
|
|
|
+ :end end
|
|
|
+ :post-blank 0
|
|
|
+ :post-affiliated begin))))
|
|
|
|
|
|
(defun org-element-node-property-interpreter (node-property contents)
|
|
|
"Interpret NODE-PROPERTY element as Org syntax.
|
|
|
CONTENTS is nil."
|
|
|
(format org-property-format
|
|
|
(format ":%s:" (org-element-property :key node-property))
|
|
|
- (org-element-property :value node-property)))
|
|
|
+ (or (org-element-property :value node-property) "")))
|
|
|
|
|
|
|
|
|
;;;; Paragraph
|
|
@@ -2238,33 +2234,35 @@ LIMIT bounds the search.
|
|
|
Return a list whose CAR is `planning' and CDR is a plist
|
|
|
containing `:closed', `:deadline', `:scheduled', `:begin',
|
|
|
`:end', `:post-blank' and `:post-affiliated' keywords."
|
|
|
- (save-excursion
|
|
|
- (let* ((case-fold-search nil)
|
|
|
- (begin (point))
|
|
|
- (post-blank (let ((before-blank (progn (forward-line) (point))))
|
|
|
- (skip-chars-forward " \r\t\n" limit)
|
|
|
- (skip-chars-backward " \t")
|
|
|
- (unless (bolp) (end-of-line))
|
|
|
- (count-lines before-blank (point))))
|
|
|
- (end (point))
|
|
|
- closed deadline scheduled)
|
|
|
- (goto-char begin)
|
|
|
- (while (re-search-forward org-keyword-time-not-clock-regexp end t)
|
|
|
- (goto-char (match-end 1))
|
|
|
- (skip-chars-forward " \t" end)
|
|
|
- (let ((keyword (match-string 1))
|
|
|
- (time (org-element-timestamp-parser)))
|
|
|
- (cond ((equal keyword org-closed-string) (setq closed time))
|
|
|
- ((equal keyword org-deadline-string) (setq deadline time))
|
|
|
- (t (setq scheduled time)))))
|
|
|
- (list 'planning
|
|
|
- (list :closed closed
|
|
|
- :deadline deadline
|
|
|
- :scheduled scheduled
|
|
|
- :begin begin
|
|
|
- :end end
|
|
|
- :post-blank post-blank
|
|
|
- :post-affiliated begin)))))
|
|
|
+ (if (not (save-excursion (forward-line -1) (org-at-heading-p)))
|
|
|
+ (org-element-paragraph-parser limit (list (point)))
|
|
|
+ (save-excursion
|
|
|
+ (let* ((case-fold-search nil)
|
|
|
+ (begin (point))
|
|
|
+ (post-blank (let ((before-blank (progn (forward-line) (point))))
|
|
|
+ (skip-chars-forward " \r\t\n" limit)
|
|
|
+ (skip-chars-backward " \t")
|
|
|
+ (unless (bolp) (end-of-line))
|
|
|
+ (count-lines before-blank (point))))
|
|
|
+ (end (point))
|
|
|
+ closed deadline scheduled)
|
|
|
+ (goto-char begin)
|
|
|
+ (while (re-search-forward org-keyword-time-not-clock-regexp end t)
|
|
|
+ (goto-char (match-end 1))
|
|
|
+ (skip-chars-forward " \t" end)
|
|
|
+ (let ((keyword (match-string 1))
|
|
|
+ (time (org-element-timestamp-parser)))
|
|
|
+ (cond ((equal keyword org-closed-string) (setq closed time))
|
|
|
+ ((equal keyword org-deadline-string) (setq deadline time))
|
|
|
+ (t (setq scheduled time)))))
|
|
|
+ (list 'planning
|
|
|
+ (list :closed closed
|
|
|
+ :deadline deadline
|
|
|
+ :scheduled scheduled
|
|
|
+ :begin begin
|
|
|
+ :end end
|
|
|
+ :post-blank post-blank
|
|
|
+ :post-affiliated begin))))))
|
|
|
|
|
|
(defun org-element-planning-interpreter (planning contents)
|
|
|
"Interpret PLANNING element as Org syntax.
|
|
@@ -3612,8 +3610,7 @@ CONTENTS is nil."
|
|
|
;; `section'). Special modes are: `first-section', `item',
|
|
|
;; `node-property', `section' and `table-row'.
|
|
|
|
|
|
-(defun org-element--current-element
|
|
|
- (limit &optional granularity special structure)
|
|
|
+(defun org-element--current-element (limit &optional granularity mode structure)
|
|
|
"Parse the element starting at point.
|
|
|
|
|
|
Return value is a list like (TYPE PROPS) where TYPE is the type
|
|
@@ -3630,12 +3627,12 @@ recursion. Allowed values are `headline', `greater-element',
|
|
|
nil), secondary values will not be parsed, since they only
|
|
|
contain objects.
|
|
|
|
|
|
-Optional argument SPECIAL, when non-nil, can be either
|
|
|
-`first-section', `item', `node-property', `section', and
|
|
|
-`table-row'.
|
|
|
+Optional argument MODE, when non-nil, can be either
|
|
|
+`first-section', `section', `planning', `item', `node-property'
|
|
|
+and `table-row'.
|
|
|
|
|
|
-If STRUCTURE isn't provided but SPECIAL is set to `item', it will
|
|
|
-be computed.
|
|
|
+If STRUCTURE isn't provided but MODE is set to `item', it will be
|
|
|
+computed.
|
|
|
|
|
|
This function assumes point is always at the beginning of the
|
|
|
element it has to parse."
|
|
@@ -3647,29 +3644,29 @@ element it has to parse."
|
|
|
(raw-secondary-p (and granularity (not (eq granularity 'object)))))
|
|
|
(cond
|
|
|
;; Item.
|
|
|
- ((eq special 'item)
|
|
|
+ ((eq mode 'item)
|
|
|
(org-element-item-parser limit structure raw-secondary-p))
|
|
|
;; Table Row.
|
|
|
- ((eq special 'table-row) (org-element-table-row-parser limit))
|
|
|
+ ((eq mode 'table-row) (org-element-table-row-parser limit))
|
|
|
;; Node Property.
|
|
|
- ((eq special 'node-property) (org-element-node-property-parser limit))
|
|
|
+ ((eq mode 'node-property) (org-element-node-property-parser limit))
|
|
|
;; Headline.
|
|
|
((org-with-limited-levels (org-at-heading-p))
|
|
|
(org-element-headline-parser limit raw-secondary-p))
|
|
|
;; Sections (must be checked after headline).
|
|
|
- ((eq special 'section) (org-element-section-parser limit))
|
|
|
- ((eq special 'first-section)
|
|
|
+ ((eq mode 'section) (org-element-section-parser limit))
|
|
|
+ ((eq mode 'first-section)
|
|
|
(org-element-section-parser
|
|
|
(or (save-excursion (org-with-limited-levels (outline-next-heading)))
|
|
|
limit)))
|
|
|
+ ;; Planning.
|
|
|
+ ((and (eq mode 'planning) (looking-at org-planning-line-re))
|
|
|
+ (org-element-planning-parser limit))
|
|
|
;; When not at bol, point is at the beginning of an item or
|
|
|
;; a footnote definition: next item is always a paragraph.
|
|
|
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
|
|
|
- ;; Planning and Clock.
|
|
|
- ((looking-at org-planning-or-clock-line-re)
|
|
|
- (if (equal (match-string 1) org-clock-string)
|
|
|
- (org-element-clock-parser limit)
|
|
|
- (org-element-planning-parser limit)))
|
|
|
+ ;; Clock.
|
|
|
+ ((looking-at org-clock-line-re) (org-element-clock-parser limit))
|
|
|
;; Inlinetask.
|
|
|
((org-at-heading-p)
|
|
|
(org-element-inlinetask-parser limit raw-secondary-p))
|
|
@@ -4082,6 +4079,18 @@ looking into captions:
|
|
|
;; object is searched only once at top level (but sometimes more for
|
|
|
;; nested types).
|
|
|
|
|
|
+(defsubst org-element--next-mode (type)
|
|
|
+ "Return next special mode according to TYPE, or nil.
|
|
|
+TYPE is a symbol representing the type of an element or object.
|
|
|
+Modes can be either `first-section', `section', `planning',
|
|
|
+`item', `node-property' and `table-row'."
|
|
|
+ (case type
|
|
|
+ (headline 'section)
|
|
|
+ (section 'planning)
|
|
|
+ (plain-list 'item)
|
|
|
+ (property-drawer 'node-property)
|
|
|
+ (table 'table-row)))
|
|
|
+
|
|
|
(defun org-element--parse-elements
|
|
|
(beg end special structure granularity visible-only acc)
|
|
|
"Parse elements between BEG and END positions.
|
|
@@ -4136,11 +4145,7 @@ Elements are accumulated into ACC."
|
|
|
(org-element--parse-elements
|
|
|
cbeg (org-element-property :contents-end element)
|
|
|
;; Possibly switch to a special mode.
|
|
|
- (case type
|
|
|
- (headline 'section)
|
|
|
- (plain-list 'item)
|
|
|
- (property-drawer 'node-property)
|
|
|
- (table 'table-row))
|
|
|
+ (org-element--next-mode type)
|
|
|
(and (memq type '(item plain-list))
|
|
|
(org-element-property :structure element))
|
|
|
granularity visible-only element))
|
|
@@ -5224,7 +5229,7 @@ the process stopped before finding the expected result."
|
|
|
(let* ((cached (and (org-element--cache-active-p)
|
|
|
(org-element--cache-find pos nil)))
|
|
|
(begin (org-element-property :begin cached))
|
|
|
- element next)
|
|
|
+ element next mode)
|
|
|
(cond
|
|
|
;; Nothing in cache before point: start parsing from first
|
|
|
;; element following headline above, or first element in
|
|
@@ -5233,7 +5238,8 @@ the process stopped before finding the expected result."
|
|
|
(when (org-with-limited-levels (outline-previous-heading))
|
|
|
(forward-line))
|
|
|
(skip-chars-forward " \r\t\n")
|
|
|
- (beginning-of-line))
|
|
|
+ (beginning-of-line)
|
|
|
+ (setq mode 'planning))
|
|
|
;; Cache returned exact match: return it.
|
|
|
((= pos begin)
|
|
|
(throw 'exit (if syncp (org-element-property :parent cached) cached)))
|
|
@@ -5244,7 +5250,8 @@ the process stopped before finding the expected result."
|
|
|
(org-with-limited-levels org-outline-regexp-bol) begin t)
|
|
|
(forward-line)
|
|
|
(skip-chars-forward " \r\t\n")
|
|
|
- (beginning-of-line))
|
|
|
+ (beginning-of-line)
|
|
|
+ (setq mode 'planning))
|
|
|
;; Check if CACHED or any of its ancestors contain point.
|
|
|
;;
|
|
|
;; If there is such an element, we inspect it in order to know
|
|
@@ -5278,8 +5285,7 @@ the process stopped before finding the expected result."
|
|
|
(save-excursion
|
|
|
(org-with-limited-levels (outline-next-heading))
|
|
|
(point))))
|
|
|
- (parent element)
|
|
|
- special-flag)
|
|
|
+ (parent element))
|
|
|
(while t
|
|
|
(when syncp
|
|
|
(cond ((= (point) pos) (throw 'exit parent))
|
|
@@ -5287,7 +5293,7 @@ the process stopped before finding the expected result."
|
|
|
(throw 'interrupt nil))))
|
|
|
(unless element
|
|
|
(setq element (org-element--current-element
|
|
|
- end 'element special-flag
|
|
|
+ end 'element mode
|
|
|
(org-element-property :structure parent)))
|
|
|
(org-element-put-property element :parent parent)
|
|
|
(org-element--cache-put element))
|
|
@@ -5327,10 +5333,7 @@ the process stopped before finding the expected result."
|
|
|
(and (= cend pos) (= (point-max) pos)))))
|
|
|
(goto-char (or next cbeg))
|
|
|
(setq next nil
|
|
|
- special-flag (case type
|
|
|
- (plain-list 'item)
|
|
|
- (property-drawer 'node-property)
|
|
|
- (table 'table-row))
|
|
|
+ mode (org-element--next-mode type)
|
|
|
parent element
|
|
|
end cend))))
|
|
|
;; Otherwise, return ELEMENT as it is the smallest
|