From a7d1dfa1710ed9ab5d18f9860fcb7c73e2a0c60c Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Tue, 16 May 2023 12:41:53 +0200 Subject: [PATCH] Use `org-element-type-p' Use `org-element-type-p' across Org source, except some tests, where `eq' can produce more meaningful failure explanations. --- lisp/ob-core.el | 63 ++++----- lisp/ob-exp.el | 4 +- lisp/ob-lob.el | 4 +- lisp/ob-ref.el | 4 +- lisp/ob-tangle.el | 9 +- lisp/oc-basic.el | 6 +- lisp/oc-biblatex.el | 2 +- lisp/oc-bibtex.el | 2 +- lisp/oc-csl.el | 4 +- lisp/oc-natbib.el | 2 +- lisp/oc.el | 31 ++--- lisp/ol.el | 15 +-- lisp/org-agenda.el | 2 +- lisp/org-archive.el | 1 - lisp/org-attach.el | 6 +- lisp/org-capture.el | 4 +- lisp/org-clock.el | 13 +- lisp/org-colview.el | 10 +- lisp/org-compat.el | 11 +- lisp/org-cycle.el | 8 +- lisp/org-element-ast.el | 6 +- lisp/org-element.el | 112 ++++++++-------- lisp/org-fold.el | 4 +- lisp/org-footnote.el | 17 +-- lisp/org-keys.el | 4 +- lisp/org-lint.el | 37 +++--- lisp/org-list.el | 35 +++-- lisp/org-macro.el | 13 +- lisp/org-pcomplete.el | 7 +- lisp/org-src.el | 25 ++-- lisp/org-table.el | 16 +-- lisp/org.el | 214 ++++++++++++++++--------------- lisp/ox-ascii.el | 39 +++--- lisp/ox-beamer.el | 4 +- lisp/ox-html.el | 16 +-- lisp/ox-icalendar.el | 2 +- lisp/ox-latex.el | 49 ++++--- lisp/ox-md.el | 8 +- lisp/ox-odt.el | 89 +++++++------ lisp/ox-org.el | 2 +- lisp/ox-publish.el | 2 +- lisp/ox-texinfo.el | 11 +- lisp/ox.el | 147 ++++++++++----------- testing/lisp/test-org-element.el | 6 +- testing/lisp/test-org.el | 2 +- testing/lisp/test-ox.el | 6 +- 46 files changed, 546 insertions(+), 528 deletions(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 2a71dc302..b43277e00 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -64,8 +64,9 @@ (declare-function org-element-at-point-no-context "org-element" (&optional pom)) (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" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-type "org-element-ast" (node &optional anonymous)) +(declare-function org-element-type-p "org-element-ast" (node &optional types)) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) (declare-function org-escape-code-in-region "org-src" (beg end)) (declare-function org-forward-heading-same-level "org" (arg &optional invisible-ok)) @@ -318,8 +319,7 @@ environment, to override this check." "Execute BODY if point is in a source block and return t. Otherwise do nothing and return nil." - `(if (memq (org-element-type (org-element-context)) - '(inline-src-block src-block)) + `(if (org-element-type-p (org-element-context) '(inline-src-block src-block)) (progn ,@body t) @@ -650,7 +650,7 @@ Remove final newline character and spurious indentation." (body (if (string-suffix-p "\n" value) (substring value 0 -1) value))) - (cond ((eq (org-element-type datum) 'inline-src-block) + (cond ((org-element-type-p datum 'inline-src-block) ;; Newline characters and indentation in an inline ;; src-block are not meaningful, since they could come from ;; some paragraph filling. Treat them as a white space. @@ -1161,8 +1161,9 @@ evaluation mechanisms." (defvar org-link-bracket-re) (defun org-babel-active-location-p () - (memq (org-element-type (save-match-data (org-element-context))) - '(babel-call inline-babel-call inline-src-block src-block))) + (org-element-type-p + (save-match-data (org-element-context)) + '(babel-call inline-babel-call inline-src-block src-block))) ;;;###autoload (defun org-babel-open-src-block-result (&optional re-run) @@ -1274,7 +1275,7 @@ buffer." (goto-char (point-min)) (while (re-search-forward "src_\\S-" nil t) (let ((,datum (save-match-data (org-element-context)))) - (when (eq (org-element-type ,datum) 'inline-src-block) + (when (org-element-type-p ,datum 'inline-src-block) (goto-char (match-beginning 0)) (let ((,end (copy-marker (org-element-property :end ,datum)))) ,@body @@ -1302,8 +1303,7 @@ buffer." (goto-char (point-min)) (while (re-search-forward "call_\\S-\\|^[ \t]*#\\+CALL:" nil t) (let ((,datum (save-match-data (org-element-context)))) - (when (memq (org-element-type ,datum) - '(babel-call inline-babel-call)) + (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)))) ,@body @@ -1332,9 +1332,9 @@ buffer." (while (re-search-forward "\\(call\\|src\\)_\\|^[ \t]*#\\+\\(BEGIN_SRC\\|CALL:\\)" nil t) (let ((,datum (save-match-data (org-element-context)))) - (when (memq (org-element-type ,datum) - '(babel-call inline-babel-call inline-src-block - src-block)) + (when (org-element-type-p + ,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)))) ,@body @@ -1352,8 +1352,8 @@ the current buffer." (org-babel-eval-wipe-error-buffer) (org-save-outline-visibility t (org-babel-map-executables nil - (if (memq (org-element-type (org-element-context)) - '(babel-call inline-babel-call)) + (if (org-element-type-p + (org-element-context) '(babel-call inline-babel-call)) (org-babel-lob-execute-maybe) (org-babel-execute-src-block arg))))) @@ -1862,7 +1862,7 @@ match-data relatively to `org-babel-src-block-regexp', which see. 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 (eq (org-element-type element) 'src-block) + (when (org-element-type-p element 'src-block) (let ((end (org-element-property :end element))) (org-with-wide-buffer ;; Ensure point is not on a blank line after the block. @@ -1934,7 +1934,7 @@ to `org-babel-named-src-block-regexp'." (names nil)) (while (re-search-forward regexp nil t) (let ((element (org-element-at-point))) - (when (eq 'src-block (org-element-type element)) + (when (org-element-type-p element 'src-block) (let ((name (org-element-property :name element))) (when name (push name names)))))) names)))) @@ -1965,7 +1965,7 @@ buffer or nil if no such result exists." (catch :found (while (re-search-forward re nil t) (let ((element (org-element-at-point))) - (when (or (eq (org-element-type element) 'keyword) + (when (or (org-element-type-p element 'keyword) (< (point) (org-element-property :post-affiliated element))) (throw :found (line-beginning-position))))))))) @@ -2164,7 +2164,7 @@ to HASH." (and (< (point) limit) (let ((result (org-element-context))) - (and (eq (org-element-type result) 'macro) + (and (org-element-type-p result 'macro) (string= (org-element-property :key result) "results") (if (not insert) (point) @@ -2412,8 +2412,8 @@ INFO may provide the values of these header arguments (in the (progn (message (replace-regexp-in-string "%" "%%" (format "%S" result))) result) (let ((inline (let ((context (org-element-context))) - (and (memq (org-element-type context) - '(inline-babel-call inline-src-block)) + (and (org-element-type-p + context '(inline-babel-call inline-src-block)) context)))) (when inline (let ((warning @@ -2427,8 +2427,8 @@ INFO may provide the values of these header arguments (in the (let* ((visible-beg (point-min-marker)) (visible-end (copy-marker (point-max) t)) (inline (let ((context (org-element-context))) - (and (memq (org-element-type context) - '(inline-babel-call inline-src-block)) + (and (org-element-type-p + context '(inline-babel-call inline-src-block)) context))) (existing-result (org-babel-where-is-src-block-result t nil hash)) (results-switches (cdr (assq :results_switches (nth 2 info)))) @@ -2681,7 +2681,7 @@ The result must be wrapped in a `results' macro to be removed. Leading white space is trimmed." (interactive) (let* ((el (or datum (org-element-context)))) - (when (memq (org-element-type el) '(inline-src-block inline-babel-call)) + (when (org-element-type-p el '(inline-src-block inline-babel-call)) (org-with-wide-buffer (goto-char (org-element-property :end el)) (skip-chars-backward " \t") @@ -2691,7 +2691,7 @@ Leading white space is trimmed." (org-element-property :contents-end (org-element-property :parent el))) (org-element-context)))) - (when (and (eq (org-element-type result) 'macro) + (when (and (org-element-type-p result 'macro) (string= (org-element-property :key result) "results")) (delete-region ; And leading whitespace. (point) @@ -2715,11 +2715,12 @@ in the buffer." (line-beginning-position 2)) (t (let ((element (org-element-at-point))) - (if (memq (org-element-type element) - ;; Possible results types. - '(drawer example-block export-block fixed-width - special-block src-block item plain-list table - latex-environment)) + (if (org-element-type-p + element + ;; Possible results types. + '(drawer example-block export-block fixed-width + special-block src-block item plain-list table + latex-environment)) (save-excursion (goto-char (min (point-max) ;for narrowed buffers (org-element-property :end element))) @@ -2807,7 +2808,7 @@ specified as an an \"attachment:\" style link." (defun org-babel-update-block-body (new-body) "Update the body of the current code block to NEW-BODY." (let ((element (org-element-at-point))) - (unless (eq (org-element-type element) 'src-block) + (unless (org-element-type-p element 'src-block) (error "Not in a source block")) (goto-char (org-babel-where-is-src-block-head element)) (let* ((ind (org-current-text-indentation)) diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 264a2a36d..ac5f873c8 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -32,8 +32,8 @@ (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-context "org-element" (&optional element)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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" (&optional buffer drop-visibility diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el index f77bda73d..6fadc3d9c 100644 --- a/lisp/ob-lob.el +++ b/lisp/ob-lob.el @@ -34,8 +34,8 @@ (declare-function org-babel-ref-split-args "ob-ref" (arg-string)) (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" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-type "org-element-ast" (node &optional anonymous)) (defvar org-babel-library-of-babel nil "Library of source-code blocks. diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 2eae3690d..00ff090a9 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -59,8 +59,8 @@ (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" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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)) (declare-function org-id-find-id-file "org-id" (id)) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 0b816a7c1..d150c1e2b 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -41,10 +41,10 @@ (declare-function org-back-to-heading "org" (&optional invisible-ok)) (declare-function org-before-first-heading-p "org" ()) (declare-function org-element--cache-active-p "org-element" ()) -(declare-function org-element-lineage "org-element" (datum &optional types with-self)) -(declare-function org-element-property "org-element" (property 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-at-point "org-element" (&optional pom cached-only)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-type-p "org-element-ast" (node types)) (declare-function org-heading-components "org" ()) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) (declare-function org-in-archived-heading-p "org" (&optional no-inheritance)) @@ -673,8 +673,7 @@ which enable the original code blocks to be found." (org-back-to-heading t)) ;; Do not skip the first block if it begins at point min. (cond ((or (org-at-heading-p) - (not (eq (org-element-type (org-element-at-point)) - 'src-block))) + (not (org-element-type-p (org-element-at-point) 'src-block))) (org-babel-next-src-block n)) ((= n 1)) (t (org-babel-next-src-block (1- n))))) diff --git a/lisp/oc-basic.el b/lisp/oc-basic.el index fdcb5bda2..84d9492ea 100644 --- a/lisp/oc-basic.el +++ b/lisp/oc-basic.el @@ -79,8 +79,8 @@ (declare-function org-open-file "org" (path &optional in-emacs line search)) (declare-function org-element-interpret-data "org-element" (data)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-type-p "org-element-ast" (node types)) (declare-function org-export-data "org-export" (data info)) (declare-function org-export-derived-backend-p "org-export" (backend &rest backends)) @@ -740,7 +740,7 @@ When DATUM is a citation reference, open bibliography entry referencing the citation key. Otherwise, select which key to follow among all keys present in the citation." (let* ((key - (if (eq 'citation-reference (org-element-type datum)) + (if (org-element-type-p datum 'citation-reference) (org-element-property :key datum) (pcase (org-cite-get-references datum t) (`(,key) key) diff --git a/lisp/oc-biblatex.el b/lisp/oc-biblatex.el index b2d31f0f6..5b0c9297b 100644 --- a/lisp/oc-biblatex.el +++ b/lisp/oc-biblatex.el @@ -70,7 +70,7 @@ (require 'org-macs) (require 'oc) -(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-property "org-element-ast" (property node)) (declare-function org-export-data "org-export" (data info)) diff --git a/lisp/oc-bibtex.el b/lisp/oc-bibtex.el index d5e5490ed..a739d0a6e 100644 --- a/lisp/oc-bibtex.el +++ b/lisp/oc-bibtex.el @@ -41,7 +41,7 @@ (require 'oc) -(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-property "org-element-ast" (property node)) (declare-function org-export-data "org-export" (data info)) diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el index b71221e8c..ca34697f0 100644 --- a/lisp/oc-csl.el +++ b/lisp/oc-csl.el @@ -137,8 +137,8 @@ (declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-put-property "org-element" (element property value)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-put-property "org-element-ast" (node property value)) (declare-function org-export-data "org-export" (data info)) (declare-function org-export-derived-backend-p "org-export" (backend &rest backends)) diff --git a/lisp/oc-natbib.el b/lisp/oc-natbib.el index 9153afd86..1c29f0d3b 100644 --- a/lisp/oc-natbib.el +++ b/lisp/oc-natbib.el @@ -48,7 +48,7 @@ (require 'oc) -(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-property "org-element-ast" (property node)) (declare-function org-export-data "org-export" (data info)) diff --git a/lisp/oc.el b/lisp/oc.el index ad2609593..6437c8958 100644 --- a/lisp/oc.el +++ b/lisp/oc.el @@ -71,25 +71,26 @@ (declare-function org-at-heading-p "org" (&optional _)) (declare-function org-collect-keywords "org" (keywords &optional unique directory)) -(declare-function org-element-adopt-elements "org-element" (parent &rest children)) +(declare-function org-element-adopt "org-element-ast" (parent &rest children)) (declare-function org-element-citation-parser "org-element" ()) (declare-function org-element-citation-reference-parser "org-element" ()) (declare-function org-element-class "org-element" (datum &optional parent)) -(declare-function org-element-contents "org-element" (element)) -(declare-function org-element-create "org-element" (type &optional props &rest children)) -(declare-function org-element-extract "org-element" (element)) -(declare-function org-element-insert-before "org-element" (element location)) -(declare-function org-element-lineage "org-element" (datum &optional types with-self)) +(declare-function org-element-contents "org-element-ast" (node)) +(declare-function org-element-create "org-element-ast" (type &optional props &rest children)) +(declare-function org-element-extract "org-element-ast" (node)) +(declare-function org-element-insert-before "org-element-ast" (node location)) +(declare-function org-element-lineage "org-element-ast" (datum &optional types with-self)) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) (declare-function org-element-normalize-string "org-element" (s)) (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only)) (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" (property element)) -(declare-function org-element-put-property "org-element" (element property value)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-put-property "org-element-ast" (node property value)) (declare-function org-element-restriction "org-element" (element)) -(declare-function org-element-set "org-element" (old new)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-set "org-element-ast" (old new)) +(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-export-derived-backend-p "org-export" (backend &rest backends)) (declare-function org-export-get-next-element "org-export" (blob info &optional n)) @@ -468,7 +469,7 @@ PROCESSOR is the name of a cite processor, as a symbol. CAPABILITY is "Set `:post-blank' property from element or object before DATUM to BLANKS. DATUM is an element or object. BLANKS is an integer. DATUM is modified by side-effect." - (if (not (eq 'plain-text (org-element-type datum))) + (if (not (org-element-type-p datum 'plain-text)) (org-element-put-property datum :post-blank blanks) ;; Remove any blank from string before DATUM so it is exported ;; with exactly BLANKS white spaces. @@ -982,7 +983,7 @@ Return newly created footnote object." (org-cite--set-previous-post-blank citation 0 info) ;; Footnote swallows citation. (org-element-insert-before footnote citation) - (org-element-adopt-elements footnote + (org-element-adopt footnote (org-element-extract citation)))) (defun org-cite-adjust-note (citation info &optional rule punct) @@ -1089,7 +1090,7 @@ the same object, call `org-cite-adjust-note' first." (next (org-element-insert-before new-next next)) (t - (org-element-adopt-elements + (org-element-adopt (org-element-property :parent citation) new-next))) (setq previous new-prev) @@ -1157,7 +1158,7 @@ raises an error if S contains a headline." (insert s) (pcase (org-element-contents (org-element-parse-buffer)) ('nil nil) - (`(,(and section (guard (eq 'section (org-element-type section))))) + (`(,(and section (guard (org-element-type-p section 'section)))) (org-element-contents section)) (_ (error "Headlines cannot replace a keyword"))))) @@ -1715,7 +1716,7 @@ ARG is the prefix argument received when calling interactively the function." (let ((context (org-element-context)) (insert (org-cite-processor-insert (org-cite-get-processor name)))) (cond - ((memq (org-element-type context) '(citation citation-reference)) + ((org-element-type-p context '(citation citation-reference)) (funcall insert context arg)) ((org-cite--allowed-p context) (funcall insert nil arg)) diff --git a/lisp/ol.el b/lisp/ol.el index e2bf90acd..6420fa4a7 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -53,10 +53,10 @@ (declare-function org-element-at-point "org-element" (&optional pom cached-only)) (declare-function org-element-cache-refresh "org-element" (pos)) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-lineage "org-element" (datum &optional types with-self)) +(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" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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)) (declare-function org-find-property "org" (property &optional value)) @@ -754,7 +754,7 @@ White spaces are not significant." (while (re-search-forward re nil t) (forward-char -1) (let ((object (org-element-context))) - (when (eq (org-element-type object) 'radio-target) + (when (org-element-type-p object 'radio-target) (goto-char (org-element-property :begin object)) (org-fold-show-context 'link-search) (throw :radio-match nil)))) @@ -1198,8 +1198,7 @@ of matched result, which is either `dedicated' or `fuzzy'." (catch :coderef-match (while (re-search-forward re nil t) (let ((element (org-element-at-point))) - (when (and (memq (org-element-type element) - '(example-block src-block)) + (when (and (org-element-type-p element '(example-block src-block)) (org-match-line (concat ".*?" (org-src-coderef-regexp (org-src-coderef-format element) @@ -1223,7 +1222,7 @@ of matched result, which is either `dedicated' or `fuzzy'." (while (re-search-forward target nil t) (backward-char) (let ((context (org-element-context))) - (when (eq (org-element-type context) 'target) + (when (org-element-type-p context 'target) (setq type 'dedicated) (goto-char (org-element-property :begin context)) (throw :target-match t)))) @@ -2058,7 +2057,7 @@ Also refresh fontification if needed." ;; Make sure point is really within the object. (backward-char) (let ((obj (org-element-context))) - (when (eq (org-element-type obj) 'radio-target) + (when (org-element-type-p obj 'radio-target) (cl-pushnew (org-element-property :value obj) rtn :test #'equal)))) rtn)))) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index bafd8b7f8..485f412e8 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4242,7 +4242,7 @@ continue from there. Optional argument ELEMENT contains element at point." (when (or (if element - (eq (org-element-type element) 'comment) + (org-element-type-p element 'comment) (save-excursion (goto-char (line-beginning-position)) (looking-at comment-start-skip))) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index bf23982f2..235fa3ab0 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -34,7 +34,6 @@ (require 'org) (require 'cl-lib) -(declare-function org-element-type "org-element" (element)) (declare-function org-datetree-find-date-create "org-datetree" (date &optional keep-restriction)) (declare-function org-inlinetask-remove-END-maybe "org-inlinetask" ()) diff --git a/lisp/org-attach.el b/lisp/org-attach.el index 824af69da..0f1b0a8c4 100644 --- a/lisp/org-attach.el +++ b/lisp/org-attach.el @@ -44,8 +44,8 @@ (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" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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" ()) @@ -741,7 +741,7 @@ It is meant to be added to `org-export-before-parsing-hook'." (save-excursion (while (re-search-forward "attachment:" nil t) (let ((link (org-element-context))) - (when (and (eq 'link (org-element-type link)) + (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) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 252527574..444eb8c5b 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -61,8 +61,8 @@ (declare-function org-datetree-find-month-create (d &optional keep-restriction)) (declare-function org-decrypt-entry "org-crypt" ()) (declare-function org-element-at-point "org-element" (&optional pom cached-only)) -(declare-function org-element-lineage "org-element" (datum &optional types with-self)) -(declare-function org-element-property "org-element" (property 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-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)) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 9a30b478e..e449e883b 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -36,8 +36,9 @@ (declare-function calendar-iso-to-absolute "cal-iso" (date)) (declare-function notifications-notify "notifications" (&rest params)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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" ()) (defvar org-element-use-cache) (declare-function org-inlinetask-at-task-p "org-inlinetask" ()) @@ -1041,7 +1042,7 @@ CLOCK is a cons cell of the form (MARKER START-TIME)." (catch 'exit (while (re-search-backward drawer-re beg t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'drawer) + (when (org-element-type-p element 'drawer) (when (> (org-element-property :end element) (car clock)) (org-fold-hide-drawer-toggle 'off nil element)) (throw 'exit nil))))))))))) @@ -1595,7 +1596,7 @@ line and position cursor in that line." " *\\sw+ +[012][0-9]:[0-5][0-9]\\)\\][ \t]*$"))) (while (re-search-forward open-clock-re end t) (let ((element (org-element-at-point))) - (when (and (eq (org-element-type element) 'clock) + (when (and (org-element-type-p element 'clock) (eq (org-element-property :status element) 'running)) (beginning-of-line) (throw 'exit t)))))) @@ -1605,7 +1606,7 @@ line and position cursor in that line." (let ((drawer-re (concat "^[ \t]*:" (regexp-quote drawer) ":[ \t]*$"))) (while (re-search-forward drawer-re end t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'drawer) + (when (org-element-type-p element 'drawer) (let ((cend (org-element-property :contents-end element))) (if (and (not org-log-states-order-reversed) cend) (goto-char cend) @@ -1619,7 +1620,7 @@ line and position cursor in that line." (save-excursion (while (re-search-forward clock-re end t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'clock) + (when (org-element-type-p element 'clock) (setq positions (cons (line-beginning-position) positions) count (1+ count)))))) (cond diff --git a/lisp/org-colview.el b/lisp/org-colview.el index b4ec8a2c6..750370dd8 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -37,13 +37,13 @@ (declare-function org-agenda-redo "org-agenda" (&optional all)) (declare-function org-agenda-do-context-action "org-agenda" ()) (declare-function org-clock-sum-today "org-clock" (&optional headline-filter)) -(declare-function org-element-extract "org-element" (element)) +(declare-function org-element-extract "org-element-ast" (node)) (declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent)) -(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-property "org-element-ast" (property node)) (declare-function org-element-restriction "org-element" (element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-type-p "org-element-ast" (node types)) (declare-function org-dynamic-block-define "org" (type func)) (declare-function org-link-display-format "ol" (s)) (declare-function org-link-open-from-string "ol" (s &optional arg)) @@ -816,7 +816,7 @@ current specifications. This function also sets (let ((case-fold-search t)) (while (re-search-forward "^[ \t]*#\\+COLUMNS: .+$" nil t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'keyword) + (when (org-element-type-p element 'keyword) (throw :found (org-element-property :value element))))) nil))) org-columns-default-format))) @@ -1020,7 +1020,7 @@ the current buffer." (catch :found (while (re-search-forward "^[ \t]*#\\+COLUMNS:\\(.*\\)" nil t) (let ((element (save-match-data (org-element-at-point)))) - (when (and (eq (org-element-type element) 'keyword) + (when (and (org-element-type-p element 'keyword) (equal (org-element-property :key element) "COLUMNS")) (replace-match (concat " " fmt) t t nil 1) diff --git a/lisp/org-compat.el b/lisp/org-compat.el index b9aa3b63c..bef3a17d3 100644 --- a/lisp/org-compat.el +++ b/lisp/org-compat.el @@ -52,9 +52,10 @@ (declare-function org-element-at-point "org-element" (&optional pom cached-only)) (declare-function org-element-at-point-no-context "org-element" (&optional pom)) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-lineage "org-element" (blob &optional types with-self)) -(declare-function org-element-type "org-element" (element)) -(declare-function org-element-property "org-element" (property element)) +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) +(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-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)) @@ -555,7 +556,7 @@ Counting starts at 1." (defun org-in-fixed-width-region-p () "Non-nil if point in a fixed-width region." (save-match-data - (eq 'fixed-width (org-element-type (org-element-at-point))))) + (org-element-type-p (org-element-at-point) 'fixed-width))) (make-obsolete 'org-in-fixed-width-region-p "use `org-element' library" "9.0") @@ -894,7 +895,7 @@ region as a drawer without further ado." (beginning-of-line) (looking-at-p "^[ \t]*:\\(\\(?:\\w\\|[-_]\\)+\\):[ \t]*$")) (org-element-at-point))))) - (when (memq (org-element-type drawer) '(drawer property-drawer)) + (when (org-element-type-p drawer '(drawer property-drawer)) (let ((post (org-element-property :post-affiliated drawer))) (org-fold-region (save-excursion (goto-char post) (line-end-position)) diff --git a/lisp/org-cycle.el b/lisp/org-cycle.el index 762654567..0201a0b55 100644 --- a/lisp/org-cycle.el +++ b/lisp/org-cycle.el @@ -35,9 +35,9 @@ (require 'org-macs) (require 'org-fold) -(declare-function org-element-type "org-element" (element)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-lineage "org-element" (datum &optional types with-self)) +(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-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)) (declare-function org-get-tags "org" (&optional pos local fontify)) @@ -389,7 +389,7 @@ same as `S-TAB') also when called without prefix argument." ;; Table: enter it or move to the next field. ((and (org-match-line "[ \t]*[|+]") (org-element-lineage element '(table) t)) - (if (and (eq 'table (org-element-type element)) + (if (and (org-element-type-p element 'table) (eq 'table.el (org-element-property :type element))) (message (substitute-command-keys "\\\ Use `\\[org-edit-special]' to edit table.el tables")) diff --git a/lisp/org-element-ast.el b/lisp/org-element-ast.el index e550a0ed8..9f44a97e1 100644 --- a/lisp/org-element-ast.el +++ b/lisp/org-element-ast.el @@ -452,7 +452,7 @@ Return modified NODE." (if idx (inline-letevals (node value) (inline-quote - (if (eq 'plain-text (org-element-type ,node)) + (if (org-element-type-p ,node 'plain-text) ;; Special case: Do not use parray for plain-text. (org-add-props ,node nil ,property ,value) (let ((parray @@ -463,7 +463,7 @@ Return modified NODE." (inline-letevals (node property value) (inline-quote (let ((idx (org-element--property-idx ,property))) - (if (and idx (not (eq 'plain-text (org-element-type ,node)))) + (if (and idx (not (org-element-type-p ,node 'plain-text))) (when-let ((parray (or (org-element--parray ,node) @@ -1049,7 +1049,7 @@ ancestors from its section can be found. There is no such limitation when DATUM belongs to a full parse tree." (let ((up (if with-self datum (org-element-property :parent datum))) ancestors) - (while (and up (not (memq (org-element-type up) types))) + (while (and up (not (org-element-type-p up types))) (unless types (push up ancestors)) (setq up (org-element-property :parent up))) (if types up (nreverse ancestors)))) diff --git a/lisp/org-element.el b/lisp/org-element.el index 248a01c85..744175254 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -1224,7 +1224,7 @@ Return a new syntax node of `org-data' type containing `:begin', (while (re-search-backward "^[ \t]*#\\+CATEGORY:" (point-min) t) (org-element-with-disabled-cache (let ((element (org-element-at-point-no-context))) - (when (eq (org-element-type element) 'keyword) + (when (org-element-type-p element 'keyword) (throw 'buffer-category (org-element-property :value element))))))))) category)) @@ -5012,8 +5012,8 @@ to interpret. Return Org syntax as a string." ;; an item or a footnote-definition, ;; ignore first line's indentation. (and (eq type 'paragraph) - (memq (org-element-type parent) - '(footnote-definition item)) + (org-element-type-p + parent '(footnote-definition item)) (eq data (car (org-element-contents parent))) (eq (org-element-property :pre-blank parent) 0))))) @@ -5152,9 +5152,9 @@ indentation removed from its contents." (put-text-property (match-beginning 1) (match-end 1) 'org-ind i datum) (setq min-ind (min i min-ind)))))))) - ((eq (org-element-type datum) 'line-break) + ((org-element-type-p datum 'line-break) (setq first-flag t)) - ((memq (org-element-type datum) org-element-recursive-objects) + ((org-element-type-p datum org-element-recursive-objects) (setq min-ind (funcall find-min-ind datum first-flag min-ind))))))) (min-ind @@ -5186,8 +5186,7 @@ indentation removed from its contents." (point))) (when (integerp i) (indent-to (- i min-ind)))))) (buffer-string))) - ((memq (org-element-type object) - org-element-recursive-objects) + ((org-element-type-p object org-element-recursive-objects) (funcall build object)) (t object))) (org-element-contents datum))) @@ -5720,8 +5719,7 @@ the cache." (= pos (org-element-property :begin hashed)) ;; We cannot rely on element :begin for elements with ;; children starting at the same pos. - (not (memq (org-element-type hashed) - '(section org-data table)))) + (not (org-element-type-p hashed '(section org-data table)))) hashed ;; No appriate HASHED. Search the cache. (while node @@ -5738,7 +5736,7 @@ the cache." ((or (< begin pos) ;; If the element is section or org-data, we also need ;; to check the following element. - (memq (org-element-type element) '(section org-data))) + (org-element-type-p element '(section org-data))) (setq lower element node (avl-tree--node-right node))) ;; We found an element in cache starting at POS. If `side' @@ -5753,7 +5751,7 @@ the cache." ((eq side 'both) (setq lower element) (setq node (avl-tree--node-right node))) - ((and (memq (org-element-type element) '(item table-row)) + ((and (org-element-type-p element '(item table-row)) (let ((parent (org-element-property :parent element))) (and (= (org-element-property :begin element) (org-element-property :contents-begin parent)) @@ -5796,7 +5794,7 @@ the cache." (org-element-property :org-element--cache-sync-key element) (org-element--format-element element))) (org-element-put-property element :cached t) - (when (memq (org-element-type element) '(headline inlinetask)) + (when (org-element-type-p element '(headline inlinetask)) (cl-incf org-element--headline-cache-size) (avl-tree-enter org-element--headline-cache element)) (cl-incf org-element--cache-size) @@ -5812,7 +5810,7 @@ Assume ELEMENT belongs to cache and that a cache is active." (when (and (org-element-property :parent element) (org-element-contents (org-element-property :parent element))) (org-element-set-contents (org-element-property :parent element) nil)) - (when (memq (org-element-type element) '(headline inlinetask)) + (when (org-element-type-p element '(headline inlinetask)) (cl-decf org-element--headline-cache-size) (avl-tree-delete org-element--headline-cache element)) (org-element--cache-log-message @@ -5877,8 +5875,8 @@ Properties are modified by side-effect." ;; is the only one that really matters and it prevents from ;; shifting it more than once. (when (and (or (not props) (memq :structure props)) - (eq (org-element-type element) 'plain-list) - (not (eq (org-element-type (org-element-property :parent element)) 'item))) + (org-element-type-p element 'plain-list) + (not (org-element-type-p (org-element-property :parent element) 'item))) (let ((structure (org-element-property :structure element))) (dolist (item structure) (cl-incf (car item) offset) @@ -6081,17 +6079,17 @@ completing the request." (if (<= pos end) (progn (org-element--cache-log-message "removing %S::%S" - (org-element-property :org-element--cache-sync-key data) - (org-element--format-element data)) + (org-element-property :org-element--cache-sync-key data) + (org-element--format-element data)) (cl-incf deletion-count) (org-element--cache-remove data) (when (and (> (log org-element--cache-size 2) 10) (> deletion-count (/ org-element--cache-size (log org-element--cache-size 2)))) (org-element--cache-log-message "Removed %S>N/LogN(=%S/%S) elements. Resetting cache to prevent performance degradation" - deletion-count - org-element--cache-size - (log org-element--cache-size 2)) + deletion-count + org-element--cache-size + (log org-element--cache-size 2)) (org-element-cache-reset) (throw 'org-element--cache-quit t))) ;; Done deleting everything starting before END. @@ -6155,8 +6153,8 @@ completing the request." ;; requests. (let ((next-request (nth 1 org-element--cache-sync-requests))) (org-element--cache-log-message "Phase 1: Unorderered requests. Merging: %S\n%S\n" - (let ((print-length 10) (print-level 3)) (prin1-to-string request)) - (let ((print-length 10) (print-level 3)) (prin1-to-string next-request))) + (let ((print-length 10) (print-level 3)) (prin1-to-string request)) + (let ((print-length 10) (print-level 3)) (prin1-to-string next-request))) (setf (org-element--request-key next-request) key) (setf (org-element--request-beg next-request) (org-element--request-beg request)) (setf (org-element--request-phase next-request) 1) @@ -6281,9 +6279,9 @@ completing the request." (unless (zerop offset) (when (>= org-element--cache-diagnostics-level 3) (org-element--cache-log-message "Shifting positions (𝝙%S) in %S::%S" - offset - (org-element-property :org-element--cache-sync-key data) - (org-element--format-element data))) + offset + (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))) ;; Update PARENT and re-parent DATA, only when @@ -6307,7 +6305,7 @@ completing the request." ;; However, the paragraph element stored in ;; cache must be deleted instead. ((and parent - (or (not (memq (org-element-type parent) org-element-greater-elements)) + (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) @@ -6316,8 +6314,8 @@ completing the request." (and (org-element-property :contents-end data) (> (org-element-property :contents-end data) (org-element-property :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)) + (org-element-property :org-element--cache-sync-key data) + (org-element--format-element data)) (org-element--cache-remove data) ;; We altered the tree structure. The tree ;; traversal needs to be restarted. @@ -6344,8 +6342,8 @@ completing the request." (org-element--format-element data) (org-element--format-element (org-element-property :parent data)) (org-element--format-element parent)) - (when (and (eq 'org-data (org-element-type parent)) - (not (eq 'headline (org-element-type data)))) + (when (and (org-element-type-p parent 'org-data) + (not (org-element-type-p data 'headline))) ;; FIXME: This check is here to see whether ;; such error happens within ;; `org-element--cache-process-request' or somewhere @@ -6364,8 +6362,8 @@ If this warning appears regularly, please report the warning text to Org mode ma ;; interruption. (when (and threshold (> begin threshold)) (org-element--cache-log-message "Reached threshold %S: %S" - threshold - (org-element--format-element data)) + threshold + (org-element--format-element data)) (setq exit-flag t)))) (if continue-flag (setq continue-flag nil) @@ -6488,7 +6486,7 @@ the expected result." (cl-incf org-element--cache-interrupt-C-g-count) (setq quit-flag nil)) (when (>= org-element--cache-interrupt-C-g-count - org-element--cache-interrupt-C-g-max-count) + org-element--cache-interrupt-C-g-max-count) (setq quit-flag t) (setq org-element--cache-interrupt-C-g-count 0) (org-element-cache-reset) @@ -6594,7 +6592,7 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li (and (org-element--open-end-p element) (or (= (org-element-property :end element) (point-max)) (and (>= pos (org-element-property :contents-end element)) - (memq (org-element-type element) '(org-data section headline))))))) + (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 @@ -6780,9 +6778,9 @@ known element in cache (it may start after END)." (if (not before) after ;; If BEFORE is a keyword, it may need to be removed to become ;; an affiliated keyword. - (when (eq 'keyword (org-element-type before)) + (when (org-element-type-p before 'keyword) (let ((prev before)) - (while (eq 'keyword (org-element-type prev)) + (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))))))) @@ -6872,7 +6870,7 @@ known element in cache (it may start after END)." ;; starting from old :begin position, we do not care that ;; its boundaries could have extended to shrunk - we ;; will re-parent and shift them anyway. - (and (eq 'headline (org-element-type up)) + (and (org-element-type-p up 'headline) (not org-element--cache-avoid-synchronous-headline-re-parsing) ;; The change is not inside headline. Not ;; updating here. @@ -6882,7 +6880,7 @@ known element in cache (it may start after END)." (org-element-with-disabled-cache (and (looking-at-p org-element-headline-re) (org-element-headline-parser)))))) - (when (eq 'headline (org-element-type current)) + (when (org-element-type-p current 'headline) (org-element--cache-log-message "Found non-robust headline that can be updated individually: %S" (org-element--format-element current)) @@ -6893,7 +6891,7 @@ known element in cache (it may start after END)." ;; org-data itself, unless the change is made ;; within blank lines at BOB (that could ;; potentially alter first-section). - (when (and (eq 'org-data (org-element-type up)) + (when (and (org-element-type-p up 'org-data) (>= beg (org-element-property :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 @@ -6906,7 +6904,7 @@ known element in cache (it may start after END)." (setq before up) (when robust-flag (setq robust-flag nil)))) (unless (or (org-element-property :parent up) - (eq 'org-data (org-element-type up))) + (org-element-type-p up 'org-data)) (org-element--cache-warn "Got element without parent. Please report it to Org mode mailing list (M-x org-submit-bug-report).\n%S" up) (org-element-cache-reset) (error "org-element--cache: Emergency exit")) @@ -7096,12 +7094,12 @@ Return non-nil when verification failed." ;; Verify correct parent for the element. (unless (or (not org-element--cache-self-verify) (org-element-property :parent element) - (eq 'org-data (org-element-type element))) + (org-element-type-p element 'org-data)) (org-element--cache-warn "Got element without parent (cache active?: %S). Please report it to Org mode mailing list (M-x org-submit-bug-report).\n%S" (org-element--cache-active-p) element) (org-element-cache-reset)) (when (and org-element--cache-self-verify (org-element--cache-active-p) - (eq 'headline (org-element-type element)) + (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) @@ -7122,12 +7120,12 @@ The element is: %S\n The parent is: %S\n The real parent is: %S" (when (and org-element--cache-self-verify (org-element--cache-active-p) element - (not (memq (org-element-type element) '(section org-data))) + (not (org-element-type-p element '(section org-data))) ;; Avoid too much slowdown (< (random 1000) (* 1000 org-element--cache-self-verify-frequency))) (let ((real-element (org-element-with-disabled-cache (org-element--parse-to - (if (memq (org-element-type element) '(table-row item)) + (if (org-element-type-p element '(table-row item)) (1+ (org-element-property :begin element)) (org-element-property :begin element)))))) (unless (and (eq (org-element-type real-element) (org-element-type element)) @@ -7173,7 +7171,7 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S" (org-element-put-property el :org-element--cache-sync-key nil) (org-element-map el t (lambda (el2) - (unless (eq 'plain-text (org-element-type el2)) + (unless (org-element-type-p el2 'plain-text) (org-element-put-property el2 :buffer nil))) nil nil nil 'with-affiliated 'no-undefer)) org-element--cache) @@ -7207,7 +7205,7 @@ The element is: %S\n The real element is: %S\n Cache around :begin:\n%S\n%S\n%S" (lambda (el) (org-element-map el t (lambda (el2) - (unless (eq 'plain-text (org-element-type el2)) + (unless (org-element-type-p el2 'plain-text) (org-element-put-property el2 :buffer (current-buffer)))) nil nil nil 'with-affiliated 'no-undefer)) org-element--cache) @@ -7420,7 +7418,7 @@ the cache." ;; does. (progn (setq tmpelement (org-element--parse-to (point))) - (while (and tmpelement (not (memq (org-element-type tmpelement) restrict-elements))) + (while (and tmpelement (not (org-element-type-p tmpelement restrict-elements))) (setq tmpelement (org-element-property :parent tmpelement))) tmpelement) (org-element--parse-to (point))))) @@ -7460,10 +7458,10 @@ the cache." () `(progn (setq tmpnext-start nil) (if (memq granularity '(headline headline+inlinetask)) - (setq tmpnext-start (or (when (memq (org-element-type data) '(headline org-data)) + (setq tmpnext-start (or (when (org-element-type-p data '(headline org-data)) (org-element-property :contents-begin data)) (org-element-property :end data))) - (setq tmpnext-start (or (when (memq (org-element-type data) org-element-greater-elements) + (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)))) ;; DATA end may be the last element inside @@ -7641,7 +7639,7 @@ the cache." ;; Try FUNC if DATA matches all the ;; restrictions. Calculate new START. (when (or (not restrict-elements) - (memq (org-element-type data) restrict-elements)) + (org-element-type-p data restrict-elements)) ;; DATA matches restriction. FUNC may ;; ;; Call FUNC. FUNC may move point. @@ -7724,7 +7722,9 @@ the cache." (setq prev data) (setq prev nil))) ;; DATA is after START. Fill the gap. - (if (memq (org-element-type (org-element--parse-to start)) '(plain-list table)) + (if (org-element-type-p + (org-element--parse-to start) + '(plain-list table)) ;; Tables and lists are special, we need a ;; trickery to make items/rows be populated ;; into cache. @@ -7844,11 +7844,11 @@ element ending there." element (org-element--cache-verify-element element)) (setq element (org-element--parse-to pom))) - (unless (eq 'org-data (org-element-type element)) + (unless (org-element-type-p element 'org-data) (unless (and cached-only (not (and element (or (= pom (org-element-property :begin element)) - (and (not (memq (org-element-type element) org-element-greater-elements)) + (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) @@ -7857,7 +7857,7 @@ element ending there." (and (not (org-element-property :contents-end element)) (>= pom (org-element-property :begin element)) (< pom (org-element-property :end element))))))) - (if (not (eq (org-element-type element) 'section)) + (if (not (org-element-type-p element 'section)) element (org-element-at-point (1+ pom) cached-only)))))) @@ -7993,7 +7993,7 @@ Providing it allows for quicker computation." (and (= pos cend) (or (= (point-max) pos) (not (memq (char-before pos) - '(?\s ?\t))))))) + '(?\s ?\t))))))) (goto-char cbeg) (narrow-to-region (point) cend) (setq parent next) @@ -8023,7 +8023,7 @@ end of ELEM-A." ;; a footnote definition is impossible: it cannot contain two ;; paragraphs in a row because it cannot contain a blank line. (when (and specialp - (or (not (eq (org-element-type elem-B) 'paragraph)) + (or (not (org-element-type-p elem-B 'paragraph)) (/= (org-element-property :begin elem-B) (org-element-property :contents-begin elem-B)))) (error "Cannot swap elements")) diff --git a/lisp/org-fold.el b/lisp/org-fold.el index 859672061..219400482 100644 --- a/lisp/org-fold.el +++ b/lisp/org-fold.el @@ -61,9 +61,9 @@ (defvar org-element-headline-re) (declare-function isearch-filter-visible "isearch" (beg end)) -(declare-function org-element-type "org-element" (element)) +(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" (property element)) +(declare-function org-element-property "org-element-ast" (property 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" ()) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index 6bdd0b32f..29acd32ff 100644 --- a/lisp/org-footnote.el +++ b/lisp/org-footnote.el @@ -45,9 +45,10 @@ (declare-function org-element-at-point "org-element" (&optional pom cached-only)) (declare-function org-element-class "org-element" (datum &optional parent)) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-lineage "org-element" (blob &optional types with-self)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) +(declare-function org-element-property "org-element-ast" (property 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-end-of-subtree "org" (&optional invisible-ok to-heading)) (declare-function org-fill-paragraph "org" (&optional justify region)) (declare-function org-in-block-p "org" (names)) @@ -197,7 +198,7 @@ extracted will be filled again." If so, return a list containing its label, beginning and ending positions, and the definition, when inline." (let ((reference (org-element-context))) - (when (eq 'footnote-reference (org-element-type reference)) + (when (org-element-type-p reference 'footnote-reference) (let ((end (save-excursion (goto-char (org-element-property :end reference)) (skip-chars-backward " \t") @@ -368,7 +369,7 @@ References are sorted according to a deep-reading order." ;; Ensure point is within the reference before parsing it. (backward-char) (let ((object (org-element-context))) - (when (eq (org-element-type object) 'footnote-reference) + (when (org-element-type-p object 'footnote-reference) (let* ((label (org-element-property :label object)) (begin (org-element-property :begin object)) (size @@ -420,7 +421,7 @@ while collecting them." (backward-char) (let ((element (org-element-at-point))) (let ((label (org-element-property :label element))) - (when (and (eq (org-element-type element) 'footnote-definition) + (when (and (org-element-type-p element 'footnote-definition) (not (member label seen))) (push label seen) (let* ((beg (progn @@ -633,8 +634,8 @@ This function ignores narrowing, if any." (while (re-search-forward org-footnote-re nil t) (backward-char) (let ((context (org-element-context))) - (when (memq (org-element-type context) - '(footnote-definition footnote-reference)) + (when (org-element-type-p + context '(footnote-definition footnote-reference)) (let ((label (org-element-property :label context))) (when label (cl-pushnew label all :test #'equal)))))) all))) diff --git a/lisp/org-keys.el b/lisp/org-keys.el index 3dbf3c017..38fac57d8 100644 --- a/lisp/org-keys.el +++ b/lisp/org-keys.el @@ -85,7 +85,7 @@ (declare-function org-down-element "org" ()) (declare-function org-edit-special "org" (&optional arg)) (declare-function org-element-at-point "org-element" (&optional pom cached-only)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-type-p "org-element-ast" (node types)) (declare-function org-emphasize "org" (&optional char)) (declare-function org-end-of-line "org" (&optional n)) (declare-function org-entry-put "org" (pom property value)) @@ -914,7 +914,7 @@ a-list placed behind the generic `org-babel-key-prefix'.") "Hook for activating single-letter code block commands." (when (and (bolp) (let ((case-fold-search t)) (looking-at "[ \t]*#\\+begin_src")) - (eq 'src-block (org-element-type (org-element-at-point)))) + (org-element-type-p (org-element-at-point) 'src-block)) (cdr (assoc keys org-babel-key-bindings)))) ;;;###autoload diff --git a/lisp/org-lint.el b/lisp/org-lint.el index c4b51a32b..45db168da 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -865,11 +865,11 @@ Use \"export %s\" instead" (defun org-lint-undefined-footnote-reference (ast) (let ((definitions - (org-element-map ast '(footnote-definition footnote-reference) - (lambda (f) - (and (or (eq 'footnote-definition (org-element-type f)) - (eq 'inline (org-element-property :type f))) - (org-element-property :label f)))))) + (org-element-map ast '(footnote-definition footnote-reference) + (lambda (f) + (and (or (org-element-type-p f 'footnote-definition) + (eq 'inline (org-element-property :type f))) + (org-element-property :label f)))))) (org-element-map ast 'footnote-reference (lambda (f) (let ((label (org-element-property :label f))) @@ -938,9 +938,10 @@ Use \"export %s\" instead" (let ((case-fold-search t) reports) (while (re-search-forward org-planning-line-re nil t) - (unless (memq (org-element-type (org-element-at-point)) - '(comment-block example-block export-block planning - src-block verse-block)) + (unless (org-element-type-p + (org-element-at-point) + '(comment-block example-block export-block planning + src-block verse-block)) (push (list (line-beginning-position) "Misplaced planning info line") reports))) reports)) @@ -976,9 +977,10 @@ Use \"export %s\" instead" (defun org-lint-indented-diary-sexp (_) (let (reports) (while (re-search-forward "^[ \t]+%%(" nil t) - (unless (memq (org-element-type (org-element-at-point)) - '(comment-block diary-sexp example-block export-block - src-block verse-block)) + (unless (org-element-type-p + (org-element-at-point) + '(comment-block diary-sexp example-block export-block + src-block verse-block)) (push (list (line-beginning-position) "Possible indented diary-sexp") reports))) reports)) @@ -996,10 +998,11 @@ Use \"export %s\" instead" (push (list (line-beginning-position) (format "Invalid block closing line \"%s\"" name)) reports)) - ((not (memq (org-element-type (org-element-at-point)) - '(center-block comment-block dynamic-block example-block - export-block quote-block special-block - src-block verse-block))) + ((not (org-element-type-p + (org-element-at-point) + '(center-block comment-block dynamic-block example-block + export-block quote-block special-block + src-block verse-block))) (push (list (line-beginning-position) (format "Possible incomplete block \"%s\"" name)) @@ -1035,8 +1038,8 @@ Use \"export %s\" instead" property-drawer section))) org-element-all-elements) (lambda (e) - (not (and (eq (org-element-type e) 'headline) - (org-element-property :commentedp e)))) + (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) "Extraneous elements in footnote section are not exported"))))) diff --git a/lisp/org-list.el b/lisp/org-list.el index d12db35ff..e22790726 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -111,15 +111,15 @@ (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-interpret-data "org-element" (data)) -(declare-function org-element-lineage "org-element" (blob &optional types with-self)) +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) (declare-function org-element-macro-interpreter "org-element" (macro ##)) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) (declare-function org-element-normalize-string "org-element" (s)) (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-put-property "org-element" (element property value)) -(declare-function org-element-set "org-element" (old new)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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)) (declare-function org-element-update-syntax "org-element" ()) (declare-function org-end-of-meta-data "org" (&optional full)) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) @@ -2380,7 +2380,7 @@ is an integer, 0 means `-', 1 means `+' etc. If WHICH is (when (org-match-line (org-item-re)) ;short-circuit (let* ((e (save-excursion (beginning-of-line) (org-element-at-point)))) ;; Check we're really on a line with a bullet. - (when (memq (org-element-type e) '(item plain-list)) + (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) @@ -2555,9 +2555,9 @@ With optional prefix argument ALL, do this for the whole buffer." (t (org-list-get-all-items (org-list-get-top-point s) s pre)))) (cookies (delq nil (mapcar - (lambda (e) - (org-list-get-checkbox e s)) - items)))) + (lambda (e) + (org-list-get-checkbox e s)) + items)))) (cl-incf c-all (length cookies)) (cl-incf c-on (cl-count "[X]" cookies :test #'equal))))))) cookies-list cache) @@ -2572,7 +2572,7 @@ With optional prefix argument ALL, do this for the whole buffer." (while (re-search-forward cookie-re end t) (let ((context (save-excursion (backward-char) (save-match-data (org-element-context))))) - (when (and (eq (org-element-type context) 'statistics-cookie) + (when (and (org-element-type-p context 'statistics-cookie) (not (string-match-p "\\" cookie-data))) (push (append @@ -2600,7 +2600,7 @@ With optional prefix argument ALL, do this for the whole buffer." structs) (while (re-search-forward box-re end t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'item) + (when (org-element-type-p element 'item) (push (org-element-property :structure element) structs) ;; Skip whole list since we have its @@ -2614,8 +2614,8 @@ With optional prefix argument ALL, do this for the whole buffer." ;; area. Then return it. (let ((count (funcall count-boxes - (and (eq (org-element-type container) - 'item) + (and (org-element-type-p + container 'item) (org-element-property :begin container)) structs @@ -3048,8 +3048,7 @@ With a prefix argument ARG, change the region in a single item." (save-excursion (while (re-search-forward org-footnote-definition-re end t) (setq element (org-element-at-point)) - (when (eq 'footnote-definition - (org-element-type element)) + (when (org-element-type-p element 'footnote-definition) (push (buffer-substring-no-properties (org-element-property :begin element) (org-element-property :end element)) @@ -3176,8 +3175,8 @@ With a prefix argument ARG, change the region in a single item." "[X]" "[ ]")) (org-list-write-struct struct - (org-list-parents-alist struct) - old))) + (org-list-parents-alist struct) + old))) ;; Ensure all text down to END (or SECTION-END) belongs ;; to the newly created item. (let ((section-end (save-excursion @@ -3472,7 +3471,7 @@ Valid parameters are: (defun org-list--depth (element) "Return the level of ELEMENT within current plain list. ELEMENT is either an item or a plain list." - (cl-count-if (lambda (ancestor) (eq (org-element-type ancestor) 'plain-list)) + (cl-count-if (lambda (ancestor) (org-element-type-p ancestor 'plain-list)) (org-element-lineage element nil t))) (defun org-list--trailing-newlines (string) diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 1b4872708..584689406 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -57,14 +57,15 @@ (declare-function org-collect-keywords "org" (keywords &optional unique directory)) (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-copy "org-element" (datum)) +(declare-function org-element-copy "org-element-ast" (datum)) (declare-function org-element-macro-parser "org-element" ()) (declare-function org-element-keyword-parser "org-element" (limit affiliated)) -(declare-function org-element-put-property "org-element" (element property value)) +(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" (property element)) +(declare-function org-element-property "org-element-ast" (property node)) (declare-function org-element-restriction "org-element" (element)) -(declare-function org-element-type "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)) (declare-function org-entry-get "org" (pom property &optional inherit literal-nil)) (declare-function org-file-contents "org" (file &optional noerror nocache)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance element)) @@ -352,7 +353,7 @@ in the buffer." (catch :exit (while (re-search-forward regexp nil t) (let ((element (org-with-point-at (match-beginning 0) (org-element-keyword-parser (line-end-position) (list (match-beginning 0)))))) - (when (eq 'keyword (org-element-type element)) + (when (org-element-type-p element 'keyword) (let ((value (org-element-property :value element))) (if (not collect) (throw :exit value) (setq result (concat result " " value))))))) @@ -366,7 +367,7 @@ Return value as a string." value (org-element-restriction 'keyword)))) (if (and (consp date) (not (cdr date)) - (eq 'timestamp (org-element-type (car date)))) + (org-element-type-p (car date) 'timestamp)) (format "(eval (if (org-string-nw-p $1) %s %S))" (format "(org-format-timestamp '%S $1)" (org-element-put-property diff --git a/lisp/org-pcomplete.el b/lisp/org-pcomplete.el index 15856baf7..c2fe76a08 100644 --- a/lisp/org-pcomplete.el +++ b/lisp/org-pcomplete.el @@ -39,8 +39,8 @@ (declare-function org-before-first-heading-p "org" ()) (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" property element) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" property 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)) (declare-function org-export-backend-options "ox" (cl-x) t) @@ -397,8 +397,7 @@ This needs more work, to handle headings with lots of spaces in them." (goto-char (point-min)) (while (re-search-forward org-drawer-regexp nil t) (let ((drawer (org-element-at-point))) - (when (memq (org-element-type drawer) - '(drawer property-drawer)) + (when (org-element-type-p drawer '(drawer property-drawer)) (push (org-element-property :drawer-name drawer) names) (goto-char (org-element-property :end drawer)))))) (pcomplete-uniquify-list names)))) diff --git a/lisp/org-src.el b/lisp/org-src.el index f15ba8e99..f0ae6aa16 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -48,11 +48,12 @@ (declare-function org-element-at-point "org-element" (&optional pom cached-only)) (declare-function org-element-class "org-element" (datum &optional parent)) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-lineage "org-element" +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) (declare-function org-element--parse-paired-brackets "org-element" (char)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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" (label &optional location)) @@ -1039,7 +1040,7 @@ A coderef format regexp can only match at the end of a line." (interactive) (let* ((context (org-element-context)) (label (org-element-property :label context))) - (unless (and (eq (org-element-type context) 'footnote-reference) + (unless (and (org-element-type-p context 'footnote-reference) (org-src--on-datum-p context)) (user-error "Not on a footnote reference")) (unless label (user-error "Cannot edit remotely anonymous footnotes")) @@ -1047,7 +1048,7 @@ A coderef format regexp can only match at the end of a line." (org-footnote-goto-definition label) (backward-char) (org-element-context))) - (inline? (eq 'footnote-reference (org-element-type definition))) + (inline? (org-element-type-p definition 'footnote-reference)) (contents (org-with-wide-buffer (buffer-substring-no-properties @@ -1106,7 +1107,7 @@ the area in the Org mode buffer. Throw an error when not at such a table." (interactive) (let ((element (org-element-at-point))) - (unless (and (eq (org-element-type element) 'table) + (unless (and (org-element-type-p element 'table) (eq (org-element-property :type element) 'table.el) (org-src--on-datum-p element)) (user-error "Not in a table.el table")) @@ -1122,7 +1123,7 @@ Throw an error when not at such a table." "Edit LaTeX fragment at point." (interactive) (let ((context (org-element-context))) - (unless (and (eq 'latex-fragment (org-element-type context)) + (unless (and (org-element-type-p context 'latex-fragment) (org-src--on-datum-p context)) (user-error "Not on a LaTeX fragment")) (let* ((contents @@ -1170,7 +1171,7 @@ will then replace the LaTeX environment in the Org mode buffer." (interactive) (let ((element (org-element-at-point))) - (unless (and (eq (org-element-type element) 'latex-environment) + (unless (and (org-element-type-p element 'latex-environment) (org-src--on-datum-p element)) (user-error "Not in a LaTeX environment")) (org-src--edit-element @@ -1194,7 +1195,7 @@ the area in the Org mode buffer. Throw an error when not at an export block." (interactive) (let ((element (org-element-at-point))) - (unless (and (eq (org-element-type element) 'export-block) + (unless (and (org-element-type-p element 'export-block) (org-src--on-datum-p element)) (user-error "Not in an export block")) (let* ((type (downcase (or (org-element-property :type element) @@ -1222,7 +1223,7 @@ then replace the area in the Org mode buffer. Throw an error when not at a comment block." (interactive) (let ((element (org-element-at-point))) - (unless (and (eq (org-element-type element) 'comment-block) + (unless (and (org-element-type-p element 'comment-block) (org-src--on-datum-p element)) (user-error "Not in a comment block")) (org-src--edit-element @@ -1286,7 +1287,7 @@ name of the sub-editing buffer." "Edit inline source code at point." (interactive) (let ((context (org-element-context))) - (unless (and (eq (org-element-type context) 'inline-src-block) + (unless (and (org-element-type-p context 'inline-src-block) (org-src--on-datum-p context)) (user-error "Not on inline source code")) (let* ((lang (org-element-property :language context)) @@ -1331,7 +1332,7 @@ will then replace the area in the Org mode buffer." (interactive) (let ((element (org-element-at-point))) - (unless (and (eq (org-element-type element) 'fixed-width) + (unless (and (org-element-type-p element 'fixed-width) (org-src--on-datum-p element)) (user-error "Not in a fixed-width area")) (org-src--edit-element diff --git a/lisp/org-table.el b/lisp/org-table.el index a33b8081f..78d9e3270 100644 --- a/lisp/org-table.el +++ b/lisp/org-table.el @@ -52,14 +52,14 @@ (declare-function org-duration-p "org-duration" (duration &optional canonical)) (declare-function org-duration-to-minutes "org-duration" (duration &optional canonical)) (declare-function org-element-at-point "org-element" (&optional pom cached-only)) -(declare-function org-element-contents "org-element" (element)) -(declare-function org-element-extract "org-element" (element)) +(declare-function org-element-contents "org-element-ast" (node)) +(declare-function org-element-extract "org-element-ast" (node)) (declare-function org-element-interpret-data "org-element" (data)) -(declare-function org-element-lineage "org-element" (blob &optional types with-self)) +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) (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)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-type "org-element" (element)) +(declare-function org-element-property "org-element-ast" (property 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)) (declare-function org-export-create-backend "ox" (&rest rest) t) @@ -754,7 +754,7 @@ Field is restored even in case of abnormal exit." (goto-char (or pos (point))) (beginning-of-line) (and (let ((case-fold-search t)) (looking-at org-TBLFM-regexp)) - (eq (org-element-type (org-element-at-point)) 'table)))) + (org-element-type-p (org-element-at-point) 'table)))) (defun org-at-table-p (&optional table-type) "Non-nil if the cursor is inside an Org table. @@ -769,7 +769,7 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables." "Non-nil when point is at a table.el table." (and (org-match-line "[ \t]*[|+]") (let ((element (org-element-at-point))) - (and (eq (org-element-type element) 'table) + (and (org-element-type-p element 'table) (eq (org-element-property :type element) 'table.el))))) (defun org-at-table-hline-p () @@ -5786,7 +5786,7 @@ This may be either a string or a function of two arguments: ignore) (org-element-map data (if special? '(table-cell table-row) 'table-row) (lambda (datum) - (when (if (eq (org-element-type datum) 'table-row) + (when (if (org-element-type-p datum 'table-row) (org-export-table-row-is-special-p datum nil) (org-export-first-sibling-p datum nil)) (push datum ignore)))) diff --git a/lisp/org.el b/lisp/org.el index 986c249a2..4f1512960 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -171,26 +171,27 @@ Stars are put in group 1 and the trimmed body in group 2.") (declare-function org-element-cache-refresh "org-element" (pos)) (declare-function org-element-cache-reset "org-element" (&optional all no-persistence)) (declare-function org-element-cache-map "org-element" (func &rest keys)) -(declare-function org-element-contents "org-element" (element)) +(declare-function org-element-contents "org-element-ast" (node)) (declare-function org-element-context "org-element" (&optional element)) -(declare-function org-element-copy "org-element" (datum)) -(declare-function org-element-create "org-element" (type &optional props &rest children)) -(declare-function org-element-extract "org-element" (element)) -(declare-function org-element-insert-before "org-element" (element location)) +(declare-function org-element-copy "org-element-ast" (datum)) +(declare-function org-element-create "org-element-ast" (type &optional props &rest children)) +(declare-function org-element-extract "org-element-ast" (node)) +(declare-function org-element-insert-before "org-element-ast" (node location)) (declare-function org-element-interpret-data "org-element" (data)) (declare-function org-element-keyword-parser "org-element" (limit affiliated)) -(declare-function org-element-lineage "org-element" (blob &optional types with-self)) +(declare-function org-element-lineage "org-element-ast" (blob &optional types with-self)) (declare-function org-element-link-parser "org-element" ()) (declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated)) (declare-function org-element-nested-p "org-element" (elem-a elem-b)) (declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only)) (declare-function org-element-parse-secondary-string "org-element" (string restriction &optional parent)) -(declare-function org-element-property "org-element" (property element)) -(declare-function org-element-put-property "org-element" (element property value)) +(declare-function org-element-property "org-element-ast" (property node)) +(declare-function org-element-put-property "org-element-ast" (node property value)) (declare-function org-element-restriction "org-element" (element)) (declare-function org-element-swap-A-B "org-element" (elem-a elem-b)) (declare-function org-element-timestamp-parser "org-element" ()) -(declare-function org-element-type "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)) (declare-function org-element--cache-active-p "org-element" ()) (declare-function org-export-dispatch "ox" (&optional arg)) (declare-function org-export-get-backend "ox" (name)) @@ -4410,7 +4411,7 @@ directory." (regexp (org-make-options-regexp keywords))) (while (and keywords (re-search-forward regexp nil t)) (let ((element (org-element-at-point))) - (when (eq 'keyword (org-element-type element)) + (when (org-element-type-p element 'keyword) (let ((value (org-element-property :value element))) (pcase (org-element-property :key element) ("SETUPFILE" @@ -6848,7 +6849,7 @@ Assume point is at a heading or an inlinetask beginning." ((looking-at-p "[ \t]*$") (forward-line)) ((and (looking-at-p org-footnote-definition-re) (let ((e (org-element-at-point))) - (and (eq (org-element-type e) 'footnote-definition) + (and (org-element-type-p e 'footnote-definition) (goto-char (org-element-property :end e)))))) ((looking-at-p org-outline-regexp) (forward-line)) ;; Give up if shifting would move before column 0 or @@ -6866,8 +6867,8 @@ Assume point is at a heading or an inlinetask beginning." (beginning-of-line) (or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") (let ((e (org-element-at-point))) - (and (memq (org-element-type e) - '(example-block src-block)) + (and (org-element-type-p + e '(example-block src-block)) (or org-src-preserve-indentation (org-element-property :preserve-indent e)) (goto-char (org-element-property :end e)) @@ -6882,7 +6883,7 @@ Assume point is at a heading or an inlinetask beginning." (cond ((and (looking-at-p org-footnote-definition-re) (let ((e (org-element-at-point))) - (and (eq (org-element-type e) 'footnote-definition) + (and (org-element-type-p e 'footnote-definition) (goto-char (org-element-property :end e)))))) ((looking-at-p org-outline-regexp) (forward-line)) ((looking-at-p "[ \t]*$") (forward-line)) @@ -6891,8 +6892,8 @@ Assume point is at a heading or an inlinetask beginning." (beginning-of-line) (or (and (looking-at-p "[ \t]*#\\+BEGIN_\\(EXAMPLE\\|SRC\\)") (let ((e (org-element-at-point))) - (and (memq (org-element-type e) - '(example-block src-block)) + (and (org-element-type-p + e '(example-block src-block)) (or org-src-preserve-indentation (org-element-property :preserve-indent e)) (goto-char (org-element-property :end e)) @@ -8025,19 +8026,19 @@ the whole buffer." (let ((case-fold-search t) (inhibit-read-only t) (default-category - (cond ((null org-category) - (if buffer-file-name - (file-name-sans-extension - (file-name-nondirectory buffer-file-name)) - "???")) - ((symbolp org-category) (symbol-name org-category)) - (t org-category)))) + (cond ((null org-category) + (if buffer-file-name + (file-name-sans-extension + (file-name-nondirectory buffer-file-name)) + "???")) + ((symbolp org-category) (symbol-name org-category)) + (t org-category)))) (let ((category (catch 'buffer-category (org-with-wide-buffer (goto-char (point-max)) (while (re-search-backward "^[ \t]*#\\+CATEGORY:" (point-min) t) (let ((element (org-element-at-point-no-context))) - (when (eq (org-element-type element) 'keyword) + (when (org-element-type-p element 'keyword) (throw 'buffer-category (org-element-property :value element)))))) default-category))) @@ -8538,7 +8539,9 @@ there is one, return it." (while (re-search-forward org-link-any-re end t) ;; Only consider valid links or links openable via ;; `org-open-at-point'. - (when (memq (org-element-type (org-element-context)) '(link comment comment-block node-property keyword)) + (when (org-element-type-p + (org-element-context) + '(link comment comment-block node-property keyword)) (push (match-string 0) links))) (setq links (org-uniquify (reverse links)))) (cond @@ -10307,8 +10310,7 @@ nil." ;; This is as accurate and faster than `org-element-at-point' since ;; planning info location is fixed in the section. (or (let ((cached (org-element-at-point nil 'cached))) - (and cached - (eq 'planning (org-element-type cached)))) + (and cached (org-element-type-p cached 'planning))) (org-with-wide-buffer (beginning-of-line) (and (looking-at-p org-planning-line-re) @@ -10468,7 +10470,7 @@ narrowing." ;; Try to find existing drawer. (while (re-search-forward regexp end t) (let ((element (org-element-at-point))) - (when (eq (org-element-type element) 'drawer) + (when (org-element-type-p element 'drawer) (let ((cend (org-element-property :contents-end element))) (when (and (not org-log-states-order-reversed) cend) (goto-char cend))) @@ -10678,7 +10680,7 @@ POS may also be a marker." (org-with-wide-buffer (goto-char pos) (let ((drawer (org-element-at-point))) - (when (and (memq (org-element-type drawer) '(drawer property-drawer)) + (when (and (org-element-type-p drawer '(drawer property-drawer)) (not (org-element-property :contents-begin drawer))) (delete-region (org-element-property :begin drawer) (progn (goto-char (org-element-property :end drawer)) @@ -12742,8 +12744,8 @@ strings." (let ((object (org-element-context))) ;; Accept to match timestamps in node ;; properties, too. - (when (memq (org-element-type object) - '(node-property timestamp)) + (when (org-element-type-p + object '(node-property timestamp)) (let ((type (org-element-property :type object))) (cond @@ -13195,7 +13197,7 @@ COLUMN formats in the current buffer." (goto-char (point-min)) (while (re-search-forward "^[ \t]*\\(?:#\\+\\|:\\)COLUMNS:" nil t) (let ((element (org-element-at-point))) - (when (memq (org-element-type element) '(keyword node-property)) + (when (org-element-type-p element '(keyword node-property)) (let ((value (org-element-property :value element)) (start 0)) (while (string-match "%[0-9]*\\([[:alnum:]_-]+\\)\\(([^)]+)\\)?\ @@ -13210,9 +13212,9 @@ COLUMN formats in the current buffer." ;; for each xxx_ALL property, make sure the bare ;; xxx property is also included (delq nil (mapcar (lambda (p) - (and (string-match-p "._ALL\\'" p) - (substring p 0 -4))) - props)))) + (and (string-match-p "._ALL\\'" p) + (substring p 0 -4))) + props)))) (lambda (a b) (string< (upcase a) (upcase b)))))) (defun org-property-values (key) @@ -14475,10 +14477,11 @@ both scheduled and deadline timestamps." (lambda () (let ((match (match-string 1))) (and (if (memq ts-type '(active inactive all)) - (eq (org-element-type (save-excursion - (backward-char) - (org-element-context))) - 'timestamp) + (org-element-type-p + (save-excursion + (backward-char) + (org-element-context)) + 'timestamp) (org-at-planning-p)) (time-less-p (org-time-string-to-time match) @@ -14497,14 +14500,15 @@ both scheduled and deadline timestamps." (lambda () (let ((match (match-string 1))) (and (if (memq ts-type '(active inactive all)) - (eq (org-element-type (save-excursion - (backward-char) - (org-element-context))) - 'timestamp) + (org-element-type-p + (save-excursion + (backward-char) + (org-element-context)) + 'timestamp) (org-at-planning-p)) (not (time-less-p - (org-time-string-to-time match) - (org-time-string-to-time d)))))))) + (org-time-string-to-time match) + (org-time-string-to-time d)))))))) (message "%d entries after %s" (org-occur regexp nil callback) d))) @@ -14521,14 +14525,15 @@ both scheduled and deadline timestamps." (let ((match (match-string 1))) (and (if (memq type '(active inactive all)) - (eq (org-element-type (save-excursion - (backward-char) - (org-element-context))) - 'timestamp) + (org-element-type-p + (save-excursion + (backward-char) + (org-element-context)) + 'timestamp) (org-at-planning-p)) (not (time-less-p - (org-time-string-to-time match) - (org-time-string-to-time start-date))) + (org-time-string-to-time match) + (org-time-string-to-time start-date))) (time-less-p (org-time-string-to-time match) (org-time-string-to-time end-date)))))))) @@ -14985,7 +14990,9 @@ When matching, the match groups are the following: (defun org-at-clock-log-p () "Non-nil if point is on a clock log line." (and (org-match-line org-clock-line-re) - (eq (org-element-type (save-match-data (org-element-at-point))) 'clock))) + (org-element-type-p + (save-match-data (org-element-at-point)) + 'clock))) (defvar org-clock-history) ; defined in org-clock.el (defvar org-clock-adjust-closest nil) ; defined in org-clock.el @@ -15770,8 +15777,9 @@ environment remains unintended." When optional argument ELEMENT is non-nil, it should be element/object at point." - (memq (org-element-type (or element (org-element-context))) - '(latex-fragment latex-environment))) + (org-element-type-p + (or element (org-element-context)) + '(latex-fragment latex-environment))) (defun org-inside-latex-macro-p () "Is point inside a LaTeX macro or its arguments?" @@ -15871,7 +15879,7 @@ fragments in the buffer." (message "Creating LaTeX previews in region... done.")) ;; Toggle preview on LaTeX code at point. ((let ((datum (org-element-context))) - (and (memq (org-element-type datum) '(latex-environment latex-fragment)) + (and (org-element-type-p datum '(latex-environment latex-fragment)) (let ((beg (org-element-property :begin datum)) (end (org-element-property :end datum))) (if (org-clear-latex-preview beg end) @@ -17634,7 +17642,7 @@ This command does many different things, depending on context: ;; line as an item, apply function on that item instead. (when (eq type 'paragraph) (let ((parent (org-element-property :parent context))) - (when (and (eq (org-element-type parent) 'item) + (when (and (org-element-type-p parent 'item) (= (line-beginning-position) (org-element-property :begin parent))) (setq context parent) @@ -18662,13 +18670,13 @@ When INSIDE is non-nil, don't consider we are within a source block when point is at #+BEGIN_SRC or #+END_SRC. When ELEMENT is provided, it is considered to be element at point." (save-match-data (setq element (or element (org-element-at-point)))) - (when (eq 'src-block (org-element-type element)) + (when (org-element-type-p element 'src-block) (or (not inside) (not (or (= (line-beginning-position) - (org-element-property :post-affiliated element)) - (= (1+ (line-end-position)) - (- (org-element-property :end element) - (org-element-property :post-blank element)))))))) + (org-element-property :post-affiliated element)) + (= (1+ (line-end-position)) + (- (org-element-property :end element) + (org-element-property :post-blank element)))))))) (defun org-context () "Return a list of contexts of the current cursor position. @@ -18978,11 +18986,11 @@ Optional argument ELEMENT contains element at BEG." (org-with-wide-buffer (when beg (goto-char beg)) (setq element (or element (org-element-at-point))) - (if (or (eq (org-element-type element) 'headline) + (if (or (org-element-type-p element 'headline) (not (org-element-lineage element '(headline inlinetask)))) nil ; Not inside heading. ;; Skip to top-level parent in section. - (while (not (eq 'section (org-element-type (org-element-property :parent element)))) + (while (not (org-element-type-p (org-element-property :parent element) 'section)) (setq element (org-element-property :parent element))) (pcase (org-element-type element) ((or `planning `property-drawer) @@ -19052,8 +19060,8 @@ ELEMENT." ((not previous) (throw 'exit 0)) ((> (org-element-property :end previous) start) (throw 'exit (org--get-expected-indentation previous t))) - ((memq (org-element-type previous) - '(footnote-definition inlinetask)) + ((org-element-type-p + previous '(footnote-definition inlinetask)) (setq start (org-element-property :begin previous))) ;; Do not indent like previous when the previous ;; element is headline data and `org-adapt-indentation' @@ -19109,7 +19117,7 @@ ELEMENT." (let ((last (org-element-at-point))) (goto-char pos) (org--get-expected-indentation - last (eq (org-element-type last) 'item))) + last (org-element-type-p last 'item))) (goto-char start) (current-indentation))) ;; In any other case, indent like the current line. @@ -19365,7 +19373,7 @@ assumed to be significant there." (looking-at-p org-drawer-regexp)) (user-error "Not at a drawer")) (let ((element (org-element-at-point-no-context))) - (unless (memq (org-element-type element) '(drawer property-drawer)) + (unless (org-element-type-p element '(drawer property-drawer)) (user-error "Not at a drawer")) (org-with-wide-buffer (org-indent-region (org-element-property :begin element) @@ -19381,10 +19389,11 @@ assumed to be significant there." (looking-at-p "[ \t]*#\\+\\(begin\\|end\\)_"))) (user-error "Not at a block")) (let ((element (org-element-at-point-no-context))) - (unless (memq (org-element-type element) - '(comment-block center-block dynamic-block example-block - export-block quote-block special-block - src-block verse-block)) + (unless (org-element-type-p + element + '(comment-block center-block dynamic-block example-block + export-block quote-block special-block + src-block verse-block)) (user-error "Not at a block")) (org-with-wide-buffer (org-indent-region (org-element-property :begin element) @@ -19479,7 +19488,7 @@ matches in paragraphs or comments, use it." (let ((parent (org-element-property :parent element))) (save-excursion (beginning-of-line) - (cond ((eq (org-element-type parent) 'item) + (cond ((org-element-type-p parent 'item) (make-string (org-list-item-body-column (org-element-property :begin parent)) ?\s)) @@ -19564,10 +19573,10 @@ a footnote definition, try to fill the first paragraph within." (goto-char beg) (let ((cuts (list beg))) (while (re-search-forward "\\\\\\\\[ \t]*\n" end t) - (when (eq 'line-break - (org-element-type - (save-excursion (backward-char) - (org-element-context)))) + (when (org-element-type-p + (save-excursion (backward-char) + (org-element-context)) + 'line-break) (push (point) cuts))) (dolist (c (delq end cuts)) (fill-region-as-paragraph c end justify) @@ -19779,7 +19788,7 @@ region only contains such lines." (when (eobp) (throw 'not-all-p nil)) (while (< (point) end) (let ((element (org-element-at-point))) - (if (eq (org-element-type element) 'fixed-width) + (if (org-element-type-p element 'fixed-width) (goto-char (org-element-property :end element)) (throw 'not-all-p nil)))) t)))) @@ -19820,7 +19829,7 @@ region only contains such lines." ((looking-at-p "[ \t]*:\\( \\|$\\)") (let* ((element (org-element-at-point)) (element-end (org-element-property :end element))) - (if (eq (org-element-type element) 'fixed-width) + (if (org-element-type-p element 'fixed-width) (progn (goto-char element-end) (skip-chars-backward " \r\t\n") (forward-line)) @@ -19876,12 +19885,13 @@ Throw an error if no block is found." (let ((element (save-excursion (goto-char (match-beginning 0)) (save-match-data (org-element-at-point))))) - (when (and (memq (org-element-type element) - '(center-block comment-block dynamic-block - example-block export-block quote-block - special-block src-block verse-block)) + (when (and (org-element-type-p + element + '(center-block comment-block dynamic-block + example-block export-block quote-block + special-block src-block verse-block)) (<= (match-beginning 0) - (org-element-property :post-affiliated element))) + (org-element-property :post-affiliated element))) (setq last-element element) (cl-decf count)))) (if (= count 0) @@ -19931,7 +19941,7 @@ If the line is empty, insert comment at its beginning. When point is within a source block, comment according to the related major mode." (if (let ((element (org-element-at-point))) - (and (eq (org-element-type element) 'src-block) + (and (org-element-type-p element 'src-block) (< (save-excursion (goto-char (org-element-property :post-affiliated element)) (line-end-position)) @@ -19955,7 +19965,7 @@ Uncomment each non-blank line between BEG and END if it only contains commented lines. Otherwise, comment them. If region is strictly within a source block, use appropriate comment syntax." (if (let ((element (org-element-at-point))) - (and (eq (org-element-type element) 'src-block) + (and (org-element-type-p element 'src-block) (< (save-excursion (goto-char (org-element-property :post-affiliated element)) (line-end-position)) @@ -19987,7 +19997,7 @@ strictly within a source block, use appropriate comment syntax." (goto-char (point-min)) (while (and (not (eobp)) (let ((element (org-element-at-point))) - (and (eq (org-element-type element) 'comment) + (and (org-element-type-p element 'comment) (goto-char (min (point-max) (org-element-property :end element))))))) @@ -20232,8 +20242,9 @@ With argument N not nil or 1, move forward N - 1 lines first." (when (or (> origin refpos) (= origin bol)) (goto-char refpos))))) ((and (looking-at org-list-full-item-re) - (memq (org-element-type (save-match-data (org-element-at-point))) - '(item plain-list))) + (org-element-type-p + (save-match-data (org-element-at-point)) + '(item plain-list))) ;; Set special position at first white space character after ;; bullet, and check-box, if any. (let ((after-bullet @@ -20771,7 +20782,7 @@ return nil." '(headline inlinetask org-data) t))) (when heading - (unless (or (eq 'inlinetask (org-element-type heading)) + (unless (or (org-element-type-p heading 'inlinetask) (not (org-element-property :contents-begin heading))) (let ((pos (point))) (goto-char (org-element-property :contents-begin heading)) @@ -20828,7 +20839,7 @@ If there is no such heading, return nil." (unless (and (org-element--cache-active-p) (let ((cached (or element (org-element-at-point nil t)))) (and cached - (eq 'headline (org-element-type cached)) + (org-element-type-p cached 'headline) (goto-char (org-element-property :end cached))))) (let ((first t) @@ -21082,8 +21093,9 @@ Function may return a real element, or a pseudo-element with type ;; Find the full plain list containing point, the check it ;; contains exactly one line per item. ((let ((l (org-element-lineage e '(plain-list) t))) - (while (memq (org-element-type (org-element-property :parent l)) - '(item plain-list)) + (while (org-element-type-p + (org-element-property :parent l) + '(item plain-list)) (setq l (org-element-property :parent l))) (and l org--single-lines-list-is-paragraph (org-with-point-at (org-element-property :post-affiliated l) @@ -21218,7 +21230,7 @@ See `org-backward-paragraph'." ;; At the beginning of the first element within a greater ;; element. Move to the beginning of the greater element. ((and parent - (not (eq 'section (org-element-type parent))) + (not (org-element-type-p parent 'section)) (= begin (org-element-property :contents-begin parent))) (funcall reach (org-element-property :begin parent))) ;; Since we have to move anyway, find the beginning @@ -21328,10 +21340,10 @@ Move to the previous element at the same level, when possible." (let* ((elem (org-element-at-point)) (parent (org-element-property :parent elem))) ;; Skip sections - (when (eq 'section (org-element-type parent)) + (when (org-element-type-p parent 'section) (setq parent (org-element-property :parent parent))) (if (and parent - (not (eq (org-element-type parent) 'org-data))) + (not (org-element-type-p parent 'org-data))) (goto-char (org-element-property :begin parent)) (if (org-with-limited-levels (org-before-first-heading-p)) (user-error "No surrounding element") @@ -21342,10 +21354,10 @@ Move to the previous element at the same level, when possible." (interactive) (let ((element (org-element-at-point))) (cond - ((memq (org-element-type element) '(plain-list table)) + ((org-element-type-p element '(plain-list table)) (goto-char (org-element-property :contents-begin element)) (forward-char)) - ((memq (org-element-type element) org-element-greater-elements) + ((org-element-type-p element org-element-greater-elements) ;; If contents are hidden, first disclose them. (when (org-invisible-p (line-end-position)) (org-cycle)) (goto-char (or (org-element-property :contents-begin element) @@ -21357,7 +21369,7 @@ Move to the previous element at the same level, when possible." (interactive) (let ((elem (or (org-element-at-point) (user-error "No element at point")))) - (if (eq (org-element-type elem) 'headline) + (if (org-element-type-p elem 'headline) ;; Preserve point when moving a whole tree, even if point was ;; on blank lines below the headline. (let ((offset (skip-chars-backward " \t\n"))) @@ -21395,8 +21407,8 @@ Move to the previous element at the same level, when possible." (goto-char (org-element-property :end elem)) (let ((next-elem (org-element-at-point))) (when (or (org-element-nested-p elem next-elem) - (and (eq (org-element-type next-elem) 'headline) - (not (eq (org-element-type elem) 'headline)))) + (and (org-element-type-p next-elem 'headline) + (not (org-element-type-p elem 'headline)))) (goto-char pos) (user-error "Cannot drag element forward")) ;; Compute new position of point: it's shifted by NEXT-ELEM @@ -21498,7 +21510,7 @@ modified." (unindent-tree (lambda (contents) (dolist (element (reverse contents)) - (if (memq (org-element-type element) '(headline section)) + (if (org-element-type-p element '(headline section)) (funcall unindent-tree (org-element-contents element)) (save-excursion (save-restriction diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el index 1a63a34b1..410ca05dd 100644 --- a/lisp/ox-ascii.el +++ b/lisp/ox-ascii.el @@ -507,7 +507,7 @@ that is according to the widest non blank line in CONTENTS." (let ((text-width (org-ascii--current-text-width element info)) (how (org-ascii--current-justification element))) (cond - ((eq (org-element-type element) 'paragraph) + ((org-element-type-p element 'paragraph) ;; Paragraphs are treated specially as they need to be filled. (org-ascii--fill-string contents text-width info how)) ((eq how 'left) contents) @@ -575,7 +575,7 @@ INFO is a plist used as a communication channel." ;; inline task among ELEMENT parents. (total-width (if (cl-some (lambda (parent) - (eq (org-element-type parent) 'inlinetask)) + (org-element-type-p parent 'inlinetask)) genealogy) (plist-get info :ascii-inlinetask-width) ;; No inlinetask: Remove global margin from text width. @@ -596,8 +596,8 @@ INFO is a plist used as a communication channel." ;; Each `quote-block' and `verse-block' above narrows text ;; width by twice the standard margin size. (+ (* (cl-count-if (lambda (parent) - (memq (org-element-type parent) - '(quote-block verse-block))) + (org-element-type-p + parent '(quote-block verse-block))) genealogy) 2 (plist-get info :ascii-quote-margin)) @@ -605,9 +605,9 @@ INFO is a plist used as a communication channel." ;; containing current line (* (cl-count-if (lambda (e) - (and (eq (org-element-type e) 'plain-list) - (not (eq (org-element-type (org-export-get-parent e)) - 'item)))) + (and (org-element-type-p e 'plain-list) + (not (org-element-type-p + (org-export-get-parent e) 'item)))) genealogy) (plist-get info :ascii-list-margin)) ;; Compute indentation offset due to current list. It is @@ -616,7 +616,7 @@ INFO is a plist used as a communication channel." (let ((indentation 0)) (dolist (e genealogy) (cond - ((not (eq 'item (org-element-type e)))) + ((not (org-element-type-p e 'item))) ((eq (org-element-property :type (org-export-get-parent e)) 'descriptive) (cl-incf indentation org-ascii-quote-margin)) @@ -660,7 +660,7 @@ the title. When optional argument TOC is non-nil, use optional title if possible. It doesn't apply to `inlinetask' elements." - (let* ((headlinep (eq (org-element-type element) 'headline)) + (let* ((headlinep (org-element-type-p element 'headline)) (numbers ;; Numbering is specific to headlines. (and headlinep @@ -886,7 +886,7 @@ is a plist used as a communication channel." (gethash link (plist-get info :exported-data))) (not (member footprint seen))) (push footprint seen) link))))) - (org-element-map (if (eq (org-element-type element) 'section) + (org-element-map (if (org-element-type-p element 'section) element ;; In a headline, only retrieve links in title ;; and relative section, not in children. @@ -1118,7 +1118,7 @@ holding export options." ;; paragraph (FIRST), if any, to be sure ;; filling will take it into consideration. (let ((first (car (org-element-contents def)))) - (if (not (eq (org-element-type first) 'paragraph)) + (if (not (org-element-type-p first 'paragraph)) (concat id "\n" (org-export-data def info)) (push id (nthcdr 2 first)) (org-export-data def info))) @@ -1338,7 +1338,7 @@ holding contextual information." (if (not (org-string-nw-p links)) contents (let* ((contents (org-element-contents headline)) (section (let ((first (car contents))) - (and (eq (org-element-type first) 'section) + (and (org-element-type-p first 'section) first)))) (concat (and section (concat (org-element-normalize-string @@ -1655,8 +1655,8 @@ the plist used as a communication channel." (concat ;; Do not indent first paragraph in a section. (unless (and (not (org-export-get-previous-element paragraph info)) - (eq (org-element-type (org-export-get-parent paragraph)) - 'section)) + (org-element-type-p + (org-export-get-parent paragraph) 'section)) (make-string indented-line-width ?\s)) (replace-regexp-in-string "\\`[ \t]+" "" contents)))) paragraph info)) @@ -1670,7 +1670,7 @@ CONTENTS is the contents of the list. INFO is a plist holding contextual information." (let ((margin (plist-get info :ascii-list-margin))) (if (or (< margin 1) - (eq (org-element-type (org-export-get-parent plain-list)) 'item)) + (org-element-type-p (org-export-get-parent plain-list) 'item)) contents (org-ascii--indent-string contents margin)))) @@ -2070,8 +2070,8 @@ See `org-ascii-paragraph-spacing' for information." (when (wholenump paragraph-spacing) (org-element-map tree 'paragraph (lambda (p) - (when (eq (org-element-type (org-export-get-next-element p info)) - 'paragraph) + (when (org-element-type-p + (org-export-get-next-element p info) 'paragraph) (org-element-put-property p :post-blank paragraph-spacing)))))) tree) @@ -2082,8 +2082,9 @@ backend used for export. INFO is a plist used as a communication channel." (org-element-map tree '(comment comment-block) (lambda (c) - (when (memq (org-element-type (org-export-get-next-element c info)) - '(comment comment-block)) + (when (org-element-type-p + (org-export-get-next-element c info) + '(comment comment-block)) (org-element-put-property c :post-blank 0)))) tree) diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index 899f750b2..2f83a6766 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -222,7 +222,7 @@ An element has an overlay specification when it starts with an `beamer' export-snippet whose value is between angular brackets. Return overlay specification, as a string, or nil." (let ((first-object (car (org-element-contents element)))) - (when (eq (org-element-type first-object) 'export-snippet) + (when (org-element-type-p first-object 'export-snippet) (let ((value (org-element-property :value first-object))) (and (string-prefix-p "<" value) (string-suffix-p ">" value) value))))) @@ -695,7 +695,7 @@ contextual information." (lambda (item _c _i) (let ((action (let ((first (car (org-element-contents item)))) - (and (eq (org-element-type first) 'paragraph) + (and (org-element-type-p first 'paragraph) (org-beamer--element-has-overlay-p first)))) (output (org-latex-item item contents info))) (if (not (and action (string-match "\\\\item" output))) output diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 58c8cad9b..2e1ca5054 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2721,7 +2721,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (concat ;; Insert separator between two footnotes in a row. (let ((prev (org-export-get-previous-element footnote-reference info))) - (when (eq (org-element-type prev) 'footnote-reference) + (when (org-element-type-p prev 'footnote-reference) (plist-get info :html-footnote-separator))) (let* ((n (org-export-get-footnote-number footnote-reference info)) (id (format "fnr.%d%s" @@ -2805,7 +2805,7 @@ holding contextual information." ;; empty one to get the correct
\(\betax\). (org-element-put-property last :post-blank 1) (setq last next) diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 7c0cb649a..a8126e936 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -166,11 +166,11 @@ Assume BACKEND is `md'." (lambda (e) (org-element-put-property e :post-blank - (if (and (eq (org-element-type e) 'paragraph) - (eq (org-element-type (org-element-property :parent e)) 'item) + (if (and (org-element-type-p e 'paragraph) + (org-element-type-p (org-element-property :parent e) 'item) (org-export-first-sibling-p e info) (let ((next (org-export-get-next-element e info))) - (and (eq (org-element-type next) 'plain-list) + (and (org-element-type-p next 'plain-list) (not (org-export-get-next-element next info))))) 0 1)))) @@ -195,7 +195,7 @@ of contents can refer to headlines." (lambda (h) (let ((section (car (org-element-contents h)))) (and - (eq 'section (org-element-type section)) + (org-element-type-p section 'section) (org-element-map section 'keyword (lambda (keyword) (when (equal "TOC" (org-element-property :key keyword)) diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index 587c8fd2b..62b2902f4 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -1307,7 +1307,7 @@ original parsed data. INFO is a plist holding export options." ;; today's date. (let* ((date (let ((date (plist-get info :date))) (and (not (cdr date)) - (eq (org-element-type (car date)) 'timestamp) + (org-element-type-p (car date) 'timestamp) (car date))))) (let ((iso-date (org-odt--format-timestamp date nil 'iso-date))) (concat @@ -1515,7 +1515,7 @@ original parsed data. INFO is a plist holding export options." (let* ((date (plist-get info :date)) ;; Check if DATE is specified as a timestamp. (timestamp (and (not (cdr date)) - (eq (org-element-type (car date)) 'timestamp) + (org-element-type-p (car date) 'timestamp) (car date)))) (when date (concat @@ -1569,8 +1569,9 @@ channel." (let ((timestamp (org-element-property :value clock)) (duration (org-element-property :duration clock))) (format "\n%s" - (if (eq (org-element-type (org-export-get-next-element clock info)) - 'clock) "OrgClock" "OrgClockLastLine") + (if (org-element-type-p + (org-export-get-next-element clock info) 'clock) + "OrgClock" "OrgClockLastLine") (concat (format "%s" "OrgClockKeyword" org-clock-string) @@ -1688,7 +1689,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (concat ;; Insert separator between two footnotes in a row. (let ((prev (org-export-get-previous-element footnote-reference info))) - (and (eq (org-element-type prev) 'footnote-reference) + (and (org-element-type-p prev 'footnote-reference) (format "%s" "OrgSuperscript" ","))) ;; Transcode footnote reference. @@ -2034,7 +2035,7 @@ CONTENTS is nil. INFO is a plist holding contextual information." (let* ((--numbered-parent-headline-at-<=-n (lambda (element n info) (cl-loop for x in (org-element-lineage element) - thereis (and (eq (org-element-type x) 'headline) + thereis (and (org-element-type-p x 'headline) (<= (org-export-get-relative-level x info) n) (org-export-numbered-headline-p x info) x)))) @@ -2077,7 +2078,7 @@ the generated string. Return value is a string if OP is set to `reference' or a cons cell like CAPTION . SHORT-CAPTION) where CAPTION and SHORT-CAPTION are strings." - (cl-assert (memq (org-element-type element) '(link table src-block paragraph))) + (cl-assert (org-element-type-p element '(link table src-block paragraph))) (let* ((element-or-parent (cl-case (org-element-type element) (link (org-export-get-parent-element element)) @@ -2242,7 +2243,7 @@ SHORT-CAPTION are strings." "Return ODT code for an inline image. LINK is the link pointing to the inline image. INFO is a plist used as a communication channel." - (cl-assert (eq (org-element-type element) 'link)) + (cl-assert (org-element-type-p element 'link)) (let* ((src (let* ((type (org-element-property :type element)) (raw-path (org-element-property :path element))) (cond ((member type '("http" "https")) @@ -2504,7 +2505,7 @@ used as a communication channel." (org-element-property :name p)))) ;; Link should point to an image file. (lambda (l) - (cl-assert (eq (org-element-type l) 'link)) + (cl-assert (org-element-type-p l 'link)) (org-export-inline-image-p l (plist-get info :odt-inline-image-rules))))) (defun org-odt--enumerable-latex-image-p (element info) @@ -2519,7 +2520,7 @@ used as a communication channel." (org-element-property :name p)))) ;; Link should point to an image file. (lambda (l) - (cl-assert (eq (org-element-type l) 'link)) + (cl-assert (org-element-type-p l 'link)) (org-export-inline-image-p l (plist-get info :odt-inline-image-rules))))) (defun org-odt--enumerable-formula-p (element info) @@ -2531,7 +2532,7 @@ used as a communication channel." (org-element-property :name p))) ;; Link should point to a MathML or ODF file. (lambda (l) - (cl-assert (eq (org-element-type l) 'link)) + (cl-assert (org-element-type-p l 'link)) (org-export-inline-image-p l (plist-get info :odt-inline-formula-rules))))) (defun org-odt--standalone-link-p (element _info &optional @@ -2556,7 +2557,7 @@ Return nil, otherwise." (funcall link-predicate element)) (org-export-get-parent element))) (t nil)))) - (when (and p (eq (org-element-type p) 'paragraph)) + (when (and p (org-element-type-p p 'paragraph)) (when (or (not paragraph-predicate) (funcall paragraph-predicate p)) (let ((contents (org-element-contents p))) @@ -2587,20 +2588,19 @@ Return nil, otherwise." ;; FIXME: Handle footnote-definition footnote-reference? (let* ((genealogy (org-element-lineage destination)) (data (reverse genealogy)) - (label (let ((type (org-element-type destination))) - (if (memq type '(headline target)) - (org-export-get-reference destination info) - (error "FIXME: Unable to resolve %S" destination))))) + (label (if (org-element-type-p destination '(headline target)) + (org-export-get-reference destination info) + (error "FIXME: Unable to resolve %S" destination)))) (or (let* ( ;; Locate top-level list. (top-level-list (cl-loop for x on data - when (eq (org-element-type (car x)) 'plain-list) + when (org-element-type-p (car x) 'plain-list) return x)) ;; Get list item nos. (item-numbers (cl-loop for (plain-list item . rest) on top-level-list by #'cddr - until (not (eq (org-element-type plain-list) 'plain-list)) + until (not (org-element-type-p plain-list 'plain-list)) collect (when (eq (org-element-property :type plain-list) 'ordered) @@ -2609,13 +2609,13 @@ Return nil, otherwise." ;; Locate top-most listified headline. (listified-headlines (cl-loop for x on data - when (and (eq (org-element-type (car x)) 'headline) + when (and (org-element-type-p (car x) 'headline) (org-export-low-level-p (car x) info)) return x)) ;; Get listified headline numbers. (listified-headline-nos (cl-loop for el in listified-headlines - when (eq (org-element-type el) 'headline) + when (org-element-type-p el 'headline) collect (when (org-export-numbered-headline-p el info) (1+ (length (org-export-get-previous-element el info t))))))) @@ -2638,7 +2638,7 @@ Return nil, otherwise." ;; Test if destination is a numbered headline. (org-export-numbered-headline-p destination info) (cl-loop for el in (cons destination genealogy) - when (and (eq (org-element-type el) 'headline) + when (and (org-element-type-p el 'headline) (not (org-export-low-level-p el info)) (org-export-numbered-headline-p el info)) return el)))) @@ -2651,7 +2651,7 @@ Return nil, otherwise." ;; Case 4: Locate a regular headline in the hierarchy. Display ;; its title. (let ((headline (cl-loop for el in (cons destination genealogy) - when (and (eq (org-element-type el) 'headline) + when (and (org-element-type-p el 'headline) (not (org-export-low-level-p el info))) return el))) ;; We found one. @@ -2780,7 +2780,7 @@ INFO is a plist holding contextual information. See ;; Check if description is a link to an inline image. (if (and (not (cdr link-contents)) (let ((desc-element (car link-contents))) - (and (eq (org-element-type desc-element) 'link) + (and (org-element-type-p desc-element 'link) (org-export-inline-image-p desc-element (plist-get info :odt-inline-image-rules))))) @@ -2818,8 +2818,8 @@ information." Style is a symbol among `quoted', `centered' and nil." (let ((up paragraph)) (while (and (setq up (org-element-property :parent up)) - (not (memq (org-element-type up) - '(center-block quote-block section))))) + (not (org-element-type-p + up '(center-block quote-block section))))) (cl-case (org-element-type up) (center-block 'centered) (quote-block 'quoted)))) @@ -2840,7 +2840,7 @@ no special environment, a center block, or a quote block." ;; a checkbox, splice checkbox and paragraph contents ;; together. (concat (let ((parent (org-element-property :parent paragraph))) - (and (eq (org-element-type parent) 'item) + (and (org-element-type-p parent 'item) (not (org-export-get-previous-element paragraph info)) (org-odt--checkbox parent))) contents))) @@ -2873,7 +2873,7 @@ contextual information." ;; continue numbering. (format "text:continue-numbering=\"%s\"" (let* ((parent (org-export-get-parent plain-list))) - (if (and parent (eq (org-element-type parent) 'item)) + (if (and parent (org-element-type-p parent 'item)) "true" "false"))) contents)) @@ -3469,21 +3469,20 @@ pertaining to indentation here." (let* ((--element-preceded-by-table-p (lambda (element info) (cl-loop for el in (org-export-get-previous-element element info t) - thereis (eq (org-element-type el) 'table)))) + thereis (org-element-type-p el 'table)))) (--walk-list-genealogy-and-collect-tags (lambda (table info) (let* ((genealogy (org-element-lineage table)) (list-genealogy - (when (eq (org-element-type (car genealogy)) 'item) + (when (org-element-type-p (car genealogy) 'item) (cl-loop for el in genealogy - when (memq (org-element-type el) - '(item plain-list)) + when (org-element-type-p el '(item plain-list)) collect el))) (llh-genealogy (apply #'nconc (cl-loop for el in genealogy - when (and (eq (org-element-type el) 'headline) + when (and (org-element-type-p el 'headline) (org-export-low-level-p el info)) collect (list el @@ -3540,7 +3539,7 @@ pertaining to indentation here." ((let ((section? (org-export-get-previous-element parent-list info))) (and section? - (eq (org-element-type section?) 'section) + (org-element-type-p section? 'section) (assq 'table (org-element-contents section?)))) '("" . "")) (t @@ -3786,7 +3785,7 @@ contextual information." (goto-char (point-min)) (skip-chars-forward " \t\n") (org-element-link-parser)))) - (if (not (eq 'link (org-element-type link))) + (if (not (org-element-type-p link 'link)) (message "LaTeX Conversion failed.") ;; Conversion succeeded. Parse above Org-style link to ;; a `link' object. @@ -3798,7 +3797,7 @@ contextual information." ;; attributes, captions to the enclosing ;; paragraph. (latex-environment - (org-element-adopt-elements + (org-element-adopt (list 'paragraph (list :style "OrgFormula" :name @@ -3863,18 +3862,18 @@ contextual information." (when (eq (org-element-property :type el) 'descriptive) (org-element-set el - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'plain-list (list :type 'descriptive-1)) (mapcar (lambda (item) - (org-element-adopt-elements + (org-element-adopt (list 'item (list :checkbox (org-element-property :checkbox item))) (list 'paragraph (list :style "Text_20_body_20_bold") (or (org-element-property :tag item) "(no term)")) - (org-element-adopt-elements + (org-element-adopt (list 'plain-list (list :type 'descriptive-2)) - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'item nil) (org-element-contents item))))) (org-element-contents el))))) @@ -3931,7 +3930,7 @@ contextual information." (org-element-set l1-list ;; Build replacement table. - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'table '(:type org :attr_odt (":style \"GriddedTable\""))) (org-element-map l1-list 'item (lambda (l1-item) @@ -3940,8 +3939,8 @@ contextual information." ;; Remove Level-2 list from the Level-item. It ;; will be subsequently attached as table-cells. (let ((cur l1-item-contents) prev) - (while (and cur (not (eq (org-element-type (car cur)) - 'plain-list))) + (while (and cur (not (org-element-type-p + (car cur) 'plain-list))) (setq prev cur) (setq cur (cdr cur))) (when prev @@ -3949,18 +3948,18 @@ contextual information." (setq l2-list (car cur))) (setq l1-item-leading-text l1-item-contents)) ;; Level-1 items start a table row. - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'table-row (list :type 'standard)) ;; Leading text of level-1 item define ;; the first table-cell. - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'table-cell nil) l1-item-leading-text) ;; Level-2 items define subsequent ;; table-cells of the row. (org-element-map l2-list 'item (lambda (l2-item) - (apply 'org-element-adopt-elements + (apply 'org-element-adopt (list 'table-cell nil) (org-element-contents l2-item))) info nil 'item)))) diff --git a/lisp/ox-org.el b/lisp/ox-org.el index 681b95d68..6aef03ed9 100644 --- a/lisp/ox-org.el +++ b/lisp/ox-org.el @@ -129,7 +129,7 @@ we make sure it is always called." (new-section (org-element-create 'section))) (pcase (org-element-type first-child) (`section nil) - (`nil (org-element-adopt-elements h new-section)) + (`nil (org-element-adopt h new-section)) (_ (org-element-insert-before new-section first-child)))))) tree) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 7084fbc7d..5c9bf5f89 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -1305,7 +1305,7 @@ the file including them will be republished as well." (goto-char (point-min)) (while (re-search-forward "^[ \t]*#\\+INCLUDE:" nil t) (let ((element (org-element-at-point))) - (when (eq 'keyword (org-element-type element)) + (when (org-element-type-p element 'keyword) (let* ((value (org-element-property :value element)) (include-filename (and (string-match "\\`\\(\".+?\"\\|\\S-+\\)" value) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index b3c6c4acb..461acd292 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -501,7 +501,7 @@ Return new tree." (when contents (let ((first (org-element-map contents '(headline section) #'identity info t))) - (unless (eq (org-element-type first) 'section) + (unless (org-element-type-p first 'section) (apply #'org-element-set-contents hl (cons `(section (:parent ,hl)) contents))))))) @@ -1046,7 +1046,7 @@ plist holding contextual information." ;; character before the closing brace. However, when the ;; footnote ends with a paragraph, it is visually pleasing ;; to move the brace right after its end. - (if (eq 'paragraph (org-element-type (org-last contents))) + (if (org-element-type-p (org-last contents) 'paragraph) (org-trim data) data)))) @@ -1350,9 +1350,10 @@ INFO is a plist holding contextual information. See ;; @anchor{}, so we refer to the headline parent ;; directly. (and `target - (guard (eq 'headline - (org-element-type - (org-element-property :parent destination)))))) + (guard + (org-element-type-p + (org-element-property :parent destination) + 'headline)))) (let ((headline (org-element-lineage destination '(headline) t))) (org-texinfo--@ref headline desc info))) (_ (org-texinfo--@ref destination desc info))))) diff --git a/lisp/ox.el b/lisp/ox.el index 52b07305d..d3bcb426c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1705,7 +1705,7 @@ OPTIONS is a plist holding export options." (catch 'exit (let ((min-level 10000)) (dolist (datum (org-element-contents data)) - (when (and (eq (org-element-type datum) 'headline) + (when (and (org-element-type-p datum 'headline) (not (org-element-property :footnote-section-p datum)) (not (memq datum (plist-get options :ignore-list)))) (setq min-level (min (org-element-property :level datum) min-level)) @@ -1821,7 +1821,7 @@ not exported." (archived (plist-get options :with-archived-trees)) (tags (org-export-get-tags datum options nil t))) (or - (and (eq (org-element-type datum) 'inlinetask) + (and (org-element-type-p datum 'inlinetask) (not (plist-get options :with-inlinetasks))) ;; Ignore subtrees with an exclude tag. (cl-some (lambda (tag) (member tag excluded)) tags) @@ -1844,7 +1844,7 @@ not exported." (cond ((null properties-set) t) ((consp properties-set) (not (member-ignore-case (org-element-property :key datum) - properties-set)))))) + properties-set)))))) (planning (not (plist-get options :with-planning))) (property-drawer (not (plist-get options :with-properties))) (statistics-cookie (not (plist-get options :with-statistics-cookies))) @@ -1859,13 +1859,13 @@ not exported." ;; objects, i.e. timestamp objects in a paragraph containing only ;; timestamps and whitespaces. (when (let ((parent (org-export-get-parent-element datum))) - (and (memq (org-element-type parent) '(paragraph verse-block)) + (and (org-element-type-p parent '(paragraph verse-block)) (not (org-element-map parent (cons 'plain-text - (remq 'timestamp org-element-all-objects)) - (lambda (obj) + (remq 'timestamp org-element-all-objects)) + (lambda (obj) (or (not (stringp obj)) (org-string-nw-p obj))) - options t)))) + options t)))) (cl-case (plist-get options :with-timestamps) ((nil) t) (active @@ -1983,8 +1983,8 @@ Return a string." ;; first line's indentation. (and (eq type 'paragraph) - (memq (org-element-type parent) - '(footnote-definition item)) + (org-element-type-p + parent '(footnote-definition item)) (eq (car (org-element-contents parent)) data) (eq (org-element-property :pre-blank parent) @@ -2812,21 +2812,21 @@ from tree." org-element-secondary-value-alist))) (mapc walk-data (org-element-property p data)))))))) (definitions - ;; Collect definitions before possibly pruning them so as - ;; to avoid parsing them again if they are required. - (org-element-map data '(footnote-definition footnote-reference) - (lambda (f) - (cond - ((eq 'footnote-definition (org-element-type f)) f) - ((and (eq 'inline (org-element-property :type f)) - (org-element-property :label f)) - f) - (t nil)))))) + ;; Collect definitions before possibly pruning them so as + ;; to avoid parsing them again if they are required. + (org-element-map data '(footnote-definition footnote-reference) + (lambda (f) + (cond + ((org-element-type-p f 'footnote-definition) f) + ((and (eq 'inline (org-element-property :type f)) + (org-element-property :label f)) + f) + (t nil)))))) ;; If a select tag is active, also ignore the section before the ;; first headline, if any. (when selected (let ((first-element (car (org-element-contents data)))) - (when (eq (org-element-type first-element) 'section) + (when (org-element-type-p first-element 'section) (org-element-extract first-element)))) ;; Prune tree and communication channel. (funcall walk-data data) @@ -2860,7 +2860,7 @@ a list of footnote definitions or in the widened buffer." (let ((known-definitions (org-element-map tree '(footnote-reference footnote-definition) (lambda (f) - (and (or (eq (org-element-type f) 'footnote-definition) + (and (or (org-element-type-p f 'footnote-definition) (eq (org-element-property :type f) 'inline)) (org-element-property :label f))))) ) ;; seen @@ -2876,27 +2876,27 @@ a list of footnote definitions or in the widened buffer." (while undefined (let* ((label (pop undefined)) (definition - (cond - ((cl-some - (lambda (d) (and (equal (org-element-property :label d) label) - d)) - definitions)) - ((pcase (org-footnote-get-definition label) - (`(,_ ,beg . ,_) - (org-with-wide-buffer - (goto-char beg) - (let ((datum (org-element-context))) - (if (eq (org-element-type datum) 'footnote-reference) - datum - ;; Parse definition with contents. - (save-restriction - (narrow-to-region - (org-element-property :begin datum) - (org-element-property :end datum)) - (org-element-map (org-element-parse-buffer) - 'footnote-definition #'identity nil t)))))) - (_ nil))) - (t (user-error "Definition not found for footnote %s" label))))) + (cond + ((cl-some + (lambda (d) (and (equal (org-element-property :label d) label) + d)) + definitions)) + ((pcase (org-footnote-get-definition label) + (`(,_ ,beg . ,_) + (org-with-wide-buffer + (goto-char beg) + (let ((datum (org-element-context))) + (if (org-element-type-p datum 'footnote-reference) + datum + ;; Parse definition with contents. + (save-restriction + (narrow-to-region + (org-element-property :begin datum) + (org-element-property :end datum)) + (org-element-map (org-element-parse-buffer) + 'footnote-definition #'identity nil t)))))) + (_ nil))) + (t (user-error "Definition not found for footnote %s" label))))) (push label defined) (push definition missing-definitions) ;; Look for footnote references within DEFINITION, since @@ -2909,7 +2909,7 @@ a list of footnote definitions or in the widened buffer." ;; definitions. Make sure those are changed into real footnote ;; definitions. (mapcar (lambda (d) - (if (eq (org-element-type d) 'footnote-definition) d + (if (org-element-type-p d 'footnote-definition) d (let ((label (org-element-property :label d))) (apply #'org-element-create 'footnote-definition `(:label ,label :post-blank 1) @@ -2935,13 +2935,13 @@ containing their first reference." (lambda (h) (and (org-element-property :footnote-section-p h) h)) nil t))) (and footnote-section - (apply #'org-element-adopt-elements + (apply #'org-element-adopt footnote-section (nreverse definitions))))) ;; If there should be a footnote section, create one containing all ;; the definitions at the end of the tree. (org-footnote-section - (org-element-adopt-elements + (org-element-adopt tree (org-element-create 'headline (list :footnote-section-p t @@ -2967,13 +2967,13 @@ containing their first reference." (unless (member label seen) (push label seen) (let ((definition - (cl-some - (lambda (d) - (and (equal (org-element-property :label d) - label) - d)) - definitions))) - (org-element-adopt-elements + (cl-some + (lambda (d) + (and (equal (org-element-property :label d) + label) + d)) + definitions))) + (org-element-adopt (org-element-lineage reference '(section)) definition) ;; Also insert definitions for nested @@ -3386,7 +3386,7 @@ not have `buffer-file-name' assigned." (while (re-search-forward include-re nil t) (unless (org-in-commented-heading-p) (let ((element (save-match-data (org-element-at-point)))) - (when (eq (org-element-type element) 'keyword) + (when (org-element-type-p element 'keyword) (beginning-of-line) ;; Extract arguments from keyword's value. (let* ((value (org-element-property :value element)) @@ -3598,7 +3598,7 @@ Return a string of lines to be included in the format expected by (or contents-begin (org-element-property :begin element)) (org-element-property (if contents-begin :contents-end :end) element)) (when (and only-contents - (memq (org-element-type element) '(headline inlinetask))) + (org-element-type-p element '(headline inlinetask))) ;; Skip planning line and property-drawer. (goto-char (point-min)) (when (looking-at-p org-planning-line-re) (forward-line)) @@ -3651,7 +3651,7 @@ Move point after the link." (new-link (org-element-copy link))) (org-element-put-property new-link :path new-path) (when (org-element-property :contents-begin link) - (org-element-adopt-elements new-link + (org-element-adopt new-link (buffer-substring (org-element-property :contents-begin link) (org-element-property :contents-end link)))) @@ -3716,7 +3716,7 @@ is to happen." (let ((link (save-excursion (forward-char -1) (save-match-data (org-element-context))))) - (when (eq 'link (org-element-type link)) + (when (org-element-type-p link 'link) ;; Look for file links within link's description. ;; Org doesn't support such construct, but ;; `org-export-insert-image-links' may activate @@ -3758,8 +3758,8 @@ is to happen." (while (not (or (eobp) (looking-at org-outline-regexp-bol))) ;; Do not move footnote definitions out of column 0. (unless (and (looking-at org-footnote-definition-re) - (eq (org-element-type (org-element-at-point)) - 'footnote-definition)) + (org-element-type-p + (org-element-at-point) 'footnote-definition)) (insert ind-str)) (forward-line)))) ;; When MINLEVEL is specified, compute minimal level for headlines @@ -3806,8 +3806,8 @@ is to happen." (let ((footnote (save-excursion (backward-char) (org-element-context)))) - (when (memq (org-element-type footnote) - '(footnote-definition footnote-reference)) + (when (org-element-type-p + footnote '(footnote-definition footnote-reference)) (let* ((label (org-element-property :label footnote))) ;; Update the footnote-reference at point and collect ;; the new label, which is only used for footnotes @@ -4247,7 +4247,7 @@ inherited from parent headlines and FILETAGS keywords." (let ((current-tag-list (org-element-property :tags element))) (dolist (parent (org-element-lineage element)) (dolist (tag (org-element-property :tags parent)) - (when (and (memq (org-element-type parent) '(headline inlinetask)) + (when (and (org-element-type-p parent '(headline inlinetask)) (not (member tag current-tag-list))) (push tag current-tag-list)))) ;; Add FILETAGS keywords and return results. @@ -4263,7 +4263,7 @@ If optional argument INHERITED is non-nil, the value can be inherited from a parent headline. Return value is a string or nil." - (let ((headline (if (eq (org-element-type datum) 'headline) datum + (let ((headline (if (org-element-type-p datum 'headline) datum (org-export-get-parent-headline datum)))) (if (not inherited) (org-element-property property datum) (let ((parent headline)) @@ -4304,8 +4304,9 @@ If no optional title is defined, fall-back to the regular title." BLOB is an element or an object. If BLOB is a headline, non-nil means it is the first sibling in the sub-tree. INFO is a plist used as a communication channel." - (memq (org-element-type (org-export-get-previous-element blob info)) - '(nil section))) + (org-element-type-p + (org-export-get-previous-element blob info) + '(nil section))) (defun org-export-last-sibling-p (datum info) "Non-nil when DATUM is the last sibling in its parent. @@ -4313,7 +4314,7 @@ DATUM is an element or an object. INFO is a plist used as a communication channel." (let ((next (org-export-get-next-element datum info))) (or (not next) - (and (eq 'headline (org-element-type datum)) + (and (org-element-type-p datum 'headline) (> (org-element-property :level datum) (org-element-property :level next)))))) @@ -4339,7 +4340,7 @@ meant to be translated with `org-export-data' or alike." (cond ((not date) nil) ((and fmt (not (cdr date)) - (eq (org-element-type (car date)) 'timestamp)) + (org-element-type-p (car date) 'timestamp)) (org-format-timestamp (car date) fmt)) (t date)))) @@ -4474,7 +4475,7 @@ Return modified DATA." (string-match-p (cdr rule) path))) (or rules org-export-default-inline-image-rule)) ;; Replace contents with image link. - (org-element-adopt-elements + (org-element-adopt (org-element-set-contents l nil) (with-temp-buffer (save-excursion (insert contents)) @@ -4625,7 +4626,7 @@ significant." ;; Matching both a name and a target is not valid, and ;; therefore undefined. (or (cl-some (lambda (datum) - (and (not (eq (org-element-type datum) 'headline)) + (and (not (org-element-type-p datum 'headline)) datum)) matches) (car matches)) @@ -4875,7 +4876,7 @@ case, return the sequence number of ELEMENT among elements or objects of the same type." ;; Ordinal of a target object refer to the ordinal of the closest ;; table, item, or headline containing the object. - (when (eq (org-element-type element) 'target) + (when (org-element-type-p element 'target) (setq element (org-element-lineage element @@ -5624,19 +5625,19 @@ argument N becomes relative to the level of that headline. Return a list of all exportable headlines as parsed elements. Footnote sections are ignored." (let* ((scope (cond ((not scope) (plist-get info :parse-tree)) - ((eq (org-element-type scope) 'headline) scope) + ((org-element-type-p scope 'headline) scope) ((org-export-get-parent-headline scope)) (t (plist-get info :parse-tree)))) (limit (plist-get info :headline-levels)) (n (if (not (wholenump n)) limit - (min (if (eq (org-element-type scope) 'org-data) n + (min (if (org-element-type-p scope 'org-data) n (+ (org-export-get-relative-level scope info) n)) limit)))) (org-element-map (org-element-contents scope) 'headline (lambda (h) (and (not (org-element-property :footnote-section-p h)) (not (equal "notoc" - (org-export-get-node-property :UNNUMBERED h t))) + (org-export-get-node-property :UNNUMBERED h t))) (>= n (org-export-get-relative-level h info)) h)) info))) @@ -6901,7 +6902,7 @@ Return file name as a string." (while (re-search-forward "^[ \t]*#\\+EXPORT_FILE_NAME:[ \t]+\\S-" nil t) (let ((element (org-element-at-point))) - (when (eq 'keyword (org-element-type element)) + (when (org-element-type-p element 'keyword) (throw :found (org-element-property :value element)))))))) ;; Extract from buffer's associated file, if any. diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el index 3a08747a9..60caa1cd3 100644 --- a/testing/lisp/test-org-element.el +++ b/testing/lisp/test-org-element.el @@ -174,13 +174,13 @@ Some other text (org-element-class datum))))) (ert-deftest test-org-element/adopt-elements () - "Test `org-element-adopt-elements' specifications." + "Test `org-element-adopt' specifications." ;; Adopt an element. (should (equal '(plain-text italic) (org-test-with-temp-text "* Headline\n *a*" (let ((tree (org-element-parse-buffer))) - (org-element-adopt-elements + (org-element-adopt (org-element-map tree 'bold 'identity nil t) '(italic nil "a")) (mapcar (lambda (blob) (org-element-type blob)) (org-element-contents @@ -190,7 +190,7 @@ Some other text (equal '("a" "b") (org-test-with-temp-text "* Headline\n *a*" (let ((tree (org-element-parse-buffer))) - (org-element-adopt-elements + (org-element-adopt (org-element-map tree 'bold 'identity nil t) "b") (org-element-contents (org-element-map tree 'bold 'identity nil t))))))) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 3ef5e7e5b..e1bd00919 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -3310,7 +3310,7 @@ Foo Bar (org-test-with-temp-text "<<>> target" (org-update-radio-target-regexp) (org-open-at-point) - (eq (org-element-type (org-element-context)) 'radio-target)))) + (org-element-type-p (org-element-context) 'radio-target)))) (ert-deftest test-org/open-at-point/radio-target-shadowed () "Test `org-open-at-point' on shadowed radio targets." diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 33d9ee669..7d7acdf16 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -1756,7 +1756,7 @@ Footnotes[fn:2], foot[fn:test] and [fn:inline:inline footnote] '((lambda (backend) (while (re-search-forward "{{{" nil t) (let ((object (org-element-context))) - (when (eq (org-element-type object) 'macro) + (when (org-element-type-p object 'macro) (delete-region (org-element-property :begin object) (org-element-property :end object))))))))) @@ -3891,7 +3891,7 @@ Another text. (ref:text) (element '(pseudo-element (:post-blank 1) "contents")) (paragraph '(paragraph nil "paragraph")) (data '(org-data nil))) - (org-element-adopt-elements data element paragraph) + (org-element-adopt data element paragraph) (org-export-data-with-backend data backend nil))))) (ert-deftest test-org-export/pseudo-objects () @@ -3907,7 +3907,7 @@ Another text. (ref:text) (plain-text . (lambda (c _i) c))))) (object '(pseudo-object (:post-blank 1) "x")) (paragraph '(paragraph nil))) - (org-element-adopt-elements paragraph "begin " object "end") + (org-element-adopt paragraph "begin " object "end") (org-export-data-with-backend paragraph backend nil)))))