org-element: New `org-element-*property*' functions
* lisp/org-element.el (org-element-begin): (org-element-end): (org-element-contents-begin): (org-element-contents-end): (org-element-post-affiliated): (org-element-post-blank): New functions for fast access to frequently used element properties. The functions are `setf'-able. Update all the relevant code in Org to use the new functions instead of genetic property queries.
This commit is contained in:
parent
81a7e8c836
commit
bc29f5de41
|
@ -65,6 +65,11 @@
|
|||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-normalize-string "org-element" (s))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-parent "org-element-ast" (node))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-type-p "org-element-ast" (node &optional types))
|
||||
|
@ -717,7 +722,7 @@ a list with the following pattern:
|
|||
;; If DATUM is provided, make sure we get node
|
||||
;; properties applicable to its location within
|
||||
;; the document.
|
||||
(org-with-point-at (org-element-property :begin datum)
|
||||
(org-with-point-at (org-element-begin datum)
|
||||
(org-babel-params-from-properties lang no-eval))
|
||||
(mapcar (lambda (h)
|
||||
(org-babel-parse-header-arguments h no-eval))
|
||||
|
@ -1135,7 +1140,7 @@ Return t if a code block was found at point, nil otherwise."
|
|||
;; we want to restore this location after executing BODY.
|
||||
(outside-position
|
||||
(and (<= (line-beginning-position)
|
||||
(org-element-property :post-affiliated element))
|
||||
(org-element-post-affiliated element))
|
||||
(point-marker)))
|
||||
(org-src-window-setup 'switch-invisibly))
|
||||
(when (and (org-babel-where-is-src-block-head element)
|
||||
|
@ -1278,7 +1283,7 @@ buffer."
|
|||
(let ((,datum (save-match-data (org-element-context))))
|
||||
(when (org-element-type-p ,datum 'inline-src-block)
|
||||
(goto-char (match-beginning 0))
|
||||
(let ((,end (copy-marker (org-element-property :end ,datum))))
|
||||
(let ((,end (copy-marker (org-element-end ,datum))))
|
||||
,@body
|
||||
(goto-char ,end)
|
||||
(set-marker ,end nil))))))
|
||||
|
@ -1306,7 +1311,7 @@ buffer."
|
|||
(let ((,datum (save-match-data (org-element-context))))
|
||||
(when (org-element-type-p ,datum '(babel-call inline-babel-call))
|
||||
(goto-char (match-beginning 0))
|
||||
(let ((,end (copy-marker (org-element-property :end ,datum))))
|
||||
(let ((,end (copy-marker (org-element-end ,datum))))
|
||||
,@body
|
||||
(goto-char ,end)
|
||||
(set-marker ,end nil))))))
|
||||
|
@ -1337,7 +1342,7 @@ buffer."
|
|||
,datum
|
||||
'(babel-call inline-babel-call inline-src-block src-block))
|
||||
(goto-char (match-beginning 0))
|
||||
(let ((,end (copy-marker (org-element-property :end ,datum))))
|
||||
(let ((,end (copy-marker (org-element-end ,datum))))
|
||||
,@body
|
||||
(goto-char ,end)
|
||||
(set-marker ,end nil))))))
|
||||
|
@ -1864,13 +1869,13 @@ If the point is not on a source block or within blank lines after an
|
|||
src block, then return nil."
|
||||
(let ((element (or src-block (org-element-at-point))))
|
||||
(when (org-element-type-p element 'src-block)
|
||||
(let ((end (org-element-property :end element)))
|
||||
(let ((end (org-element-end element)))
|
||||
(org-with-wide-buffer
|
||||
;; Ensure point is not on a blank line after the block.
|
||||
(beginning-of-line)
|
||||
(skip-chars-forward " \r\t\n" end)
|
||||
(when (< (point) end)
|
||||
(prog1 (goto-char (org-element-property :post-affiliated element))
|
||||
(prog1 (goto-char (org-element-post-affiliated element))
|
||||
(looking-at org-babel-src-block-regexp))))))))
|
||||
|
||||
;;;###autoload
|
||||
|
@ -1968,7 +1973,7 @@ buffer or nil if no such result exists."
|
|||
(let ((element (org-element-at-point)))
|
||||
(when (or (org-element-type-p element 'keyword)
|
||||
(< (point)
|
||||
(org-element-property :post-affiliated element)))
|
||||
(org-element-post-affiliated element)))
|
||||
(throw :found (line-beginning-position)))))))))
|
||||
|
||||
(defun org-babel-result-names (&optional file)
|
||||
|
@ -2115,11 +2120,11 @@ leave point where new results should be inserted."
|
|||
(let ((case-fold-search t)) (looking-at org-babel-result-regexp))
|
||||
(unless (string= (match-string 1) hash)
|
||||
(let* ((e (org-element-at-point))
|
||||
(post (copy-marker (org-element-property :post-affiliated e))))
|
||||
(post (copy-marker (org-element-post-affiliated e))))
|
||||
;; Delete contents.
|
||||
(delete-region post
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :end e))
|
||||
(goto-char (org-element-end e))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-beginning-position 2)))
|
||||
;; Delete RESULT keyword. However, if RESULTS keyword is
|
||||
|
@ -2155,11 +2160,11 @@ to HASH."
|
|||
;; Results for inline objects are located right after them.
|
||||
;; There is no RESULTS line to insert either.
|
||||
(let ((limit (pcase (org-element-type (org-element-parent context))
|
||||
(`section (org-element-property
|
||||
:end (org-element-parent context)))
|
||||
(_ (org-element-property
|
||||
:contents-end (org-element-parent context))))))
|
||||
(goto-char (org-element-property :end context))
|
||||
(`section (org-element-end
|
||||
(org-element-parent context)))
|
||||
(_ (org-element-contents-end
|
||||
(org-element-parent context))))))
|
||||
(goto-char (org-element-end context))
|
||||
(skip-chars-forward " \t\n" limit)
|
||||
(throw :found
|
||||
(and
|
||||
|
@ -2172,14 +2177,14 @@ to HASH."
|
|||
(delete-region
|
||||
(point)
|
||||
(progn
|
||||
(goto-char (org-element-property :end result))
|
||||
(goto-char (org-element-end result))
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
(point))))))))
|
||||
((or `babel-call `src-block)
|
||||
(let* ((name (org-element-property :name context))
|
||||
(named-results (and name (org-babel-find-named-result name))))
|
||||
(goto-char (or named-results (org-element-property :end context)))
|
||||
(goto-char (or named-results (org-element-end context)))
|
||||
(cond
|
||||
;; Existing results named after the current source.
|
||||
(named-results
|
||||
|
@ -2192,17 +2197,17 @@ to HASH."
|
|||
;; buffer or outside CONTEXT parent.
|
||||
((eq (point)
|
||||
(or (pcase (org-element-type (org-element-parent context))
|
||||
((or `section `org-data) (org-element-property
|
||||
:end (org-element-parent context)))
|
||||
(_ (org-element-property
|
||||
:contents-end (org-element-parent context))))
|
||||
((or `section `org-data)
|
||||
(org-element-end (org-element-parent context)))
|
||||
(_ (org-element-contents-end
|
||||
(org-element-parent context))))
|
||||
(point-max))))
|
||||
;; Check if next element is an anonymous result below
|
||||
;; the current block.
|
||||
((let* ((next (org-element-at-point))
|
||||
(end (save-excursion
|
||||
(goto-char
|
||||
(org-element-property :post-affiliated next))
|
||||
(org-element-post-affiliated next))
|
||||
(line-end-position)))
|
||||
(empty-result-re (concat org-babel-result-regexp "$"))
|
||||
(case-fold-search t))
|
||||
|
@ -2218,7 +2223,7 @@ to HASH."
|
|||
;; after the previous element.
|
||||
(when insert
|
||||
(save-excursion
|
||||
(goto-char (min (org-element-property :end context) (point-max)))
|
||||
(goto-char (min (org-element-end context) (point-max)))
|
||||
(skip-chars-backward " \t\n")
|
||||
(forward-line)
|
||||
(unless (bolp) (insert "\n"))
|
||||
|
@ -2231,7 +2236,7 @@ to HASH."
|
|||
"Read ELEMENT into emacs-lisp.
|
||||
Return nil if ELEMENT cannot be read."
|
||||
(org-with-wide-buffer
|
||||
(goto-char (org-element-property :post-affiliated element))
|
||||
(goto-char (org-element-post-affiliated element))
|
||||
(pcase (org-element-type element)
|
||||
(`fixed-width
|
||||
(let ((v (org-trim (org-element-property :value element))))
|
||||
|
@ -2253,17 +2258,17 @@ Return nil if ELEMENT cannot be read."
|
|||
(save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(<= (org-element-property :end element)
|
||||
(<= (org-element-end element)
|
||||
(point))))
|
||||
(org-babel-read-link)
|
||||
(buffer-substring-no-properties
|
||||
(org-element-property :contents-begin element)
|
||||
(org-element-property :contents-end element))))
|
||||
(org-element-contents-begin element)
|
||||
(org-element-contents-end element))))
|
||||
((or `center-block `quote-block `verse-block `special-block)
|
||||
(org-remove-indentation
|
||||
(buffer-substring-no-properties
|
||||
(org-element-property :contents-begin element)
|
||||
(org-element-property :contents-end element))))
|
||||
(org-element-contents-begin element)
|
||||
(org-element-contents-end element))))
|
||||
(_ nil))))
|
||||
|
||||
(defun org-babel-read-result ()
|
||||
|
@ -2450,7 +2455,7 @@ INFO may provide the values of these header arguments (in the
|
|||
(progn
|
||||
(when outside-scope (widen))
|
||||
(if existing-result (goto-char existing-result)
|
||||
(goto-char (org-element-property :end inline))
|
||||
(goto-char (org-element-end inline))
|
||||
(skip-chars-backward " \t"))
|
||||
(unless inline
|
||||
(setq indent (current-indentation))
|
||||
|
@ -2684,19 +2689,19 @@ Leading white space is trimmed."
|
|||
(let* ((el (or datum (org-element-context))))
|
||||
(when (org-element-type-p el '(inline-src-block inline-babel-call))
|
||||
(org-with-wide-buffer
|
||||
(goto-char (org-element-property :end el))
|
||||
(goto-char (org-element-end el))
|
||||
(skip-chars-backward " \t")
|
||||
(let ((result (save-excursion
|
||||
(skip-chars-forward
|
||||
" \t\n"
|
||||
(org-element-property
|
||||
:contents-end (org-element-parent el)))
|
||||
(org-element-contents-end
|
||||
(org-element-parent el)))
|
||||
(org-element-context))))
|
||||
(when (and (org-element-type-p result 'macro)
|
||||
(string= (org-element-property :key result) "results"))
|
||||
(delete-region ; And leading whitespace.
|
||||
(point)
|
||||
(progn (goto-char (org-element-property :end result))
|
||||
(progn (goto-char (org-element-end result))
|
||||
(skip-chars-backward " \t\n")
|
||||
(point)))))))))
|
||||
|
||||
|
@ -2724,7 +2729,7 @@ in the buffer."
|
|||
latex-environment))
|
||||
(save-excursion
|
||||
(goto-char (min (point-max) ;for narrowed buffers
|
||||
(org-element-property :end element)))
|
||||
(org-element-end element)))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-beginning-position 2))
|
||||
(point))))))
|
||||
|
@ -2827,7 +2832,7 @@ specified as an an \"attachment:\" style link."
|
|||
(buffer-string))))))
|
||||
(delete-region body-start
|
||||
(org-with-wide-buffer
|
||||
(goto-char (org-element-property :end element))
|
||||
(goto-char (org-element-end element))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-beginning-position)))
|
||||
(goto-char body-start)
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-escape-code-in-string "org-src" (s))
|
||||
(declare-function org-export-copy-buffer "ox"
|
||||
|
@ -195,11 +197,11 @@ this template."
|
|||
nil)
|
||||
(type type)))
|
||||
(begin
|
||||
(copy-marker (org-element-property :begin element)))
|
||||
(copy-marker (org-element-begin element)))
|
||||
(end
|
||||
(copy-marker
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(goto-char (org-element-end element))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(point)))))
|
||||
(pcase type
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
(declare-function org-babel-lob-get-info "ob-lob" (&optional datum no-eval))
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-end-of-meta-data "org" (&optional full))
|
||||
(declare-function org-find-property "org" (property &optional value))
|
||||
|
@ -171,7 +172,7 @@ Emacs Lisp representation of the value of the variable."
|
|||
(let ((e (org-element-at-point)))
|
||||
(when (equal (org-element-property :name e) ref)
|
||||
(goto-char
|
||||
(org-element-property :post-affiliated e))
|
||||
(org-element-post-affiliated e))
|
||||
(pcase (org-element-type e)
|
||||
(`babel-call
|
||||
(throw :found
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
(declare-function org-element--cache-active-p "org-element" ())
|
||||
(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-heading-components "org" ())
|
||||
|
@ -458,10 +459,10 @@ code blocks by target file."
|
|||
(org-babel-map-src-blocks (buffer-file-name)
|
||||
(let ((current-heading-pos
|
||||
(if (org-element--cache-active-p)
|
||||
(or (org-element-property
|
||||
:begin (org-element-lineage
|
||||
(org-element-at-point)
|
||||
'headline t))
|
||||
(or (org-element-begin
|
||||
(org-element-lineage
|
||||
(org-element-at-point)
|
||||
'headline t))
|
||||
1)
|
||||
(org-with-wide-buffer
|
||||
(org-with-limited-levels (outline-previous-heading))))))
|
||||
|
|
78
lisp/oc.el
78
lisp/oc.el
|
@ -86,6 +86,12 @@
|
|||
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
|
||||
(declare-function org-element-context "org-element" (&optional element))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-post-blank "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-parent "org-element-ast" (node))
|
||||
(declare-function org-element-put-property "org-element-ast" (node property value))
|
||||
(declare-function org-element-restriction "org-element" (element))
|
||||
|
@ -494,7 +500,7 @@ S is split at beginning of match group N upon matching REGEXP against it.
|
|||
This function assumes S precedes CITATION."
|
||||
;; When extracting the citation, remove white spaces before it, but
|
||||
;; preserve those after it.
|
||||
(let ((post-blank (org-element-property :post-blank citation)))
|
||||
(let ((post-blank (org-element-post-blank citation)))
|
||||
(when (and post-blank (> post-blank 0))
|
||||
(org-element-insert-before (make-string post-blank ?\s) citation)))
|
||||
(org-element-insert-before
|
||||
|
@ -526,7 +532,7 @@ The function assumes S follows CITATION. Parse tree is modified by side-effect.
|
|||
(org-element-insert-before
|
||||
;; Blanks between citation and punct are now before punct and
|
||||
;; citation.
|
||||
(concat (make-string (or (org-element-property :post-blank citation) 0) ?\s)
|
||||
(concat (make-string (or (org-element-post-blank citation) 0) ?\s)
|
||||
punct)
|
||||
citation))
|
||||
|
||||
|
@ -632,12 +638,12 @@ or from the current buffer."
|
|||
(let ((contents (org-element-contents citation)))
|
||||
(cond
|
||||
((null contents)
|
||||
(org-with-point-at (org-element-property :contents-begin citation)
|
||||
(narrow-to-region (point) (org-element-property :contents-end citation))
|
||||
(org-with-point-at (org-element-contents-begin citation)
|
||||
(narrow-to-region (point) (org-element-contents-end citation))
|
||||
(let ((references nil))
|
||||
(while (not (eobp))
|
||||
(let ((reference (org-element-citation-reference-parser)))
|
||||
(goto-char (org-element-property :end reference))
|
||||
(goto-char (org-element-end reference))
|
||||
(push (if keys-only
|
||||
(org-element-property :key reference)
|
||||
reference)
|
||||
|
@ -649,8 +655,8 @@ or from the current buffer."
|
|||
(defun org-cite-boundaries (citation)
|
||||
"Return the beginning and end strict position of CITATION.
|
||||
Returns a (BEG . END) pair."
|
||||
(let ((beg (org-element-property :begin citation))
|
||||
(end (org-with-point-at (org-element-property :end citation)
|
||||
(let ((beg (org-element-begin citation))
|
||||
(end (org-with-point-at (org-element-end citation)
|
||||
(skip-chars-backward " \t")
|
||||
(point))))
|
||||
(cons beg end)))
|
||||
|
@ -659,8 +665,8 @@ Returns a (BEG . END) pair."
|
|||
"Return citation REFERENCE's key boundaries as buffer positions.
|
||||
The function returns a pair (START . END) where START and END denote positions
|
||||
in the current buffer. Positions include leading \"@\" character."
|
||||
(org-with-point-at (org-element-property :begin reference)
|
||||
(let ((end (org-element-property :end reference)))
|
||||
(org-with-point-at (org-element-begin reference)
|
||||
(let ((end (org-element-end reference)))
|
||||
(re-search-forward org-element-citation-key-re end t)
|
||||
(cons (match-beginning 0) (match-end 0)))))
|
||||
|
||||
|
@ -743,7 +749,7 @@ When removing the last reference, also remove the whole citation."
|
|||
(org-with-point-at begin
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
(pos-after-blank (org-element-property :end datum))
|
||||
(pos-after-blank (org-element-end datum))
|
||||
(first-on-line?
|
||||
(= pos-before-blank (line-beginning-position)))
|
||||
(last-on-line?
|
||||
|
@ -768,20 +774,20 @@ When removing the last reference, also remove the whole citation."
|
|||
('citation-reference
|
||||
(let* ((citation (org-element-parent datum))
|
||||
(references (org-cite-get-references citation))
|
||||
(begin (org-element-property :begin datum))
|
||||
(end (org-element-property :end datum)))
|
||||
(begin (org-element-begin datum))
|
||||
(end (org-element-end datum)))
|
||||
(cond
|
||||
;; Single reference.
|
||||
((= 1 (length references))
|
||||
(org-cite-delete-citation citation))
|
||||
;; First reference, no prefix.
|
||||
((and (= begin (org-element-property :contents-begin citation))
|
||||
((and (= begin (org-element-contents-begin citation))
|
||||
(not (org-element-property :prefix citation)))
|
||||
(org-with-point-at (org-element-property :begin datum)
|
||||
(org-with-point-at (org-element-begin datum)
|
||||
(skip-chars-backward " \t")
|
||||
(delete-region (point) end)))
|
||||
;; Last reference, no suffix.
|
||||
((and (= end (org-element-property :contents-end citation))
|
||||
((and (= end (org-element-contents-end citation))
|
||||
(not (org-element-property :suffix citation)))
|
||||
(delete-region (1- begin) (1- (cdr (org-cite-boundaries citation)))))
|
||||
;; Somewhere in-between.
|
||||
|
@ -978,9 +984,9 @@ Return newly created footnote object."
|
|||
(list 'footnote-reference
|
||||
(list :label nil
|
||||
:type 'inline
|
||||
:contents-begin (org-element-property :begin citation)
|
||||
:contents-end (org-element-property :end citation)
|
||||
:post-blank (org-element-property :post-blank citation)))))
|
||||
:contents-begin (org-element-begin citation)
|
||||
:contents-end (org-element-end citation)
|
||||
:post-blank (org-element-post-blank citation)))))
|
||||
;; Remove any white space before citation.
|
||||
(org-cite--set-previous-post-blank citation 0 info)
|
||||
;; Footnote swallows citation.
|
||||
|
@ -1226,8 +1232,8 @@ and must return either a string, an object, or a secondary string."
|
|||
"Fontify CITE with `org-cite' and `org-cite-key' faces.
|
||||
CITE is a citation object. The function applies `org-cite' face
|
||||
on the whole citation, and `org-cite-key' face on each key."
|
||||
(let ((beg (org-element-property :begin cite))
|
||||
(end (org-with-point-at (org-element-property :end cite)
|
||||
(let ((beg (org-element-begin cite))
|
||||
(end (org-with-point-at (org-element-end cite)
|
||||
(skip-chars-backward " \t")
|
||||
(point))))
|
||||
(add-text-properties beg end '(font-lock-multiline t))
|
||||
|
@ -1256,7 +1262,7 @@ from the processor set in `org-cite-activate-processor'."
|
|||
(save-match-data (funcall activate cite))
|
||||
;; Move after cite object and make sure to return
|
||||
;; a non-nil value.
|
||||
(goto-char (org-element-property :end cite)))))))
|
||||
(goto-char (org-element-end cite)))))))
|
||||
|
||||
|
||||
;;; Internal interface with Org Export library (export capability)
|
||||
|
@ -1374,7 +1380,7 @@ INFO is the communication channel, as a plist. Parse tree is modified
|
|||
by side-effect."
|
||||
(dolist (cite (org-cite-list-citations info))
|
||||
(let ((replacement (org-cite-export-citation cite nil info))
|
||||
(blanks (or (org-element-property :post-blank cite) 0)))
|
||||
(blanks (or (org-element-post-blank cite) 0)))
|
||||
(if (null replacement)
|
||||
;; Before removing the citation, transfer its `:post-blank'
|
||||
;; property to the object before, if any.
|
||||
|
@ -1419,7 +1425,7 @@ by side effect."
|
|||
(lambda (keyword)
|
||||
(when (equal "PRINT_BIBLIOGRAPHY" (org-element-property :key keyword))
|
||||
(let ((replacement (org-cite-export-bibliography keyword nil info))
|
||||
(blanks (or (org-element-property :post-blank keyword) 0)))
|
||||
(blanks (or (org-element-post-blank keyword) 0)))
|
||||
(pcase replacement
|
||||
;; Before removing the citation, transfer its
|
||||
;; `:post-blank' property to the element before, if any.
|
||||
|
@ -1500,7 +1506,7 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
|
|||
;;
|
||||
;; XXX: Inserting citation in a secondary value is not allowed
|
||||
;; yet. Is it useful?
|
||||
((let ((post (org-element-property :post-affiliated context)))
|
||||
((let ((post (org-element-post-affiliated context)))
|
||||
(and post (< (point) post)))
|
||||
(let ((case-fold-search t))
|
||||
(looking-back
|
||||
|
@ -1516,8 +1522,8 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
|
|||
((memq type '(nil paragraph)))
|
||||
;; So are contents of verse blocks.
|
||||
((eq type 'verse-block)
|
||||
(and (>= (point) (org-element-property :contents-begin context))
|
||||
(< (point) (org-element-property :contents-end context))))
|
||||
(and (>= (point) (org-element-contents-begin context))
|
||||
(< (point) (org-element-contents-end context))))
|
||||
;; In an headline or inlinetask, point must be either on the
|
||||
;; heading itself or on the blank lines below.
|
||||
((memq type '(headline inlinetask))
|
||||
|
@ -1542,7 +1548,7 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
|
|||
;; White spaces after an object or blank lines after an element
|
||||
;; are OK.
|
||||
((>= (point)
|
||||
(save-excursion (goto-char (org-element-property :end context))
|
||||
(save-excursion (goto-char (org-element-end context))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(if (eq (org-element-class context) 'object) (point)
|
||||
(line-beginning-position 2)))))
|
||||
|
@ -1552,33 +1558,33 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
|
|||
;; At the start of a list item is fine, as long as the bullet is
|
||||
;; unaffected.
|
||||
((eq type 'item)
|
||||
(> (point) (+ (org-element-property :begin context)
|
||||
(> (point) (+ (org-element-begin context)
|
||||
(org-current-text-indentation)
|
||||
(if (org-element-property :checkbox context)
|
||||
5 1))))
|
||||
;; Other elements are invalid.
|
||||
((eq (org-element-class context) 'element) nil)
|
||||
;; Just before object is fine.
|
||||
((= (point) (org-element-property :begin context)))
|
||||
((= (point) (org-element-begin context)))
|
||||
;; Within recursive object too, but not in a link.
|
||||
((eq type 'link) nil)
|
||||
((eq type 'table-cell)
|
||||
;; :contents-begin is not reliable on empty cells, so special
|
||||
;; case it.
|
||||
(<= (save-excursion (skip-chars-backward " \t") (point))
|
||||
(org-element-property :contents-end context)))
|
||||
((let ((cbeg (org-element-property :contents-begin context))
|
||||
(cend (org-element-property :contents-end context)))
|
||||
(org-element-contents-end context)))
|
||||
((let ((cbeg (org-element-contents-begin context))
|
||||
(cend (org-element-contents-end context)))
|
||||
(and cbeg (>= (point) cbeg) (<= (point) cend)))))))
|
||||
|
||||
(defun org-cite--insert-string-before (string reference)
|
||||
"Insert STRING before citation REFERENCE object."
|
||||
(org-with-point-at (org-element-property :begin reference)
|
||||
(org-with-point-at (org-element-begin reference)
|
||||
(insert string ";")))
|
||||
|
||||
(defun org-cite--insert-string-after (string reference)
|
||||
"Insert STRING after citation REFERENCE object."
|
||||
(org-with-point-at (org-element-property :end reference)
|
||||
(org-with-point-at (org-element-end reference)
|
||||
;; Make sure to move forward when we're inserting at point, so the
|
||||
;; insertion can happen multiple times.
|
||||
(if (char-equal ?\; (char-before))
|
||||
|
@ -1649,7 +1655,7 @@ More specifically,
|
|||
;; action depends on the point.
|
||||
(if arg
|
||||
(org-cite-delete-citation context)
|
||||
(let* ((begin (org-element-property :begin context))
|
||||
(let* ((begin (org-element-begin context))
|
||||
(style-end (1- (org-with-point-at begin (search-forward ":")))))
|
||||
(if (>= style-end (point))
|
||||
;; On style part, edit the style.
|
||||
|
@ -1663,7 +1669,7 @@ More specifically,
|
|||
;; point.
|
||||
(let* ((references (org-cite-get-references context))
|
||||
(key (concat "@" (funcall select-key nil))))
|
||||
(if (< (point) (org-element-property :contents-begin context))
|
||||
(if (< (point) (org-element-contents-begin context))
|
||||
(org-cite--insert-string-before key (car references))
|
||||
(org-cite--insert-string-after key (org-last references))))))))
|
||||
;; On a citation reference. If ARG is not nil, remove the
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
|
||||
(declare-function org-element-link-parser "org-element" ())
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-element-update-syntax "org-element" ())
|
||||
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
|
||||
|
@ -755,7 +756,7 @@ White spaces are not significant."
|
|||
(forward-char -1)
|
||||
(let ((object (org-element-context)))
|
||||
(when (org-element-type-p object 'radio-target)
|
||||
(goto-char (org-element-property :begin object))
|
||||
(goto-char (org-element-begin object))
|
||||
(org-fold-show-context 'link-search)
|
||||
(throw :radio-match nil))))
|
||||
(goto-char origin)
|
||||
|
@ -1118,7 +1119,7 @@ for internal and \"file\" links, or stored as a parameter in
|
|||
(_ path))
|
||||
;; Prevent fuzzy links from matching themselves.
|
||||
(and (equal type "fuzzy")
|
||||
(+ 2 (org-element-property :begin link)))))
|
||||
(+ 2 (org-element-begin link)))))
|
||||
(point))))
|
||||
(unless (and (<= (point-min) destination)
|
||||
(>= (point-max) destination))
|
||||
|
@ -1224,7 +1225,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
|
|||
(let ((context (org-element-context)))
|
||||
(when (org-element-type-p context 'target)
|
||||
(setq type 'dedicated)
|
||||
(goto-char (org-element-property :begin context))
|
||||
(goto-char (org-element-begin context))
|
||||
(throw :target-match t))))
|
||||
nil))))
|
||||
;; Look for elements named after S, only if not in a headline
|
||||
|
@ -1475,7 +1476,7 @@ is non-nil, move backward."
|
|||
(pcase (org-element-lineage context 'link t)
|
||||
(`nil nil)
|
||||
(link
|
||||
(goto-char (org-element-property :begin link))
|
||||
(goto-char (org-element-begin link))
|
||||
(when (org-invisible-p) (org-fold-show-context 'link-search))
|
||||
(throw :found t)))))
|
||||
(goto-char pos)
|
||||
|
|
|
@ -6340,7 +6340,7 @@ specification like [h]h:mm."
|
|||
(org-element-property
|
||||
:hour-end
|
||||
(org-element-property :deadline el))))
|
||||
(goto-char (org-element-property :contents-begin el))
|
||||
(goto-char (org-element-contents-begin el))
|
||||
(catch :skip
|
||||
(org-agenda-skip el)
|
||||
(let* ((s (substring (org-element-property
|
||||
|
@ -6348,7 +6348,7 @@ specification like [h]h:mm."
|
|||
(org-element-property :deadline el))
|
||||
1 -1))
|
||||
(pos (save-excursion
|
||||
(goto-char (org-element-property :contents-begin el))
|
||||
(goto-char (org-element-contents-begin el))
|
||||
;; We intentionally leave NOERROR
|
||||
;; argument in `re-search-forward' nil. If
|
||||
;; the search fails here, something went
|
||||
|
@ -6427,7 +6427,7 @@ specification like [h]h:mm."
|
|||
(/= deadline current)))
|
||||
(throw :skip nil))
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :begin el))
|
||||
(goto-char (org-element-begin el))
|
||||
(let* ((category (org-get-category))
|
||||
(effort (save-match-data (or (get-text-property (point) 'effort)
|
||||
(org-element-property (intern (concat ":" (upcase org-effort-property))) el))))
|
||||
|
@ -6435,7 +6435,7 @@ specification like [h]h:mm."
|
|||
(level (make-string (org-element-property :level el)
|
||||
?\s))
|
||||
(head (save-excursion
|
||||
(goto-char (org-element-property :begin el))
|
||||
(goto-char (org-element-begin el))
|
||||
(re-search-forward org-outline-regexp-bol)
|
||||
(buffer-substring-no-properties (point) (line-end-position))))
|
||||
(inherited-tags
|
||||
|
@ -6683,7 +6683,7 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
(org-element-property
|
||||
:hour-end
|
||||
(org-element-property :scheduled el))))
|
||||
(goto-char (org-element-property :contents-begin el))
|
||||
(goto-char (org-element-contents-begin el))
|
||||
(catch :skip
|
||||
(org-agenda-skip el)
|
||||
(let* ((s (substring (org-element-property
|
||||
|
@ -6691,7 +6691,7 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
(org-element-property :scheduled el))
|
||||
1 -1))
|
||||
(pos (save-excursion
|
||||
(goto-char (org-element-property :contents-begin el))
|
||||
(goto-char (org-element-contents-begin el))
|
||||
;; We intentionally leave NOERROR
|
||||
;; argument in `re-search-forward' nil. If
|
||||
;; the search fails here, something went
|
||||
|
@ -6814,7 +6814,7 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
org-habit-show-habits-only-for-today))))
|
||||
(throw :skip nil))
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :begin el))
|
||||
(goto-char (org-element-begin el))
|
||||
(let* ((category (org-get-category))
|
||||
(effort (save-match-data
|
||||
(or (get-text-property (point) 'effort)
|
||||
|
@ -6832,7 +6832,7 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
(level (make-string (org-element-property :level el)
|
||||
?\s))
|
||||
(head (save-excursion
|
||||
(goto-char (org-element-property :begin el))
|
||||
(goto-char (org-element-begin el))
|
||||
(re-search-forward org-outline-regexp-bol)
|
||||
(buffer-substring (point) (line-end-position))))
|
||||
(time
|
||||
|
@ -6868,7 +6868,7 @@ scheduled items with an hour specification like [h]h:mm."
|
|||
'org-agenda-done)
|
||||
(todayp 'org-scheduled-today)
|
||||
(t 'org-scheduled)))
|
||||
(habitp (and habitp (org-habit-parse-todo (org-element-property :begin el)))))
|
||||
(habitp (and habitp (org-habit-parse-todo (org-element-begin el)))))
|
||||
(org-add-props item props
|
||||
'undone-face face
|
||||
'face (if donep 'org-agenda-done face)
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
(declare-function dired-dwim-target-directory "dired-aux")
|
||||
(declare-function dired-get-marked-files "dired" (&optional localp arg filter distinguish-one-marked error))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-inlinetask-goto-beginning "org-inlinetask" ())
|
||||
(declare-function org-inlinetask-in-task-p "org-inlinetask" ())
|
||||
|
@ -744,17 +748,17 @@ It is meant to be added to `org-export-before-parsing-hook'."
|
|||
(when (and (org-element-type-p link 'link)
|
||||
(string-equal "attachment"
|
||||
(org-element-property :type link)))
|
||||
(let* ((description (and (org-element-property :contents-begin link)
|
||||
(let* ((description (and (org-element-contents-begin link)
|
||||
(buffer-substring-no-properties
|
||||
(org-element-property :contents-begin link)
|
||||
(org-element-property :contents-end link))))
|
||||
(org-element-contents-begin link)
|
||||
(org-element-contents-end link))))
|
||||
(file (org-element-property :path link))
|
||||
(new-link (org-link-make-string
|
||||
(concat "file:" (org-attach-expand file))
|
||||
description)))
|
||||
(goto-char (org-element-property :end link))
|
||||
(goto-char (org-element-end link))
|
||||
(skip-chars-backward " \t")
|
||||
(delete-region (org-element-property :begin link) (point))
|
||||
(delete-region (org-element-begin link) (point))
|
||||
(insert new-link)))))))
|
||||
|
||||
(defun org-attach-follow (file arg)
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-encrypt-entry "org-crypt" ())
|
||||
(declare-function org-insert-link "ol" (&optional complete-file link-location default-description))
|
||||
(declare-function org-link-make-string "ol" (link &optional description))
|
||||
|
@ -1314,7 +1316,7 @@ may have been stored before."
|
|||
(point-marker))))
|
||||
(when item
|
||||
(let ((i (save-excursion
|
||||
(goto-char (org-element-property :post-affiliated item))
|
||||
(goto-char (org-element-post-affiliated item))
|
||||
(org-current-text-indentation))))
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
|
@ -1382,8 +1384,8 @@ may have been stored before."
|
|||
((pred (lambda (e) (eq 'table.el (org-element-property :type e))))
|
||||
nil)
|
||||
(table
|
||||
(goto-char (org-element-property :contents-end table))
|
||||
(narrow-to-region (org-element-property :post-affiliated table)
|
||||
(goto-char (org-element-contents-end table))
|
||||
(narrow-to-region (org-element-post-affiliated table)
|
||||
(point))
|
||||
(throw :found t))))
|
||||
;; No table found. Create it with an empty header.
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
(declare-function calendar-iso-to-absolute "cal-iso" (date))
|
||||
(declare-function notifications-notify "notifications" (&rest params))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-element--cache-active-p "org-element" ())
|
||||
|
@ -1043,7 +1045,7 @@ CLOCK is a cons cell of the form (MARKER START-TIME)."
|
|||
(while (re-search-backward drawer-re beg t)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (org-element-type-p element 'drawer)
|
||||
(when (> (org-element-property :end element) (car clock))
|
||||
(when (> (org-element-end element) (car clock))
|
||||
(org-fold-hide-drawer-toggle 'off nil element))
|
||||
(throw 'exit nil)))))))))))
|
||||
|
||||
|
@ -1607,7 +1609,7 @@ line and position cursor in that line."
|
|||
(while (re-search-forward drawer-re end t)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (org-element-type-p element 'drawer)
|
||||
(let ((cend (org-element-property :contents-end element)))
|
||||
(let ((cend (org-element-contents-end element)))
|
||||
(if (and (not org-log-states-order-reversed) cend)
|
||||
(goto-char cend)
|
||||
(forward-line))
|
||||
|
|
|
@ -56,6 +56,11 @@
|
|||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-end-of-subtree "org" (&optional invisible-ok to-heading))
|
||||
(declare-function org-get-heading "org" (&optional no-tags no-todo no-priority no-comment))
|
||||
(declare-function org-get-tags "org" (&optional pos local))
|
||||
|
@ -896,10 +901,10 @@ region as a drawer without further ado."
|
|||
(looking-at-p "^[ \t]*:\\(\\(?:\\w\\|[-_]\\)+\\):[ \t]*$"))
|
||||
(org-element-at-point)))))
|
||||
(when (org-element-type-p drawer '(drawer property-drawer))
|
||||
(let ((post (org-element-property :post-affiliated drawer)))
|
||||
(let ((post (org-element-post-affiliated drawer)))
|
||||
(org-fold-region
|
||||
(save-excursion (goto-char post) (line-end-position))
|
||||
(save-excursion (goto-char (org-element-property :end drawer))
|
||||
(save-excursion (goto-char (org-element-end drawer))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-end-position))
|
||||
flag (if (eq org-fold-core-style 'text-properties) 'drawer 'outline))
|
||||
|
@ -1389,7 +1394,7 @@ ELEMENT is the element at point."
|
|||
;; Only in inline footnotes, within the definition.
|
||||
(and (eq (org-element-property :type object) 'inline)
|
||||
(< (save-excursion
|
||||
(goto-char (org-element-property :begin object))
|
||||
(goto-char (org-element-begin object))
|
||||
(search-forward ":" nil t 2))
|
||||
(point))))
|
||||
(otherwise t))))
|
||||
|
@ -1410,7 +1415,7 @@ ELEMENT is the element at point."
|
|||
;; Ignore checks in code, verbatim and others.
|
||||
(org--flyspell-object-check-p (org-element-at-point-no-context)))
|
||||
(let* ((element (org-element-at-point-no-context))
|
||||
(post-affiliated (org-element-property :post-affiliated element)))
|
||||
(post-affiliated (org-element-post-affiliated element)))
|
||||
(cond
|
||||
;; Ignore checks in all affiliated keywords but captions.
|
||||
((< (point) post-affiliated)
|
||||
|
@ -1436,7 +1441,7 @@ ELEMENT is the element at point."
|
|||
(save-excursion
|
||||
(end-of-line)
|
||||
(skip-chars-forward " \r\t\n")
|
||||
(< (point) (org-element-property :end element)))))
|
||||
(< (point) (org-element-end element)))))
|
||||
;; Arbitrary list of keywords where checks are meaningful.
|
||||
;; Make sure point is on the value part of the element.
|
||||
(keyword
|
||||
|
@ -1448,8 +1453,8 @@ ELEMENT is the element at point."
|
|||
;; table rows (after affiliated keywords) but some objects
|
||||
;; must not be affected.
|
||||
((paragraph table-row verse-block)
|
||||
(let ((cbeg (org-element-property :contents-begin element))
|
||||
(cend (org-element-property :contents-end element)))
|
||||
(let ((cbeg (org-element-contents-begin element))
|
||||
(cend (org-element-contents-end element)))
|
||||
(and cbeg (>= (point) cbeg) (< (point) cend)
|
||||
(org--flyspell-object-check-p element))))))))))
|
||||
(put 'org-mode 'flyspell-mode-predicate 'org-mode-flyspell-verify)
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self))
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-display-inline-images "org" (&optional include-linked refresh beg end))
|
||||
|
@ -404,8 +405,8 @@ Use `\\[org-edit-special]' to edit table.el tables"))
|
|||
t)))
|
||||
(and item
|
||||
(= (line-beginning-position)
|
||||
(org-element-property :post-affiliated
|
||||
item)))))
|
||||
(org-element-post-affiliated
|
||||
item)))))
|
||||
(org-match-line org-outline-regexp))
|
||||
(or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))
|
||||
(org-cycle-internal-local))
|
||||
|
|
|
@ -549,6 +549,48 @@ value of DATUM `:parent' property."
|
|||
OBJECT is the object to consider."
|
||||
(org-element-lineage object org-element-all-elements))
|
||||
|
||||
(defsubst org-element-begin (node)
|
||||
"Get `:begin' property of NODE."
|
||||
(org-element-property :begin node))
|
||||
|
||||
(gv-define-setter org-element-begin (value node)
|
||||
`(org-element-put-property ,node :begin ,value))
|
||||
|
||||
(defsubst org-element-end (node)
|
||||
"Get `:end' property of NODE."
|
||||
(org-element-property :end node))
|
||||
|
||||
(gv-define-setter org-element-end (value node)
|
||||
`(org-element-put-property ,node :end ,value))
|
||||
|
||||
(defsubst org-element-contents-begin (node)
|
||||
"Get `:contents-begin' property of NODE."
|
||||
(org-element-property :contents-begin node))
|
||||
|
||||
(gv-define-setter org-element-contents-begin (value node)
|
||||
`(org-element-put-property ,node :contents-begin ,value))
|
||||
|
||||
(defsubst org-element-contents-end (node)
|
||||
"Get `:contents-end' property of NODE."
|
||||
(org-element-property :contents-end node))
|
||||
|
||||
(gv-define-setter org-element-contents-end (value node)
|
||||
`(org-element-put-property ,node :contents-end ,value))
|
||||
|
||||
(defsubst org-element-post-affiliated (node)
|
||||
"Get `:post-affiliated' property of NODE."
|
||||
(org-element-property :post-affiliated node))
|
||||
|
||||
(gv-define-setter org-element-post-affiliated (value node)
|
||||
`(org-element-put-property ,node :post-affiliated ,value))
|
||||
|
||||
(defsubst org-element-post-blank (node)
|
||||
"Get `:post-blank' property of NODE."
|
||||
(org-element-property :post-blank node))
|
||||
|
||||
(gv-define-setter org-element-post-blank (value node)
|
||||
`(org-element-put-property ,node :post-blank ,value))
|
||||
|
||||
(defconst org-element--cache-element-properties
|
||||
'(:cached
|
||||
:org-element--cache-sync-key
|
||||
|
@ -569,7 +611,7 @@ Return nil if STRING is nil."
|
|||
(defun org-element--substring (element beg-offset end-offset)
|
||||
"Get substring inside ELEMENT according to BEG-OFFSET and END-OFFSET."
|
||||
(with-current-buffer (org-element-property :buffer element)
|
||||
(let ((beg (org-element-property :begin element)))
|
||||
(let ((beg (org-element-begin element)))
|
||||
(buffer-substring-no-properties
|
||||
(+ beg beg-offset) (+ beg end-offset)))))
|
||||
|
||||
|
@ -955,8 +997,8 @@ Return value is a plist."
|
|||
;; properties.
|
||||
(org-element-put-property
|
||||
element :robust-begin
|
||||
(let ((contents-begin (org-element-property :contents-begin element))
|
||||
(contents-end (org-element-property :contents-end element)))
|
||||
(let ((contents-begin (org-element-contents-begin element))
|
||||
(contents-end (org-element-contents-end element)))
|
||||
(when contents-begin
|
||||
(progn (goto-char contents-begin)
|
||||
(when (looking-at-p org-element-planning-line-re)
|
||||
|
@ -972,19 +1014,19 @@ Return value is a plist."
|
|||
(point))))))
|
||||
(org-element-put-property
|
||||
element :robust-end
|
||||
(let ((contents-end (org-element-property :contents-end element))
|
||||
(let ((contents-end (org-element-contents-end element))
|
||||
(robust-begin (org-element-property :robust-begin element)))
|
||||
(when contents-end
|
||||
(when (> (- contents-end 2) robust-begin)
|
||||
(- contents-end 2)))))
|
||||
(unless (org-element-property :robust-end element)
|
||||
(org-element-put-property element :robust-begin nil))
|
||||
(goto-char (org-element-property :begin element))
|
||||
(goto-char (org-element-begin element))
|
||||
(setcar (cdr element)
|
||||
(nconc
|
||||
(nth 1 element)
|
||||
(org-element--get-time-properties)))
|
||||
(goto-char (org-element-property :begin element))
|
||||
(goto-char (org-element-begin element))
|
||||
(setcar (cdr element)
|
||||
(nconc
|
||||
(nth 1 element)
|
||||
|
@ -1015,7 +1057,7 @@ parsed as a secondary string, but as a plain string instead.
|
|||
|
||||
Throw `:org-element-deferred-retry' signal at the end."
|
||||
(with-current-buffer (org-element-property :buffer headline)
|
||||
(org-with-point-at (org-element-property :begin headline)
|
||||
(org-with-point-at (org-element-begin headline)
|
||||
(let* ((begin (point))
|
||||
(true-level (prog1 (skip-chars-forward "*")
|
||||
(skip-chars-forward " \t")))
|
||||
|
@ -4632,7 +4674,7 @@ of 1 and a \"phone\" tag, and will return its beginning position:
|
|||
(lambda (hl)
|
||||
(and (= (org-element-property :level hl) 1)
|
||||
(member \"phone\" (org-element-property :tags hl))
|
||||
(org-element-property :begin hl)))
|
||||
(org-element-begin hl)))
|
||||
nil t)
|
||||
|
||||
The next example will return a flat list of all `plain-list' type
|
||||
|
@ -4754,8 +4796,8 @@ Elements are accumulated into ACC."
|
|||
;; its category.
|
||||
(let* ((element (org-element--current-element end granularity mode structure))
|
||||
(type (org-element-type element))
|
||||
(cbeg (org-element-property :contents-begin element)))
|
||||
(goto-char (org-element-property :end element))
|
||||
(cbeg (org-element-contents-begin element)))
|
||||
(goto-char (org-element-end element))
|
||||
;; Fill ELEMENT contents by side-effect.
|
||||
(cond
|
||||
;; If element has no contents, don't modify it.
|
||||
|
@ -4770,7 +4812,7 @@ Elements are accumulated into ACC."
|
|||
(eq type 'section))
|
||||
(eq type 'headline)))
|
||||
(org-element--parse-elements
|
||||
cbeg (org-element-property :contents-end element)
|
||||
cbeg (org-element-contents-end element)
|
||||
;; Possibly switch to a special mode.
|
||||
(org-element--next-mode mode type t)
|
||||
(and (memq type '(item plain-list))
|
||||
|
@ -4780,7 +4822,7 @@ Elements are accumulated into ACC."
|
|||
;; GRANULARITY allows it.
|
||||
((memq granularity '(object nil))
|
||||
(org-element--parse-objects
|
||||
cbeg (org-element-property :contents-end element) element
|
||||
cbeg (org-element-contents-end element) element
|
||||
(org-element-restriction type))))
|
||||
(push (org-element-put-property element :parent acc) elements)
|
||||
;; Update mode.
|
||||
|
@ -4929,20 +4971,20 @@ the list of objects itself."
|
|||
(while (and (not (eobp))
|
||||
(setq next-object (org-element--object-lex restriction)))
|
||||
;; Text before any object.
|
||||
(let ((obj-beg (org-element-property :begin next-object)))
|
||||
(let ((obj-beg (org-element-begin next-object)))
|
||||
(unless (= (point) obj-beg)
|
||||
(let ((text (buffer-substring-no-properties (point) obj-beg)))
|
||||
(push (if acc (org-element-put-property text :parent acc) text)
|
||||
contents))))
|
||||
;; Object...
|
||||
(let ((obj-end (org-element-property :end next-object))
|
||||
(cont-beg (org-element-property :contents-begin next-object)))
|
||||
(let ((obj-end (org-element-end next-object))
|
||||
(cont-beg (org-element-contents-begin next-object)))
|
||||
(when acc (org-element-put-property next-object :parent acc))
|
||||
(push (if cont-beg
|
||||
;; Fill contents of NEXT-OBJECT if possible.
|
||||
(org-element--parse-objects
|
||||
cont-beg
|
||||
(org-element-property :contents-end next-object)
|
||||
(org-element-contents-end next-object)
|
||||
next-object
|
||||
(org-element-restriction next-object))
|
||||
next-object)
|
||||
|
@ -5035,7 +5077,7 @@ to interpret. Return Org syntax as a string."
|
|||
(if (memq type '(org-data anonymous)) results
|
||||
;; Build white spaces. If no `:post-blank' property
|
||||
;; is specified, assume its value is 0.
|
||||
(let ((blank (or (org-element-property :post-blank data) 0)))
|
||||
(let ((blank (or (org-element-post-blank data) 0)))
|
||||
(if (eq (org-element-class data parent) 'object)
|
||||
(concat results (make-string blank ?\s))
|
||||
(concat (org-element--interpret-affiliated-keywords data)
|
||||
|
@ -5524,7 +5566,7 @@ current `org-element--cache-sync-keys-value' and the element key."
|
|||
(or (when-let ((key-cons (org-element-property :org-element--cache-sync-key element)))
|
||||
(when (eq org-element--cache-sync-keys-value (car key-cons))
|
||||
(cdr key-cons)))
|
||||
(let* ((begin (org-element-property :begin element))
|
||||
(let* ((begin (org-element-begin element))
|
||||
(type (org-element-type element))
|
||||
;; Increase beginning position of items (respectively
|
||||
;; table rows) by one, so the first item can get
|
||||
|
@ -5730,7 +5772,7 @@ the cache."
|
|||
;; exact. Extra elements starting before/after could
|
||||
;; have been added to cache and HASHED may no longer be
|
||||
;; valid.
|
||||
(= pos (org-element-property :begin hashed))
|
||||
(= pos (org-element-begin hashed))
|
||||
;; We cannot rely on element :begin for elements with
|
||||
;; children starting at the same pos.
|
||||
(not (org-element-type-p hashed '(section org-data table))))
|
||||
|
@ -5738,11 +5780,11 @@ the cache."
|
|||
;; No appriate HASHED. Search the cache.
|
||||
(while node
|
||||
(let* ((element (avl-tree--node-data node))
|
||||
(begin (org-element-property :begin element)))
|
||||
(begin (org-element-begin element)))
|
||||
(cond
|
||||
((and limit
|
||||
(not (org-element--cache-key-less-p
|
||||
(org-element--cache-key element) limit)))
|
||||
(org-element--cache-key element) limit)))
|
||||
(setq node (avl-tree--node-left node)))
|
||||
((> begin pos)
|
||||
(setq upper element
|
||||
|
@ -5767,8 +5809,8 @@ the cache."
|
|||
(setq node (avl-tree--node-right node)))
|
||||
((and (org-element-type-p element '(item table-row))
|
||||
(let ((parent (org-element-parent element)))
|
||||
(and (= (org-element-property :begin element)
|
||||
(org-element-property :contents-begin parent))
|
||||
(and (= (org-element-begin element)
|
||||
(org-element-contents-begin parent))
|
||||
(setq node nil
|
||||
lower parent
|
||||
upper parent)))))
|
||||
|
@ -5792,7 +5834,7 @@ the cache."
|
|||
;; the new element so `avl-tree-enter' can insert it at the
|
||||
;; right spot in the cache.
|
||||
(let* ((keys (org-element--cache-find
|
||||
(org-element-property :begin element) 'both))
|
||||
(org-element-begin element) 'both))
|
||||
(new-key (org-element--cache-generate-key
|
||||
(and (car keys) (org-element--cache-key (car keys)))
|
||||
(cond ((cdr keys) (org-element--cache-key (cdr keys)))
|
||||
|
@ -5836,7 +5878,7 @@ Assume ELEMENT belongs to cache and that a cache is active."
|
|||
If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report)."
|
||||
(org-element-type element)
|
||||
(current-buffer)
|
||||
(org-element-property :begin element)
|
||||
(org-element-begin element)
|
||||
(org-element-property :org-element--cache-sync-key element))
|
||||
(org-element-cache-reset)
|
||||
(throw 'quit nil))
|
||||
|
@ -5849,7 +5891,7 @@ If this warning appears regularly, please report the warning text to Org mode ma
|
|||
If this warning appears regularly, please report the warning text to Org mode mailing list (M-x org-submit-bug-report)."
|
||||
(org-element-type element)
|
||||
(current-buffer)
|
||||
(org-element-property :begin element)
|
||||
(org-element-begin element)
|
||||
(org-element-property :org-element--cache-sync-key element))
|
||||
(org-element-cache-reset)
|
||||
(throw 'quit nil)))))
|
||||
|
@ -5897,17 +5939,17 @@ Properties are modified by side-effect."
|
|||
(cl-incf (nth 6 item) offset))))
|
||||
;; Do not use loop for inline expansion to work during compile time.
|
||||
(when (or (not props) (memq :begin props))
|
||||
(cl-incf (org-element-property :begin element) offset))
|
||||
(cl-incf (org-element-begin element) offset))
|
||||
(when (or (not props) (memq :end props))
|
||||
(cl-incf (org-element-property :end element) offset))
|
||||
(cl-incf (org-element-end element) offset))
|
||||
(when (or (not props) (memq :post-affiliated props))
|
||||
(cl-incf (org-element-property :post-affiliated element) offset))
|
||||
(cl-incf (org-element-post-affiliated element) offset))
|
||||
(when (and (or (not props) (memq :contents-begin props))
|
||||
(org-element-property :contents-begin element))
|
||||
(cl-incf (org-element-property :contents-begin element) offset))
|
||||
(org-element-contents-begin element))
|
||||
(cl-incf (org-element-contents-begin element) offset))
|
||||
(when (and (or (not props) (memq :contents-end props))
|
||||
(org-element-property :contents-end element))
|
||||
(cl-incf (org-element-property :contents-end element) offset))
|
||||
(org-element-contents-end element))
|
||||
(cl-incf (org-element-contents-end element) offset))
|
||||
(when (and (or (not props) (memq :robust-begin props))
|
||||
(org-element-property :robust-begin element))
|
||||
(cl-incf (org-element-property :robust-begin element) offset))
|
||||
|
@ -6088,7 +6130,7 @@ completing the request."
|
|||
(if data
|
||||
;; We found first element in cache starting at or
|
||||
;; after REQUEST-KEY.
|
||||
(let ((pos (org-element-property :begin data)))
|
||||
(let ((pos (org-element-begin data)))
|
||||
;; FIXME: Maybe simply (< pos end)?
|
||||
(if (<= pos end)
|
||||
(progn
|
||||
|
@ -6216,9 +6258,9 @@ completing the request."
|
|||
(let ((up parent))
|
||||
(while (and up
|
||||
(or (not cached-before)
|
||||
(> (org-element-property :begin up)
|
||||
(org-element-property :begin cached-before))))
|
||||
(when (> (org-element-property :end up) future-change)
|
||||
(> (org-element-begin up)
|
||||
(org-element-begin cached-before))))
|
||||
(when (> (org-element-end up) future-change)
|
||||
;; Offset future cache request.
|
||||
(org-element--cache-shift-positions
|
||||
up (- offset)
|
||||
|
@ -6277,10 +6319,10 @@ completing the request."
|
|||
(org-element--cache-log-message "Reached next request.")
|
||||
(let ((next-request (nth 1 org-element--cache-sync-requests)))
|
||||
(unless (and (org-element-property :cached (org-element--request-parent next-request))
|
||||
(org-element-property :begin (org-element--request-parent next-request))
|
||||
(org-element-begin (org-element--request-parent next-request))
|
||||
parent
|
||||
(> (org-element-property :begin (org-element--request-parent next-request))
|
||||
(org-element-property :begin parent)))
|
||||
(> (org-element-begin (org-element--request-parent next-request))
|
||||
(org-element-begin parent)))
|
||||
(setf (org-element--request-parent next-request) parent)))
|
||||
(throw 'org-element--cache-quit t))
|
||||
;; Handle interruption request. Update current request.
|
||||
|
@ -6297,11 +6339,11 @@ completing the request."
|
|||
(org-element-property :org-element--cache-sync-key data)
|
||||
(org-element--format-element data)))
|
||||
(org-element--cache-shift-positions data offset))
|
||||
(let ((begin (org-element-property :begin data)))
|
||||
(let ((begin (org-element-begin data)))
|
||||
;; Update PARENT and re-parent DATA, only when
|
||||
;; necessary. Propagate new structures for lists.
|
||||
(while (and parent
|
||||
(<= (org-element-property :end parent) begin))
|
||||
(<= (org-element-end parent) begin))
|
||||
(setq parent (org-element-parent parent)))
|
||||
(cond ((and (not parent) (zerop offset)) (throw 'org-element--cache-quit nil))
|
||||
;; Consider scenario when DATA lays within
|
||||
|
@ -6320,13 +6362,13 @@ completing the request."
|
|||
;; cache must be deleted instead.
|
||||
((and parent
|
||||
(or (not (org-element-type-p parent org-element-greater-elements))
|
||||
(and (org-element-property :contents-begin parent)
|
||||
(< (org-element-property :begin data) (org-element-property :contents-begin parent)))
|
||||
(and (org-element-property :contents-end parent)
|
||||
(>= (org-element-property :begin data) (org-element-property :contents-end parent)))
|
||||
(> (org-element-property :end data) (org-element-property :end parent))
|
||||
(and (org-element-property :contents-end data)
|
||||
(> (org-element-property :contents-end data) (org-element-property :contents-end parent)))))
|
||||
(and (org-element-contents-begin parent)
|
||||
(< (org-element-begin data) (org-element-contents-begin parent)))
|
||||
(and (org-element-contents-end parent)
|
||||
(>= (org-element-begin data) (org-element-contents-end parent)))
|
||||
(> (org-element-end data) (org-element-end parent))
|
||||
(and (org-element-contents-end data)
|
||||
(> (org-element-contents-end data) (org-element-contents-end parent)))))
|
||||
(org-element--cache-log-message "org-element-cache: Removing obsolete element with key %S::%S"
|
||||
(org-element-property :org-element--cache-sync-key data)
|
||||
(org-element--format-element data))
|
||||
|
@ -6345,8 +6387,8 @@ completing the request."
|
|||
(not (eq parent data))
|
||||
(let ((p (org-element-parent data)))
|
||||
(or (not p)
|
||||
(< (org-element-property :begin p)
|
||||
(org-element-property :begin parent))
|
||||
(< (org-element-begin p)
|
||||
(org-element-begin parent))
|
||||
(unless (eq p parent)
|
||||
(not (org-element-property :cached p))
|
||||
;; (not (avl-tree-member-p org-element--cache p))
|
||||
|
@ -6397,10 +6439,10 @@ it and does not have closing term.
|
|||
|
||||
Examples of such elements are: section, headline, org-data,
|
||||
and footnote-definition."
|
||||
(and (org-element-property :contents-end element)
|
||||
(= (org-element-property :contents-end element)
|
||||
(and (org-element-contents-end element)
|
||||
(= (org-element-contents-end element)
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(goto-char (org-element-end element))
|
||||
(skip-chars-backward " \r\n\t")
|
||||
(line-beginning-position 2)))))
|
||||
|
||||
|
@ -6437,13 +6479,13 @@ the expected result."
|
|||
;; file.
|
||||
((and (not cached) (org-element--cache-active-p))
|
||||
(setq element (org-element-org-data-parser))
|
||||
(unless (org-element-property :begin element)
|
||||
(unless (org-element-begin element)
|
||||
(org-element--cache-warn "Error parsing org-data. Got %S\nPlease report to Org mode mailing list (M-x org-submit-bug-report)." element))
|
||||
(org-element--cache-log-message
|
||||
"Nothing in cache. Adding org-data: %S"
|
||||
(org-element--format-element element))
|
||||
(org-element--cache-put element)
|
||||
(goto-char (org-element-property :contents-begin element))
|
||||
(goto-char (org-element-contents-begin element))
|
||||
(setq mode 'org-data))
|
||||
;; Nothing in cache before point because cache is not active.
|
||||
;; Parse from previous heading to avoid re-parsing the whole
|
||||
|
@ -6482,15 +6524,15 @@ the expected result."
|
|||
(t
|
||||
(let ((up cached)
|
||||
(pos (if (= (point-max) pos) (1- pos) pos)))
|
||||
(while (and up (<= (org-element-property :end up) pos))
|
||||
(setq next (org-element-property :end up)
|
||||
(while (and up (<= (org-element-end up) pos))
|
||||
(setq next (org-element-end up)
|
||||
element up
|
||||
mode (org-element--next-mode (org-element-property :mode element) (org-element-type element) nil)
|
||||
up (org-element-parent up)))
|
||||
(when next (goto-char next))
|
||||
(when up (setq element up)))))
|
||||
;; Parse successively each element until we reach POS.
|
||||
(let ((end (or (org-element-property :end element) (point-max)))
|
||||
(let ((end (or (org-element-end element) (point-max)))
|
||||
(parent (org-element-parent element)))
|
||||
(while t
|
||||
(when (org-element--cache-interrupt-p time-limit)
|
||||
|
@ -6533,7 +6575,7 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li
|
|||
(org-element-cache-reset)
|
||||
(error "org-element--cache: Emergency exit"))))
|
||||
(org-element-put-property element :parent parent))
|
||||
(let ((elem-end (org-element-property :end element))
|
||||
(let ((elem-end (org-element-end element))
|
||||
(type (org-element-type element)))
|
||||
(cond
|
||||
;; Skip any element ending before point. Also skip
|
||||
|
@ -6580,8 +6622,8 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li
|
|||
;; can start after it, but more than one may end there.
|
||||
;; Arbitrarily, we choose to return the innermost of
|
||||
;; such elements.
|
||||
((let ((cbeg (org-element-property :contents-begin element))
|
||||
(cend (org-element-property :contents-end element)))
|
||||
((let ((cbeg (org-element-contents-begin element))
|
||||
(cend (org-element-contents-end element)))
|
||||
(when (and cbeg cend
|
||||
(or (< cbeg pos)
|
||||
(and (= cbeg pos)
|
||||
|
@ -6604,16 +6646,16 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li
|
|||
;; return the outermost element inside
|
||||
;; the headline section.
|
||||
(and (org-element--open-end-p element)
|
||||
(or (= (org-element-property :end element) (point-max))
|
||||
(and (>= pos (org-element-property :contents-end element))
|
||||
(or (= (org-element-end element) (point-max))
|
||||
(and (>= pos (org-element-contents-end element))
|
||||
(org-element-type-p element '(org-data section headline)))))))
|
||||
(goto-char (or next cbeg))
|
||||
(setq mode (if next mode (org-element--next-mode mode type t))
|
||||
next nil
|
||||
parent element
|
||||
end (if (org-element--open-end-p element)
|
||||
(org-element-property :end element)
|
||||
(org-element-property :contents-end element))))))
|
||||
(org-element-end element)
|
||||
(org-element-contents-end element))))))
|
||||
;; Otherwise, return ELEMENT as it is the smallest
|
||||
;; element containing POS.
|
||||
(t (throw 'exit (if syncp parent element)))))
|
||||
|
@ -6796,8 +6838,8 @@ known element in cache (it may start after END)."
|
|||
(let ((prev before))
|
||||
(while (org-element-type-p prev 'keyword)
|
||||
(setq before prev
|
||||
beg (org-element-property :begin prev))
|
||||
(setq prev (org-element--cache-find (1- (org-element-property :begin before)))))))
|
||||
beg (org-element-begin prev))
|
||||
(setq prev (org-element--cache-find (1- (org-element-begin before)))))))
|
||||
(let ((up before)
|
||||
(robust-flag t))
|
||||
(while up
|
||||
|
@ -6810,8 +6852,8 @@ known element in cache (it may start after END)."
|
|||
;; Sensitive change. This is
|
||||
;; unconditionally non-robust change.
|
||||
(not org-element--cache-change-warning)
|
||||
(let ((cbeg (org-element-property :contents-begin up))
|
||||
(cend (org-element-property :contents-end up)))
|
||||
(let ((cbeg (org-element-contents-begin up))
|
||||
(cend (org-element-contents-end up)))
|
||||
(and cbeg
|
||||
(<= cbeg beg)
|
||||
(or (> cend end)
|
||||
|
@ -6841,7 +6883,7 @@ known element in cache (it may start after END)."
|
|||
(or (not (numberp org-element--cache-change-warning))
|
||||
(> org-element--cache-change-warning
|
||||
(org-element-property :level up)))
|
||||
(org-with-point-at (org-element-property :contents-begin up)
|
||||
(org-with-point-at (org-element-contents-begin up)
|
||||
(unless
|
||||
(save-match-data
|
||||
(when (looking-at-p org-element-planning-line-re)
|
||||
|
@ -6888,9 +6930,9 @@ known element in cache (it may start after END)."
|
|||
(not org-element--cache-avoid-synchronous-headline-re-parsing)
|
||||
;; The change is not inside headline. Not
|
||||
;; updating here.
|
||||
(not (<= beg (org-element-property :begin up)))
|
||||
(not (> end (org-element-property :end up)))
|
||||
(let ((current (org-with-point-at (org-element-property :begin up)
|
||||
(not (<= beg (org-element-begin up)))
|
||||
(not (> end (org-element-end up)))
|
||||
(let ((current (org-with-point-at (org-element-begin up)
|
||||
(org-element-with-disabled-cache
|
||||
(and (looking-at-p org-element-headline-re)
|
||||
(org-element-headline-parser))))))
|
||||
|
@ -6906,7 +6948,7 @@ known element in cache (it may start after END)."
|
|||
;; within blank lines at BOB (that could
|
||||
;; potentially alter first-section).
|
||||
(when (and (org-element-type-p up 'org-data)
|
||||
(>= beg (org-element-property :contents-begin up)))
|
||||
(>= beg (org-element-contents-begin up)))
|
||||
(org-element-set up (org-with-point-at 1 (org-element-org-data-parser)) org-element--cache-element-properties)
|
||||
(org-element--cache-log-message
|
||||
"Found non-robust change invalidating org-data. Re-parsing: %S"
|
||||
|
@ -6930,7 +6972,7 @@ known element in cache (it may start after END)."
|
|||
;;
|
||||
;; As a special case, do not remove BEFORE if it is a robust
|
||||
;; container for current changes.
|
||||
(if (or (< (org-element-property :end before) beg) robust-flag) after
|
||||
(if (or (< (org-element-end before) beg) robust-flag) after
|
||||
before)))))
|
||||
|
||||
(defun org-element--cache-submit-request (beg end offset)
|
||||
|
@ -6988,9 +7030,9 @@ change, as an integer."
|
|||
(setf (org-element--request-key next)
|
||||
(org-element--cache-key first))
|
||||
(setf (org-element--request-beg next)
|
||||
(org-element-property :begin first))
|
||||
(org-element-begin first))
|
||||
(setf (org-element--request-end next)
|
||||
(max (org-element-property :end first)
|
||||
(max (org-element-end first)
|
||||
(org-element--request-end next)))
|
||||
(setf (org-element--request-parent next)
|
||||
(org-element-parent first))))
|
||||
|
@ -7011,9 +7053,9 @@ change, as an integer."
|
|||
"Current request intersects with next. Updating. New parent: %S"
|
||||
(org-element--format-element first))
|
||||
(setf (org-element--request-key next) (org-element--cache-key first))
|
||||
(setf (org-element--request-beg next) (org-element-property :begin first))
|
||||
(setf (org-element--request-beg next) (org-element-begin first))
|
||||
(setf (org-element--request-end next)
|
||||
(max (org-element-property :end first)
|
||||
(max (org-element-end first)
|
||||
(org-element--request-end next)))
|
||||
(setf (org-element--request-parent next) (org-element-parent first))))))
|
||||
;; Ensure cache is correct up to END. Also make sure that NEXT,
|
||||
|
@ -7026,7 +7068,7 @@ change, as an integer."
|
|||
(when next (org-element--cache-sync (current-buffer) end beg offset 'force))
|
||||
(let ((first (org-element--cache-for-removal beg end offset)))
|
||||
(if first
|
||||
(push (let ((first-beg (org-element-property :begin first))
|
||||
(push (let ((first-beg (org-element-begin first))
|
||||
(key (org-element--cache-key first)))
|
||||
(cond
|
||||
;; When changes happen before the first known
|
||||
|
@ -7042,7 +7084,7 @@ change, as an integer."
|
|||
;; The current modification is completely inside
|
||||
;; FIRST. Clear and update cached elements in
|
||||
;; region containing FIRST.
|
||||
((let ((first-end (org-element-property :end first)))
|
||||
((let ((first-end (org-element-end first)))
|
||||
(when (> first-end end)
|
||||
(org-element--cache-log-message "Extending to non-robust element %S" (org-element--format-element first))
|
||||
(vector key first-beg first-end offset (org-element-parent first) 0))))
|
||||
|
@ -7056,16 +7098,16 @@ change, as an integer."
|
|||
;; parent of FIRST and everything inside
|
||||
;; BEG..END.
|
||||
(let* ((element (org-element--cache-find end))
|
||||
(element-end (org-element-property :end element))
|
||||
(element-end (org-element-end element))
|
||||
(up element))
|
||||
(while (and (not (eq up first))
|
||||
(setq up (org-element-parent up))
|
||||
(>= (org-element-property :begin up) first-beg))
|
||||
(>= (org-element-begin up) first-beg))
|
||||
;; Note that UP might have been already
|
||||
;; shifted if it is a robust element. After
|
||||
;; deletion, it can put it's end before yet
|
||||
;; unprocessed ELEMENT.
|
||||
(setq element-end (max (org-element-property :end up) element-end)
|
||||
(setq element-end (max (org-element-end up) element-end)
|
||||
element up))
|
||||
;; Extend region to remove elements between
|
||||
;; beginning of first and the end of outermost
|
||||
|
@ -7116,9 +7158,9 @@ Return non-nil when verification failed."
|
|||
(org-element-type-p element 'headline)
|
||||
;; Avoid too much slowdown
|
||||
(< (random 1000) (* 1000 org-element--cache-self-verify-frequency)))
|
||||
(org-with-point-at (org-element-property :begin element)
|
||||
(org-with-point-at (org-element-begin element)
|
||||
(org-element-with-disabled-cache (org-up-heading-or-point-min))
|
||||
(unless (or (= (point) (org-element-property :begin (org-element-parent element)))
|
||||
(unless (or (= (point) (org-element-begin (org-element-parent element)))
|
||||
(eq (point) (point-min)))
|
||||
(org-element--cache-warn
|
||||
"Cached element has wrong parent in %s. Resetting.
|
||||
|
@ -7127,7 +7169,7 @@ The element is: %S\n The parent is: %S\n The real parent is: %S"
|
|||
(buffer-name (current-buffer))
|
||||
(org-element--format-element element)
|
||||
(org-element--format-element (org-element-parent element))
|
||||
(org-element--format-element (org-element--current-element (org-element-property :end (org-element-parent element)))))
|
||||
(org-element--format-element (org-element--current-element (org-element-end (org-element-parent element)))))
|
||||
(org-element-cache-reset))
|
||||
(org-element--cache-verify-element (org-element-parent element))))
|
||||
;; Verify the element itself.
|
||||
|
@ -7140,13 +7182,13 @@ The element is: %S\n The parent is: %S\n The real parent is: %S"
|
|||
(let ((real-element (org-element-with-disabled-cache
|
||||
(org-element--parse-to
|
||||
(if (org-element-type-p element '(table-row item))
|
||||
(1+ (org-element-property :begin element))
|
||||
(org-element-property :begin element))))))
|
||||
(1+ (org-element-begin element))
|
||||
(org-element-begin element))))))
|
||||
(unless (and (eq (org-element-type real-element) (org-element-type element))
|
||||
(eq (org-element-property :begin real-element) (org-element-property :begin element))
|
||||
(eq (org-element-property :end real-element) (org-element-property :end element))
|
||||
(eq (org-element-property :contents-begin real-element) (org-element-property :contents-begin element))
|
||||
(eq (org-element-property :contents-end real-element) (org-element-property :contents-end element))
|
||||
(eq (org-element-begin real-element) (org-element-begin element))
|
||||
(eq (org-element-end real-element) (org-element-end element))
|
||||
(eq (org-element-contents-begin real-element) (org-element-contents-begin element))
|
||||
(eq (org-element-contents-end real-element) (org-element-contents-end element))
|
||||
(or (not (org-element-property :ID real-element))
|
||||
(string= (org-element-property :ID real-element) (org-element-property :ID element))))
|
||||
(org-element--cache-warn "(%S) Cached element is incorrect in %s. (Cache tic up to date: %S) Resetting.
|
||||
|
@ -7159,9 +7201,9 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S"
|
|||
"no" "yes")
|
||||
(org-element--format-element element)
|
||||
(org-element--format-element real-element)
|
||||
(org-element--format-element (org-element--cache-find (1- (org-element-property :begin real-element))))
|
||||
(org-element--format-element (car (org-element--cache-find (org-element-property :begin real-element) 'both)))
|
||||
(org-element--format-element (cdr (org-element--cache-find (org-element-property :begin real-element) 'both))))
|
||||
(org-element--format-element (org-element--cache-find (1- (org-element-begin real-element))))
|
||||
(org-element--format-element (car (org-element--cache-find (org-element-begin real-element) 'both)))
|
||||
(org-element--format-element (cdr (org-element--cache-find (org-element-begin real-element) 'both))))
|
||||
(org-element-cache-reset))))))
|
||||
|
||||
;;; Cache persistence
|
||||
|
@ -7454,15 +7496,15 @@ the cache."
|
|||
(re-search-forward (or (car-safe ,re) ,re) nil 'move)))
|
||||
(unless (or (< (point) (or start -1))
|
||||
(and data
|
||||
(< (point) (org-element-property :begin data))))
|
||||
(< (point) (org-element-begin data))))
|
||||
(if (cdr-safe ,re)
|
||||
;; Avoid parsing when we are 100%
|
||||
;; sure that regexp is good enough
|
||||
;; to find new START.
|
||||
(setq start (match-beginning 0))
|
||||
(setq start (max (or start -1)
|
||||
(or (org-element-property :begin data) -1)
|
||||
(or (org-element-property :begin (element-match-at-point)) -1))))
|
||||
(or (org-element-begin data) -1)
|
||||
(or (org-element-begin (element-match-at-point)) -1))))
|
||||
(when (>= start to-pos) (cache-walk-abort))
|
||||
(when (eq start -1) (setq start nil)))
|
||||
(cache-walk-abort))))
|
||||
|
@ -7473,21 +7515,21 @@ the cache."
|
|||
(setq tmpnext-start nil)
|
||||
(if (memq granularity '(headline headline+inlinetask))
|
||||
(setq tmpnext-start (or (when (org-element-type-p data '(headline org-data))
|
||||
(org-element-property :contents-begin data))
|
||||
(org-element-property :end data)))
|
||||
(org-element-contents-begin data))
|
||||
(org-element-end data)))
|
||||
(setq tmpnext-start (or (when (org-element-type-p data org-element-greater-elements)
|
||||
(org-element-property :contents-begin data))
|
||||
(org-element-property :end data))))
|
||||
(org-element-contents-begin data))
|
||||
(org-element-end data))))
|
||||
;; DATA end may be the last element inside
|
||||
;; i.e. source block. Skip up to the end
|
||||
;; of parent in such case.
|
||||
(setq tmpparent data)
|
||||
(catch :exit
|
||||
(when (eq tmpnext-start (org-element-property :contents-end tmpparent))
|
||||
(setq tmpnext-start (org-element-property :end tmpparent)))
|
||||
(when (eq tmpnext-start (org-element-contents-end tmpparent))
|
||||
(setq tmpnext-start (org-element-end tmpparent)))
|
||||
(while (setq tmpparent (org-element-parent tmpparent))
|
||||
(if (eq tmpnext-start (org-element-property :contents-end tmpparent))
|
||||
(setq tmpnext-start (org-element-property :end tmpparent))
|
||||
(if (eq tmpnext-start (org-element-contents-end tmpparent))
|
||||
(setq tmpnext-start (org-element-end tmpparent))
|
||||
(throw :exit t))))
|
||||
tmpnext-start))
|
||||
;; Check if cache does not have gaps.
|
||||
|
@ -7516,7 +7558,7 @@ the cache."
|
|||
(start (and from-pos
|
||||
(progn
|
||||
(goto-char from-pos)
|
||||
(org-element-property :begin (element-match-at-point)))))
|
||||
(org-element-begin (element-match-at-point)))))
|
||||
;; Some elements may start at the same position, so we
|
||||
;; also keep track of the last processed element and make
|
||||
;; sure that we do not try to search it again.
|
||||
|
@ -7597,7 +7639,7 @@ the cache."
|
|||
(org-element--cache-key prev))))
|
||||
;; ... or when we are before START.
|
||||
(or (not start)
|
||||
(not (> start (org-element-property :begin data)))))
|
||||
(not (> start (org-element-begin data)))))
|
||||
(progn (push node stack)
|
||||
(setq node (avl-tree--node-left node)))
|
||||
;; The whole tree left to DATA is before START and
|
||||
|
@ -7612,12 +7654,12 @@ the cache."
|
|||
;; NEXT-ELEMENT-RE.
|
||||
;; If DATA is after start, we have found a cache gap
|
||||
;; and need to fill it.
|
||||
(unless (or (and start (< (org-element-property :begin data) start))
|
||||
(unless (or (and start (< (org-element-begin data) start))
|
||||
(and prev (not (org-element--cache-key-less-p
|
||||
(org-element--cache-key prev)
|
||||
(org-element--cache-key data)))))
|
||||
;; DATA is at of after START and PREV.
|
||||
(if (or (not start) (= (org-element-property :begin data) start))
|
||||
(if (or (not start) (= (org-element-begin data) start))
|
||||
;; DATA is at START. Match it.
|
||||
;; In the process, we may alter the buffer,
|
||||
;; so also keep track of the cache state.
|
||||
|
@ -7630,11 +7672,11 @@ the cache."
|
|||
;; next regexp match after :begin of the current
|
||||
;; element.
|
||||
(when (if last-match next-re fail-re)
|
||||
(goto-char (org-element-property :begin data))
|
||||
(goto-char (org-element-begin data))
|
||||
(move-start-to-next-match
|
||||
(if last-match next-re fail-re)))
|
||||
(when (and (or (not start) (eq (org-element-property :begin data) start))
|
||||
(< (org-element-property :begin data) to-pos))
|
||||
(when (and (or (not start) (eq (org-element-begin data) start))
|
||||
(< (org-element-begin data) to-pos))
|
||||
;; Calculate where next possible element
|
||||
;; starts and update START if needed.
|
||||
(setq start (next-element-start))
|
||||
|
@ -7721,7 +7763,7 @@ the cache."
|
|||
;; element past already processed
|
||||
;; place.
|
||||
(when (and start
|
||||
(<= start (org-element-property :begin data))
|
||||
(<= start (org-element-begin data))
|
||||
(not org-element-cache-map-continue-from))
|
||||
(goto-char start)
|
||||
(setq data (element-match-at-point))
|
||||
|
@ -7753,7 +7795,7 @@ the cache."
|
|||
(setq continue-flag nil)
|
||||
(setq node (if (and (car stack)
|
||||
;; If START advanced beyond stack parent, skip the right branch.
|
||||
(or (and start (< (org-element-property :begin (avl-tree--node-data (car stack))) start))
|
||||
(or (and start (< (org-element-begin (avl-tree--node-data (car stack))) start))
|
||||
(and prev (org-element--cache-key-less-p
|
||||
(org-element--cache-key (avl-tree--node-data (car stack)))
|
||||
(org-element--cache-key prev)))))
|
||||
|
@ -7861,16 +7903,16 @@ element ending there."
|
|||
(unless (org-element-type-p element 'org-data)
|
||||
(unless (and cached-only
|
||||
(not (and element
|
||||
(or (= pom (org-element-property :begin element))
|
||||
(or (= pom (org-element-begin element))
|
||||
(and (not (org-element-type-p element org-element-greater-elements))
|
||||
(>= pom (org-element-property :begin element))
|
||||
(< pom (org-element-property :end element)))
|
||||
(and (org-element-property :contents-begin element)
|
||||
(>= pom (org-element-property :begin element))
|
||||
(< pom (org-element-property :contents-begin element)))
|
||||
(and (not (org-element-property :contents-end element))
|
||||
(>= pom (org-element-property :begin element))
|
||||
(< pom (org-element-property :end element)))))))
|
||||
(>= pom (org-element-begin element))
|
||||
(< pom (org-element-end element)))
|
||||
(and (org-element-contents-begin element)
|
||||
(>= pom (org-element-begin element))
|
||||
(< pom (org-element-contents-begin element)))
|
||||
(and (not (org-element-contents-end element))
|
||||
(>= pom (org-element-begin element))
|
||||
(< pom (org-element-end element)))))))
|
||||
(if (not (org-element-type-p element 'section))
|
||||
element
|
||||
(org-element-at-point (1+ pom) cached-only))))))
|
||||
|
@ -7910,7 +7952,7 @@ Providing it allows for quicker computation."
|
|||
(let* ((pos (point))
|
||||
(element (or element (org-element-at-point)))
|
||||
(type (org-element-type element))
|
||||
(post (org-element-property :post-affiliated element)))
|
||||
(post (org-element-post-affiliated element)))
|
||||
;; If point is inside an element containing objects or
|
||||
;; a secondary string, narrow buffer to the container and
|
||||
;; proceed with parsing. Otherwise, return ELEMENT.
|
||||
|
@ -7947,7 +7989,7 @@ Providing it allows for quicker computation."
|
|||
;; At an headline or inlinetask, objects are in title.
|
||||
((memq type '(headline inlinetask))
|
||||
(let ((case-fold-search nil))
|
||||
(goto-char (org-element-property :begin element))
|
||||
(goto-char (org-element-begin element))
|
||||
(looking-at org-complex-heading-regexp)
|
||||
(let ((end (match-end 4)))
|
||||
(if (not end) (throw 'objects-forbidden element)
|
||||
|
@ -7959,8 +8001,8 @@ Providing it allows for quicker computation."
|
|||
;; At a paragraph, a table-row or a verse block, objects are
|
||||
;; located within their contents.
|
||||
((memq type '(paragraph table-row verse-block))
|
||||
(let ((cbeg (org-element-property :contents-begin element))
|
||||
(cend (org-element-property :contents-end element)))
|
||||
(let ((cbeg (org-element-contents-begin element))
|
||||
(cend (org-element-contents-end element)))
|
||||
;; CBEG is nil for table rules.
|
||||
(if (and cbeg cend (>= pos cbeg)
|
||||
(or (< pos cend) (and (= pos cend) (eobp))))
|
||||
|
@ -7977,11 +8019,11 @@ Providing it allows for quicker computation."
|
|||
(when next (org-element-put-property next :parent parent))
|
||||
;; Process NEXT, if any, in order to know if we need to
|
||||
;; skip it, return it or move into it.
|
||||
(if (or (not next) (> (org-element-property :begin next) pos))
|
||||
(if (or (not next) (> (org-element-begin next) pos))
|
||||
(throw 'exit (or last parent))
|
||||
(let ((end (org-element-property :end next))
|
||||
(cbeg (org-element-property :contents-begin next))
|
||||
(cend (org-element-property :contents-end next)))
|
||||
(let ((end (org-element-end next))
|
||||
(cbeg (org-element-contents-begin next))
|
||||
(cend (org-element-contents-end next)))
|
||||
(cond
|
||||
;; Skip objects ending before point. Also skip
|
||||
;; objects ending at point unless it is also the
|
||||
|
@ -8017,10 +8059,10 @@ Providing it allows for quicker computation."
|
|||
|
||||
(defun org-element-nested-p (elem-A elem-B)
|
||||
"Non-nil when elements ELEM-A and ELEM-B are nested."
|
||||
(let ((beg-A (org-element-property :begin elem-A))
|
||||
(beg-B (org-element-property :begin elem-B))
|
||||
(end-A (org-element-property :end elem-A))
|
||||
(end-B (org-element-property :end elem-B)))
|
||||
(let ((beg-A (org-element-begin elem-A))
|
||||
(beg-B (org-element-begin elem-B))
|
||||
(end-A (org-element-end elem-A))
|
||||
(end-B (org-element-end elem-B)))
|
||||
(or (and (>= beg-A beg-B) (<= end-A end-B))
|
||||
(and (>= beg-B beg-A) (<= end-B end-A)))))
|
||||
|
||||
|
@ -8028,7 +8070,7 @@ Providing it allows for quicker computation."
|
|||
"Swap elements ELEM-A and ELEM-B.
|
||||
Assume ELEM-B is after ELEM-A in the buffer. Leave point at the
|
||||
end of ELEM-A."
|
||||
(goto-char (org-element-property :begin elem-A))
|
||||
(goto-char (org-element-begin elem-A))
|
||||
;; There are two special cases when an element doesn't start at bol:
|
||||
;; the first paragraph in an item or in a footnote definition.
|
||||
(let ((specialp (not (bolp))))
|
||||
|
@ -8038,8 +8080,8 @@ end of ELEM-A."
|
|||
;; paragraphs in a row because it cannot contain a blank line.
|
||||
(when (and specialp
|
||||
(or (not (org-element-type-p elem-B 'paragraph))
|
||||
(/= (org-element-property :begin elem-B)
|
||||
(org-element-property :contents-begin elem-B))))
|
||||
(/= (org-element-begin elem-B)
|
||||
(org-element-contents-begin elem-B))))
|
||||
(error "Cannot swap elements"))
|
||||
;; Preserve folding state when `org-fold-core-style' is set to
|
||||
;; `text-properties'.
|
||||
|
@ -8047,16 +8089,16 @@ end of ELEM-A."
|
|||
;; In a special situation, ELEM-A will have no indentation. We'll
|
||||
;; give it ELEM-B's (which will in, in turn, have no indentation).
|
||||
(let* ((ind-B (when specialp
|
||||
(goto-char (org-element-property :begin elem-B))
|
||||
(goto-char (org-element-begin elem-B))
|
||||
(current-indentation)))
|
||||
(beg-A (org-element-property :begin elem-A))
|
||||
(beg-A (org-element-begin elem-A))
|
||||
(end-A (save-excursion
|
||||
(goto-char (org-element-property :end elem-A))
|
||||
(goto-char (org-element-end elem-A))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-end-position)))
|
||||
(beg-B (org-element-property :begin elem-B))
|
||||
(beg-B (org-element-begin elem-B))
|
||||
(end-B (save-excursion
|
||||
(goto-char (org-element-property :end elem-B))
|
||||
(goto-char (org-element-end elem-B))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-end-position)))
|
||||
;; Store inner folds responsible for visibility status.
|
||||
|
@ -8083,7 +8125,7 @@ end of ELEM-A."
|
|||
(insert body-B)
|
||||
;; Restore ex ELEM-A folds.
|
||||
(org-fold-core-regions (cdr folds) :relative beg-A)
|
||||
(goto-char (org-element-property :end elem-B))))))
|
||||
(goto-char (org-element-end elem-B))))))
|
||||
|
||||
(provide 'org-element)
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@
|
|||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element--current-element "org-element" (limit &optional granularity mode structure))
|
||||
(declare-function org-element--cache-active-p "org-element" ())
|
||||
(declare-function org-toggle-custom-properties-visibility "org" ())
|
||||
|
@ -528,12 +530,12 @@ Return a non-nil value when toggling is successful."
|
|||
comment-block dynamic-block example-block export-block
|
||||
quote-block special-block src-block verse-block))
|
||||
(_ (error "Unknown category: %S" category))))
|
||||
(let* ((post (org-element-property :post-affiliated element))
|
||||
(let* ((post (org-element-post-affiliated element))
|
||||
(start (save-excursion
|
||||
(goto-char post)
|
||||
(line-end-position)))
|
||||
(end (save-excursion
|
||||
(goto-char (org-element-property :end element))
|
||||
(goto-char (org-element-end element))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-end-position))))
|
||||
;; Do nothing when not before or at the block opening line or
|
||||
|
@ -614,7 +616,7 @@ Return a non-nil value when toggling is successful."
|
|||
;; Make sure to skip drawer entirely or we might flag it
|
||||
;; another time when matching its ending line with
|
||||
;; `org-drawer-regexp'.
|
||||
(goto-char (org-element-property :end drawer))))))))
|
||||
(goto-char (org-element-end drawer))))))))
|
||||
|
||||
(defun org-fold-hide-archived-subtrees (beg end)
|
||||
"Re-hide all archived subtrees after a visibility state change."
|
||||
|
|
120
lisp/org-lint.el
120
lisp/org-lint.el
|
@ -387,7 +387,7 @@ called with one argument, the key used for comparison."
|
|||
(and (org-string-equal-ignore-case
|
||||
"CUSTOM_ID" (org-element-property :key property))
|
||||
(org-element-property :value property)))
|
||||
(lambda (property _) (org-element-property :begin property))
|
||||
(lambda (property _) (org-element-begin property))
|
||||
(lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key))))
|
||||
|
||||
(defun org-lint-duplicate-name (ast)
|
||||
|
@ -396,7 +396,7 @@ called with one argument, the key used for comparison."
|
|||
org-element-all-elements
|
||||
(lambda (datum) (org-element-property :name datum))
|
||||
(lambda (datum name)
|
||||
(goto-char (org-element-property :begin datum))
|
||||
(goto-char (org-element-begin datum))
|
||||
(re-search-forward
|
||||
(format "^[ \t]*#\\+[A-Za-z]+:[ \t]*%s[ \t]*$" (regexp-quote name)))
|
||||
(match-beginning 0))
|
||||
|
@ -407,7 +407,7 @@ called with one argument, the key used for comparison."
|
|||
ast
|
||||
'target
|
||||
(lambda (target) (split-string (org-element-property :value target)))
|
||||
(lambda (target _) (org-element-property :begin target))
|
||||
(lambda (target _) (org-element-begin target))
|
||||
(lambda (key)
|
||||
(format "Duplicate target <<%s>>" (mapconcat #'identity key " ")))))
|
||||
|
||||
|
@ -416,7 +416,7 @@ called with one argument, the key used for comparison."
|
|||
ast
|
||||
'footnote-definition
|
||||
(lambda (definition) (org-element-property :label definition))
|
||||
(lambda (definition _) (org-element-property :post-affiliated definition))
|
||||
(lambda (definition _) (org-element-post-affiliated definition))
|
||||
(lambda (key) (format "Duplicate footnote definition \"%s\"" key))))
|
||||
|
||||
(defun org-lint-orphaned-affiliated-keywords (ast)
|
||||
|
@ -431,7 +431,7 @@ called with one argument, the key used for comparison."
|
|||
(and (or (let ((case-fold-search t))
|
||||
(string-match-p "\\`ATTR_[-_A-Za-z0-9]+\\'" key))
|
||||
(member key keywords))
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
(format "Orphaned affiliated keyword: \"%s\"" key))))))))
|
||||
|
||||
(defun org-lint-obsolete-affiliated-keywords (_)
|
||||
|
@ -443,7 +443,7 @@ called with one argument, the key used for comparison."
|
|||
(while (re-search-forward regexp nil t)
|
||||
(let ((key (upcase (match-string-no-properties 1))))
|
||||
(when (< (point)
|
||||
(org-element-property :post-affiliated (org-element-at-point)))
|
||||
(org-element-post-affiliated (org-element-at-point)))
|
||||
(push
|
||||
(list (line-beginning-position)
|
||||
(format
|
||||
|
@ -464,7 +464,7 @@ called with one argument, the key used for comparison."
|
|||
(let ((type (org-element-property :type b)))
|
||||
(when (member-ignore-case type deprecated)
|
||||
(list
|
||||
(org-element-property :post-affiliated b)
|
||||
(org-element-post-affiliated b)
|
||||
(format
|
||||
"Deprecated syntax for export block. Use \"BEGIN_EXPORT %s\" \
|
||||
instead"
|
||||
|
@ -486,14 +486,14 @@ instead"
|
|||
(let ((value (org-element-property :value datum)))
|
||||
(and (string= key "PROPERTY")
|
||||
(string-match deprecated-re value)
|
||||
(list (org-element-property :begin datum)
|
||||
(list (org-element-begin datum)
|
||||
(format "Deprecated syntax for \"%s\". \
|
||||
Use header-args instead"
|
||||
(match-string-no-properties 1 value))))))
|
||||
(`node-property
|
||||
(and (member-ignore-case key deprecated-babel-properties)
|
||||
(list
|
||||
(org-element-property :begin datum)
|
||||
(org-element-begin datum)
|
||||
(format "Deprecated syntax for \"%s\". \
|
||||
Use :header-args: instead"
|
||||
key))))))))))
|
||||
|
@ -502,7 +502,7 @@ Use :header-args: instead"
|
|||
(org-element-map ast 'src-block
|
||||
(lambda (b)
|
||||
(unless (org-element-property :language b)
|
||||
(list (org-element-property :post-affiliated b)
|
||||
(list (org-element-post-affiliated b)
|
||||
"Missing language in source block")))))
|
||||
|
||||
(defun org-lint-suspicious-language-in-src-block (ast)
|
||||
|
@ -517,7 +517,7 @@ Use :header-args: instead"
|
|||
(org-element-map ast 'export-block
|
||||
(lambda (b)
|
||||
(unless (org-element-property :type b)
|
||||
(list (org-element-property :post-affiliated b)
|
||||
(list (org-element-post-affiliated b)
|
||||
"Missing backend in export block")))))
|
||||
|
||||
(defun org-lint-invalid-babel-call-block (ast)
|
||||
|
@ -525,12 +525,12 @@ Use :header-args: instead"
|
|||
(lambda (b)
|
||||
(cond
|
||||
((not (org-element-property :call b))
|
||||
(list (org-element-property :post-affiliated b)
|
||||
(list (org-element-post-affiliated b)
|
||||
"Invalid syntax in babel call block"))
|
||||
((let ((h (org-element-property :end-header b)))
|
||||
(and h (string-match-p "\\`\\[.*\\]\\'" h)))
|
||||
(list
|
||||
(org-element-property :post-affiliated b)
|
||||
(org-element-post-affiliated b)
|
||||
"Babel call's end header must not be wrapped within brackets"))))))
|
||||
|
||||
(defun org-lint-deprecated-category-setup (ast)
|
||||
|
@ -540,7 +540,7 @@ Use :header-args: instead"
|
|||
(cond
|
||||
((not (string= (org-element-property :key k) "CATEGORY")) nil)
|
||||
(category-flag
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
"Spurious CATEGORY keyword. Set :CATEGORY: property instead"))
|
||||
(t (setf category-flag t) nil))))))
|
||||
|
||||
|
@ -551,7 +551,7 @@ Use :header-args: instead"
|
|||
(let ((ref (org-element-property :path link)))
|
||||
(and (equal (org-element-property :type link) "coderef")
|
||||
(not (ignore-errors (org-export-resolve-coderef ref info)))
|
||||
(list (org-element-property :begin link)
|
||||
(list (org-element-begin link)
|
||||
(format "Unknown coderef \"%s\"" ref))))))))
|
||||
|
||||
(defun org-lint-invalid-custom-id-link (ast)
|
||||
|
@ -560,7 +560,7 @@ Use :header-args: instead"
|
|||
(lambda (link)
|
||||
(and (equal (org-element-property :type link) "custom-id")
|
||||
(not (ignore-errors (org-export-resolve-id-link link info)))
|
||||
(list (org-element-property :begin link)
|
||||
(list (org-element-begin link)
|
||||
(format "Unknown custom ID \"%s\""
|
||||
(org-element-property :path link))))))))
|
||||
|
||||
|
@ -570,7 +570,7 @@ Use :header-args: instead"
|
|||
(lambda (link)
|
||||
(and (equal (org-element-property :type link) "fuzzy")
|
||||
(not (ignore-errors (org-export-resolve-fuzzy-link link info)))
|
||||
(list (org-element-property :begin link)
|
||||
(list (org-element-begin link)
|
||||
(format "Unknown fuzzy location \"%s\""
|
||||
(let ((path (org-element-property :path link)))
|
||||
(if (string-prefix-p "*" path)
|
||||
|
@ -583,7 +583,7 @@ Use :header-args: instead"
|
|||
(let ((id (org-element-property :path link)))
|
||||
(and (equal (org-element-property :type link) "id")
|
||||
(not (org-id-find id))
|
||||
(list (org-element-property :begin link)
|
||||
(list (org-element-begin link)
|
||||
(format "Unknown ID \"%s\"" id)))))))
|
||||
|
||||
(defun org-lint-special-property-in-properties-drawer (ast)
|
||||
|
@ -591,7 +591,7 @@ Use :header-args: instead"
|
|||
(lambda (p)
|
||||
(let ((key (org-element-property :key p)))
|
||||
(and (member-ignore-case key org-special-properties)
|
||||
(list (org-element-property :begin p)
|
||||
(list (org-element-begin p)
|
||||
(format
|
||||
"Special property \"%s\" found in a properties drawer"
|
||||
key)))))))
|
||||
|
@ -605,7 +605,7 @@ Use :header-args: instead"
|
|||
(mapcar #'org-element-type
|
||||
(assq d (reverse (org-element-contents
|
||||
(org-element-parent d)))))))
|
||||
(list (org-element-property :post-affiliated d)
|
||||
(list (org-element-post-affiliated d)
|
||||
(if (or (and headline? (member before '(nil (planning))))
|
||||
(and (null headline?) (member before '(nil (comment)))))
|
||||
"Incorrect contents for PROPERTIES drawer"
|
||||
|
@ -618,7 +618,7 @@ Use :header-args: instead"
|
|||
(let ((value (org-element-property :value p)))
|
||||
(and (org-string-nw-p value)
|
||||
(not (org-duration-p value))
|
||||
(list (org-element-property :begin p)
|
||||
(list (org-element-begin p)
|
||||
(format "Invalid effort duration format: %S" value))))))))
|
||||
|
||||
(defun org-lint-link-to-local-file (ast)
|
||||
|
@ -630,11 +630,11 @@ Use :header-args: instead"
|
|||
(let* ((path (org-element-property :path l))
|
||||
(file (if (string= type "file")
|
||||
path
|
||||
(org-with-point-at (org-element-property :begin l)
|
||||
(org-with-point-at (org-element-begin l)
|
||||
(org-attach-expand path)))))
|
||||
(and (not (file-remote-p file))
|
||||
(not (file-exists-p file))
|
||||
(list (org-element-property :begin l)
|
||||
(list (org-element-begin l)
|
||||
(format (if (org-element-lineage l 'link)
|
||||
"Link to non-existent image file %S \
|
||||
in description"
|
||||
|
@ -652,7 +652,7 @@ in description"
|
|||
(and (not (org-url-p file))
|
||||
(not (file-remote-p file))
|
||||
(not (file-exists-p file))
|
||||
(list (org-element-property :begin k)
|
||||
(list (org-element-begin k)
|
||||
(format "Non-existent setup file %S" file))))))))
|
||||
|
||||
(defun org-lint-wrong-include-link-parameter (ast)
|
||||
|
@ -665,7 +665,7 @@ in description"
|
|||
(save-match-data
|
||||
(org-strip-quotes (match-string 1 value))))))
|
||||
(if (not path)
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
"Missing location argument in INCLUDE keyword")
|
||||
(let* ((file (org-string-nw-p
|
||||
(if (string-match "::\\(.*\\)\\'" path)
|
||||
|
@ -677,7 +677,7 @@ in description"
|
|||
(if (and file
|
||||
(not (file-remote-p file))
|
||||
(not (file-exists-p file)))
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
"Non-existent file argument in INCLUDE keyword")
|
||||
(let* ((visiting (if file (find-buffer-visiting file)
|
||||
(current-buffer)))
|
||||
|
@ -688,7 +688,7 @@ in description"
|
|||
(when (and search
|
||||
(not (ignore-errors
|
||||
(org-link-search search nil t))))
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
(format
|
||||
"Invalid search part \"%s\" in INCLUDE keyword"
|
||||
search))))
|
||||
|
@ -707,7 +707,7 @@ in description"
|
|||
(value (org-element-property :value k)))
|
||||
(when (string-match regexp value)
|
||||
(let ((markup (match-string-no-properties 1 value)))
|
||||
(list (org-element-property :post-affiliated k)
|
||||
(list (org-element-post-affiliated k)
|
||||
(format "Obsolete markup \"%s\" in INCLUDE keyword. \
|
||||
Use \"export %s\" instead"
|
||||
markup
|
||||
|
@ -734,11 +734,11 @@ Use \"export %s\" instead"
|
|||
(setf start (match-end 0))
|
||||
(let ((item (match-string 1 value)))
|
||||
(unless (member item allowed)
|
||||
(push (list (org-element-property :post-affiliated k)
|
||||
(push (list (org-element-post-affiliated k)
|
||||
(format "Unknown OPTIONS item \"%s\"" item))
|
||||
reports))
|
||||
(unless (match-string 2 value)
|
||||
(push (list (org-element-property :post-affiliated k)
|
||||
(push (list (org-element-post-affiliated k)
|
||||
(format "Missing value for option item %S" item))
|
||||
reports))))))))
|
||||
reports))
|
||||
|
@ -779,7 +779,7 @@ Use \"export %s\" instead"
|
|||
(check-arity
|
||||
(lambda (arity macro)
|
||||
(let* ((name (org-element-property :key macro))
|
||||
(pos (org-element-property :begin macro))
|
||||
(pos (org-element-begin macro))
|
||||
(args (org-element-property :args macro))
|
||||
(l (length args)))
|
||||
(cond
|
||||
|
@ -814,17 +814,17 @@ Use \"export %s\" instead"
|
|||
(org-trim (substring value (match-end 0))))))
|
||||
(cond
|
||||
((not name)
|
||||
(push (list (org-element-property :post-affiliated k)
|
||||
(push (list (org-element-post-affiliated k)
|
||||
"Missing name in MACRO keyword")
|
||||
reports))
|
||||
((not (org-string-nw-p template))
|
||||
(push (list (org-element-property :post-affiliated k)
|
||||
(push (list (org-element-post-affiliated k)
|
||||
"Missing template in macro \"%s\"" name)
|
||||
reports))
|
||||
(t
|
||||
(unless (let ((args (funcall extract-placeholders template)))
|
||||
(equal (number-sequence 1 (or (org-last args) 0)) args))
|
||||
(push (list (org-element-property :post-affiliated k)
|
||||
(push (list (org-element-post-affiliated k)
|
||||
(format "Unused placeholders in macro \"%s\""
|
||||
name))
|
||||
reports))))))))
|
||||
|
@ -840,7 +840,7 @@ Use \"export %s\" instead"
|
|||
(template (cdr (assoc-string name templates t))))
|
||||
(pcase template
|
||||
(`nil
|
||||
(push (list (org-element-property :begin macro)
|
||||
(push (list (org-element-begin macro)
|
||||
(format "Undefined macro %S" name))
|
||||
reports))
|
||||
((guard (string= name "keyword"))
|
||||
|
@ -875,7 +875,7 @@ Use \"export %s\" instead"
|
|||
(let ((label (org-element-property :label f)))
|
||||
(and (eq 'standard (org-element-property :type f))
|
||||
(not (member label definitions))
|
||||
(list (org-element-property :begin f)
|
||||
(list (org-element-begin f)
|
||||
(format "Missing definition for footnote [%s]"
|
||||
label))))))))
|
||||
|
||||
|
@ -887,7 +887,7 @@ Use \"export %s\" instead"
|
|||
(let ((label (org-element-property :label f)))
|
||||
(and label
|
||||
(not (member label references))
|
||||
(list (org-element-property :post-affiliated f)
|
||||
(list (org-element-post-affiliated f)
|
||||
(format "No reference for footnote definition [%s]"
|
||||
label))))))))
|
||||
|
||||
|
@ -898,7 +898,7 @@ Use \"export %s\" instead"
|
|||
(and name
|
||||
(string-match-p ":" name)
|
||||
(list (progn
|
||||
(goto-char (org-element-property :begin e))
|
||||
(goto-char (org-element-begin e))
|
||||
(re-search-forward
|
||||
(format "^[ \t]*#\\+\\w+: +%s *$" (regexp-quote name)))
|
||||
(match-beginning 0))
|
||||
|
@ -954,16 +954,16 @@ Use \"export %s\" instead"
|
|||
(pcase (org-element-type element)
|
||||
(`drawer
|
||||
;; Find drawer opening lines within non-empty drawers.
|
||||
(let ((end (org-element-property :contents-end element)))
|
||||
(let ((end (org-element-contents-end element)))
|
||||
(when end
|
||||
(while (re-search-forward org-drawer-regexp end t)
|
||||
(let ((n (org-trim (match-string-no-properties 0))))
|
||||
(push (list (line-beginning-position)
|
||||
(format "Possible misleading drawer entry %S" n))
|
||||
reports))))
|
||||
(goto-char (org-element-property :end element))))
|
||||
(goto-char (org-element-end element))))
|
||||
(`property-drawer
|
||||
(goto-char (org-element-property :end element)))
|
||||
(goto-char (org-element-end element)))
|
||||
((or `comment-block `example-block `export-block `src-block
|
||||
`verse-block)
|
||||
nil)
|
||||
|
@ -1041,7 +1041,7 @@ Use \"export %s\" instead"
|
|||
(not (and (org-element-type-p e 'headline)
|
||||
(org-element-property :commentedp e))))
|
||||
nil t '(footnote-definition property-drawer))
|
||||
(list (org-element-property :begin h)
|
||||
(list (org-element-begin h)
|
||||
"Extraneous elements in footnote section are not exported")))))
|
||||
|
||||
(defun org-lint-quote-section (ast)
|
||||
|
@ -1050,7 +1050,7 @@ Use \"export %s\" instead"
|
|||
(let ((title (org-element-property :raw-value h)))
|
||||
(and (or (string-prefix-p "QUOTE " title)
|
||||
(string-prefix-p (concat org-comment-string " QUOTE ") title))
|
||||
(list (org-element-property :begin h)
|
||||
(list (org-element-begin h)
|
||||
"Deprecated QUOTE section"))))))
|
||||
|
||||
(defun org-lint-file-application (ast)
|
||||
|
@ -1058,7 +1058,7 @@ Use \"export %s\" instead"
|
|||
(lambda (l)
|
||||
(let ((app (org-element-property :application l)))
|
||||
(and app
|
||||
(list (org-element-property :begin l)
|
||||
(list (org-element-begin l)
|
||||
(format "Deprecated \"file+%s\" link type" app)))))))
|
||||
|
||||
(defun org-lint-percent-encoding-link-escape (ast)
|
||||
|
@ -1075,7 +1075,7 @@ Use \"export %s\" instead"
|
|||
(throw :obsolete nil)))
|
||||
(string-match-p "%" uri))))
|
||||
(when obsolete-flag
|
||||
(list (org-element-property :begin l)
|
||||
(list (org-element-begin l)
|
||||
"Link escaped with obsolete percent-encoding syntax")))))))
|
||||
|
||||
(defun org-lint-wrong-header-argument (ast)
|
||||
|
@ -1097,8 +1097,8 @@ Use \"export %s\" instead"
|
|||
(mapcar #'car org-babel-load-languages))))))
|
||||
(dolist (header headers)
|
||||
(let ((h (symbol-name (car header)))
|
||||
(p (or (org-element-property :post-affiliated datum)
|
||||
(org-element-property :begin datum))))
|
||||
(p (or (org-element-post-affiliated datum)
|
||||
(org-element-begin datum))))
|
||||
(cond
|
||||
((not (string-prefix-p ":" h))
|
||||
(push
|
||||
|
@ -1184,8 +1184,8 @@ Use \"export %s\" instead"
|
|||
(when (not (cdr header))
|
||||
(push
|
||||
(list
|
||||
(or (org-element-property :post-affiliated datum)
|
||||
(org-element-property :begin datum))
|
||||
(or (org-element-post-affiliated datum)
|
||||
(org-element-begin datum))
|
||||
(format "Empty value in header argument \"%s\"" (symbol-name (car header))))
|
||||
reports))))))
|
||||
reports))
|
||||
|
@ -1242,8 +1242,8 @@ Use \"export %s\" instead"
|
|||
((assq group groups-alist)
|
||||
(push
|
||||
(list
|
||||
(or (org-element-property :post-affiliated datum)
|
||||
(org-element-property :begin datum))
|
||||
(or (org-element-post-affiliated datum)
|
||||
(org-element-begin datum))
|
||||
(format
|
||||
"Forbidden combination in header \"%s\": %s, %s"
|
||||
(car header)
|
||||
|
@ -1256,8 +1256,8 @@ Use \"export %s\" instead"
|
|||
(unless valid-value
|
||||
(push
|
||||
(list
|
||||
(or (org-element-property :post-affiliated datum)
|
||||
(org-element-property :begin datum))
|
||||
(or (org-element-post-affiliated datum)
|
||||
(org-element-begin datum))
|
||||
(format "Unknown value \"%s\" for header \"%s\""
|
||||
v
|
||||
(car header)))
|
||||
|
@ -1268,7 +1268,7 @@ Use \"export %s\" instead"
|
|||
(org-element-map ast '(headline inlinetask)
|
||||
(lambda (h)
|
||||
(when (member "" (org-element-property :tags h))
|
||||
(list (org-element-property :begin h)
|
||||
(list (org-element-begin h)
|
||||
"Tags contain a spurious colon")))))
|
||||
|
||||
(defun org-lint-non-existent-bibliography (ast)
|
||||
|
@ -1278,7 +1278,7 @@ Use \"export %s\" instead"
|
|||
(let ((file (org-strip-quotes (org-element-property :value k))))
|
||||
(and (not (file-remote-p file))
|
||||
(not (file-exists-p file))
|
||||
(list (org-element-property :begin k)
|
||||
(list (org-element-begin k)
|
||||
(format "Non-existent bibliography %S" file))))))))
|
||||
|
||||
(defun org-lint-missing-print-bibliography (ast)
|
||||
|
@ -1295,7 +1295,7 @@ Use \"export %s\" instead"
|
|||
(lambda (k)
|
||||
(when (equal "CITE_EXPORT" (org-element-property :key k))
|
||||
(let ((value (org-element-property :value k))
|
||||
(source (org-element-property :begin k)))
|
||||
(source (org-element-begin k)))
|
||||
(if (equal value "")
|
||||
(list source "Missing export processor name")
|
||||
(condition-case _
|
||||
|
@ -1317,7 +1317,7 @@ Use \"export %s\" instead"
|
|||
;; XXX: The code below signals the error at the beginning
|
||||
;; of the paragraph containing the faulty object. It is
|
||||
;; not very accurate but may be enough for now.
|
||||
(list (org-element-property :contents-begin
|
||||
(list (org-element-contents-begin
|
||||
(org-element-parent text))
|
||||
"Possibly incomplete citation markup")))))
|
||||
|
||||
|
@ -1335,13 +1335,13 @@ Use \"export %s\" instead"
|
|||
(string-to-number (match-string 0 bullet)))))
|
||||
(true-number
|
||||
(org-list-get-item-number
|
||||
(org-element-property :begin item)
|
||||
(org-element-begin item)
|
||||
(org-element-property :structure item)
|
||||
(org-list-prevs-alist (org-element-property :structure item))
|
||||
(org-list-parents-alist (org-element-property :structure item)))))
|
||||
(unless (equal bullet-number (car (last true-number)))
|
||||
(list
|
||||
(org-element-property :begin item)
|
||||
(org-element-begin item)
|
||||
(format "Bullet counter \"%s\" is not the same with item position %d. Consider adding manual [@%d] counter."
|
||||
bullet (car (last true-number)) bullet-number))))))))
|
||||
|
||||
|
@ -1351,7 +1351,7 @@ AST is the buffer parse tree."
|
|||
(org-element-map ast 'latex-fragment
|
||||
(lambda (fragment)
|
||||
(and (string-match-p "^[$][^$]" (org-element-property :value fragment))
|
||||
(list (org-element-property :begin fragment)
|
||||
(list (org-element-begin fragment)
|
||||
"Potentially confusing LaTeX fragment format. Prefer using more reliable \\(...\\)")))))
|
||||
(defun org-lint-LaTeX-$-ambiguous (_)
|
||||
"Report LaTeX fragment-like text.
|
||||
|
|
|
@ -117,6 +117,13 @@
|
|||
(declare-function org-element-normalize-string "org-element" (s))
|
||||
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-post-blank "org-element" (node))
|
||||
(declare-function org-element-parent "org-element-ast" (node))
|
||||
(declare-function org-element-put-property "org-element-ast" (node property value))
|
||||
(declare-function org-element-set "org-element-ast" (old new))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
|
@ -2383,10 +2390,10 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is
|
|||
(when (org-element-type-p e '(item plain-list))
|
||||
;; Look for ATTR_ORG attribute in the current plain list.
|
||||
(let ((plain-list (org-element-lineage e 'plain-list t)))
|
||||
(org-with-point-at (org-element-property :post-affiliated plain-list)
|
||||
(org-with-point-at (org-element-post-affiliated plain-list)
|
||||
(let ((case-fold-search t)
|
||||
(regexp "^[ \t]*#\\+attr_org:.* :radio \\(\\S-+\\)")
|
||||
(begin (org-element-property :begin plain-list)))
|
||||
(begin (org-element-begin plain-list)))
|
||||
(and (re-search-backward regexp begin t)
|
||||
(not (string-equal "nil" (match-string 1)))))))))))
|
||||
|
||||
|
@ -2583,7 +2590,7 @@ With optional prefix argument ALL, do this for the whole buffer."
|
|||
'(drawer center-block dynamic-block inlinetask item
|
||||
quote-block special-block verse-block)))
|
||||
(beg (if container
|
||||
(org-element-property :contents-begin container)
|
||||
(org-element-contents-begin container)
|
||||
(save-excursion
|
||||
(org-with-limited-levels
|
||||
(outline-previous-heading))
|
||||
|
@ -2593,7 +2600,7 @@ With optional prefix argument ALL, do this for the whole buffer."
|
|||
(goto-char beg)
|
||||
(let ((end
|
||||
(if container
|
||||
(org-element-property :contents-end container)
|
||||
(org-element-contents-end container)
|
||||
(save-excursion
|
||||
(org-with-limited-levels (outline-next-heading))
|
||||
(point))))
|
||||
|
@ -2608,7 +2615,7 @@ With optional prefix argument ALL, do this for the whole buffer."
|
|||
(while (setq element (org-element-lineage
|
||||
element 'plain-list))
|
||||
(goto-char
|
||||
(min (org-element-property :end element)
|
||||
(min (org-element-end element)
|
||||
end))))))
|
||||
;; Cache count for cookies applying to the same
|
||||
;; area. Then return it.
|
||||
|
@ -3050,25 +3057,23 @@ With a prefix argument ARG, change the region in a single item."
|
|||
(setq element (org-element-at-point))
|
||||
(when (org-element-type-p element 'footnote-definition)
|
||||
(push (buffer-substring-no-properties
|
||||
(org-element-property :begin element)
|
||||
(org-element-property :end element))
|
||||
(org-element-begin element)
|
||||
(org-element-end element))
|
||||
definitions)
|
||||
;; Ensure at least 2 blank lines after the last
|
||||
;; footnote definition, thus not slurping the
|
||||
;; following element.
|
||||
(unless (<= 2 (org-element-property
|
||||
:post-blank
|
||||
(unless (<= 2 (org-element-post-blank
|
||||
(org-element-at-point)))
|
||||
(setf (car definitions)
|
||||
(concat (car definitions)
|
||||
(make-string
|
||||
(- 2 (org-element-property
|
||||
:post-blank
|
||||
(- 2 (org-element-post-blank
|
||||
(org-element-at-point)))
|
||||
?\n))))
|
||||
(delete-region
|
||||
(org-element-property :begin element)
|
||||
(org-element-property :end element))))
|
||||
(org-element-begin element)
|
||||
(org-element-end element))))
|
||||
definitions))))
|
||||
(shift-text
|
||||
(lambda (ind end)
|
||||
|
@ -3215,8 +3220,7 @@ With a prefix argument ARG, change the region in a single item."
|
|||
(when footnote-definitions
|
||||
;; If the new list is followed by same-level items,
|
||||
;; move past them as well.
|
||||
(goto-char (org-element-property
|
||||
:end
|
||||
(goto-char (org-element-end
|
||||
(org-element-lineage
|
||||
(org-element-at-point (1- end))
|
||||
'plain-list t)))
|
||||
|
|
|
@ -63,6 +63,8 @@
|
|||
(declare-function org-element-put-property "org-element-ast" (node property value))
|
||||
(declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-restriction "org-element" (element))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
|
@ -255,7 +257,7 @@ a definition in TEMPLATES."
|
|||
(org-element-put-property macro :parent nil)
|
||||
(let* ((key (org-element-property :key macro))
|
||||
(value (org-macro-expand macro templates))
|
||||
(begin (org-element-property :begin macro))
|
||||
(begin (org-element-begin macro))
|
||||
(signature (list begin
|
||||
macro
|
||||
(org-element-property :args macro))))
|
||||
|
@ -269,7 +271,7 @@ a definition in TEMPLATES."
|
|||
(delete-region
|
||||
begin
|
||||
;; Preserve white spaces after the macro.
|
||||
(progn (goto-char (org-element-property :end macro))
|
||||
(progn (goto-char (org-element-end macro))
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
;; Leave point before replacement in case of
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
(declare-function org-buffer-property-keys "org" (&optional specials defaults columns))
|
||||
(declare-function org-element-at-point "org-element" (&optional pom cached-only))
|
||||
(declare-function org-element-property "org-element-ast" property node)
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-end-of-meta-data "org" (&optional full))
|
||||
(declare-function org-entry-properties "org" (&optional pom which))
|
||||
|
@ -399,7 +400,7 @@ This needs more work, to handle headings with lots of spaces in them."
|
|||
(let ((drawer (org-element-at-point)))
|
||||
(when (org-element-type-p drawer '(drawer property-drawer))
|
||||
(push (org-element-property :drawer-name drawer) names)
|
||||
(goto-char (org-element-property :end drawer))))))
|
||||
(goto-char (org-element-end drawer))))))
|
||||
(pcomplete-uniquify-list names))))
|
||||
(substring pcomplete-stub 1))) ;remove initial colon
|
||||
|
||||
|
|
|
@ -52,6 +52,13 @@
|
|||
(blob &optional types with-self))
|
||||
(declare-function org-element--parse-paired-brackets "org-element" (char))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-begin "org-element" (node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-contents-begin "org-element" (node))
|
||||
(declare-function org-element-contents-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-post-blank "org-element" (node))
|
||||
(declare-function org-element-parent "org-element-ast" (node))
|
||||
(declare-function org-element-type "org-element-ast" (node &optional anonymous))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-footnote-goto-definition "org-footnote"
|
||||
|
@ -378,36 +385,36 @@ where BEG and END are buffer positions and CONTENTS is a string."
|
|||
(cond
|
||||
((eq type 'footnote-definition)
|
||||
(let* ((beg (progn
|
||||
(goto-char (org-element-property :post-affiliated datum))
|
||||
(goto-char (org-element-post-affiliated datum))
|
||||
(search-forward "]")))
|
||||
(end (or (org-element-property :contents-end datum) beg)))
|
||||
(end (or (org-element-contents-end datum) beg)))
|
||||
(list beg end (buffer-substring-no-properties beg end))))
|
||||
((eq type 'inline-src-block)
|
||||
(let ((beg (progn (goto-char (org-element-property :begin datum))
|
||||
(let ((beg (progn (goto-char (org-element-begin datum))
|
||||
(search-forward "{" (line-end-position) t)))
|
||||
(end (progn (goto-char (org-element-property :end datum))
|
||||
(end (progn (goto-char (org-element-end datum))
|
||||
(search-backward "}" (line-beginning-position) t))))
|
||||
(list beg end (buffer-substring-no-properties beg end))))
|
||||
((eq type 'latex-fragment)
|
||||
(let ((beg (org-element-property :begin datum))
|
||||
(end (org-with-point-at (org-element-property :end datum)
|
||||
(let ((beg (org-element-begin datum))
|
||||
(end (org-with-point-at (org-element-end datum)
|
||||
(skip-chars-backward " \t")
|
||||
(point))))
|
||||
(list beg end (buffer-substring-no-properties beg end))))
|
||||
((org-element-property :contents-begin datum)
|
||||
(let ((beg (org-element-property :contents-begin datum))
|
||||
(end (org-element-property :contents-end datum)))
|
||||
((org-element-contents-begin datum)
|
||||
(let ((beg (org-element-contents-begin datum))
|
||||
(end (org-element-contents-end datum)))
|
||||
(list beg end (buffer-substring-no-properties beg end))))
|
||||
((memq type '(example-block export-block src-block comment-block))
|
||||
(list (progn (goto-char (org-element-property :post-affiliated datum))
|
||||
(list (progn (goto-char (org-element-post-affiliated datum))
|
||||
(line-beginning-position 2))
|
||||
(progn (goto-char (org-element-property :end datum))
|
||||
(progn (goto-char (org-element-end datum))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-beginning-position 1))
|
||||
(org-element-property :value datum)))
|
||||
((memq type '(fixed-width latex-environment table))
|
||||
(let ((beg (org-element-property :post-affiliated datum))
|
||||
(end (progn (goto-char (org-element-property :end datum))
|
||||
(let ((beg (org-element-post-affiliated datum))
|
||||
(end (progn (goto-char (org-element-end datum))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(line-beginning-position 2))))
|
||||
(list beg
|
||||
|
@ -448,10 +455,10 @@ END."
|
|||
"Non-nil when point is on DATUM.
|
||||
DATUM is an element or an object. Consider blank lines or white
|
||||
spaces after it as being outside."
|
||||
(and (>= (point) (org-element-property :begin datum))
|
||||
(and (>= (point) (org-element-begin datum))
|
||||
(<= (point)
|
||||
(org-with-wide-buffer
|
||||
(goto-char (org-element-property :end datum))
|
||||
(goto-char (org-element-end datum))
|
||||
(skip-chars-backward " \r\t\n")
|
||||
(if (eq (org-element-class datum) 'element)
|
||||
(line-end-position)
|
||||
|
@ -541,7 +548,7 @@ Leave point in edit buffer."
|
|||
(source-file-name (buffer-file-name (buffer-base-buffer)))
|
||||
(source-tab-width (if indent-tabs-mode tab-width 0))
|
||||
(type (org-element-type datum))
|
||||
(block-ind (org-with-point-at (org-element-property :begin datum)
|
||||
(block-ind (org-with-point-at (org-element-begin datum)
|
||||
(cond
|
||||
((save-excursion (skip-chars-backward " \t") (bolp))
|
||||
(org-current-text-indentation))
|
||||
|
@ -1052,12 +1059,12 @@ A coderef format regexp can only match at the end of a line."
|
|||
(contents
|
||||
(org-with-wide-buffer
|
||||
(buffer-substring-no-properties
|
||||
(or (org-element-property :post-affiliated definition)
|
||||
(org-element-property :begin definition))
|
||||
(or (org-element-post-affiliated definition)
|
||||
(org-element-begin definition))
|
||||
(cond
|
||||
(inline? (1+ (org-element-property :contents-end definition)))
|
||||
((org-element-property :contents-end definition))
|
||||
(t (goto-char (org-element-property :post-affiliated definition))
|
||||
(inline? (1+ (org-element-contents-end definition)))
|
||||
((org-element-contents-end definition))
|
||||
(t (goto-char (org-element-post-affiliated definition))
|
||||
(line-end-position)))))))
|
||||
(add-text-properties
|
||||
0
|
||||
|
@ -1128,9 +1135,9 @@ Throw an error when not at such a table."
|
|||
(user-error "Not on a LaTeX fragment"))
|
||||
(let* ((contents
|
||||
(buffer-substring-no-properties
|
||||
(org-element-property :begin context)
|
||||
(- (org-element-property :end context)
|
||||
(org-element-property :post-blank context))))
|
||||
(org-element-begin context)
|
||||
(- (org-element-end context)
|
||||
(org-element-post-blank context))))
|
||||
(delim-length (if (string-match "\\`\\$[^$]" contents) 1 2)))
|
||||
;; Make the LaTeX deliminators read-only.
|
||||
(add-text-properties 0 delim-length
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
|
||||
(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only keep-deferred))
|
||||
(declare-function org-element-property "org-element-ast" (property node))
|
||||
(declare-function org-element-end "org-element" (node))
|
||||
(declare-function org-element-post-affiliated "org-element" (node))
|
||||
(declare-function org-element-type-p "org-element-ast" (node types))
|
||||
(declare-function org-element-cache-reset "org-element" (&optional all no-persistence))
|
||||
(declare-function org-entry-get "org" (pom property &optional inherit literal-nil))
|
||||
|
@ -1015,7 +1017,7 @@ With a non-nil optional argument TABLE-TYPE, return the beginning
|
|||
of a table.el-type table. This function assumes point is on
|
||||
a table."
|
||||
(cond (table-type
|
||||
(org-element-property :post-affiliated (org-element-at-point)))
|
||||
(org-element-post-affiliated (org-element-at-point)))
|
||||
((save-excursion
|
||||
(and (re-search-backward org-table-border-regexp nil t)
|
||||
(line-beginning-position 2))))
|
||||
|
@ -1029,7 +1031,7 @@ a table.el-type table. This function assumes point is on
|
|||
a table."
|
||||
(save-excursion
|
||||
(cond (table-type
|
||||
(goto-char (org-element-property :end (org-element-at-point)))
|
||||
(goto-char (org-element-end (org-element-at-point)))
|
||||
(skip-chars-backward " \t\n")
|
||||
(line-beginning-position 2))
|
||||
((re-search-forward org-table-border-regexp nil t)
|
||||
|
@ -4264,8 +4266,8 @@ beginning and end position of the current table."
|
|||
(unless quietly
|
||||
(message "Mapping tables: %d%%"
|
||||
(floor (* 100.0 (point)) (buffer-size))))
|
||||
(goto-char (org-element-property :post-affiliated table))
|
||||
(let ((end (copy-marker (org-element-property :end table))))
|
||||
(goto-char (org-element-post-affiliated table))
|
||||
(let ((end (copy-marker (org-element-end table))))
|
||||
(unwind-protect
|
||||
(progn (funcall f) (goto-char end))
|
||||
(set-marker end nil)))))))
|
||||
|
|
346
lisp/org.el
346
lisp/org.el
File diff suppressed because it is too large
Load Diff
|
@ -1482,7 +1482,7 @@ contextual information."
|
|||
(org-element-property :bullet item)))
|
||||
(num (number-to-string
|
||||
(car (last (org-list-get-item-number
|
||||
(org-element-property :begin item)
|
||||
(org-element-begin item)
|
||||
struct
|
||||
(org-list-prevs-alist struct)
|
||||
(org-list-parents-alist struct)))))))
|
||||
|
|
|
@ -745,7 +745,7 @@ INFO is a plist used as a communication channel."
|
|||
(org-not-nil
|
||||
(org-export-read-attribute :attr_texinfo plain-list :compact)))
|
||||
(not (org-element-contents item))
|
||||
(eq 1 (org-element-property :post-blank item)))
|
||||
(eq 1 (org-element-post-blank item)))
|
||||
(org-element-put-property next-item :findex findex)
|
||||
(org-element-put-property next-item :kindex kindex)
|
||||
(org-element-put-property item :findex nil)
|
||||
|
@ -1186,12 +1186,12 @@ contextual information."
|
|||
(when (and compact
|
||||
(org-export-get-next-element item info)
|
||||
(not (org-element-contents item))
|
||||
(eq 1 (org-element-property :post-blank item)))
|
||||
(eq 1 (org-element-post-blank item)))
|
||||
(org-element-put-property item :post-blank 0))
|
||||
(if (and compact
|
||||
(setq previous-item (org-export-get-previous-element item info))
|
||||
(not (org-element-contents previous-item))
|
||||
(eq 0 (org-element-property :post-blank previous-item)))
|
||||
(eq 0 (org-element-post-blank previous-item)))
|
||||
(format "@itemx%s\n%s"
|
||||
(if tag (concat " " (org-export-data tag info)) "")
|
||||
(or contents ""))
|
||||
|
@ -1769,8 +1769,8 @@ a communication channel."
|
|||
;; approximation of the length of the cell in the
|
||||
;; output. It can sometimes fail (e.g. it considers
|
||||
;; "/a/" being larger than "ab").
|
||||
(let ((w (- (org-element-property :contents-end cell)
|
||||
(org-element-property :contents-begin cell))))
|
||||
(let ((w (- (org-element-contents-end cell)
|
||||
(org-element-contents-begin cell))))
|
||||
(aset widths idx (max w (aref widths idx))))
|
||||
(cl-incf idx))
|
||||
info)))
|
||||
|
|
48
lisp/ox.el
48
lisp/ox.el
|
@ -1785,8 +1785,8 @@ not exported."
|
|||
;; local structure of the document upon interpreting it back into
|
||||
;; Org syntax.
|
||||
(let* ((previous (org-export-get-previous-element datum options))
|
||||
(before (or (org-element-property :post-blank previous) 0))
|
||||
(after (or (org-element-property :post-blank datum) 0)))
|
||||
(before (or (org-element-post-blank previous) 0))
|
||||
(after (or (org-element-post-blank datum) 0)))
|
||||
(when previous
|
||||
(org-element-put-property previous :post-blank (max before after 1))))
|
||||
t)
|
||||
|
@ -1998,7 +1998,7 @@ Return a string."
|
|||
(t
|
||||
(org-export-filter-apply-functions
|
||||
(plist-get info (intern (format ":filter-%s" type)))
|
||||
(let ((blank (or (org-element-property :post-blank data) 0)))
|
||||
(let ((blank (or (org-element-post-blank data) 0)))
|
||||
(if (eq (org-element-class data parent) 'object)
|
||||
(concat results (make-string blank ?\s))
|
||||
(concat (org-element-normalize-string results)
|
||||
|
@ -2747,8 +2747,8 @@ Narrowing, if any, is ignored."
|
|||
(while (re-search-forward regexp nil t)
|
||||
(let ((element (org-element-at-point)))
|
||||
(when (org-element-property :commentedp element)
|
||||
(delete-region (org-element-property :begin element)
|
||||
(org-element-property :end element))))))))
|
||||
(delete-region (org-element-begin element)
|
||||
(org-element-end element))))))))
|
||||
|
||||
(defun org-export--prune-tree (data info)
|
||||
"Prune non exportable elements from DATA.
|
||||
|
@ -2772,7 +2772,7 @@ from tree."
|
|||
(let ((type (org-element-type data)))
|
||||
(if (org-export--skip-p data info selected excluded)
|
||||
(if (memq type '(table-cell table-row)) (push data ignore)
|
||||
(let ((post-blank (org-element-property :post-blank data)))
|
||||
(let ((post-blank (org-element-post-blank data)))
|
||||
(if (or (not post-blank) (zerop post-blank)
|
||||
(eq 'element (org-element-class data)))
|
||||
(org-element-extract data)
|
||||
|
@ -2786,7 +2786,7 @@ from tree."
|
|||
(`plain-text
|
||||
(string-match-p
|
||||
(rx whitespace eos) previous))
|
||||
(_ (org-element-property :post-blank previous))))
|
||||
(_ (org-element-post-blank previous))))
|
||||
;; Previous object ends with whitespace already.
|
||||
(org-element-extract data)
|
||||
(org-element-set data (make-string post-blank ?\s)))))))
|
||||
|
@ -2883,8 +2883,8 @@ a list of footnote definitions or in the widened buffer."
|
|||
;; Parse definition with contents.
|
||||
(save-restriction
|
||||
(narrow-to-region
|
||||
(org-element-property :begin datum)
|
||||
(org-element-property :end datum))
|
||||
(org-element-begin datum)
|
||||
(org-element-end datum))
|
||||
(org-element-map (org-element-parse-buffer nil nil 'defer)
|
||||
'footnote-definition #'identity nil t))))))
|
||||
(_ nil)))
|
||||
|
@ -2984,7 +2984,7 @@ returned by the function."
|
|||
(lambda (datum)
|
||||
(let* ((type (org-element-type datum))
|
||||
(post-blank
|
||||
(pcase (org-element-property :post-blank datum)
|
||||
(pcase (org-element-post-blank datum)
|
||||
(`nil nil)
|
||||
(n (make-string n (if (eq type 'latex-environment) ?\n ?\s)))))
|
||||
(new
|
||||
|
@ -3585,9 +3585,9 @@ Return a string of lines to be included in the format expected by
|
|||
(error "%s for %s::%s" (error-message-string err) file location)))
|
||||
(let* ((element (org-element-at-point))
|
||||
(contents-begin
|
||||
(and only-contents (org-element-property :contents-begin element))))
|
||||
(and only-contents (org-element-contents-begin element))))
|
||||
(narrow-to-region
|
||||
(or contents-begin (org-element-property :begin element))
|
||||
(or contents-begin (org-element-begin element))
|
||||
(org-element-property (if contents-begin :contents-end :end) element))
|
||||
(when (and only-contents
|
||||
(org-element-type-p element '(headline inlinetask)))
|
||||
|
@ -3637,18 +3637,18 @@ Move point after the link."
|
|||
(if (or (not (string= "file" (org-element-property :type link)))
|
||||
(file-remote-p path)
|
||||
(file-name-absolute-p path))
|
||||
(goto-char (org-element-property :end link))
|
||||
(goto-char (org-element-end link))
|
||||
(let ((new-path (file-relative-name (expand-file-name path file-dir)
|
||||
includer-dir))
|
||||
(new-link (org-element-copy link)))
|
||||
(org-element-put-property new-link :path new-path)
|
||||
(when (org-element-property :contents-begin link)
|
||||
(when (org-element-contents-begin link)
|
||||
(org-element-adopt new-link
|
||||
(buffer-substring
|
||||
(org-element-property :contents-begin link)
|
||||
(org-element-property :contents-end link))))
|
||||
(delete-region (org-element-property :begin link)
|
||||
(org-element-property :end link))
|
||||
(org-element-contents-begin link)
|
||||
(org-element-contents-end link))))
|
||||
(delete-region (org-element-begin link)
|
||||
(org-element-end link))
|
||||
(insert (org-element-interpret-data new-link))))))
|
||||
|
||||
(defun org-export--prepare-file-contents
|
||||
|
@ -3714,11 +3714,11 @@ is to happen."
|
|||
;; `org-export-insert-image-links' may activate
|
||||
;; them.
|
||||
(let ((contents-begin
|
||||
(org-element-property :contents-begin link))
|
||||
(begin (org-element-property :begin link)))
|
||||
(org-element-contents-begin link))
|
||||
(begin (org-element-begin link)))
|
||||
(when contents-begin
|
||||
(save-excursion
|
||||
(goto-char (org-element-property :contents-end link))
|
||||
(goto-char (org-element-contents-end link))
|
||||
(while (re-search-backward regexp contents-begin t)
|
||||
(save-match-data
|
||||
(org-export--update-included-link
|
||||
|
@ -3789,7 +3789,7 @@ is to happen."
|
|||
(lambda (f old new)
|
||||
;; Replace OLD label with NEW in footnote F.
|
||||
(save-excursion
|
||||
(goto-char (+ (org-element-property :begin f) 4))
|
||||
(goto-char (+ (org-element-begin f) 4))
|
||||
(looking-at (regexp-quote old))
|
||||
(replace-match new))))
|
||||
(seen-alist))
|
||||
|
@ -4874,7 +4874,7 @@ objects of the same type."
|
|||
;; Special case 2: An item returns its number as a list.
|
||||
(item (let ((struct (org-element-property :structure element)))
|
||||
(org-list-get-item-number
|
||||
(org-element-property :begin element)
|
||||
(org-element-begin element)
|
||||
struct
|
||||
(org-list-prevs-alist struct)
|
||||
(org-list-parents-alist struct))))
|
||||
|
@ -5960,7 +5960,7 @@ INFO is the current export state, as a plist."
|
|||
text info)))
|
||||
(cond ((not p) nil)
|
||||
((stringp p) (substring p -1))
|
||||
((memq (org-element-property :post-blank p)
|
||||
((memq (org-element-post-blank p)
|
||||
'(0 nil))
|
||||
'no-blank)
|
||||
(t 'blank)))))
|
||||
|
|
|
@ -489,5 +489,4 @@ The =[[= causes a false positive which ~org-babel-detangle~ should handle proper
|
|||
:ID: 73115FB0-6565-442B-BB95-50195A499EF4
|
||||
:END:
|
||||
#+begin_src emacs-lisp :tangle yes :comments link
|
||||
;; detangle
|
||||
#+end_src
|
||||
|
|
Loading…
Reference in New Issue