2015-07-31 16:02:15 -04:00
|
|
|
|
;;; org-element.el --- Parser for Org Syntax -*- lexical-binding: t; -*-
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2019-01-01 05:50:56 -05:00
|
|
|
|
;; Copyright (C) 2012-2019 Free Software Foundation, Inc.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
|
|
|
|
|
;; Keywords: outlines, hypermedia, calendar, wp
|
|
|
|
|
|
2012-09-24 13:15:42 -04:00
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
2012-09-24 13:15:42 -04:00
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2017-09-13 18:52:52 -04:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
2018-01-16 11:22:00 -05:00
|
|
|
|
;; See <https://orgmode.org/worg/dev/org-syntax.html> for details about
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; Lisp-wise, a syntax object can be represented as a list.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; It follows the pattern (TYPE PROPERTIES CONTENTS), where:
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; TYPE is a symbol describing the object.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; PROPERTIES is the property list attached to it. See docstring of
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; appropriate parsing function to get an exhaustive list.
|
|
|
|
|
;; CONTENTS is a list of syntax objects or raw strings contained
|
|
|
|
|
;; in the current object, when applicable.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; For the whole document, TYPE is `org-data' and PROPERTIES is nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
2017-06-13 04:41:13 -04:00
|
|
|
|
;; The first part of this file defines constants for the Org syntax,
|
|
|
|
|
;; while the second one provide accessors and setters functions.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
|
|
|
|
;; The next part implements a parser and an interpreter for each
|
|
|
|
|
;; element and object type in Org syntax.
|
|
|
|
|
;;
|
|
|
|
|
;; The following part creates a fully recursive buffer parser. It
|
|
|
|
|
;; also provides a tool to map a function to elements or objects
|
|
|
|
|
;; matching some criteria in the parse tree. Functions of interest
|
|
|
|
|
;; are `org-element-parse-buffer', `org-element-map' and, to a lesser
|
|
|
|
|
;; extent, `org-element-parse-secondary-string'.
|
|
|
|
|
;;
|
|
|
|
|
;; The penultimate part is the cradle of an interpreter for the
|
|
|
|
|
;; obtained parse tree: `org-element-interpret-data'.
|
|
|
|
|
;;
|
2012-08-08 07:55:18 -04:00
|
|
|
|
;; The library ends by furnishing `org-element-at-point' function, and
|
|
|
|
|
;; a way to give information about document structure around point
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; with `org-element-context'. A cache mechanism is also provided for
|
|
|
|
|
;; these functions.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2012-08-06 13:13:43 -04:00
|
|
|
|
(require 'org)
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(require 'avl-tree)
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(require 'cl-lib)
|
2012-08-06 11:06:13 -04:00
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;;; Definitions And Rules
|
|
|
|
|
;;
|
|
|
|
|
;; Define elements, greater elements and specify recursive objects,
|
|
|
|
|
;; along with the affiliated keywords recognized. Also set up
|
|
|
|
|
;; restrictions on recursive objects combinations.
|
|
|
|
|
;;
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; `org-element-update-syntax' builds proper syntax regexps according
|
|
|
|
|
;; to current setup.
|
|
|
|
|
|
|
|
|
|
(defvar org-element-paragraph-separate nil
|
2012-08-17 09:22:36 -04:00
|
|
|
|
"Regexp to separate paragraphs in an Org buffer.
|
|
|
|
|
In the case of lines starting with \"#\" and \":\", this regexp
|
|
|
|
|
is not sufficient to know if point is at a paragraph ending. See
|
|
|
|
|
`org-element-paragraph-parser' for more information.")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2014-11-09 17:55:27 -05:00
|
|
|
|
(defvar org-element--object-regexp nil
|
|
|
|
|
"Regexp possibly matching the beginning of an object.
|
|
|
|
|
This regexp allows false positives. Dedicated parser (e.g.,
|
|
|
|
|
`org-export-bold-parser') will take care of further filtering.
|
|
|
|
|
Radio links are not matched by this regexp, as they are treated
|
|
|
|
|
specially in `org-element--object-lex'.")
|
|
|
|
|
|
|
|
|
|
(defun org-element--set-regexps ()
|
|
|
|
|
"Build variable syntax regexps."
|
|
|
|
|
(setq org-element-paragraph-separate
|
|
|
|
|
(concat "^\\(?:"
|
|
|
|
|
;; Headlines, inlinetasks.
|
|
|
|
|
org-outline-regexp "\\|"
|
|
|
|
|
;; Footnote definitions.
|
2015-12-16 12:22:27 -05:00
|
|
|
|
"\\[fn:[-_[:word:]]+\\]" "\\|"
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; Diary sexps.
|
|
|
|
|
"%%(" "\\|"
|
|
|
|
|
"[ \t]*\\(?:"
|
|
|
|
|
;; Empty lines.
|
|
|
|
|
"$" "\\|"
|
|
|
|
|
;; Tables (any type).
|
2015-06-29 08:49:00 -04:00
|
|
|
|
"|" "\\|"
|
|
|
|
|
"\\+\\(?:-+\\+\\)+[ \t]*$" "\\|"
|
2015-04-27 16:24:00 -04:00
|
|
|
|
;; Comments, keyword-like or block-like constructs.
|
|
|
|
|
;; Blocks and keywords with dual values need to be
|
|
|
|
|
;; double-checked.
|
|
|
|
|
"#\\(?: \\|$\\|\\+\\(?:"
|
|
|
|
|
"BEGIN_\\S-+" "\\|"
|
2015-05-01 03:23:35 -04:00
|
|
|
|
"\\S-+\\(?:\\[.*\\]\\)?:[ \t]*\\)\\)"
|
2015-04-27 16:24:00 -04:00
|
|
|
|
"\\|"
|
|
|
|
|
;; Drawers (any type) and fixed-width areas. Drawers
|
|
|
|
|
;; need to be double-checked.
|
|
|
|
|
":\\(?: \\|$\\|[-_[:word:]]+:[ \t]*$\\)" "\\|"
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; Horizontal rules.
|
|
|
|
|
"-\\{5,\\}[ \t]*$" "\\|"
|
|
|
|
|
;; LaTeX environments.
|
2015-04-27 16:24:00 -04:00
|
|
|
|
"\\\\begin{\\([A-Za-z0-9*]+\\)}" "\\|"
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; Clock lines.
|
|
|
|
|
(regexp-quote org-clock-string) "\\|"
|
|
|
|
|
;; Lists.
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(let ((term (pcase org-plain-list-ordered-item-terminator
|
|
|
|
|
(?\) ")") (?. "\\.") (_ "[.)]")))
|
2014-11-09 17:55:27 -05:00
|
|
|
|
(alpha (and org-list-allow-alphabetical "\\|[A-Za-z]")))
|
|
|
|
|
(concat "\\(?:[-+*]\\|\\(?:[0-9]+" alpha "\\)" term "\\)"
|
|
|
|
|
"\\(?:[ \t]\\|$\\)"))
|
|
|
|
|
"\\)\\)")
|
|
|
|
|
org-element--object-regexp
|
|
|
|
|
(mapconcat #'identity
|
2016-07-07 09:58:29 -04:00
|
|
|
|
(let ((link-types (regexp-opt (org-link-types))))
|
2014-11-09 17:55:27 -05:00
|
|
|
|
(list
|
|
|
|
|
;; Sub/superscript.
|
|
|
|
|
"\\(?:[_^][-{(*+.,[:alnum:]]\\)"
|
|
|
|
|
;; Bold, code, italic, strike-through, underline
|
|
|
|
|
;; and verbatim.
|
|
|
|
|
(concat "[*~=+_/]"
|
|
|
|
|
(format "[^%s]"
|
|
|
|
|
(nth 2 org-emphasis-regexp-components)))
|
|
|
|
|
;; Plain links.
|
|
|
|
|
(concat "\\<" link-types ":")
|
|
|
|
|
;; Objects starting with "[": regular link,
|
|
|
|
|
;; footnote reference, statistics cookie,
|
|
|
|
|
;; timestamp (inactive).
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(concat "\\[\\(?:"
|
|
|
|
|
"fn:" "\\|"
|
|
|
|
|
"\\[" "\\|"
|
|
|
|
|
"[0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}" "\\|"
|
|
|
|
|
"[0-9]*\\(?:%\\|/[0-9]*\\)\\]"
|
|
|
|
|
"\\)")
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; Objects starting with "@": export snippets.
|
|
|
|
|
"@@"
|
|
|
|
|
;; Objects starting with "{": macro.
|
|
|
|
|
"{{{"
|
|
|
|
|
;; Objects starting with "<" : timestamp
|
|
|
|
|
;; (active, diary), target, radio target and
|
|
|
|
|
;; angular links.
|
|
|
|
|
(concat "<\\(?:%%\\|<\\|[0-9]\\|" link-types "\\)")
|
|
|
|
|
;; Objects starting with "$": latex fragment.
|
|
|
|
|
"\\$"
|
|
|
|
|
;; Objects starting with "\": line break,
|
|
|
|
|
;; entity, latex fragment.
|
2015-03-22 16:45:00 -04:00
|
|
|
|
"\\\\\\(?:[a-zA-Z[(]\\|\\\\[ \t]*$\\|_ +\\)"
|
2014-11-09 17:55:27 -05:00
|
|
|
|
;; Objects starting with raw text: inline Babel
|
|
|
|
|
;; source block, inline Babel call.
|
|
|
|
|
"\\(?:call\\|src\\)_"))
|
|
|
|
|
"\\|")))
|
|
|
|
|
|
|
|
|
|
(org-element--set-regexps)
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-element-update-syntax ()
|
|
|
|
|
"Update parser internals."
|
|
|
|
|
(interactive)
|
|
|
|
|
(org-element--set-regexps)
|
|
|
|
|
(org-element-cache-reset 'all))
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defconst org-element-all-elements
|
2012-10-27 08:23:37 -04:00
|
|
|
|
'(babel-call center-block clock comment comment-block diary-sexp drawer
|
2014-09-08 05:57:27 -04:00
|
|
|
|
dynamic-block example-block export-block fixed-width
|
|
|
|
|
footnote-definition headline horizontal-rule inlinetask item
|
|
|
|
|
keyword latex-environment node-property paragraph plain-list
|
|
|
|
|
planning property-drawer quote-block section
|
|
|
|
|
special-block src-block table table-row verse-block)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Complete list of element types.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element-greater-elements
|
|
|
|
|
'(center-block drawer dynamic-block footnote-definition headline inlinetask
|
2012-09-23 09:52:02 -04:00
|
|
|
|
item plain-list property-drawer quote-block section
|
|
|
|
|
special-block table)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"List of recursive element types aka Greater Elements.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element-all-objects
|
|
|
|
|
'(bold code entity export-snippet footnote-reference inline-babel-call
|
|
|
|
|
inline-src-block italic line-break latex-fragment link macro
|
|
|
|
|
radio-target statistics-cookie strike-through subscript superscript
|
|
|
|
|
table-cell target timestamp underline verbatim)
|
|
|
|
|
"Complete list of object types.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element-recursive-objects
|
2014-07-06 05:08:57 -04:00
|
|
|
|
'(bold footnote-reference italic link subscript radio-target strike-through
|
|
|
|
|
superscript table-cell underline)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"List of recursive object types.")
|
|
|
|
|
|
2015-02-09 06:02:16 -05:00
|
|
|
|
(defconst org-element-object-containers
|
|
|
|
|
(append org-element-recursive-objects '(paragraph table-row verse-block))
|
|
|
|
|
"List of object or element types that can directly contain objects.")
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defconst org-element-affiliated-keywords
|
|
|
|
|
'("CAPTION" "DATA" "HEADER" "HEADERS" "LABEL" "NAME" "PLOT" "RESNAME" "RESULT"
|
|
|
|
|
"RESULTS" "SOURCE" "SRCNAME" "TBLNAME")
|
|
|
|
|
"List of affiliated keywords as strings.
|
2014-03-17 05:31:37 -04:00
|
|
|
|
By default, all keywords setting attributes (e.g., \"ATTR_LATEX\")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
are affiliated keywords and need not to be in this list.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element-keyword-translation-alist
|
|
|
|
|
'(("DATA" . "NAME") ("LABEL" . "NAME") ("RESNAME" . "NAME")
|
|
|
|
|
("SOURCE" . "NAME") ("SRCNAME" . "NAME") ("TBLNAME" . "NAME")
|
|
|
|
|
("RESULT" . "RESULTS") ("HEADERS" . "HEADER"))
|
|
|
|
|
"Alist of usual translations for keywords.
|
|
|
|
|
The key is the old name and the value the new one. The property
|
|
|
|
|
holding their value will be named after the translated name.")
|
|
|
|
|
|
2012-09-13 10:51:54 -04:00
|
|
|
|
(defconst org-element-multiple-keywords '("CAPTION" "HEADER")
|
|
|
|
|
"List of affiliated keywords that can occur more than once in an element.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Their value will be consed into a list of strings, which will be
|
|
|
|
|
returned as the value of the property.
|
|
|
|
|
|
|
|
|
|
This list is checked after translations have been applied. See
|
|
|
|
|
`org-element-keyword-translation-alist'.
|
|
|
|
|
|
2014-03-17 05:31:37 -04:00
|
|
|
|
By default, all keywords setting attributes (e.g., \"ATTR_LATEX\")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
allow multiple occurrences and need not to be in this list.")
|
|
|
|
|
|
2012-09-30 14:02:28 -04:00
|
|
|
|
(defconst org-element-parsed-keywords '("CAPTION")
|
|
|
|
|
"List of affiliated keywords whose value can be parsed.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Their value will be stored as a secondary string: a list of
|
|
|
|
|
strings and objects.
|
|
|
|
|
|
|
|
|
|
This list is checked after translations have been applied. See
|
|
|
|
|
`org-element-keyword-translation-alist'.")
|
|
|
|
|
|
2015-01-25 06:32:03 -05:00
|
|
|
|
(defconst org-element--parsed-properties-alist
|
|
|
|
|
(mapcar (lambda (k) (cons k (intern (concat ":" (downcase k)))))
|
|
|
|
|
org-element-parsed-keywords)
|
|
|
|
|
"Alist of parsed keywords and associated properties.
|
|
|
|
|
This is generated from `org-element-parsed-keywords', which
|
|
|
|
|
see.")
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defconst org-element-dual-keywords '("CAPTION" "RESULTS")
|
2012-09-30 14:02:28 -04:00
|
|
|
|
"List of affiliated keywords which can have a secondary value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
In Org syntax, they can be written with optional square brackets
|
2012-09-30 14:02:28 -04:00
|
|
|
|
before the colons. For example, RESULTS keyword can be
|
2012-07-28 01:02:21 -04:00
|
|
|
|
associated to a hash value with the following:
|
|
|
|
|
|
|
|
|
|
#+RESULTS[hash-string]: some-source
|
|
|
|
|
|
|
|
|
|
This list is checked after translations have been applied. See
|
|
|
|
|
`org-element-keyword-translation-alist'.")
|
|
|
|
|
|
2013-12-15 09:20:03 -05:00
|
|
|
|
(defconst org-element--affiliated-re
|
2015-05-01 03:23:35 -04:00
|
|
|
|
(format "[ \t]*#\\+\\(?:%s\\):[ \t]*"
|
2013-12-15 09:20:03 -05:00
|
|
|
|
(concat
|
|
|
|
|
;; Dual affiliated keywords.
|
|
|
|
|
(format "\\(?1:%s\\)\\(?:\\[\\(.*\\)\\]\\)?"
|
|
|
|
|
(regexp-opt org-element-dual-keywords))
|
|
|
|
|
"\\|"
|
|
|
|
|
;; Regular affiliated keywords.
|
|
|
|
|
(format "\\(?1:%s\\)"
|
|
|
|
|
(regexp-opt
|
2015-11-06 07:04:20 -05:00
|
|
|
|
(cl-remove-if
|
2015-05-01 03:23:35 -04:00
|
|
|
|
(lambda (k) (member k org-element-dual-keywords))
|
2013-12-15 09:20:03 -05:00
|
|
|
|
org-element-affiliated-keywords)))
|
|
|
|
|
"\\|"
|
|
|
|
|
;; Export attributes.
|
|
|
|
|
"\\(?1:ATTR_[-_A-Za-z0-9]+\\)"))
|
|
|
|
|
"Regexp matching any affiliated keyword.
|
|
|
|
|
|
|
|
|
|
Keyword name is put in match group 1. Moreover, if keyword
|
|
|
|
|
belongs to `org-element-dual-keywords', put the dual value in
|
|
|
|
|
match group 2.
|
|
|
|
|
|
|
|
|
|
Don't modify it, set `org-element-affiliated-keywords' instead.")
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defconst org-element-object-restrictions
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let* ((standard-set (remq 'table-cell org-element-all-objects))
|
2013-03-04 02:34:46 -05:00
|
|
|
|
(standard-set-no-line-break (remq 'line-break standard-set)))
|
|
|
|
|
`((bold ,@standard-set)
|
|
|
|
|
(footnote-reference ,@standard-set)
|
|
|
|
|
(headline ,@standard-set-no-line-break)
|
|
|
|
|
(inlinetask ,@standard-set-no-line-break)
|
|
|
|
|
(italic ,@standard-set)
|
|
|
|
|
(item ,@standard-set-no-line-break)
|
2015-02-15 15:37:26 -05:00
|
|
|
|
(keyword ,@(remq 'footnote-reference standard-set))
|
2017-03-06 11:38:05 -05:00
|
|
|
|
;; Ignore all links in a link description. Also ignore
|
|
|
|
|
;; radio-targets and line breaks.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(link bold code entity export-snippet inline-babel-call inline-src-block
|
2016-12-17 05:35:50 -05:00
|
|
|
|
italic latex-fragment macro statistics-cookie strike-through
|
|
|
|
|
subscript superscript underline verbatim)
|
2013-03-04 02:34:46 -05:00
|
|
|
|
(paragraph ,@standard-set)
|
|
|
|
|
;; Remove any variable object from radio target as it would
|
|
|
|
|
;; prevent it from being properly recognized.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(radio-target bold code entity italic latex-fragment strike-through
|
|
|
|
|
subscript superscript underline superscript)
|
2013-03-04 02:34:46 -05:00
|
|
|
|
(strike-through ,@standard-set)
|
|
|
|
|
(subscript ,@standard-set)
|
|
|
|
|
(superscript ,@standard-set)
|
2018-09-20 05:23:49 -04:00
|
|
|
|
;; Ignore inline babel call and inline source block as formulas
|
|
|
|
|
;; are possible. Also ignore line breaks and statistics
|
|
|
|
|
;; cookies.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(table-cell bold code entity export-snippet footnote-reference italic
|
|
|
|
|
latex-fragment link macro radio-target strike-through
|
|
|
|
|
subscript superscript target timestamp underline verbatim)
|
2013-03-04 02:34:46 -05:00
|
|
|
|
(table-row table-cell)
|
|
|
|
|
(underline ,@standard-set)
|
|
|
|
|
(verse-block ,@standard-set)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Alist of objects restrictions.
|
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
key is an element or object type containing objects and value is
|
|
|
|
|
a list of types that can be contained within an element or object
|
|
|
|
|
of such type.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
For example, in a `radio-target' object, one can only find
|
2014-03-23 06:28:26 -04:00
|
|
|
|
entities, latex-fragments, subscript, superscript and text
|
|
|
|
|
markup.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
This alist also applies to secondary string. For example, an
|
|
|
|
|
`headline' type element doesn't directly contain objects, but
|
|
|
|
|
still has an entry since one of its properties (`:title') does.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element-secondary-value-alist
|
2015-03-01 11:03:02 -05:00
|
|
|
|
'((headline :title)
|
|
|
|
|
(inlinetask :title)
|
|
|
|
|
(item :tag))
|
|
|
|
|
"Alist between element types and locations of secondary values.")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(defconst org-element--pair-round-table
|
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
|
(modify-syntax-entry ?\( "()" table)
|
|
|
|
|
(modify-syntax-entry ?\) ")(" table)
|
|
|
|
|
(dolist (char '(?\{ ?\} ?\[ ?\] ?\< ?\>) table)
|
|
|
|
|
(modify-syntax-entry char " " table)))
|
|
|
|
|
"Table used internally to pair only round brackets.
|
|
|
|
|
Other brackets are treated as spaces.")
|
|
|
|
|
|
2015-02-15 07:33:25 -05:00
|
|
|
|
(defconst org-element--pair-square-table
|
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
|
(modify-syntax-entry ?\[ "(]" table)
|
|
|
|
|
(modify-syntax-entry ?\] ")[" table)
|
|
|
|
|
(dolist (char '(?\{ ?\} ?\( ?\) ?\< ?\>) table)
|
|
|
|
|
(modify-syntax-entry char " " table)))
|
|
|
|
|
"Table used internally to pair only square brackets.
|
|
|
|
|
Other brackets are treated as spaces.")
|
|
|
|
|
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(defconst org-element--pair-curly-table
|
|
|
|
|
(let ((table (make-syntax-table)))
|
|
|
|
|
(modify-syntax-entry ?\{ "(}" table)
|
|
|
|
|
(modify-syntax-entry ?\} "){" table)
|
2016-03-16 13:13:52 -04:00
|
|
|
|
(dolist (char '(?\[ ?\] ?\( ?\) ?\< ?\>) table)
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(modify-syntax-entry char " " table)))
|
|
|
|
|
"Table used internally to pair only curly brackets.
|
|
|
|
|
Other brackets are treated as spaces.")
|
|
|
|
|
|
2016-06-10 17:42:50 -04:00
|
|
|
|
(defun org-element--parse-paired-brackets (char)
|
|
|
|
|
"Parse paired brackets at point.
|
|
|
|
|
CHAR is the opening bracket to consider, as a character. Return
|
|
|
|
|
contents between brackets, as a string, or nil. Also move point
|
|
|
|
|
past the brackets."
|
|
|
|
|
(when (eq char (char-after))
|
|
|
|
|
(let ((syntax-table (pcase char
|
|
|
|
|
(?\{ org-element--pair-curly-table)
|
|
|
|
|
(?\[ org-element--pair-square-table)
|
|
|
|
|
(?\( org-element--pair-round-table)
|
|
|
|
|
(_ nil)))
|
|
|
|
|
(pos (point)))
|
|
|
|
|
(when syntax-table
|
|
|
|
|
(with-syntax-table syntax-table
|
|
|
|
|
(let ((end (ignore-errors (scan-lists pos 1 0))))
|
|
|
|
|
(when end
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(buffer-substring-no-properties (1+ pos) (1- end)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Accessors and Setters
|
|
|
|
|
;;
|
|
|
|
|
;; Provide four accessors: `org-element-type', `org-element-property'
|
|
|
|
|
;; `org-element-contents' and `org-element-restriction'.
|
|
|
|
|
;;
|
2016-01-24 15:30:39 -05:00
|
|
|
|
;; Setter functions allow modification of elements by side effect.
|
|
|
|
|
;; There is `org-element-put-property', `org-element-set-contents'.
|
|
|
|
|
;; These low-level functions are useful to build a parse tree.
|
2013-11-30 17:31:42 -05:00
|
|
|
|
;;
|
2017-04-30 15:11:45 -04:00
|
|
|
|
;; `org-element-adopt-elements', `org-element-set-element',
|
2013-11-30 17:31:42 -05:00
|
|
|
|
;; `org-element-extract-element' and `org-element-insert-before' are
|
|
|
|
|
;; high-level functions useful to modify a parse tree.
|
|
|
|
|
;;
|
|
|
|
|
;; `org-element-secondary-p' is a predicate used to know if a given
|
2016-10-25 07:13:26 -04:00
|
|
|
|
;; object belongs to a secondary string. `org-element-class' tells if
|
|
|
|
|
;; some parsed data is an element or an object, handling pseudo
|
|
|
|
|
;; elements and objects. `org-element-copy' returns an element or
|
|
|
|
|
;; object, stripping its parent property in the process.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defsubst org-element-type (element)
|
|
|
|
|
"Return type of ELEMENT.
|
|
|
|
|
|
|
|
|
|
The function returns the type of the element or object provided.
|
|
|
|
|
It can also return the following special value:
|
|
|
|
|
`plain-text' for a string
|
|
|
|
|
`org-data' for a complete document
|
|
|
|
|
nil in any other case."
|
|
|
|
|
(cond
|
|
|
|
|
((not (consp element)) (and (stringp element) 'plain-text))
|
|
|
|
|
((symbolp (car element)) (car element))))
|
|
|
|
|
|
|
|
|
|
(defsubst org-element-property (property element)
|
|
|
|
|
"Extract the value from the PROPERTY of an ELEMENT."
|
2012-10-25 15:33:57 -04:00
|
|
|
|
(if (stringp element) (get-text-property 0 property element)
|
|
|
|
|
(plist-get (nth 1 element) property)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defsubst org-element-contents (element)
|
|
|
|
|
"Extract contents from an ELEMENT."
|
2012-10-29 14:03:54 -04:00
|
|
|
|
(cond ((not (consp element)) nil)
|
|
|
|
|
((symbolp (car element)) (nthcdr 2 element))
|
|
|
|
|
(t element)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defsubst org-element-restriction (element)
|
|
|
|
|
"Return restriction associated to ELEMENT.
|
|
|
|
|
ELEMENT can be an element, an object or a symbol representing an
|
|
|
|
|
element or object type."
|
|
|
|
|
(cdr (assq (if (symbolp element) element (org-element-type element))
|
|
|
|
|
org-element-object-restrictions)))
|
|
|
|
|
|
|
|
|
|
(defsubst org-element-put-property (element property value)
|
|
|
|
|
"In ELEMENT set PROPERTY to VALUE.
|
|
|
|
|
Return modified element."
|
2012-10-25 15:33:57 -04:00
|
|
|
|
(if (stringp element) (org-add-props element nil property value)
|
|
|
|
|
(setcar (cdr element) (plist-put (nth 1 element) property value))
|
|
|
|
|
element))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defsubst org-element-set-contents (element &rest contents)
|
2016-01-21 12:42:24 -05:00
|
|
|
|
"Set ELEMENT's contents to CONTENTS.
|
|
|
|
|
Return ELEMENT."
|
|
|
|
|
(cond ((null element) contents)
|
2012-10-29 14:03:54 -04:00
|
|
|
|
((not (symbolp (car element))) contents)
|
2016-01-21 12:42:24 -05:00
|
|
|
|
((cdr element) (setcdr (cdr element) contents) element)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(t (nconc element contents))))
|
|
|
|
|
|
2013-11-30 09:23:07 -05:00
|
|
|
|
(defun org-element-secondary-p (object)
|
2015-03-01 11:03:02 -05:00
|
|
|
|
"Non-nil when OBJECT directly belongs to a secondary string.
|
2013-11-30 09:23:07 -05:00
|
|
|
|
Return value is the property name, as a keyword, or nil."
|
|
|
|
|
(let* ((parent (org-element-property :parent object))
|
2015-03-01 11:03:02 -05:00
|
|
|
|
(properties (cdr (assq (org-element-type parent)
|
|
|
|
|
org-element-secondary-value-alist))))
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(dolist (p properties)
|
|
|
|
|
(and (memq object (org-element-property p parent))
|
|
|
|
|
(throw 'exit p))))))
|
2013-11-30 09:23:07 -05:00
|
|
|
|
|
2016-12-29 12:48:20 -05:00
|
|
|
|
(defsubst org-element-class (datum &optional parent)
|
2016-10-25 07:13:26 -04:00
|
|
|
|
"Return class for ELEMENT, as a symbol.
|
|
|
|
|
Class is either `element' or `object'. Optional argument PARENT
|
|
|
|
|
is the element or object containing DATUM. It defaults to the
|
|
|
|
|
value of DATUM `:parent' property."
|
|
|
|
|
(let ((type (org-element-type datum))
|
|
|
|
|
(parent (or parent (org-element-property :parent datum))))
|
|
|
|
|
(cond
|
|
|
|
|
;; Trivial cases.
|
|
|
|
|
((memq type org-element-all-objects) 'object)
|
|
|
|
|
((memq type org-element-all-elements) 'element)
|
|
|
|
|
;; Special cases.
|
|
|
|
|
((eq type 'org-data) 'element)
|
|
|
|
|
((eq type 'plain-text) 'object)
|
|
|
|
|
((not type) 'object)
|
|
|
|
|
;; Pseudo object or elements. Make a guess about its class.
|
|
|
|
|
;; Basically a pseudo object is contained within another object,
|
|
|
|
|
;; a secondary string or a container element.
|
|
|
|
|
((not parent) 'element)
|
|
|
|
|
(t
|
|
|
|
|
(let ((parent-type (org-element-type parent)))
|
|
|
|
|
(cond ((not parent-type) 'object)
|
|
|
|
|
((memq parent-type org-element-object-containers) 'object)
|
2016-10-28 09:46:22 -04:00
|
|
|
|
((org-element-secondary-p datum) 'object)
|
2016-10-25 07:13:26 -04:00
|
|
|
|
(t 'element)))))))
|
|
|
|
|
|
2012-08-18 04:13:35 -04:00
|
|
|
|
(defsubst org-element-adopt-elements (parent &rest children)
|
|
|
|
|
"Append elements to the contents of another element.
|
|
|
|
|
|
|
|
|
|
PARENT is an element or object. CHILDREN can be elements,
|
|
|
|
|
objects, or a strings.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
The function takes care of setting `:parent' property for CHILD.
|
|
|
|
|
Return parent element."
|
2018-03-03 04:00:06 -05:00
|
|
|
|
(declare (indent 1))
|
2015-06-23 05:18:36 -04:00
|
|
|
|
(if (not children) parent
|
|
|
|
|
;; Link every child to PARENT. If PARENT is nil, it is a secondary
|
|
|
|
|
;; string: parent is the list itself.
|
|
|
|
|
(dolist (child children)
|
|
|
|
|
(org-element-put-property child :parent (or parent children)))
|
|
|
|
|
;; Add CHILDREN at the end of PARENT contents.
|
|
|
|
|
(when parent
|
|
|
|
|
(apply #'org-element-set-contents
|
|
|
|
|
parent
|
|
|
|
|
(nconc (org-element-contents parent) children)))
|
|
|
|
|
;; Return modified PARENT element.
|
|
|
|
|
(or parent children)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2013-11-30 08:25:55 -05:00
|
|
|
|
(defun org-element-extract-element (element)
|
|
|
|
|
"Extract ELEMENT from parse tree.
|
|
|
|
|
Remove element from the parse tree by side-effect, and return it
|
|
|
|
|
with its `:parent' property stripped out."
|
|
|
|
|
(let ((parent (org-element-property :parent element))
|
|
|
|
|
(secondary (org-element-secondary-p element)))
|
|
|
|
|
(if secondary
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
parent secondary
|
|
|
|
|
(delq element (org-element-property secondary parent)))
|
|
|
|
|
(apply #'org-element-set-contents
|
|
|
|
|
parent
|
|
|
|
|
(delq element (org-element-contents parent))))
|
|
|
|
|
;; Return ELEMENT with its :parent removed.
|
|
|
|
|
(org-element-put-property element :parent nil)))
|
|
|
|
|
|
2013-11-30 17:31:42 -05:00
|
|
|
|
(defun org-element-insert-before (element location)
|
|
|
|
|
"Insert ELEMENT before LOCATION in parse tree.
|
|
|
|
|
LOCATION is an element, object or string within the parse tree.
|
|
|
|
|
Parse tree is modified by side effect."
|
|
|
|
|
(let* ((parent (org-element-property :parent location))
|
|
|
|
|
(property (org-element-secondary-p location))
|
|
|
|
|
(siblings (if property (org-element-property property parent)
|
2013-12-26 06:19:58 -05:00
|
|
|
|
(org-element-contents parent)))
|
|
|
|
|
;; Special case: LOCATION is the first element of an
|
|
|
|
|
;; independent secondary string (e.g. :title property). Add
|
|
|
|
|
;; ELEMENT in-place.
|
|
|
|
|
(specialp (and (not property)
|
|
|
|
|
(eq siblings parent)
|
|
|
|
|
(eq (car parent) location))))
|
2017-02-13 10:29:54 -05:00
|
|
|
|
;; Install ELEMENT at the appropriate LOCATION within SIBLINGS.
|
2013-12-26 06:19:58 -05:00
|
|
|
|
(cond (specialp)
|
|
|
|
|
((or (null siblings) (eq (car siblings) location))
|
2013-11-30 17:31:42 -05:00
|
|
|
|
(push element siblings))
|
|
|
|
|
((null location) (nconc siblings (list element)))
|
2017-02-13 10:29:54 -05:00
|
|
|
|
(t
|
|
|
|
|
(let ((index (cl-position location siblings)))
|
|
|
|
|
(unless index (error "No location found to insert element"))
|
|
|
|
|
(push element (cdr (nthcdr (1- index) siblings))))))
|
2013-11-30 17:31:42 -05:00
|
|
|
|
;; Store SIBLINGS at appropriate place in parse tree.
|
2013-12-26 06:19:58 -05:00
|
|
|
|
(cond
|
|
|
|
|
(specialp (setcdr parent (copy-sequence parent)) (setcar parent element))
|
|
|
|
|
(property (org-element-put-property parent property siblings))
|
|
|
|
|
(t (apply #'org-element-set-contents parent siblings)))
|
2013-11-30 17:31:42 -05:00
|
|
|
|
;; Set appropriate :parent property.
|
|
|
|
|
(org-element-put-property element :parent parent)))
|
|
|
|
|
|
2013-12-01 09:48:54 -05:00
|
|
|
|
(defun org-element-set-element (old new)
|
|
|
|
|
"Replace element or object OLD with element or object NEW.
|
|
|
|
|
The function takes care of setting `:parent' property for NEW."
|
|
|
|
|
;; Ensure OLD and NEW have the same parent.
|
|
|
|
|
(org-element-put-property new :parent (org-element-property :parent old))
|
|
|
|
|
(if (or (memq (org-element-type old) '(plain-text nil))
|
|
|
|
|
(memq (org-element-type new) '(plain-text nil)))
|
|
|
|
|
;; We cannot replace OLD with NEW since one of them is not an
|
|
|
|
|
;; object or element. We take the long path.
|
|
|
|
|
(progn (org-element-insert-before new old)
|
|
|
|
|
(org-element-extract-element old))
|
|
|
|
|
;; Since OLD is going to be changed into NEW by side-effect, first
|
|
|
|
|
;; make sure that every element or object within NEW has OLD as
|
|
|
|
|
;; parent.
|
|
|
|
|
(dolist (blob (org-element-contents new))
|
|
|
|
|
(org-element-put-property blob :parent old))
|
|
|
|
|
;; Transfer contents.
|
|
|
|
|
(apply #'org-element-set-contents old (org-element-contents new))
|
|
|
|
|
;; Overwrite OLD's properties with NEW's.
|
|
|
|
|
(setcar (cdr old) (nth 1 new))
|
|
|
|
|
;; Transfer type.
|
|
|
|
|
(setcar old (car new))))
|
|
|
|
|
|
2015-06-23 05:18:36 -04:00
|
|
|
|
(defun org-element-create (type &optional props &rest children)
|
|
|
|
|
"Create a new element of type TYPE.
|
|
|
|
|
Optional argument PROPS, when non-nil, is a plist defining the
|
|
|
|
|
properties of the element. CHILDREN can be elements, objects or
|
|
|
|
|
strings."
|
|
|
|
|
(apply #'org-element-adopt-elements (list type props) children))
|
|
|
|
|
|
2015-02-09 04:07:34 -05:00
|
|
|
|
(defun org-element-copy (datum)
|
|
|
|
|
"Return a copy of DATUM.
|
2015-02-09 04:57:39 -05:00
|
|
|
|
DATUM is an element, object, string or nil. `:parent' property
|
|
|
|
|
is cleared and contents are removed in the process."
|
2015-02-09 04:07:34 -05:00
|
|
|
|
(when datum
|
|
|
|
|
(let ((type (org-element-type datum)))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase type
|
|
|
|
|
(`org-data (list 'org-data nil))
|
|
|
|
|
(`plain-text (substring-no-properties datum))
|
|
|
|
|
(`nil (copy-sequence datum))
|
|
|
|
|
(_
|
2015-02-09 04:07:34 -05:00
|
|
|
|
(list type (plist-put (copy-sequence (nth 1 datum)) :parent nil)))))))
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Greater elements
|
|
|
|
|
;;
|
|
|
|
|
;; For each greater element type, we define a parser and an
|
|
|
|
|
;; interpreter.
|
|
|
|
|
;;
|
|
|
|
|
;; A parser returns the element or object as the list described above.
|
|
|
|
|
;; Most of them accepts no argument. Though, exceptions exist. Hence
|
|
|
|
|
;; every element containing a secondary string (see
|
|
|
|
|
;; `org-element-secondary-value-alist') will accept an optional
|
2015-03-01 11:03:02 -05:00
|
|
|
|
;; argument to toggle parsing of these secondary strings. Moreover,
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; `item' parser requires current list's structure as its first
|
|
|
|
|
;; element.
|
|
|
|
|
;;
|
|
|
|
|
;; An interpreter accepts two arguments: the list representation of
|
|
|
|
|
;; the element or object, and its contents. The latter may be nil,
|
|
|
|
|
;; depending on the element or object considered. It returns the
|
|
|
|
|
;; appropriate Org syntax, as a string.
|
|
|
|
|
;;
|
|
|
|
|
;; Parsing functions must follow the naming convention:
|
|
|
|
|
;; org-element-TYPE-parser, where TYPE is greater element's type, as
|
|
|
|
|
;; defined in `org-element-greater-elements'.
|
|
|
|
|
;;
|
|
|
|
|
;; Similarly, interpreting functions must follow the naming
|
|
|
|
|
;; convention: org-element-TYPE-interpreter.
|
|
|
|
|
;;
|
|
|
|
|
;; With the exception of `headline' and `item' types, greater elements
|
|
|
|
|
;; cannot contain other greater elements of their own type.
|
|
|
|
|
;;
|
|
|
|
|
;; Beside implementing a parser and an interpreter, adding a new
|
2016-01-25 07:35:15 -05:00
|
|
|
|
;; greater element requires tweaking `org-element--current-element'.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Moreover, the newly defined type must be added to both
|
|
|
|
|
;; `org-element-all-elements' and `org-element-greater-elements'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Center Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-center-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a center block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `center-block' and CDR is a plist
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end',
|
|
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the block."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_CENTER[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let ((block-end-line (match-beginning 0)))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
;; Empty blocks have no contents.
|
|
|
|
|
(contents-begin (progn (forward-line)
|
|
|
|
|
(and (< (point) block-end-line)
|
|
|
|
|
(point))))
|
|
|
|
|
(contents-end (and contents-begin block-end-line))
|
|
|
|
|
(pos-before-blank (progn (goto-char block-end-line)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(end (save-excursion
|
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(list 'center-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-center-block-interpreter (_ contents)
|
|
|
|
|
"Interpret a center-block element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the element."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_center\n%s#+end_center" contents))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Drawer
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-drawer-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a drawer.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `drawer' and CDR is a plist containing
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
`:drawer-name', `:begin', `:end', `:contents-begin',
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
`:contents-end', `:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at beginning of drawer."
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let ((case-fold-search t))
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(if (not (save-excursion (re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
;; Incomplete drawer: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((drawer-end-line (match-beginning 0))
|
|
|
|
|
(name (progn (looking-at org-drawer-regexp)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
;; Empty drawers have no contents.
|
|
|
|
|
(contents-begin (progn (forward-line)
|
|
|
|
|
(and (< (point) drawer-end-line)
|
|
|
|
|
(point))))
|
|
|
|
|
(contents-end (and contents-begin drawer-end-line))
|
|
|
|
|
(pos-before-blank (progn (goto-char drawer-end-line)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(list 'drawer
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:drawer-name name
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(cdr affiliated))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-drawer-interpreter (drawer contents)
|
|
|
|
|
"Interpret DRAWER element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the element."
|
|
|
|
|
(format ":%s:\n%s:END:"
|
|
|
|
|
(org-element-property :drawer-name drawer)
|
|
|
|
|
contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Dynamic Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-dynamic-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a dynamic block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `dynamic-block' and CDR is a plist
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
containing `:block-name', `:begin', `:end', `:contents-begin',
|
|
|
|
|
`:contents-end', `:arguments', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at beginning of dynamic block."
|
|
|
|
|
(let ((case-fold-search t))
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(if (not (save-excursion
|
|
|
|
|
(re-search-forward "^[ \t]*#\\+END:?[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let ((block-end-line (match-beginning 0)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((name (progn (looking-at org-dblock-start-re)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
|
|
|
|
(arguments (match-string-no-properties 3))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
;; Empty blocks have no contents.
|
|
|
|
|
(contents-begin (progn (forward-line)
|
|
|
|
|
(and (< (point) block-end-line)
|
|
|
|
|
(point))))
|
|
|
|
|
(contents-end (and contents-begin block-end-line))
|
|
|
|
|
(pos-before-blank (progn (goto-char block-end-line)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'dynamic-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:block-name name
|
|
|
|
|
:arguments arguments
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-dynamic-block-interpreter (dynamic-block contents)
|
|
|
|
|
"Interpret DYNAMIC-BLOCK element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the element."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin: %s%s\n%s#+end:"
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-property :block-name dynamic-block)
|
|
|
|
|
(let ((args (org-element-property :arguments dynamic-block)))
|
2017-05-19 10:29:12 -04:00
|
|
|
|
(if args (concat " " args) ""))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Footnote Definition
|
|
|
|
|
|
2016-01-14 03:31:24 -05:00
|
|
|
|
(defconst org-element--footnote-separator
|
|
|
|
|
(concat org-outline-regexp-bol "\\|"
|
|
|
|
|
org-footnote-definition-re "\\|"
|
|
|
|
|
"^\\([ \t]*\n\\)\\{2,\\}")
|
|
|
|
|
"Regexp used as a footnote definition separator.")
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-footnote-definition-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a footnote definition.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `footnote-definition' and CDR is
|
|
|
|
|
a plist containing `:label', `:begin' `:end', `:contents-begin',
|
2017-11-09 16:47:35 -05:00
|
|
|
|
`:contents-end', `:pre-blank',`:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the footnote definition."
|
|
|
|
|
(save-excursion
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let* ((label (progn (looking-at org-footnote-definition-re)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2017-06-07 17:45:17 -04:00
|
|
|
|
(end
|
2016-01-14 03:31:24 -05:00
|
|
|
|
(save-excursion
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(cond
|
|
|
|
|
((not
|
|
|
|
|
(re-search-forward org-element--footnote-separator limit t))
|
|
|
|
|
limit)
|
2017-06-07 17:45:17 -04:00
|
|
|
|
((eq ?\[ (char-after (match-beginning 0)))
|
2016-01-14 03:31:24 -05:00
|
|
|
|
;; At a new footnote definition, make sure we end
|
|
|
|
|
;; before any affiliated keyword above.
|
|
|
|
|
(forward-line -1)
|
|
|
|
|
(while (and (> (point) post-affiliated)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(looking-at-p org-element--affiliated-re))
|
2016-01-14 03:31:24 -05:00
|
|
|
|
(forward-line -1))
|
|
|
|
|
(line-beginning-position 2))
|
2017-06-07 17:45:17 -04:00
|
|
|
|
((eq ?* (char-after (match-beginning 0))) (match-beginning 0))
|
|
|
|
|
(t (skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(if (= limit (point)) limit (line-beginning-position))))))
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(pre-blank 0)
|
2016-01-14 03:31:24 -05:00
|
|
|
|
(contents-begin
|
2017-06-07 17:45:17 -04:00
|
|
|
|
(progn (search-forward "]")
|
|
|
|
|
(skip-chars-forward " \r\t\n" end)
|
|
|
|
|
(cond ((= (point) end) nil)
|
|
|
|
|
((= (line-beginning-position) post-affiliated) (point))
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(t
|
|
|
|
|
(setq pre-blank
|
|
|
|
|
(count-lines (line-beginning-position) begin))
|
|
|
|
|
(line-beginning-position)))))
|
2017-06-07 17:45:17 -04:00
|
|
|
|
(contents-end
|
|
|
|
|
(progn (goto-char end)
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(line-beginning-position 2))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'footnote-definition
|
|
|
|
|
(nconc
|
|
|
|
|
(list :label label
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
2017-06-07 17:45:17 -04:00
|
|
|
|
:contents-end (and contents-begin contents-end)
|
2017-11-09 16:47:35 -05:00
|
|
|
|
:pre-blank pre-blank
|
2017-06-07 17:45:17 -04:00
|
|
|
|
:post-blank (count-lines contents-end end)
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-footnote-definition-interpreter (footnote-definition contents)
|
|
|
|
|
"Interpret FOOTNOTE-DEFINITION element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the footnote-definition."
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(let ((pre-blank
|
|
|
|
|
(min (or (org-element-property :pre-blank footnote-definition)
|
|
|
|
|
;; 0 is specific to paragraphs at the beginning of
|
|
|
|
|
;; the footnote definition, so we use 1 as
|
|
|
|
|
;; a fall-back value, which is more universal.
|
|
|
|
|
1)
|
|
|
|
|
;; Footnote ends after more than two consecutive empty
|
|
|
|
|
;; lines: limit ourselves to 2 newline characters.
|
|
|
|
|
2)))
|
|
|
|
|
(concat (format "[fn:%s]" (org-element-property :label footnote-definition))
|
|
|
|
|
(if (= pre-blank 0) (concat " " (org-trim contents))
|
|
|
|
|
(concat (make-string pre-blank ?\n) contents)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Headline
|
|
|
|
|
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(defun org-element--get-node-properties ()
|
|
|
|
|
"Return node properties associated to headline at point.
|
|
|
|
|
Upcase property names. It avoids confusion between properties
|
|
|
|
|
obtained through property drawer and default properties from the
|
|
|
|
|
parser (e.g. `:end' and :END:). Return value is a plist."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(when (looking-at-p org-planning-line-re) (forward-line))
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(when (looking-at org-property-drawer-re)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(let ((end (match-end 0)) properties)
|
|
|
|
|
(while (< (line-end-position) end)
|
|
|
|
|
(looking-at org-property-re)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(push (match-string-no-properties 3) properties)
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(push (intern (concat ":" (upcase (match-string 2)))) properties)
|
|
|
|
|
(forward-line))
|
|
|
|
|
properties))))
|
|
|
|
|
|
|
|
|
|
(defun org-element--get-time-properties ()
|
|
|
|
|
"Return time properties associated to headline at point.
|
|
|
|
|
Return value is a plist."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(when (progn (forward-line) (looking-at org-planning-line-re))
|
|
|
|
|
(let ((end (line-end-position)) plist)
|
|
|
|
|
(while (re-search-forward org-keyword-time-not-clock-regexp end t)
|
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(let ((keyword (match-string 1))
|
|
|
|
|
(time (org-element-timestamp-parser)))
|
|
|
|
|
(cond ((equal keyword org-scheduled-string)
|
|
|
|
|
(setq plist (plist-put plist :scheduled time)))
|
|
|
|
|
((equal keyword org-deadline-string)
|
|
|
|
|
(setq plist (plist-put plist :deadline time)))
|
|
|
|
|
(t (setq plist (plist-put plist :closed time))))))
|
|
|
|
|
plist))))
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defun org-element-headline-parser (limit &optional raw-secondary-p)
|
2013-02-23 07:47:44 -05:00
|
|
|
|
"Parse a headline.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `headline' and CDR is a plist
|
2015-01-28 05:41:39 -05:00
|
|
|
|
containing `:raw-value', `:title', `:begin', `:end',
|
|
|
|
|
`:pre-blank', `:contents-begin' and `:contents-end', `:level',
|
|
|
|
|
`:priority', `:tags', `:todo-keyword',`:todo-type', `:scheduled',
|
|
|
|
|
`:deadline', `:closed', `:archivedp', `:commentedp'
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
`:footnote-section-p', `:post-blank' and `:post-affiliated'
|
|
|
|
|
keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
The plist also contains any property set in the property drawer,
|
2013-02-18 02:58:59 -05:00
|
|
|
|
with its name in upper cases and colons added at the
|
2014-03-17 05:31:37 -04:00
|
|
|
|
beginning (e.g., `:CUSTOM_ID').
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2014-04-09 17:26:05 -04:00
|
|
|
|
LIMIT is a buffer position bounding the search.
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
When RAW-SECONDARY-P is non-nil, headline's title will not be
|
|
|
|
|
parsed as a secondary string, but as a plain string instead.
|
|
|
|
|
|
|
|
|
|
Assume point is at beginning of the headline."
|
|
|
|
|
(save-excursion
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(let* ((begin (point))
|
|
|
|
|
(level (prog1 (org-reduced-level (skip-chars-forward "*"))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(todo (and org-todo-regexp
|
2018-06-06 09:41:50 -04:00
|
|
|
|
(let (case-fold-search) (looking-at (concat org-todo-regexp " ")))
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")
|
2018-06-06 09:41:50 -04:00
|
|
|
|
(match-string 1))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(todo-type
|
|
|
|
|
(and todo (if (member todo org-done-keywords) 'done 'todo)))
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(priority (and (looking-at "\\[#.\\][ \t]*")
|
|
|
|
|
(progn (goto-char (match-end 0))
|
|
|
|
|
(aref (match-string 0) 2))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(commentedp
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(and (let (case-fold-search) (looking-at org-comment-string))
|
|
|
|
|
(goto-char (match-end 0))))
|
|
|
|
|
(title-start (point))
|
|
|
|
|
(tags (when (re-search-forward
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
"[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(line-end-position)
|
|
|
|
|
'move)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(org-split-string (match-string 1) ":")))
|
|
|
|
|
(title-end (point))
|
|
|
|
|
(raw-value (org-trim
|
|
|
|
|
(buffer-substring-no-properties title-start title-end)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(archivedp (member org-archive-tag tags))
|
|
|
|
|
(footnote-section-p (and org-footnote-section
|
|
|
|
|
(string= org-footnote-section raw-value)))
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(standard-props (org-element--get-node-properties))
|
|
|
|
|
(time-props (org-element--get-time-properties))
|
2014-04-09 17:49:04 -04:00
|
|
|
|
(end (min (save-excursion (org-end-of-subtree t t)) limit))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(contents-begin (save-excursion
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(forward-line)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(skip-chars-forward " \r\t\n" end)
|
|
|
|
|
(and (/= (point) end) (line-beginning-position))))
|
|
|
|
|
(contents-end (and contents-begin
|
|
|
|
|
(progn (goto-char end)
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(line-beginning-position 2)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((headline
|
|
|
|
|
(list 'headline
|
|
|
|
|
(nconc
|
|
|
|
|
(list :raw-value raw-value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
2012-07-28 17:21:38 -04:00
|
|
|
|
:pre-blank
|
|
|
|
|
(if (not contents-begin) 0
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(1- (count-lines begin contents-begin)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:level level
|
2015-01-27 16:25:15 -05:00
|
|
|
|
:priority priority
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:tags tags
|
|
|
|
|
:todo-keyword todo
|
|
|
|
|
:todo-type todo-type
|
2016-11-09 17:25:53 -05:00
|
|
|
|
:post-blank
|
|
|
|
|
(if contents-end
|
|
|
|
|
(count-lines contents-end end)
|
|
|
|
|
(1- (count-lines begin end)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:footnote-section-p footnote-section-p
|
|
|
|
|
:archivedp archivedp
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:commentedp commentedp
|
|
|
|
|
:post-affiliated begin)
|
2012-09-28 08:50:21 -04:00
|
|
|
|
time-props
|
2012-07-28 01:02:21 -04:00
|
|
|
|
standard-props))))
|
|
|
|
|
(org-element-put-property
|
|
|
|
|
headline :title
|
|
|
|
|
(if raw-secondary-p raw-value
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(progn (goto-char title-start)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(point))
|
|
|
|
|
(progn (goto-char title-end)
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(point))
|
|
|
|
|
nil
|
|
|
|
|
(org-element-restriction 'headline)
|
|
|
|
|
headline)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-headline-interpreter (headline contents)
|
|
|
|
|
"Interpret HEADLINE element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the element."
|
|
|
|
|
(let* ((level (org-element-property :level headline))
|
|
|
|
|
(todo (org-element-property :todo-keyword headline))
|
|
|
|
|
(priority (org-element-property :priority headline))
|
|
|
|
|
(title (org-element-interpret-data
|
|
|
|
|
(org-element-property :title headline)))
|
2015-04-24 08:28:17 -04:00
|
|
|
|
(tags (let ((tag-list (org-element-property :tags headline)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(and tag-list
|
2014-08-28 05:07:24 -04:00
|
|
|
|
(format ":%s:" (mapconcat #'identity tag-list ":")))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(commentedp (org-element-property :commentedp headline))
|
|
|
|
|
(pre-blank (or (org-element-property :pre-blank headline) 0))
|
2014-08-28 05:07:24 -04:00
|
|
|
|
(heading
|
|
|
|
|
(concat (make-string (if org-odd-levels-only (1- (* level 2)) level)
|
|
|
|
|
?*)
|
|
|
|
|
(and todo (concat " " todo))
|
|
|
|
|
(and commentedp (concat " " org-comment-string))
|
2015-01-27 11:49:22 -05:00
|
|
|
|
(and priority (format " [#%c]" priority))
|
2014-08-28 05:07:24 -04:00
|
|
|
|
" "
|
|
|
|
|
(if (and org-footnote-section
|
|
|
|
|
(org-element-property :footnote-section-p headline))
|
|
|
|
|
org-footnote-section
|
|
|
|
|
title))))
|
|
|
|
|
(concat
|
|
|
|
|
heading
|
|
|
|
|
;; Align tags.
|
|
|
|
|
(when tags
|
|
|
|
|
(cond
|
|
|
|
|
((zerop org-tags-column) (format " %s" tags))
|
|
|
|
|
((< org-tags-column 0)
|
|
|
|
|
(concat
|
|
|
|
|
(make-string
|
|
|
|
|
(max (- (+ org-tags-column (length heading) (length tags))) 1)
|
|
|
|
|
?\s)
|
|
|
|
|
tags))
|
|
|
|
|
(t
|
|
|
|
|
(concat
|
|
|
|
|
(make-string (max (- org-tags-column (length heading)) 1) ?\s)
|
|
|
|
|
tags))))
|
|
|
|
|
(make-string (1+ pre-blank) ?\n)
|
|
|
|
|
contents)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inlinetask
|
|
|
|
|
|
|
|
|
|
(defun org-element-inlinetask-parser (limit &optional raw-secondary-p)
|
|
|
|
|
"Parse an inline task.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `inlinetask' and CDR is a plist
|
2016-11-09 17:25:53 -05:00
|
|
|
|
containing `:title', `:begin', `:end', `:pre-blank',
|
|
|
|
|
`:contents-begin' and `:contents-end', `:level', `:priority',
|
|
|
|
|
`:raw-value', `:tags', `:todo-keyword', `:todo-type',
|
|
|
|
|
`:scheduled', `:deadline', `:closed', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
The plist also contains any property set in the property drawer,
|
2013-02-18 02:58:59 -05:00
|
|
|
|
with its name in upper cases and colons added at the
|
2014-03-17 05:31:37 -04:00
|
|
|
|
beginning (e.g., `:CUSTOM_ID').
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
When optional argument RAW-SECONDARY-P is non-nil, inline-task's
|
|
|
|
|
title will not be parsed as a secondary string, but as a plain
|
|
|
|
|
string instead.
|
|
|
|
|
|
|
|
|
|
Assume point is at beginning of the inline task."
|
|
|
|
|
(save-excursion
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(let* ((begin (point))
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(level (prog1 (org-reduced-level (skip-chars-forward "*"))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(todo (and org-todo-regexp
|
|
|
|
|
(let (case-fold-search) (looking-at org-todo-regexp))
|
|
|
|
|
(progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(match-string 0))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(todo-type (and todo
|
|
|
|
|
(if (member todo org-done-keywords) 'done 'todo)))
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(priority (and (looking-at "\\[#.\\][ \t]*")
|
|
|
|
|
(progn (goto-char (match-end 0))
|
|
|
|
|
(aref (match-string 0) 2))))
|
|
|
|
|
(title-start (point))
|
|
|
|
|
(tags (when (re-search-forward
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
"[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$"
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(line-end-position)
|
|
|
|
|
'move)
|
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(org-split-string (match-string 1) ":")))
|
|
|
|
|
(title-end (point))
|
|
|
|
|
(raw-value (org-trim
|
|
|
|
|
(buffer-substring-no-properties title-start title-end)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(task-end (save-excursion
|
|
|
|
|
(end-of-line)
|
2014-02-17 16:59:25 -05:00
|
|
|
|
(and (re-search-forward org-outline-regexp-bol limit t)
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(looking-at-p "[ \t]*END[ \t]*$")
|
2014-02-17 16:59:25 -05:00
|
|
|
|
(line-beginning-position))))
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(standard-props (and task-end (org-element--get-node-properties)))
|
|
|
|
|
(time-props (and task-end (org-element--get-time-properties)))
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(contents-begin (and task-end
|
|
|
|
|
(< (point) task-end)
|
|
|
|
|
(progn
|
|
|
|
|
(forward-line)
|
|
|
|
|
(skip-chars-forward " \t\n")
|
|
|
|
|
(line-beginning-position))))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(contents-end (and contents-begin task-end))
|
2016-11-09 17:25:53 -05:00
|
|
|
|
(end (progn (when task-end (goto-char task-end))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(inlinetask
|
|
|
|
|
(list 'inlinetask
|
|
|
|
|
(nconc
|
2012-09-09 08:13:24 -04:00
|
|
|
|
(list :raw-value raw-value
|
|
|
|
|
:begin begin
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:end end
|
2016-11-09 17:25:53 -05:00
|
|
|
|
:pre-blank
|
|
|
|
|
(if (not contents-begin) 0
|
|
|
|
|
(1- (count-lines begin contents-begin)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
2015-01-27 16:25:15 -05:00
|
|
|
|
:level level
|
|
|
|
|
:priority priority
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:tags tags
|
|
|
|
|
:todo-keyword todo
|
|
|
|
|
:todo-type todo-type
|
2016-11-09 17:25:53 -05:00
|
|
|
|
:post-blank (1- (count-lines (or task-end begin) end))
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:post-affiliated begin)
|
2012-09-28 08:50:21 -04:00
|
|
|
|
time-props
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
standard-props))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-put-property
|
|
|
|
|
inlinetask :title
|
2012-09-09 08:13:24 -04:00
|
|
|
|
(if raw-secondary-p raw-value
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(progn (goto-char title-start)
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(point))
|
|
|
|
|
(progn (goto-char title-end)
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(point))
|
|
|
|
|
nil
|
|
|
|
|
(org-element-restriction 'inlinetask)
|
|
|
|
|
inlinetask))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-inlinetask-interpreter (inlinetask contents)
|
|
|
|
|
"Interpret INLINETASK element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of inlinetask."
|
|
|
|
|
(let* ((level (org-element-property :level inlinetask))
|
|
|
|
|
(todo (org-element-property :todo-keyword inlinetask))
|
|
|
|
|
(priority (org-element-property :priority inlinetask))
|
|
|
|
|
(title (org-element-interpret-data
|
|
|
|
|
(org-element-property :title inlinetask)))
|
|
|
|
|
(tags (let ((tag-list (org-element-property :tags inlinetask)))
|
|
|
|
|
(and tag-list
|
|
|
|
|
(format ":%s:" (mapconcat 'identity tag-list ":")))))
|
|
|
|
|
(task (concat (make-string level ?*)
|
|
|
|
|
(and todo (concat " " todo))
|
2015-01-27 11:49:22 -05:00
|
|
|
|
(and priority (format " [#%c]" priority))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(and title (concat " " title)))))
|
|
|
|
|
(concat task
|
|
|
|
|
;; Align tags.
|
|
|
|
|
(when tags
|
|
|
|
|
(cond
|
|
|
|
|
((zerop org-tags-column) (format " %s" tags))
|
|
|
|
|
((< org-tags-column 0)
|
|
|
|
|
(concat
|
|
|
|
|
(make-string
|
|
|
|
|
(max (- (+ org-tags-column (length task) (length tags))) 1)
|
2018-01-24 06:56:25 -05:00
|
|
|
|
?\s)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
tags))
|
|
|
|
|
(t
|
|
|
|
|
(concat
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(make-string (max (- org-tags-column (length task)) 1) ?\s)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
tags))))
|
|
|
|
|
;; Prefer degenerate inlinetasks when there are no
|
|
|
|
|
;; contents.
|
|
|
|
|
(when contents
|
|
|
|
|
(concat "\n"
|
|
|
|
|
contents
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(make-string level ?*) " end")))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Item
|
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-item-parser (_ struct &optional raw-secondary-p)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse an item.
|
|
|
|
|
|
|
|
|
|
STRUCT is the structure of the plain list.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `item' and CDR is a plist containing
|
|
|
|
|
`:bullet', `:begin', `:end', `:contents-begin', `:contents-end',
|
2017-11-09 16:47:35 -05:00
|
|
|
|
`:checkbox', `:counter', `:tag', `:structure', `:pre-blank',
|
|
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
When optional argument RAW-SECONDARY-P is non-nil, item's tag, if
|
|
|
|
|
any, will not be parsed as a secondary string, but as a plain
|
|
|
|
|
string instead.
|
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the item."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(beginning-of-line)
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(looking-at org-list-full-item-re)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let* ((begin (point))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(bullet (match-string-no-properties 1))
|
2015-05-07 17:45:41 -04:00
|
|
|
|
(checkbox (let ((box (match-string 3)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(cond ((equal "[ ]" box) 'off)
|
|
|
|
|
((equal "[X]" box) 'on)
|
|
|
|
|
((equal "[-]" box) 'trans))))
|
2015-05-07 17:45:41 -04:00
|
|
|
|
(counter (let ((c (match-string 2)))
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(save-match-data
|
|
|
|
|
(cond
|
|
|
|
|
((not c) nil)
|
|
|
|
|
((string-match "[A-Za-z]" c)
|
|
|
|
|
(- (string-to-char (upcase (match-string 0 c)))
|
|
|
|
|
64))
|
|
|
|
|
((string-match "[0-9]+" c)
|
|
|
|
|
(string-to-number (match-string 0 c)))))))
|
2013-11-04 12:16:28 -05:00
|
|
|
|
(end (progn (goto-char (nth 6 (assq (point) struct)))
|
2015-05-07 17:45:41 -04:00
|
|
|
|
(if (bolp) (point) (line-beginning-position 2))))
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(pre-blank 0)
|
2012-08-18 06:37:39 -04:00
|
|
|
|
(contents-begin
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(progn
|
|
|
|
|
(goto-char
|
|
|
|
|
;; Ignore tags in un-ordered lists: they are just
|
|
|
|
|
;; a part of item's body.
|
|
|
|
|
(if (and (match-beginning 4)
|
|
|
|
|
(save-match-data (string-match "[.)]" bullet)))
|
|
|
|
|
(match-beginning 4)
|
|
|
|
|
(match-end 0)))
|
|
|
|
|
(skip-chars-forward " \r\t\n" end)
|
|
|
|
|
(cond ((= (point) end) nil)
|
|
|
|
|
;; If first line isn't empty, contents really
|
|
|
|
|
;; start at the text after item's meta-data.
|
|
|
|
|
((= (line-beginning-position) begin) (point))
|
|
|
|
|
(t
|
|
|
|
|
(setq pre-blank
|
|
|
|
|
(count-lines (line-beginning-position) begin))
|
|
|
|
|
(line-beginning-position)))))
|
2015-05-07 17:45:41 -04:00
|
|
|
|
(contents-end (and contents-begin
|
|
|
|
|
(progn (goto-char end)
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(line-beginning-position 2))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(item
|
|
|
|
|
(list 'item
|
|
|
|
|
(list :bullet bullet
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
2015-05-07 17:45:41 -04:00
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:checkbox checkbox
|
|
|
|
|
:counter counter
|
|
|
|
|
:structure struct
|
2017-11-09 16:47:35 -05:00
|
|
|
|
:pre-blank pre-blank
|
2015-05-07 17:45:41 -04:00
|
|
|
|
:post-blank (count-lines (or contents-end begin) end)
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:post-affiliated begin))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-put-property
|
|
|
|
|
item :tag
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(let ((raw (org-list-get-tag begin struct)))
|
|
|
|
|
(when raw
|
|
|
|
|
(if raw-secondary-p raw
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(match-beginning 4) (match-end 4) nil
|
|
|
|
|
(org-element-restriction 'item)
|
|
|
|
|
item))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-item-interpreter (item contents)
|
|
|
|
|
"Interpret ITEM element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the element."
|
2018-01-28 10:09:54 -05:00
|
|
|
|
(let ((tag (pcase (org-element-property :tag item)
|
|
|
|
|
(`nil nil)
|
|
|
|
|
(tag (format "%s :: " (org-element-interpret-data tag)))))
|
|
|
|
|
(bullet
|
|
|
|
|
(org-list-bullet-string
|
|
|
|
|
(cond
|
|
|
|
|
((not (string-match-p "[0-9a-zA-Z]"
|
|
|
|
|
(org-element-property :bullet item))) "- ")
|
|
|
|
|
((eq org-plain-list-ordered-item-terminator ?\)) "1)")
|
|
|
|
|
(t "1.")))))
|
|
|
|
|
(concat
|
|
|
|
|
bullet
|
|
|
|
|
(pcase (org-element-property :counter item)
|
|
|
|
|
(`nil nil)
|
|
|
|
|
(counter (format "[@%d] " counter)))
|
|
|
|
|
(pcase (org-element-property :checkbox item)
|
|
|
|
|
(`on "[X] ")
|
|
|
|
|
(`off "[ ] ")
|
|
|
|
|
(`trans "[-] ")
|
|
|
|
|
(_ nil))
|
|
|
|
|
tag
|
|
|
|
|
(when contents
|
|
|
|
|
(let* ((ind (make-string (if tag 5 (length bullet)) ?\s))
|
|
|
|
|
(pre-blank
|
|
|
|
|
(min (or (org-element-property :pre-blank item)
|
|
|
|
|
;; 0 is specific to paragraphs at the
|
|
|
|
|
;; beginning of the item, so we use 1 as
|
|
|
|
|
;; a fall-back value, which is more universal.
|
|
|
|
|
1)
|
|
|
|
|
;; Lists ends after more than two consecutive
|
|
|
|
|
;; empty lines: limit ourselves to 2 newline
|
|
|
|
|
;; characters.
|
|
|
|
|
2))
|
|
|
|
|
(contents (replace-regexp-in-string
|
|
|
|
|
"\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
|
|
|
|
|
(if (= pre-blank 0) (org-trim contents)
|
|
|
|
|
(concat (make-string pre-blank ?\n) contents)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Plain List
|
|
|
|
|
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(defun org-element--list-struct (limit)
|
2013-06-01 15:38:15 -04:00
|
|
|
|
;; Return structure of list at point. Internal function. See
|
|
|
|
|
;; `org-list-struct' for details.
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(let ((case-fold-search t)
|
2013-06-01 15:38:15 -04:00
|
|
|
|
(top-ind limit)
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(item-re (org-item-re))
|
|
|
|
|
(inlinetask-re (and (featurep 'org-inlinetask) "^\\*+ "))
|
|
|
|
|
items struct)
|
|
|
|
|
(save-excursion
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(catch :exit
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(while t
|
|
|
|
|
(cond
|
|
|
|
|
;; At limit: end all items.
|
|
|
|
|
((>= (point) limit)
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(let ((end (progn (skip-chars-backward " \r\t\n")
|
|
|
|
|
(line-beginning-position 2))))
|
|
|
|
|
(dolist (item items) (setcar (nthcdr 6 item) end)))
|
|
|
|
|
(throw :exit (sort (nconc items struct) #'car-less-than-car)))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
;; At list end: end all items.
|
|
|
|
|
((looking-at org-list-end-re)
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(dolist (item items) (setcar (nthcdr 6 item) (point)))
|
|
|
|
|
(throw :exit (sort (nconc items struct) #'car-less-than-car)))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
;; At a new item: end previous sibling.
|
|
|
|
|
((looking-at item-re)
|
|
|
|
|
(let ((ind (save-excursion (skip-chars-forward " \t")
|
|
|
|
|
(current-column))))
|
2013-06-01 15:38:15 -04:00
|
|
|
|
(setq top-ind (min top-ind ind))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(while (and items (<= ind (nth 1 (car items))))
|
|
|
|
|
(let ((item (pop items)))
|
|
|
|
|
(setcar (nthcdr 6 item) (point))
|
|
|
|
|
(push item struct)))
|
|
|
|
|
(push (progn (looking-at org-list-full-item-re)
|
|
|
|
|
(let ((bullet (match-string-no-properties 1)))
|
|
|
|
|
(list (point)
|
|
|
|
|
ind
|
|
|
|
|
bullet
|
|
|
|
|
(match-string-no-properties 2) ; counter
|
|
|
|
|
(match-string-no-properties 3) ; checkbox
|
|
|
|
|
;; Description tag.
|
|
|
|
|
(and (save-match-data
|
|
|
|
|
(string-match "[-+*]" bullet))
|
|
|
|
|
(match-string-no-properties 4))
|
|
|
|
|
;; Ending position, unknown so far.
|
|
|
|
|
nil)))
|
|
|
|
|
items))
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(forward-line))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
;; Skip empty lines.
|
|
|
|
|
((looking-at "^[ \t]*$") (forward-line))
|
|
|
|
|
;; Skip inline tasks and blank lines along the way.
|
|
|
|
|
((and inlinetask-re (looking-at inlinetask-re))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(let ((origin (point)))
|
|
|
|
|
(when (re-search-forward inlinetask-re limit t)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(if (looking-at-p "END[ \t]*$") (forward-line)
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(goto-char origin)))))
|
|
|
|
|
;; At some text line. Check if it ends any previous item.
|
|
|
|
|
(t
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(let ((ind (save-excursion
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(current-column)))
|
|
|
|
|
(end (save-excursion
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(line-beginning-position 2))))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(while (<= ind (nth 1 (car items)))
|
|
|
|
|
(let ((item (pop items)))
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(setcar (nthcdr 6 item) end)
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(push item struct)
|
|
|
|
|
(unless items
|
2017-11-04 16:50:11 -04:00
|
|
|
|
(throw :exit (sort struct #'car-less-than-car))))))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
;; Skip blocks (any type) and drawers contents.
|
|
|
|
|
(cond
|
2015-06-09 11:05:21 -04:00
|
|
|
|
((and (looking-at "[ \t]*#\\+BEGIN\\(:\\|_\\S-+\\)")
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(re-search-forward
|
2014-03-14 11:15:57 -04:00
|
|
|
|
(format "^[ \t]*#\\+END%s[ \t]*$" (match-string 1))
|
2013-05-31 14:13:29 -04:00
|
|
|
|
limit t)))
|
2013-10-20 08:40:09 -04:00
|
|
|
|
((and (looking-at org-drawer-regexp)
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t))))
|
|
|
|
|
(forward-line))))))))
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-plain-list-parser (limit affiliated structure)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a plain list.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value. STRUCTURE is the structure of the plain list being
|
|
|
|
|
parsed.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `plain-list' and CDR is a plist
|
|
|
|
|
containing `:type', `:begin', `:end', `:contents-begin' and
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
`:contents-end', `:structure', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the list."
|
|
|
|
|
(save-excursion
|
2013-05-31 14:13:29 -04:00
|
|
|
|
(let* ((struct (or structure (org-element--list-struct limit)))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(type (cond ((looking-at-p "[ \t]*[A-Za-z0-9]") 'ordered)
|
2013-11-04 12:16:28 -05:00
|
|
|
|
((nth 5 (assq (point) struct)) 'descriptive)
|
|
|
|
|
(t 'unordered)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(contents-begin (point))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(begin (car affiliated))
|
2013-11-04 12:16:28 -05:00
|
|
|
|
(contents-end (let* ((item (assq contents-begin struct))
|
|
|
|
|
(ind (nth 1 item))
|
|
|
|
|
(pos (nth 6 item)))
|
|
|
|
|
(while (and (setq item (assq pos struct))
|
|
|
|
|
(= (nth 1 item) ind))
|
|
|
|
|
(setq pos (nth 6 item)))
|
|
|
|
|
pos))
|
|
|
|
|
(end (progn (goto-char contents-end)
|
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
2013-07-21 09:51:14 -04:00
|
|
|
|
(if (= (point) limit) limit (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Return value.
|
|
|
|
|
(list 'plain-list
|
|
|
|
|
(nconc
|
|
|
|
|
(list :type type
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:structure struct
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines contents-end end)
|
|
|
|
|
:post-affiliated contents-begin)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-plain-list-interpreter (_ contents)
|
|
|
|
|
"Interpret plain-list element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the element."
|
2012-08-02 15:56:39 -04:00
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert contents)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(org-list-repair)
|
|
|
|
|
(buffer-string)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
2012-09-23 09:52:02 -04:00
|
|
|
|
;;;; Property Drawer
|
|
|
|
|
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(defun org-element-property-drawer-parser (limit)
|
2012-09-23 09:52:02 -04:00
|
|
|
|
"Parse a property drawer.
|
|
|
|
|
|
2014-09-13 16:43:45 -04:00
|
|
|
|
LIMIT bounds the search.
|
2012-09-23 09:52:02 -04:00
|
|
|
|
|
2014-09-13 16:43:45 -04:00
|
|
|
|
Return a list whose car is `property-drawer' and cdr is a plist
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end',
|
|
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
2012-09-23 09:52:02 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the property drawer."
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(begin (point))
|
|
|
|
|
(contents-begin (line-beginning-position 2)))
|
|
|
|
|
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t)
|
|
|
|
|
(let ((contents-end (and (> (match-beginning 0) contents-begin)
|
|
|
|
|
(match-beginning 0)))
|
|
|
|
|
(before-blank (progn (forward-line) (point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
|
|
|
|
(list 'property-drawer
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin (and contents-end contents-begin)
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank (count-lines before-blank end)
|
|
|
|
|
:post-affiliated begin))))))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-property-drawer-interpreter (_ contents)
|
|
|
|
|
"Interpret property-drawer element as Org syntax.
|
2012-09-23 09:52:02 -04:00
|
|
|
|
CONTENTS is the properties within the drawer."
|
|
|
|
|
(format ":PROPERTIES:\n%s:END:" contents))
|
|
|
|
|
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;;; Quote Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-quote-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a quote block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `quote-block' and CDR is a plist
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end',
|
|
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the block."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_QUOTE[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let ((block-end-line (match-beginning 0)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
;; Empty blocks have no contents.
|
|
|
|
|
(contents-begin (progn (forward-line)
|
|
|
|
|
(and (< (point) block-end-line)
|
|
|
|
|
(point))))
|
|
|
|
|
(contents-end (and contents-begin block-end-line))
|
|
|
|
|
(pos-before-blank (progn (goto-char block-end-line)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'quote-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-quote-block-interpreter (_ contents)
|
|
|
|
|
"Interpret quote-block element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the element."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_quote\n%s#+end_quote" contents))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Section
|
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-section-parser (_)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a section.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `section' and CDR is a plist
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
containing `:begin', `:end', `:contents-begin', `contents-end',
|
|
|
|
|
`:post-blank' and `:post-affiliated' keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
;; Beginning of section is the beginning of the first non-blank
|
|
|
|
|
;; line after previous headline.
|
2012-09-01 16:52:43 -04:00
|
|
|
|
(let ((begin (point))
|
|
|
|
|
(end (progn (org-with-limited-levels (outline-next-heading))
|
|
|
|
|
(point)))
|
|
|
|
|
(pos-before-blank (progn (skip-chars-backward " \r\t\n")
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(line-beginning-position 2))))
|
2012-09-01 16:52:43 -04:00
|
|
|
|
(list 'section
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin begin
|
|
|
|
|
:contents-end pos-before-blank
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated begin)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-section-interpreter (_ contents)
|
|
|
|
|
"Interpret section element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the element."
|
|
|
|
|
contents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Special Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-special-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a special block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `special-block' and CDR is a plist
|
2014-09-08 05:57:27 -04:00
|
|
|
|
containing `:type', `:begin', `:end', `:contents-begin',
|
|
|
|
|
`:contents-end', `:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the block."
|
|
|
|
|
(let* ((case-fold-search t)
|
2013-06-17 11:08:53 -04:00
|
|
|
|
(type (progn (looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
|
2014-09-17 13:38:06 -04:00
|
|
|
|
(match-string-no-properties 1))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward
|
2013-06-17 11:08:53 -04:00
|
|
|
|
(format "^[ \t]*#\\+END_%s[ \t]*$" (regexp-quote type))
|
|
|
|
|
limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(let ((block-end-line (match-beginning 0)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
;; Empty blocks have no contents.
|
|
|
|
|
(contents-begin (progn (forward-line)
|
|
|
|
|
(and (< (point) block-end-line)
|
|
|
|
|
(point))))
|
|
|
|
|
(contents-end (and contents-begin block-end-line))
|
|
|
|
|
(pos-before-blank (progn (goto-char block-end-line)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
org-element: Fix parsing with trailing spaces at eob
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, , org-element-footnote-definition-parser,
org-element-inlinetask-parser, org-element-plain-list-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-clock-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-planning-parser,
org-element-property-drawer-parser, org-element-src-block-parser,
org-element-table-parser,
org-element-verse-block-parserorg-element-dynamic-block-parser):
Make sure element never ends at the end of a blank non-empty line.
* testing/lisp/test-org-element.el: Add test.
2012-10-05 19:02:03 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'special-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :type type
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-special-block-interpreter (special-block contents)
|
|
|
|
|
"Interpret SPECIAL-BLOCK element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the element."
|
|
|
|
|
(let ((block-type (org-element-property :type special-block)))
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_%s\n%s#+end_%s" block-type contents block-type)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Elements
|
|
|
|
|
;;
|
|
|
|
|
;; For each element, a parser and an interpreter are also defined.
|
|
|
|
|
;; Both follow the same naming convention used for greater elements.
|
|
|
|
|
;;
|
|
|
|
|
;; Also, as for greater elements, adding a new element type is done
|
|
|
|
|
;; through the following steps: implement a parser and an interpreter,
|
|
|
|
|
;; tweak `org-element--current-element' so that it recognizes the new
|
|
|
|
|
;; type and add that new type to `org-element-all-elements'.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Babel Call
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-babel-call-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a babel call.
|
|
|
|
|
|
2015-04-21 05:54:22 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which car is
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
the buffer position at the beginning of the first affiliated
|
2015-04-21 05:54:22 -04:00
|
|
|
|
keyword and cdr is a plist of affiliated keywords along with
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-04-21 05:54:22 -04:00
|
|
|
|
Return a list whose car is `babel-call' and cdr is a plist
|
|
|
|
|
containing `:call', `:inside-header', `:arguments',
|
|
|
|
|
`:end-header', `:begin', `:end', `:value', `:post-blank' and
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
`:post-affiliated' as keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
2015-04-21 05:54:22 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
|
|
|
|
(post-affiliated (point))
|
2017-06-20 15:20:30 -04:00
|
|
|
|
(before-blank (line-beginning-position 2))
|
|
|
|
|
(value (progn (search-forward ":" before-blank t)
|
|
|
|
|
(skip-chars-forward " \t")
|
2015-04-21 05:54:22 -04:00
|
|
|
|
(org-trim
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point) (line-end-position)))))
|
2017-06-20 15:20:30 -04:00
|
|
|
|
(call
|
|
|
|
|
(or (org-string-nw-p
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(point) (progn (skip-chars-forward "^[]()" before-blank)
|
|
|
|
|
(point))))))
|
|
|
|
|
(inside-header (org-element--parse-paired-brackets ?\[))
|
|
|
|
|
(arguments (org-string-nw-p
|
|
|
|
|
(org-element--parse-paired-brackets ?\()))
|
|
|
|
|
(end-header
|
|
|
|
|
(org-string-nw-p
|
|
|
|
|
(org-trim
|
|
|
|
|
(buffer-substring-no-properties (point) (line-end-position)))))
|
|
|
|
|
(end (progn (forward-line)
|
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'babel-call
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(nconc
|
2017-06-20 15:20:30 -04:00
|
|
|
|
(list :call call
|
|
|
|
|
:inside-header inside-header
|
|
|
|
|
:arguments arguments
|
|
|
|
|
:end-header end-header
|
2015-04-21 05:54:22 -04:00
|
|
|
|
:begin begin
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
:end end
|
2013-10-20 07:14:23 -04:00
|
|
|
|
:value value
|
2017-06-20 15:20:30 -04:00
|
|
|
|
:post-blank (count-lines before-blank end)
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-babel-call-interpreter (babel-call _)
|
|
|
|
|
"Interpret BABEL-CALL element as Org syntax."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(concat "#+call: "
|
2015-04-21 05:54:22 -04:00
|
|
|
|
(org-element-property :call babel-call)
|
|
|
|
|
(let ((h (org-element-property :inside-header babel-call)))
|
|
|
|
|
(and h (format "[%s]" h)))
|
|
|
|
|
(concat "(" (org-element-property :arguments babel-call) ")")
|
|
|
|
|
(let ((h (org-element-property :end-header babel-call)))
|
|
|
|
|
(and h (concat " " h)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Clock
|
|
|
|
|
|
|
|
|
|
(defun org-element-clock-parser (limit)
|
|
|
|
|
"Parse a clock.
|
|
|
|
|
|
|
|
|
|
LIMIT bounds the search.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `clock' and CDR is a plist containing
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
`:status', `:value', `:time', `:begin', `:end', `:post-blank' and
|
|
|
|
|
`:post-affiliated' as keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((case-fold-search nil)
|
|
|
|
|
(begin (point))
|
|
|
|
|
(value (progn (search-forward org-clock-string (line-end-position) t)
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(org-element-timestamp-parser)))
|
|
|
|
|
(duration (and (search-forward " => " (line-end-position) t)
|
|
|
|
|
(progn (skip-chars-forward " \t")
|
|
|
|
|
(looking-at "\\(\\S-+\\)[ \t]*$"))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(status (if duration 'closed 'running))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(post-blank (let ((before-blank (progn (forward-line) (point))))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
org-element: Fix parsing with trailing spaces at eob
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, , org-element-footnote-definition-parser,
org-element-inlinetask-parser, org-element-plain-list-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-clock-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-planning-parser,
org-element-property-drawer-parser, org-element-src-block-parser,
org-element-table-parser,
org-element-verse-block-parserorg-element-dynamic-block-parser):
Make sure element never ends at the end of a blank non-empty line.
* testing/lisp/test-org-element.el: Add test.
2012-10-05 19:02:03 -04:00
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(unless (bolp) (end-of-line))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(count-lines before-blank (point))))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'clock
|
|
|
|
|
(list :status status
|
|
|
|
|
:value value
|
2012-09-28 08:50:21 -04:00
|
|
|
|
:duration duration
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:post-blank post-blank
|
|
|
|
|
:post-affiliated begin)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-clock-interpreter (clock _)
|
|
|
|
|
"Interpret CLOCK element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(concat org-clock-string " "
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(org-element-timestamp-interpreter
|
|
|
|
|
(org-element-property :value clock) nil)
|
|
|
|
|
(let ((duration (org-element-property :duration clock)))
|
|
|
|
|
(and duration
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(concat " => "
|
|
|
|
|
(apply 'format
|
|
|
|
|
"%2s:%02s"
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(org-split-string duration ":")))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Comment
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-comment-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a comment.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `comment' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:begin', `:end', `:value', `:post-blank',
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at comment beginning."
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-08-04 04:16:12 -04:00
|
|
|
|
(value (prog2 (looking-at "[ \t]*# ?")
|
2012-08-02 13:47:14 -04:00
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(match-end 0) (line-end-position))
|
|
|
|
|
(forward-line)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(com-end
|
|
|
|
|
;; Get comments ending.
|
|
|
|
|
(progn
|
2012-08-02 13:47:14 -04:00
|
|
|
|
(while (and (< (point) limit) (looking-at "[ \t]*#\\( \\|$\\)"))
|
2012-07-31 19:27:27 -04:00
|
|
|
|
;; Accumulate lines without leading hash and first
|
|
|
|
|
;; whitespace.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(setq value
|
|
|
|
|
(concat value
|
2012-08-02 13:47:14 -04:00
|
|
|
|
"\n"
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(buffer-substring-no-properties
|
2012-08-02 13:47:14 -04:00
|
|
|
|
(match-end 0) (line-end-position))))
|
|
|
|
|
(forward-line))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(point)))
|
|
|
|
|
(end (progn (goto-char com-end)
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
2013-11-10 04:18:17 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'comment
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines com-end end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-comment-interpreter (comment _)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Interpret COMMENT element as Org syntax.
|
|
|
|
|
CONTENTS is nil."
|
2012-07-31 19:27:27 -04:00
|
|
|
|
(replace-regexp-in-string "^" "# " (org-element-property :value comment)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Comment Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-comment-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse an export block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `comment-block' and CDR is a plist
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
containing `:begin', `:end', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at comment block beginning."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_COMMENT[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((contents-end (match-beginning 0)))
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(contents-begin (progn (forward-line) (point)))
|
|
|
|
|
(pos-before-blank (progn (goto-char contents-end)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(value (buffer-substring-no-properties
|
|
|
|
|
contents-begin contents-end)))
|
|
|
|
|
(list 'comment-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-comment-block-interpreter (comment-block _)
|
|
|
|
|
"Interpret COMMENT-BLOCK element as Org syntax."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_comment\n%s#+end_comment"
|
2014-08-07 08:45:28 -04:00
|
|
|
|
(org-element-normalize-string
|
|
|
|
|
(org-remove-indentation
|
|
|
|
|
(org-element-property :value comment-block)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
2012-10-27 08:23:37 -04:00
|
|
|
|
;;;; Diary Sexp
|
|
|
|
|
|
|
|
|
|
(defun org-element-diary-sexp-parser (limit affiliated)
|
|
|
|
|
"Parse a diary sexp.
|
|
|
|
|
|
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `diary-sexp' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:begin', `:end', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords."
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(value (progn (looking-at "\\(%%(.*\\)[ \t]*$")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(pos-before-blank (progn (forward-line) (point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(list 'diary-sexp
|
|
|
|
|
(nconc
|
|
|
|
|
(list :value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(cdr affiliated))))))
|
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-diary-sexp-interpreter (diary-sexp _)
|
|
|
|
|
"Interpret DIARY-SEXP as Org syntax."
|
2012-10-27 08:23:37 -04:00
|
|
|
|
(org-element-property :value diary-sexp))
|
|
|
|
|
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;;; Example Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-example-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse an example block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `example-block' and CDR is a plist
|
|
|
|
|
containing `:begin', `:end', `:number-lines', `:preserve-indent',
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
`:retain-labels', `:use-labels', `:label-fmt', `:switches',
|
|
|
|
|
`:value', `:post-blank' and `:post-affiliated' keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_EXAMPLE[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((contents-end (match-beginning 0)))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((switches
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(progn
|
|
|
|
|
(looking-at "^[ \t]*#\\+BEGIN_EXAMPLE\\(?: +\\(.*\\)\\)?")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
;; Switches analysis.
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(number-lines
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(and switches
|
|
|
|
|
(string-match "\\([-+]\\)n\\(?: *\\([0-9]+\\)\\)?\\>"
|
|
|
|
|
switches)
|
|
|
|
|
(cons
|
|
|
|
|
(if (equal (match-string 1 switches) "-")
|
|
|
|
|
'new
|
|
|
|
|
'continued)
|
|
|
|
|
(if (not (match-end 2)) 0
|
|
|
|
|
;; Subtract 1 to give number of lines before
|
|
|
|
|
;; first line.
|
|
|
|
|
(1- (string-to-number (match-string 2 switches)))))))
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(preserve-indent
|
2013-10-27 06:03:05 -04:00
|
|
|
|
(and switches (string-match "-i\\>" switches)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Should labels be retained in (or stripped from) example
|
|
|
|
|
;; blocks?
|
|
|
|
|
(retain-labels
|
|
|
|
|
(or (not switches)
|
|
|
|
|
(not (string-match "-r\\>" switches))
|
|
|
|
|
(and number-lines (string-match "-k\\>" switches))))
|
|
|
|
|
;; What should code-references use - labels or
|
|
|
|
|
;; line-numbers?
|
|
|
|
|
(use-labels
|
|
|
|
|
(or (not switches)
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(and retain-labels
|
|
|
|
|
(not (string-match "-k\\>" switches)))))
|
|
|
|
|
(label-fmt
|
|
|
|
|
(and switches
|
|
|
|
|
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
|
|
|
|
|
(match-string 1 switches)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Standard block parsing.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2016-02-09 17:19:20 -05:00
|
|
|
|
(contents-begin (line-beginning-position 2))
|
|
|
|
|
(value (org-unescape-code-in-string
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
contents-begin contents-end)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(pos-before-blank (progn (goto-char contents-end)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'example-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
|
|
|
|
:switches switches
|
|
|
|
|
:number-lines number-lines
|
|
|
|
|
:preserve-indent preserve-indent
|
|
|
|
|
:retain-labels retain-labels
|
|
|
|
|
:use-labels use-labels
|
|
|
|
|
:label-fmt label-fmt
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-example-block-interpreter (example-block _)
|
|
|
|
|
"Interpret EXAMPLE-BLOCK element as Org syntax."
|
2013-10-27 06:03:05 -04:00
|
|
|
|
(let ((switches (org-element-property :switches example-block))
|
2018-02-04 04:04:17 -05:00
|
|
|
|
(value
|
|
|
|
|
(let ((val (org-element-property :value example-block)))
|
|
|
|
|
(cond
|
|
|
|
|
((or org-src-preserve-indentation
|
|
|
|
|
(org-element-property :preserve-indent example-block))
|
|
|
|
|
val)
|
|
|
|
|
((= 0 org-edit-src-content-indentation)
|
|
|
|
|
(org-remove-indentation val))
|
|
|
|
|
(t
|
|
|
|
|
(let ((ind (make-string org-edit-src-content-indentation ?\s)))
|
|
|
|
|
(replace-regexp-in-string "^[ \t]*\\S-"
|
|
|
|
|
(concat ind "\\&")
|
|
|
|
|
(org-remove-indentation val))))))))
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(concat "#+begin_example" (and switches (concat " " switches)) "\n"
|
2018-02-04 04:04:17 -05:00
|
|
|
|
(org-element-normalize-string (org-escape-code-in-string value))
|
2018-01-24 06:56:25 -05:00
|
|
|
|
"#+end_example")))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
2014-09-08 05:57:27 -04:00
|
|
|
|
;;;; Export Block
|
|
|
|
|
|
|
|
|
|
(defun org-element-export-block-parser (limit affiliated)
|
|
|
|
|
"Parse an export block.
|
|
|
|
|
|
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `export-block' and CDR is a plist
|
|
|
|
|
containing `:begin', `:end', `:type', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
|
|
|
|
|
|
|
|
|
Assume point is at export-block beginning."
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(let* ((case-fold-search t))
|
2014-09-08 05:57:27 -04:00
|
|
|
|
(if (not (save-excursion
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_EXPORT[ \t]*$" limit t)))
|
2014-09-08 05:57:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((contents-end (match-beginning 0))
|
|
|
|
|
(backend
|
|
|
|
|
(progn
|
|
|
|
|
(looking-at
|
|
|
|
|
"[ \t]*#\\+BEGIN_EXPORT\\(?:[ \t]+\\(\\S-+\\)\\)?[ \t]*$")
|
|
|
|
|
(match-string-no-properties 1)))
|
|
|
|
|
(begin (car affiliated))
|
|
|
|
|
(post-affiliated (point))
|
|
|
|
|
(contents-begin (progn (forward-line) (point)))
|
|
|
|
|
(pos-before-blank (progn (goto-char contents-end)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(if (eobp) (point) (line-beginning-position))))
|
2016-05-13 11:53:22 -04:00
|
|
|
|
(value (org-unescape-code-in-string
|
|
|
|
|
(buffer-substring-no-properties contents-begin
|
|
|
|
|
contents-end))))
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(list 'export-block
|
|
|
|
|
(nconc
|
2016-01-02 05:53:24 -05:00
|
|
|
|
(list :type (and backend (upcase backend))
|
2015-02-03 10:16:54 -05:00
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
|
|
|
|
(cdr affiliated))))))))
|
2014-09-08 05:57:27 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-export-block-interpreter (export-block _)
|
|
|
|
|
"Interpret EXPORT-BLOCK element as Org syntax."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_export %s\n%s#+end_export"
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(org-element-property :type export-block)
|
|
|
|
|
(org-element-property :value export-block)))
|
2014-09-08 05:57:27 -04:00
|
|
|
|
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;;; Fixed-width
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-fixed-width-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a fixed-width section.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `fixed-width' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:begin', `:end', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the fixed-width area."
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(end-area
|
|
|
|
|
(progn
|
|
|
|
|
(while (and (< (point) limit)
|
|
|
|
|
(looking-at "[ \t]*:\\( \\|$\\)"))
|
|
|
|
|
(forward-line))
|
2018-07-01 18:24:38 -04:00
|
|
|
|
(if (bolp) (line-end-position 0) (point))))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'fixed-width
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
2018-07-01 18:24:38 -04:00
|
|
|
|
:value (replace-regexp-in-string
|
|
|
|
|
"^[ \t]*: ?" ""
|
|
|
|
|
(buffer-substring-no-properties post-affiliated
|
|
|
|
|
end-area))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines end-area end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-fixed-width-interpreter (fixed-width _)
|
|
|
|
|
"Interpret FIXED-WIDTH element as Org syntax."
|
2013-04-26 04:38:05 -04:00
|
|
|
|
(let ((value (org-element-property :value fixed-width)))
|
2018-07-01 18:24:38 -04:00
|
|
|
|
(and value (replace-regexp-in-string "^" ": " value))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Horizontal Rule
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-horizontal-rule-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse an horizontal rule.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `horizontal-rule' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:begin', `:end', `:post-blank' and `:post-affiliated'
|
|
|
|
|
keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(post-hr (progn (forward-line) (point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'horizontal-rule
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines post-hr end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-horizontal-rule-interpreter (&rest _)
|
|
|
|
|
"Interpret HORIZONTAL-RULE element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"-----")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Keyword
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-keyword-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a keyword at point.
|
|
|
|
|
|
2012-09-23 09:52:02 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `keyword' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:key', `:value', `:begin', `:end', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
2014-01-04 17:28:49 -05:00
|
|
|
|
;; An orphaned affiliated keyword is considered as a regular
|
|
|
|
|
;; keyword. In this case AFFILIATED is nil, so we take care of
|
|
|
|
|
;; this corner case.
|
|
|
|
|
(let ((begin (or (car affiliated) (point)))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(upcase (match-string-no-properties 1))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(value (org-trim (buffer-substring-no-properties
|
|
|
|
|
(match-end 0) (point-at-eol))))
|
|
|
|
|
(pos-before-blank (progn (forward-line) (point)))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'keyword
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(nconc
|
|
|
|
|
(list :key key
|
|
|
|
|
:value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-keyword-interpreter (keyword _)
|
|
|
|
|
"Interpret KEYWORD element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(format "#+%s: %s"
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(downcase (org-element-property :key keyword))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-property :value keyword)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Environment
|
|
|
|
|
|
2014-07-22 09:09:03 -04:00
|
|
|
|
(defconst org-element--latex-begin-environment
|
|
|
|
|
"^[ \t]*\\\\begin{\\([A-Za-z0-9*]+\\)}"
|
|
|
|
|
"Regexp matching the beginning of a LaTeX environment.
|
|
|
|
|
The environment is captured by the first group.
|
|
|
|
|
|
|
|
|
|
See also `org-element--latex-end-environment'.")
|
|
|
|
|
|
|
|
|
|
(defconst org-element--latex-end-environment
|
|
|
|
|
"\\\\end{%s}[ \t]*$"
|
|
|
|
|
"Format string matching the ending of a LaTeX environment.
|
|
|
|
|
See also `org-element--latex-begin-environment'.")
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-latex-environment-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a LaTeX environment.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `latex-environment' and CDR is a plist
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
containing `:begin', `:end', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the latex environment."
|
|
|
|
|
(save-excursion
|
2012-10-27 08:19:58 -04:00
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(code-begin (point)))
|
2014-07-22 09:09:03 -04:00
|
|
|
|
(looking-at org-element--latex-begin-environment)
|
|
|
|
|
(if (not (re-search-forward (format org-element--latex-end-environment
|
2012-10-27 08:19:58 -04:00
|
|
|
|
(regexp-quote (match-string 1)))
|
|
|
|
|
limit t))
|
|
|
|
|
;; Incomplete latex environment: parse it as a paragraph.
|
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
|
|
|
|
(let* ((code-end (progn (forward-line) (point)))
|
|
|
|
|
(begin (car affiliated))
|
|
|
|
|
(value (buffer-substring-no-properties code-begin code-end))
|
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-10-27 08:19:58 -04:00
|
|
|
|
(list 'latex-environment
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines code-end end)
|
2013-02-22 08:31:05 -05:00
|
|
|
|
:post-affiliated code-begin)
|
2012-10-27 08:19:58 -04:00
|
|
|
|
(cdr affiliated))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-latex-environment-interpreter (latex-environment _)
|
|
|
|
|
"Interpret LATEX-ENVIRONMENT element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-property :value latex-environment))
|
|
|
|
|
|
|
|
|
|
|
2012-09-23 09:52:02 -04:00
|
|
|
|
;;;; Node Property
|
|
|
|
|
|
|
|
|
|
(defun org-element-node-property-parser (limit)
|
|
|
|
|
"Parse a node-property at point.
|
|
|
|
|
|
|
|
|
|
LIMIT bounds the search.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `node-property' and CDR is a plist
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
containing `:key', `:value', `:begin', `:end', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords."
|
2014-08-31 05:10:56 -04:00
|
|
|
|
(looking-at org-property-re)
|
2014-08-31 05:43:27 -04:00
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
(begin (point))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(key (match-string-no-properties 2))
|
|
|
|
|
(value (match-string-no-properties 3))
|
2014-08-31 05:10:56 -04:00
|
|
|
|
(end (save-excursion
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(if (re-search-forward org-property-re limit t)
|
|
|
|
|
(line-beginning-position)
|
|
|
|
|
limit))))
|
|
|
|
|
(list 'node-property
|
|
|
|
|
(list :key key
|
|
|
|
|
:value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
2014-08-31 05:43:27 -04:00
|
|
|
|
:post-blank 0
|
|
|
|
|
:post-affiliated begin))))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-node-property-interpreter (node-property _)
|
|
|
|
|
"Interpret NODE-PROPERTY element as Org syntax."
|
2012-09-23 09:52:02 -04:00
|
|
|
|
(format org-property-format
|
|
|
|
|
(format ":%s:" (org-element-property :key node-property))
|
2014-08-31 05:10:56 -04:00
|
|
|
|
(or (org-element-property :value node-property) "")))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;;; Paragraph
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-paragraph-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a paragraph.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `paragraph' and CDR is a plist
|
|
|
|
|
containing `:begin', `:end', `:contents-begin' and
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
`:contents-end', `:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the paragraph."
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
2012-08-25 09:26:33 -04:00
|
|
|
|
(contents-begin (point))
|
2012-07-28 08:35:35 -04:00
|
|
|
|
(before-blank
|
2012-08-17 09:22:36 -04:00
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(end-of-line)
|
2015-04-27 16:24:00 -04:00
|
|
|
|
;; A matching `org-element-paragraph-separate' is not
|
|
|
|
|
;; necessarily the end of the paragraph. In particular,
|
|
|
|
|
;; drawers, blocks or LaTeX environments opening lines
|
|
|
|
|
;; must be closed. Moreover keywords with a secondary
|
|
|
|
|
;; value must belong to "dual keywords".
|
|
|
|
|
(while (not
|
|
|
|
|
(cond
|
|
|
|
|
((not (and (re-search-forward
|
|
|
|
|
org-element-paragraph-separate limit 'move)
|
|
|
|
|
(progn (beginning-of-line) t))))
|
|
|
|
|
((looking-at org-drawer-regexp)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(re-search-forward "^[ \t]*:END:[ \t]*$" limit t)))
|
|
|
|
|
((looking-at "[ \t]*#\\+BEGIN_\\(\\S-+\\)")
|
|
|
|
|
(save-excursion
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(format "^[ \t]*#\\+END_%s[ \t]*$"
|
|
|
|
|
(regexp-quote (match-string 1)))
|
|
|
|
|
limit t)))
|
|
|
|
|
((looking-at org-element--latex-begin-environment)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(re-search-forward
|
|
|
|
|
(format org-element--latex-end-environment
|
|
|
|
|
(regexp-quote (match-string 1)))
|
|
|
|
|
limit t)))
|
|
|
|
|
((looking-at "[ \t]*#\\+\\(\\S-+\\)\\[.*\\]:")
|
|
|
|
|
(member-ignore-case (match-string 1)
|
|
|
|
|
org-element-dual-keywords))
|
|
|
|
|
;; Everything else is unambiguous.
|
|
|
|
|
(t)))
|
|
|
|
|
(end-of-line))
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(if (= (point) limit) limit
|
|
|
|
|
(goto-char (line-beginning-position)))))
|
2015-04-27 16:24:00 -04:00
|
|
|
|
(contents-end (save-excursion
|
|
|
|
|
(skip-chars-backward " \r\t\n" contents-begin)
|
|
|
|
|
(line-beginning-position 2)))
|
2012-07-28 08:35:35 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'paragraph
|
|
|
|
|
(nconc
|
2012-08-25 09:26:33 -04:00
|
|
|
|
(list :begin begin
|
2012-07-28 01:02:21 -04:00
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines before-blank end)
|
|
|
|
|
:post-affiliated contents-begin)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-paragraph-interpreter (_ contents)
|
|
|
|
|
"Interpret paragraph element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the element."
|
|
|
|
|
contents)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Planning
|
|
|
|
|
|
|
|
|
|
(defun org-element-planning-parser (limit)
|
|
|
|
|
"Parse a planning.
|
|
|
|
|
|
|
|
|
|
LIMIT bounds the search.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `planning' and CDR is a plist
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
containing `:closed', `:deadline', `:scheduled', `:begin',
|
|
|
|
|
`:end', `:post-blank' and `:post-affiliated' keywords."
|
2014-09-13 16:31:06 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((case-fold-search nil)
|
|
|
|
|
(begin (point))
|
|
|
|
|
(post-blank (let ((before-blank (progn (forward-line) (point))))
|
|
|
|
|
(skip-chars-forward " \r\t\n" limit)
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(unless (bolp) (end-of-line))
|
|
|
|
|
(count-lines before-blank (point))))
|
|
|
|
|
(end (point))
|
|
|
|
|
closed deadline scheduled)
|
|
|
|
|
(goto-char begin)
|
|
|
|
|
(while (re-search-forward org-keyword-time-not-clock-regexp end t)
|
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(skip-chars-forward " \t" end)
|
|
|
|
|
(let ((keyword (match-string 1))
|
|
|
|
|
(time (org-element-timestamp-parser)))
|
|
|
|
|
(cond ((equal keyword org-closed-string) (setq closed time))
|
|
|
|
|
((equal keyword org-deadline-string) (setq deadline time))
|
|
|
|
|
(t (setq scheduled time)))))
|
|
|
|
|
(list 'planning
|
|
|
|
|
(list :closed closed
|
|
|
|
|
:deadline deadline
|
|
|
|
|
:scheduled scheduled
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank
|
|
|
|
|
:post-affiliated begin)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-planning-interpreter (planning _)
|
|
|
|
|
"Interpret PLANNING element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(mapconcat
|
2015-07-31 16:02:15 -04:00
|
|
|
|
#'identity
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(delq nil
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(list (let ((deadline (org-element-property :deadline planning)))
|
|
|
|
|
(when deadline
|
|
|
|
|
(concat org-deadline-string " "
|
|
|
|
|
(org-element-timestamp-interpreter deadline nil))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((scheduled (org-element-property :scheduled planning)))
|
|
|
|
|
(when scheduled
|
2012-09-28 08:50:21 -04:00
|
|
|
|
(concat org-scheduled-string " "
|
|
|
|
|
(org-element-timestamp-interpreter scheduled nil))))
|
|
|
|
|
(let ((closed (org-element-property :closed planning)))
|
|
|
|
|
(when closed
|
|
|
|
|
(concat org-closed-string " "
|
|
|
|
|
(org-element-timestamp-interpreter closed nil))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
" "))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Src Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-src-block-parser (limit affiliated)
|
2018-09-20 05:23:49 -04:00
|
|
|
|
"Parse a source block.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `src-block' and CDR is a plist
|
|
|
|
|
containing `:language', `:switches', `:parameters', `:begin',
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
`:end', `:number-lines', `:retain-labels', `:use-labels',
|
|
|
|
|
`:label-fmt', `:preserve-indent', `:value', `:post-blank' and
|
|
|
|
|
`:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the block."
|
|
|
|
|
(let ((case-fold-search t))
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(if (not (save-excursion (re-search-forward "^[ \t]*#\\+END_SRC[ \t]*$"
|
|
|
|
|
limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((contents-end (match-beginning 0)))
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Get language as a string.
|
|
|
|
|
(language
|
|
|
|
|
(progn
|
|
|
|
|
(looking-at
|
2016-05-16 10:58:01 -04:00
|
|
|
|
"^[ \t]*#\\+BEGIN_SRC\
|
|
|
|
|
\\(?: +\\(\\S-+\\)\\)?\
|
|
|
|
|
\\(\\(?: +\\(?:-\\(?:l \".+\"\\|[ikr]\\)\\|[-+]n\\(?: *[0-9]+\\)?\\)\\)+\\)?\
|
|
|
|
|
\\(.*\\)[ \t]*$")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Get switches.
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(switches (match-string-no-properties 2))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Get parameters.
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(parameters (match-string-no-properties 3))
|
2016-05-16 10:58:01 -04:00
|
|
|
|
;; Switches analysis.
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(number-lines
|
2016-05-16 10:58:01 -04:00
|
|
|
|
(and switches
|
|
|
|
|
(string-match "\\([-+]\\)n\\(?: *\\([0-9]+\\)\\)?\\>"
|
|
|
|
|
switches)
|
|
|
|
|
(cons
|
|
|
|
|
(if (equal (match-string 1 switches) "-")
|
|
|
|
|
'new
|
|
|
|
|
'continued)
|
|
|
|
|
(if (not (match-end 2)) 0
|
|
|
|
|
;; Subtract 1 to give number of lines before
|
|
|
|
|
;; first line.
|
|
|
|
|
(1- (string-to-number (match-string 2 switches)))))))
|
2013-10-27 06:03:05 -04:00
|
|
|
|
(preserve-indent (and switches
|
|
|
|
|
(string-match "-i\\>" switches)))
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(label-fmt
|
|
|
|
|
(and switches
|
|
|
|
|
(string-match "-l +\"\\([^\"\n]+\\)\"" switches)
|
|
|
|
|
(match-string 1 switches)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Should labels be retained in (or stripped from)
|
2018-09-20 05:23:49 -04:00
|
|
|
|
;; source blocks?
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(retain-labels
|
|
|
|
|
(or (not switches)
|
|
|
|
|
(not (string-match "-r\\>" switches))
|
|
|
|
|
(and number-lines (string-match "-k\\>" switches))))
|
|
|
|
|
;; What should code-references use - labels or
|
|
|
|
|
;; line-numbers?
|
|
|
|
|
(use-labels
|
|
|
|
|
(or (not switches)
|
2013-05-25 08:18:48 -04:00
|
|
|
|
(and retain-labels
|
|
|
|
|
(not (string-match "-k\\>" switches)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Retrieve code.
|
2016-02-09 17:19:20 -05:00
|
|
|
|
(value (org-unescape-code-in-string
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(line-beginning-position 2) contents-end)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(pos-before-blank (progn (goto-char contents-end)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
|
|
|
|
;; Get position after ending blank lines.
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'src-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :language language
|
|
|
|
|
:switches (and (org-string-nw-p switches)
|
|
|
|
|
(org-trim switches))
|
|
|
|
|
:parameters (and (org-string-nw-p parameters)
|
|
|
|
|
(org-trim parameters))
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:number-lines number-lines
|
|
|
|
|
:preserve-indent preserve-indent
|
|
|
|
|
:retain-labels retain-labels
|
|
|
|
|
:use-labels use-labels
|
|
|
|
|
:label-fmt label-fmt
|
|
|
|
|
:value value
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-src-block-interpreter (src-block _)
|
|
|
|
|
"Interpret SRC-BLOCK element as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((lang (org-element-property :language src-block))
|
|
|
|
|
(switches (org-element-property :switches src-block))
|
|
|
|
|
(params (org-element-property :parameters src-block))
|
2013-10-27 06:03:05 -04:00
|
|
|
|
(value
|
|
|
|
|
(let ((val (org-element-property :value src-block)))
|
|
|
|
|
(cond
|
|
|
|
|
((or org-src-preserve-indentation
|
|
|
|
|
(org-element-property :preserve-indent src-block))
|
|
|
|
|
val)
|
2016-02-10 08:11:48 -05:00
|
|
|
|
((zerop org-edit-src-content-indentation)
|
|
|
|
|
(org-remove-indentation val))
|
2013-10-27 06:03:05 -04:00
|
|
|
|
(t
|
|
|
|
|
(let ((ind (make-string org-edit-src-content-indentation ?\s)))
|
2018-02-04 04:04:17 -05:00
|
|
|
|
(replace-regexp-in-string "^[ \t]*\\S-"
|
|
|
|
|
(concat ind "\\&")
|
|
|
|
|
(org-remove-indentation val))))))))
|
|
|
|
|
(format "#+begin_src%s\n%s#+end_src"
|
|
|
|
|
(concat (and lang (concat " " lang))
|
|
|
|
|
(and switches (concat " " switches))
|
|
|
|
|
(and params (concat " " params)))
|
|
|
|
|
(org-element-normalize-string (org-escape-code-in-string value)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Table
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-table-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a table at point.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `table' and CDR is a plist containing
|
|
|
|
|
`:begin', `:end', `:tblfm', `:type', `:contents-begin',
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
`:contents-end', `:value', `:post-blank' and `:post-affiliated'
|
|
|
|
|
keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the table."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((case-fold-search t)
|
|
|
|
|
(table-begin (point))
|
2015-06-28 05:37:13 -04:00
|
|
|
|
(type (if (looking-at "[ \t]*|") 'org 'table.el))
|
2015-06-28 15:09:16 -04:00
|
|
|
|
(end-re (format "^[ \t]*\\($\\|[^| \t%s]\\)"
|
|
|
|
|
(if (eq type 'org) "" "+")))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(begin (car affiliated))
|
org-element: Fix parsing with trailing spaces at eob
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, , org-element-footnote-definition-parser,
org-element-inlinetask-parser, org-element-plain-list-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-clock-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-planning-parser,
org-element-property-drawer-parser, org-element-src-block-parser,
org-element-table-parser,
org-element-verse-block-parserorg-element-dynamic-block-parser):
Make sure element never ends at the end of a blank non-empty line.
* testing/lisp/test-org-element.el: Add test.
2012-10-05 19:02:03 -04:00
|
|
|
|
(table-end
|
2015-06-28 15:09:16 -04:00
|
|
|
|
(if (re-search-forward end-re limit 'move)
|
org-element: Fix parsing with trailing spaces at eob
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, , org-element-footnote-definition-parser,
org-element-inlinetask-parser, org-element-plain-list-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-clock-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-planning-parser,
org-element-property-drawer-parser, org-element-src-block-parser,
org-element-table-parser,
org-element-verse-block-parserorg-element-dynamic-block-parser):
Make sure element never ends at the end of a blank non-empty line.
* testing/lisp/test-org-element.el: Add test.
2012-10-05 19:02:03 -04:00
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(point)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(tblfm (let (acc)
|
|
|
|
|
(while (looking-at "[ \t]*#\\+TBLFM: +\\(.*\\)[ \t]*$")
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(push (match-string-no-properties 1) acc)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(forward-line))
|
|
|
|
|
acc))
|
|
|
|
|
(pos-before-blank (point))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'table
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:type type
|
|
|
|
|
:tblfm tblfm
|
|
|
|
|
;; Only `org' tables have contents. `table.el' tables
|
|
|
|
|
;; use a `:value' property to store raw table as
|
|
|
|
|
;; a string.
|
|
|
|
|
:contents-begin (and (eq type 'org) table-begin)
|
|
|
|
|
:contents-end (and (eq type 'org) table-end)
|
|
|
|
|
:value (and (eq type 'table.el)
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
table-begin table-end))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated table-begin)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-table-interpreter (table contents)
|
|
|
|
|
"Interpret TABLE element as Org syntax.
|
2014-08-24 15:28:56 -04:00
|
|
|
|
CONTENTS is a string, if table's type is `org', or nil."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(if (eq (org-element-property :type table) 'table.el)
|
|
|
|
|
(org-remove-indentation (org-element-property :value table))
|
|
|
|
|
(concat (with-temp-buffer (insert contents)
|
|
|
|
|
(org-table-align)
|
|
|
|
|
(buffer-string))
|
|
|
|
|
(mapconcat (lambda (fm) (concat "#+TBLFM: " fm))
|
|
|
|
|
(reverse (org-element-property :tblfm table))
|
|
|
|
|
"\n"))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Table Row
|
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-table-row-parser (_)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse table row at point.
|
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `table-row' and CDR is a plist
|
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end',
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
`:type', `:post-blank' and `:post-affiliated' keywords."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((type (if (looking-at "^[ \t]*|-") 'rule 'standard))
|
|
|
|
|
(begin (point))
|
|
|
|
|
;; A table rule has no contents. In that case, ensure
|
|
|
|
|
;; CONTENTS-BEGIN matches CONTENTS-END.
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(contents-begin (and (eq type 'standard) (search-forward "|")))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(contents-end (and (eq type 'standard)
|
|
|
|
|
(progn
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(skip-chars-backward " \t")
|
|
|
|
|
(point))))
|
2015-06-28 15:09:16 -04:00
|
|
|
|
(end (line-beginning-position 2)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'table-row
|
|
|
|
|
(list :type type
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add :post-affiliated property to all elements
* lisp/org-element.el (org-element-headline-parser,
org-element-inlinetask-parser, org-element-item-parser,
org-element-section-parser, org-element-clock-parser,
org-element-node-property-parser, org-element-planning-parser,
org-element-table-row-parser): Add dummy :post-affiliated property.
* lisp/org.el (org--get-expected-indentation, org-indent-line,
org-indent-region, org-adaptive-fill-function,
org-toggle-fixed-width, org-forward-paragraph,
org-backward-paragraph, org-mode-flyspell-verify): Remove nullity
checks for :post-affiliated.
Even though these elements cannot have affiliated keywords, beginning
of element is a logical default value. It makes checking the nullity
of the unnecessary.
2014-08-26 09:33:13 -04:00
|
|
|
|
:post-blank 0
|
|
|
|
|
:post-affiliated begin)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-table-row-interpreter (table-row contents)
|
|
|
|
|
"Interpret TABLE-ROW element as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the table row."
|
|
|
|
|
(if (eq (org-element-property :type table-row) 'rule) "|-"
|
2016-06-27 17:59:44 -04:00
|
|
|
|
(concat "|" contents)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Verse Block
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(defun org-element-verse-block-parser (limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse a verse block.
|
|
|
|
|
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
LIMIT bounds the search. AFFILIATED is a list of which CAR is
|
|
|
|
|
the buffer position at the beginning of the first affiliated
|
|
|
|
|
keyword and CDR is a plist of affiliated keywords along with
|
|
|
|
|
their value.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is `verse-block' and CDR is a plist
|
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end',
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
`:post-blank' and `:post-affiliated' keywords.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at beginning of the block."
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(if (not (save-excursion
|
2012-09-30 06:22:40 -04:00
|
|
|
|
(re-search-forward "^[ \t]*#\\+END_VERSE[ \t]*$" limit t)))
|
2012-08-18 07:34:27 -04:00
|
|
|
|
;; Incomplete block: parse it as a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(org-element-paragraph-parser limit affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((contents-end (match-beginning 0)))
|
|
|
|
|
(save-excursion
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((begin (car affiliated))
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
(post-affiliated (point))
|
org-element: Remove folding status in parsed data
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-item-parser, org-element-quote-block-parser,
org-element-comment-block-parser, org-element-export-block-parser,
org-element-verse-block-parser, org-element-special-block-parser,
org-element-example-block-parser, org-element-headline-parser,
org-element-inlinetask-parser): Remove :hiddenp property.
* lisp/org.el (org-end-of-line, org-down-element): Use an equivalent
of :hiddenp property.
* testing/lisp/test-org-element.el: Remove tests.
The property is removed because it is buggy (e.g., when there's a link
just after a block opening line) and not really useful.
2013-10-03 16:57:02 -04:00
|
|
|
|
(contents-begin (progn (forward-line) (point)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(pos-before-blank (progn (goto-char contents-end)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(point)))
|
2012-07-28 17:21:38 -04:00
|
|
|
|
(end (progn (skip-chars-forward " \r\t\n" limit)
|
2013-11-10 05:28:14 -05:00
|
|
|
|
(if (eobp) (point) (line-beginning-position)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(list 'verse-block
|
|
|
|
|
(nconc
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
org-element: Add `:post-affiliated' property to elements when applicable
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-property-drawer-parser,
org-element-quote-block-parser, org-element-special-block-parser,
org-element-babel-call-parser, org-element-comment-parser,
org-element-comment-block-parser, org-element-diary-sexp-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-src-block-parser,
org-element-table-parser, org-element-verse-block-parser): Add
`:post-affiliated' property to elements.
(org-element-inlinetask-parser): Remove affilated keywords.
* lisp/org.el (org-adaptive-fill-function): Use new property.
This property is cheap to compute during parsing and allows to
determine if point is on an affiliated keyword or not by checking if
it is between :begin and :post-affiliated positions.
2012-10-29 05:58:52 -04:00
|
|
|
|
:post-blank (count-lines pos-before-blank end)
|
|
|
|
|
:post-affiliated post-affiliated)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cdr affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-verse-block-interpreter (_ contents)
|
|
|
|
|
"Interpret verse-block element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is verse block contents."
|
2018-01-24 06:56:25 -05:00
|
|
|
|
(format "#+begin_verse\n%s#+end_verse" contents))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Objects
|
|
|
|
|
;;
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
;; Unlike to elements, raw text can be found between objects. Hence,
|
|
|
|
|
;; `org-element--object-lex' is provided to find the next object in
|
|
|
|
|
;; buffer.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
2014-03-17 05:31:37 -04:00
|
|
|
|
;; Some object types (e.g., `italic') are recursive. Restrictions on
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; object types they can contain will be specified in
|
|
|
|
|
;; `org-element-object-restrictions'.
|
|
|
|
|
;;
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
;; Creating a new type of object requires to alter
|
|
|
|
|
;; `org-element--object-regexp' and `org-element--object-lex', add the
|
|
|
|
|
;; new type in `org-element-all-objects', and possibly add
|
|
|
|
|
;; restrictions in `org-element-object-restrictions'.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;;;; Bold
|
|
|
|
|
|
|
|
|
|
(defun org-element-bold-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse bold object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a bold object, return a list whose car is `bold' and cdr
|
|
|
|
|
is a plist with `:begin', `:end', `:contents-begin' and
|
|
|
|
|
`:contents-end' and `:post-blank' keywords. Otherwise, return
|
|
|
|
|
nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first star marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-emph-re)
|
|
|
|
|
(let ((begin (match-beginning 2))
|
|
|
|
|
(contents-begin (match-beginning 4))
|
|
|
|
|
(contents-end (match-end 4))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'bold
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-bold-interpreter (_ contents)
|
|
|
|
|
"Interpret bold object as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format "*%s*" contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Code
|
|
|
|
|
|
|
|
|
|
(defun org-element-code-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse code object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a code object, return a list whose car is `code' and cdr
|
|
|
|
|
is a plist with `:value', `:begin', `:end' and `:post-blank'
|
|
|
|
|
keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first tilde marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
2016-12-08 03:44:26 -05:00
|
|
|
|
(when (looking-at org-verbatim-re)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((begin (match-beginning 2))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(value (match-string-no-properties 4))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'code
|
|
|
|
|
(list :value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-code-interpreter (code _)
|
|
|
|
|
"Interpret CODE object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(format "~%s~" (org-element-property :value code)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Entity
|
|
|
|
|
|
|
|
|
|
(defun org-element-entity-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse entity at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an entity, return a list whose car is `entity' and cdr
|
|
|
|
|
a plist with `:begin', `:end', `:latex', `:latex-math-p',
|
|
|
|
|
`:html', `:latin1', `:utf-8', `:ascii', `:use-brackets-p' and
|
|
|
|
|
`:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the entity."
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(catch 'no-object
|
2015-03-22 16:45:00 -04:00
|
|
|
|
(when (looking-at "\\\\\\(?:\\(?1:_ +\\)\\|\\(?1:there4\\|sup[123]\\|frac[13][24]\\|[a-zA-Z]+\\)\\(?2:$\\|{}\\|[^[:alpha:]]\\)\\)")
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((value (or (org-entity-get (match-string 1))
|
|
|
|
|
(throw 'no-object nil)))
|
|
|
|
|
(begin (match-beginning 0))
|
|
|
|
|
(bracketsp (string= (match-string 2) "{}"))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 1))
|
|
|
|
|
(when bracketsp (forward-char 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'entity
|
|
|
|
|
(list :name (car value)
|
|
|
|
|
:latex (nth 1 value)
|
|
|
|
|
:latex-math-p (nth 2 value)
|
|
|
|
|
:html (nth 3 value)
|
|
|
|
|
:ascii (nth 4 value)
|
|
|
|
|
:latin1 (nth 5 value)
|
|
|
|
|
:utf-8 (nth 6 value)
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:use-brackets-p bracketsp
|
|
|
|
|
:post-blank post-blank)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-entity-interpreter (entity _)
|
|
|
|
|
"Interpret ENTITY object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(concat "\\"
|
|
|
|
|
(org-element-property :name entity)
|
|
|
|
|
(when (org-element-property :use-brackets-p entity) "{}")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Export Snippet
|
|
|
|
|
|
|
|
|
|
(defun org-element-export-snippet-parser ()
|
|
|
|
|
"Parse export snippet at point.
|
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an export snippet, return a list whose car is
|
|
|
|
|
`export-snippet' and cdr a plist with `:begin', `:end',
|
|
|
|
|
`:back-end', `:value' and `:post-blank' as keywords. Otherwise,
|
|
|
|
|
return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the snippet."
|
|
|
|
|
(save-excursion
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let (contents-end)
|
|
|
|
|
(when (and (looking-at "@@\\([-A-Za-z0-9]+\\):")
|
|
|
|
|
(setq contents-end
|
|
|
|
|
(save-match-data (goto-char (match-end 0))
|
|
|
|
|
(re-search-forward "@@" nil t)
|
|
|
|
|
(match-beginning 0))))
|
|
|
|
|
(let* ((begin (match-beginning 0))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(back-end (match-string-no-properties 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(value (buffer-substring-no-properties
|
|
|
|
|
(match-end 0) contents-end))
|
|
|
|
|
(post-blank (skip-chars-forward " \t"))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'export-snippet
|
|
|
|
|
(list :back-end back-end
|
|
|
|
|
:value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-export-snippet-interpreter (export-snippet _)
|
|
|
|
|
"Interpret EXPORT-SNIPPET object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(format "@@%s:%s@@"
|
|
|
|
|
(org-element-property :back-end export-snippet)
|
|
|
|
|
(org-element-property :value export-snippet)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Footnote Reference
|
|
|
|
|
|
|
|
|
|
(defun org-element-footnote-reference-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse footnote reference at point, if any.
|
|
|
|
|
|
|
|
|
|
When at a footnote reference, return a list whose car is
|
|
|
|
|
`footnote-reference' and cdr a plist with `:label', `:type',
|
2014-07-06 05:08:57 -04:00
|
|
|
|
`:begin', `:end', `:content-begin', `:contents-end' and
|
|
|
|
|
`:post-blank' as keywords. Otherwise, return nil."
|
2015-02-15 07:33:25 -05:00
|
|
|
|
(when (looking-at org-footnote-re)
|
|
|
|
|
(let ((closing (with-syntax-table org-element--pair-square-table
|
|
|
|
|
(ignore-errors (scan-lists (point) 1 0)))))
|
|
|
|
|
(when closing
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((begin (point))
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(label (match-string-no-properties 1))
|
2015-02-15 07:33:25 -05:00
|
|
|
|
(inner-begin (match-end 0))
|
|
|
|
|
(inner-end (1- closing))
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(type (if (match-end 2) 'inline 'standard))
|
2015-02-15 07:33:25 -05:00
|
|
|
|
(post-blank (progn (goto-char closing)
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'footnote-reference
|
|
|
|
|
(list :label label
|
|
|
|
|
:type type
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin (and (eq type 'inline) inner-begin)
|
|
|
|
|
:contents-end (and (eq type 'inline) inner-end)
|
|
|
|
|
:post-blank post-blank))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-footnote-reference-interpreter (footnote-reference contents)
|
|
|
|
|
"Interpret FOOTNOTE-REFERENCE object as Org syntax.
|
2014-07-06 13:06:54 -04:00
|
|
|
|
CONTENTS is its definition, when inline, or nil."
|
2015-12-16 12:22:27 -05:00
|
|
|
|
(format "[fn:%s%s]"
|
|
|
|
|
(or (org-element-property :label footnote-reference) "")
|
|
|
|
|
(if contents (concat ":" contents) "")))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Babel Call
|
|
|
|
|
|
|
|
|
|
(defun org-element-inline-babel-call-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse inline babel call at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an inline babel call, return a list whose car is
|
2015-04-21 05:54:22 -04:00
|
|
|
|
`inline-babel-call' and cdr a plist with `:call',
|
|
|
|
|
`:inside-header', `:arguments', `:end-header', `:begin', `:end',
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
`:value' and `:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the babel call."
|
|
|
|
|
(save-excursion
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(catch :no-object
|
|
|
|
|
(when (let ((case-fold-search nil))
|
2018-02-03 18:30:00 -05:00
|
|
|
|
(looking-at "\\<call_\\([^ \t\n[(]+\\)[([]"))
|
2016-06-10 17:42:50 -04:00
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(let* ((begin (match-beginning 0))
|
|
|
|
|
(call (match-string-no-properties 1))
|
|
|
|
|
(inside-header
|
|
|
|
|
(let ((p (org-element--parse-paired-brackets ?\[)))
|
|
|
|
|
(and (org-string-nw-p p)
|
|
|
|
|
(replace-regexp-in-string "\n[ \t]*" " " (org-trim p)))))
|
2016-06-16 10:19:18 -04:00
|
|
|
|
(arguments (org-string-nw-p
|
|
|
|
|
(or (org-element--parse-paired-brackets ?\()
|
|
|
|
|
;; Parenthesis are mandatory.
|
|
|
|
|
(throw :no-object nil))))
|
2016-06-10 17:42:50 -04:00
|
|
|
|
(end-header
|
|
|
|
|
(let ((p (org-element--parse-paired-brackets ?\[)))
|
|
|
|
|
(and (org-string-nw-p p)
|
|
|
|
|
(replace-regexp-in-string "\n[ \t]*" " " (org-trim p)))))
|
|
|
|
|
(value (buffer-substring-no-properties begin (point)))
|
|
|
|
|
(post-blank (skip-chars-forward " \t"))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'inline-babel-call
|
|
|
|
|
(list :call call
|
|
|
|
|
:inside-header inside-header
|
|
|
|
|
:arguments arguments
|
|
|
|
|
:end-header end-header
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
|
|
|
|
:post-blank post-blank)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-inline-babel-call-interpreter (inline-babel-call _)
|
|
|
|
|
"Interpret INLINE-BABEL-CALL object as Org syntax."
|
2015-04-21 05:54:22 -04:00
|
|
|
|
(concat "call_"
|
|
|
|
|
(org-element-property :call inline-babel-call)
|
|
|
|
|
(let ((h (org-element-property :inside-header inline-babel-call)))
|
|
|
|
|
(and h (format "[%s]" h)))
|
|
|
|
|
"(" (org-element-property :arguments inline-babel-call) ")"
|
|
|
|
|
(let ((h (org-element-property :end-header inline-babel-call)))
|
|
|
|
|
(and h (format "[%s]" h)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Inline Src Block
|
|
|
|
|
|
|
|
|
|
(defun org-element-inline-src-block-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse inline source block at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an inline source block, return a list whose car is
|
|
|
|
|
`inline-src-block' and cdr a plist with `:begin', `:end',
|
|
|
|
|
`:language', `:value', `:parameters' and `:post-blank' as
|
|
|
|
|
keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2018-09-20 05:23:49 -04:00
|
|
|
|
Assume point is at the beginning of the inline source block."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(catch :no-object
|
|
|
|
|
(when (let ((case-fold-search nil))
|
2018-02-03 18:30:00 -05:00
|
|
|
|
(looking-at "\\<src_\\([^ \t\n[{]+\\)[{[]"))
|
2016-06-10 17:42:50 -04:00
|
|
|
|
(goto-char (match-end 1))
|
|
|
|
|
(let ((begin (match-beginning 0))
|
2015-12-30 17:59:57 -05:00
|
|
|
|
(language (match-string-no-properties 1))
|
|
|
|
|
(parameters
|
2016-06-10 17:42:50 -04:00
|
|
|
|
(let ((p (org-element--parse-paired-brackets ?\[)))
|
|
|
|
|
(and (org-string-nw-p p)
|
|
|
|
|
(replace-regexp-in-string "\n[ \t]*" " " (org-trim p)))))
|
|
|
|
|
(value (or (org-element--parse-paired-brackets ?\{)
|
|
|
|
|
(throw :no-object nil)))
|
|
|
|
|
(post-blank (skip-chars-forward " \t")))
|
|
|
|
|
(list 'inline-src-block
|
|
|
|
|
(list :language language
|
|
|
|
|
:value value
|
|
|
|
|
:parameters parameters
|
|
|
|
|
:begin begin
|
|
|
|
|
:end (point)
|
|
|
|
|
:post-blank post-blank)))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-inline-src-block-interpreter (inline-src-block _)
|
|
|
|
|
"Interpret INLINE-SRC-BLOCK object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((language (org-element-property :language inline-src-block))
|
|
|
|
|
(arguments (org-element-property :parameters inline-src-block))
|
|
|
|
|
(body (org-element-property :value inline-src-block)))
|
|
|
|
|
(format "src_%s%s{%s}"
|
|
|
|
|
language
|
|
|
|
|
(if arguments (format "[%s]" arguments) "")
|
|
|
|
|
body)))
|
|
|
|
|
|
|
|
|
|
;;;; Italic
|
|
|
|
|
|
|
|
|
|
(defun org-element-italic-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse italic object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an italic object, return a list whose car is `italic' and
|
|
|
|
|
cdr is a plist with `:begin', `:end', `:contents-begin' and
|
|
|
|
|
`:contents-end' and `:post-blank' keywords. Otherwise, return
|
|
|
|
|
nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first slash marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-emph-re)
|
|
|
|
|
(let ((begin (match-beginning 2))
|
|
|
|
|
(contents-begin (match-beginning 4))
|
|
|
|
|
(contents-end (match-end 4))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'italic
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-italic-interpreter (_ contents)
|
|
|
|
|
"Interpret italic object as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format "/%s/" contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Latex Fragment
|
|
|
|
|
|
|
|
|
|
(defun org-element-latex-fragment-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse LaTeX fragment at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a LaTeX fragment, return a list whose car is
|
|
|
|
|
`latex-fragment' and cdr a plist with `:value', `:begin', `:end',
|
|
|
|
|
and `:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2013-10-24 11:15:23 -04:00
|
|
|
|
Assume point is at the beginning of the LaTeX fragment."
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(catch 'no-object
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((begin (point))
|
2014-07-06 17:15:44 -04:00
|
|
|
|
(after-fragment
|
2017-06-26 16:07:05 -04:00
|
|
|
|
(cond
|
|
|
|
|
((not (eq ?$ (char-after)))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (char-after (1+ (point)))
|
2014-07-06 17:15:44 -04:00
|
|
|
|
(?\( (search-forward "\\)" nil t))
|
|
|
|
|
(?\[ (search-forward "\\]" nil t))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(_
|
2014-07-06 17:15:44 -04:00
|
|
|
|
;; Macro.
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(and (looking-at "\\\\[a-zA-Z]+\\*?\\(\\(\\[[^][\n{}]*\\]\\)\
|
|
|
|
|
\\|\\({[^{}\n]*}\\)\\)*")
|
2017-06-26 16:07:05 -04:00
|
|
|
|
(match-end 0)))))
|
|
|
|
|
((eq ?$ (char-after (1+ (point))))
|
|
|
|
|
(search-forward "$$" nil t 2))
|
|
|
|
|
(t
|
|
|
|
|
(and (not (eq ?$ (char-before)))
|
|
|
|
|
(not (memq (char-after (1+ (point)))
|
|
|
|
|
'(?\s ?\t ?\n ?, ?. ?\;)))
|
|
|
|
|
(search-forward "$" nil t 2)
|
|
|
|
|
(not (memq (char-before (match-beginning 0))
|
|
|
|
|
'(?\s ?\t ?\n ?, ?.)))
|
|
|
|
|
(looking-at-p
|
|
|
|
|
"\\(\\s.\\|\\s-\\|\\s(\\|\\s)\\|\\s\"\\|'\\|$\\)")
|
|
|
|
|
(point)))))
|
|
|
|
|
(post-blank
|
|
|
|
|
(if (not after-fragment) (throw 'no-object nil)
|
|
|
|
|
(goto-char after-fragment)
|
|
|
|
|
(skip-chars-forward " \t")))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'latex-fragment
|
2014-07-06 17:15:44 -04:00
|
|
|
|
(list :value (buffer-substring-no-properties begin after-fragment)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-latex-fragment-interpreter (latex-fragment _)
|
|
|
|
|
"Interpret LATEX-FRAGMENT object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-property :value latex-fragment))
|
|
|
|
|
|
|
|
|
|
;;;; Line Break
|
|
|
|
|
|
|
|
|
|
(defun org-element-line-break-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse line break at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a line break, return a list whose car is `line-break',
|
|
|
|
|
and cdr a plist with `:begin', `:end' and `:post-blank' keywords.
|
|
|
|
|
Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the line break."
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(when (and (looking-at-p "\\\\\\\\[ \t]*$")
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(not (eq (char-before) ?\\)))
|
|
|
|
|
(list 'line-break
|
|
|
|
|
(list :begin (point)
|
2015-03-06 19:52:58 -05:00
|
|
|
|
:end (line-beginning-position 2)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
:post-blank 0))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-line-break-interpreter (&rest _)
|
|
|
|
|
"Interpret LINE-BREAK object as Org syntax."
|
2012-12-12 16:47:12 -05:00
|
|
|
|
"\\\\\n")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Link
|
|
|
|
|
|
|
|
|
|
(defun org-element-link-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse link at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a link, return a list whose car is `link' and cdr a plist
|
2016-10-08 18:26:45 -04:00
|
|
|
|
with `:type', `:path', `:format', `:raw-link', `:application',
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
`:search-option', `:begin', `:end', `:contents-begin',
|
|
|
|
|
`:contents-end' and `:post-blank' as keywords. Otherwise, return
|
|
|
|
|
nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the link."
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(catch 'no-object
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((begin (point))
|
2016-10-08 18:26:45 -04:00
|
|
|
|
end contents-begin contents-end link-end post-blank path type format
|
2015-07-31 16:02:15 -04:00
|
|
|
|
raw-link search-option application)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(cond
|
|
|
|
|
;; Type 1: Text targeted from a radio target.
|
2014-04-10 16:23:27 -04:00
|
|
|
|
((and org-target-link-regexp
|
|
|
|
|
(save-excursion (or (bolp) (backward-char))
|
|
|
|
|
(looking-at org-target-link-regexp)))
|
2016-10-08 18:26:45 -04:00
|
|
|
|
(setq type "radio")
|
|
|
|
|
(setq format 'plain)
|
|
|
|
|
(setq link-end (match-end 1))
|
|
|
|
|
(setq path (match-string-no-properties 1))
|
|
|
|
|
(setq contents-begin (match-beginning 1))
|
|
|
|
|
(setq contents-end (match-end 1)))
|
2018-01-16 13:42:57 -05:00
|
|
|
|
;; Type 2: Standard link, i.e. [[https://orgmode.org][homepage]]
|
2012-07-28 01:02:21 -04:00
|
|
|
|
((looking-at org-bracket-link-regexp)
|
2016-10-08 18:26:45 -04:00
|
|
|
|
(setq format 'bracket)
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq contents-begin (match-beginning 3))
|
|
|
|
|
(setq contents-end (match-end 3))
|
|
|
|
|
(setq link-end (match-end 0))
|
|
|
|
|
;; RAW-LINK is the original link. Expand any
|
|
|
|
|
;; abbreviation in it.
|
|
|
|
|
;;
|
|
|
|
|
;; Also treat any newline character and associated
|
|
|
|
|
;; indentation as a single space character. This is not
|
|
|
|
|
;; compatible with RFC 3986, which requires to ignore
|
|
|
|
|
;; them altogether. However, doing so would require
|
|
|
|
|
;; users to encode spaces on the fly when writing links
|
|
|
|
|
;; (e.g., insert [[shell:ls%20*.org]] instead of
|
|
|
|
|
;; [[shell:ls *.org]], which defeats Org's focus on
|
|
|
|
|
;; simplicity.
|
2015-08-19 09:12:57 -04:00
|
|
|
|
(setq raw-link (org-link-expand-abbrev
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"[ \t]*\n[ \t]*" " "
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(match-string-no-properties 1))))
|
2015-08-04 10:40:25 -04:00
|
|
|
|
;; Determine TYPE of link and set PATH accordingly. According
|
|
|
|
|
;; to RFC 3986, remove whitespaces from URI in external links.
|
|
|
|
|
;; In internal ones, treat indentation as a single space.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(cond
|
|
|
|
|
;; File type.
|
2013-07-20 06:45:58 -04:00
|
|
|
|
((or (file-name-absolute-p raw-link)
|
2014-07-26 04:47:29 -04:00
|
|
|
|
(string-match "\\`\\.\\.?/" raw-link))
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq type "file")
|
|
|
|
|
(setq path raw-link))
|
2016-07-07 09:58:29 -04:00
|
|
|
|
;; Explicit type (http, irc, bbdb...).
|
2014-07-26 04:47:29 -04:00
|
|
|
|
((string-match org-link-types-re raw-link)
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq type (match-string 1 raw-link))
|
|
|
|
|
(setq path (substring raw-link (match-end 0))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Code-ref type: PATH is the name of the reference.
|
2016-07-25 09:21:12 -04:00
|
|
|
|
((and (string-match-p "\\`(" raw-link)
|
|
|
|
|
(string-match-p ")\\'" raw-link))
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq type "coderef")
|
|
|
|
|
(setq path (substring raw-link 1 -1)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Custom-id type: PATH is the name of the custom id.
|
2015-05-13 06:37:53 -04:00
|
|
|
|
((= (string-to-char raw-link) ?#)
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq type "custom-id")
|
|
|
|
|
(setq path (substring raw-link 1)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Fuzzy type: Internal link either matches a target, an
|
|
|
|
|
;; headline name or nothing. PATH is the target or
|
|
|
|
|
;; headline's name.
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(t
|
|
|
|
|
(setq type "fuzzy")
|
|
|
|
|
(setq path raw-link))))
|
2018-01-16 13:42:57 -05:00
|
|
|
|
;; Type 3: Plain link, e.g., https://orgmode.org
|
2012-07-28 01:02:21 -04:00
|
|
|
|
((looking-at org-plain-link-re)
|
2016-10-08 18:26:45 -04:00
|
|
|
|
(setq format 'plain)
|
|
|
|
|
(setq raw-link (match-string-no-properties 0))
|
|
|
|
|
(setq type (match-string-no-properties 1))
|
|
|
|
|
(setq link-end (match-end 0))
|
|
|
|
|
(setq path (match-string-no-properties 2)))
|
2018-01-16 13:42:57 -05:00
|
|
|
|
;; Type 4: Angular link, e.g., <https://orgmode.org>. Unlike to
|
2015-08-04 10:40:25 -04:00
|
|
|
|
;; bracket links, follow RFC 3986 and remove any extra
|
|
|
|
|
;; whitespace in URI.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
((looking-at org-angle-link-re)
|
2016-10-08 18:26:45 -04:00
|
|
|
|
(setq format 'angle)
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(setq type (match-string-no-properties 1))
|
2015-08-04 10:40:25 -04:00
|
|
|
|
(setq link-end (match-end 0))
|
|
|
|
|
(setq raw-link
|
|
|
|
|
(buffer-substring-no-properties
|
|
|
|
|
(match-beginning 1) (match-end 2)))
|
|
|
|
|
(setq path (replace-regexp-in-string
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
"[ \t]*\n[ \t]*" "" (match-string-no-properties 2))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(t (throw 'no-object nil)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; In any case, deduce end point after trailing white space from
|
|
|
|
|
;; LINK-END variable.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(save-excursion
|
2015-08-19 09:12:57 -04:00
|
|
|
|
(setq post-blank
|
|
|
|
|
(progn (goto-char link-end) (skip-chars-forward " \t")))
|
|
|
|
|
(setq end (point)))
|
|
|
|
|
;; Special "file" type link processing. Extract opening
|
|
|
|
|
;; application and search option, if any. Also normalize URI.
|
|
|
|
|
(when (string-match "\\`file\\(?:\\+\\(.+\\)\\)?\\'" type)
|
|
|
|
|
(setq application (match-string 1 type) type "file")
|
|
|
|
|
(when (string-match "::\\(.*\\)\\'" path)
|
|
|
|
|
(setq search-option (match-string 1 path))
|
|
|
|
|
(setq path (replace-match "" nil nil path)))
|
2017-02-16 16:42:59 -05:00
|
|
|
|
(setq path (replace-regexp-in-string "\\`///*\\(.:\\)?/" "\\1/" path)))
|
2015-08-19 09:12:57 -04:00
|
|
|
|
;; Translate link, if `org-link-translation-function' is set.
|
|
|
|
|
(let ((trans (and (functionp org-link-translation-function)
|
|
|
|
|
(funcall org-link-translation-function type path))))
|
2015-08-19 10:24:34 -04:00
|
|
|
|
(when trans
|
|
|
|
|
(setq type (car trans))
|
2015-09-25 18:04:05 -04:00
|
|
|
|
(setq path (cdr trans))))
|
2015-08-19 09:12:57 -04:00
|
|
|
|
(list 'link
|
|
|
|
|
(list :type type
|
|
|
|
|
:path path
|
2016-10-08 18:26:45 -04:00
|
|
|
|
:format format
|
2015-08-19 09:12:57 -04:00
|
|
|
|
:raw-link (or raw-link path)
|
|
|
|
|
:application application
|
|
|
|
|
:search-option search-option
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-link-interpreter (link contents)
|
|
|
|
|
"Interpret LINK object as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the object, or nil."
|
|
|
|
|
(let ((type (org-element-property :type link))
|
2015-08-19 09:12:57 -04:00
|
|
|
|
(path (org-element-property :path link)))
|
|
|
|
|
(if (string= type "radio") path
|
2016-10-08 18:26:45 -04:00
|
|
|
|
(let ((fmt (pcase (org-element-property :format link)
|
|
|
|
|
;; Links with contents and internal links have to
|
|
|
|
|
;; use bracket syntax. Ignore `:format' in these
|
|
|
|
|
;; cases. This is also the default syntax when the
|
|
|
|
|
;; property is not defined, e.g., when the object
|
|
|
|
|
;; was crafted by the user.
|
2016-10-24 17:56:34 -04:00
|
|
|
|
((guard contents)
|
|
|
|
|
(format "[[%%s][%s]]"
|
|
|
|
|
;; Since this is going to be used as
|
|
|
|
|
;; a format string, escape percent signs
|
|
|
|
|
;; in description.
|
|
|
|
|
(replace-regexp-in-string "%" "%%" contents)))
|
2016-10-08 18:26:45 -04:00
|
|
|
|
((or `bracket
|
|
|
|
|
`nil
|
|
|
|
|
(guard (member type '("coderef" "custom-id" "fuzzy"))))
|
|
|
|
|
"[[%s]]")
|
|
|
|
|
;; Otherwise, just obey to `:format'.
|
|
|
|
|
(`angle "<%s>")
|
|
|
|
|
(`plain "%s")
|
|
|
|
|
(f (error "Wrong `:format' value: %s" f)))))
|
|
|
|
|
(format fmt
|
|
|
|
|
(pcase type
|
|
|
|
|
("coderef" (format "(%s)" path))
|
|
|
|
|
("custom-id" (concat "#" path))
|
|
|
|
|
("file"
|
|
|
|
|
(let ((app (org-element-property :application link))
|
|
|
|
|
(opt (org-element-property :search-option link)))
|
|
|
|
|
(concat type (and app (concat "+" app)) ":"
|
|
|
|
|
path
|
|
|
|
|
(and opt (concat "::" opt)))))
|
|
|
|
|
("fuzzy" path)
|
|
|
|
|
(_ (concat type ":" path))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Macro
|
|
|
|
|
|
|
|
|
|
(defun org-element-macro-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse macro at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a macro, return a list whose car is `macro' and cdr
|
|
|
|
|
a plist with `:key', `:args', `:begin', `:end', `:value' and
|
|
|
|
|
`:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the macro."
|
|
|
|
|
(save-excursion
|
2018-01-29 09:17:37 -05:00
|
|
|
|
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))\\)?}}}")
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((begin (point))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(key (downcase (match-string-no-properties 1)))
|
|
|
|
|
(value (match-string-no-properties 0))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point))
|
2018-01-29 09:17:37 -05:00
|
|
|
|
(args (pcase (match-string-no-properties 3)
|
|
|
|
|
(`nil nil)
|
|
|
|
|
(a (org-macro-extract-arguments
|
|
|
|
|
(replace-regexp-in-string
|
|
|
|
|
"[ \t\r\n]+" " " (org-trim a)))))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(list 'macro
|
|
|
|
|
(list :key key
|
|
|
|
|
:value value
|
|
|
|
|
:args args
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-macro-interpreter (macro _)
|
|
|
|
|
"Interpret MACRO object as Org syntax."
|
2018-01-29 09:17:37 -05:00
|
|
|
|
(format "{{{%s%s}}}"
|
|
|
|
|
(org-element-property :key macro)
|
|
|
|
|
(pcase (org-element-property :args macro)
|
|
|
|
|
(`nil "")
|
|
|
|
|
(args (format "(%s)" (apply #'org-macro-escape-arguments args))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Radio-target
|
|
|
|
|
|
|
|
|
|
(defun org-element-radio-target-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse radio target at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a radio target, return a list whose car is `radio-target'
|
|
|
|
|
and cdr a plist with `:begin', `:end', `:contents-begin',
|
|
|
|
|
`:contents-end', `:value' and `:post-blank' as keywords.
|
|
|
|
|
Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the radio target."
|
|
|
|
|
(save-excursion
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-radio-target-regexp)
|
|
|
|
|
(let ((begin (point))
|
|
|
|
|
(contents-begin (match-beginning 1))
|
|
|
|
|
(contents-end (match-end 1))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(value (match-string-no-properties 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'radio-target
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank
|
|
|
|
|
:value value))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-radio-target-interpreter (_ contents)
|
|
|
|
|
"Interpret target object as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(concat "<<<" contents ">>>"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Statistics Cookie
|
|
|
|
|
|
|
|
|
|
(defun org-element-statistics-cookie-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse statistics cookie at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a statistics cookie, return a list whose car is
|
|
|
|
|
`statistics-cookie', and cdr a plist with `:begin', `:end',
|
|
|
|
|
`:value' and `:post-blank' keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the statistics-cookie."
|
|
|
|
|
(save-excursion
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at "\\[[0-9]*\\(%\\|/[0-9]*\\)\\]")
|
|
|
|
|
(let* ((begin (point))
|
|
|
|
|
(value (buffer-substring-no-properties
|
|
|
|
|
(match-beginning 0) (match-end 0)))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'statistics-cookie
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-statistics-cookie-interpreter (statistics-cookie _)
|
|
|
|
|
"Interpret STATISTICS-COOKIE object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-property :value statistics-cookie))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Strike-Through
|
|
|
|
|
|
|
|
|
|
(defun org-element-strike-through-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse strike-through object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a strike-through object, return a list whose car is
|
|
|
|
|
`strike-through' and cdr is a plist with `:begin', `:end',
|
|
|
|
|
`:contents-begin' and `:contents-end' and `:post-blank' keywords.
|
|
|
|
|
Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first plus sign marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-emph-re)
|
|
|
|
|
(let ((begin (match-beginning 2))
|
|
|
|
|
(contents-begin (match-beginning 4))
|
|
|
|
|
(contents-end (match-end 4))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'strike-through
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-strike-through-interpreter (_ contents)
|
|
|
|
|
"Interpret strike-through object as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format "+%s+" contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Subscript
|
|
|
|
|
|
|
|
|
|
(defun org-element-subscript-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse subscript at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a subscript object, return a list whose car is
|
|
|
|
|
`subscript' and cdr a plist with `:begin', `:end',
|
|
|
|
|
`:contents-begin', `:contents-end', `:use-brackets-p' and
|
|
|
|
|
`:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the underscore."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-match-substring-regexp)
|
|
|
|
|
(let ((bracketsp (match-beginning 4))
|
|
|
|
|
(begin (match-beginning 2))
|
|
|
|
|
(contents-begin (or (match-beginning 4)
|
|
|
|
|
(match-beginning 3)))
|
|
|
|
|
(contents-end (or (match-end 4) (match-end 3)))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'subscript
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:use-brackets-p bracketsp
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-subscript-interpreter (subscript contents)
|
|
|
|
|
"Interpret SUBSCRIPT object as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format
|
|
|
|
|
(if (org-element-property :use-brackets-p subscript) "_{%s}" "_%s")
|
|
|
|
|
contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Superscript
|
|
|
|
|
|
|
|
|
|
(defun org-element-superscript-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse superscript at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a superscript object, return a list whose car is
|
|
|
|
|
`superscript' and cdr a plist with `:begin', `:end',
|
|
|
|
|
`:contents-begin', `:contents-end', `:use-brackets-p' and
|
|
|
|
|
`:post-blank' as keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the caret."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-match-substring-regexp)
|
|
|
|
|
(let ((bracketsp (match-beginning 4))
|
|
|
|
|
(begin (match-beginning 2))
|
|
|
|
|
(contents-begin (or (match-beginning 4)
|
|
|
|
|
(match-beginning 3)))
|
|
|
|
|
(contents-end (or (match-end 4) (match-end 3)))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'superscript
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:use-brackets-p bracketsp
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element-superscript-interpreter (superscript contents)
|
|
|
|
|
"Interpret SUPERSCRIPT object as Org syntax.
|
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format
|
|
|
|
|
(if (org-element-property :use-brackets-p superscript) "^{%s}" "^%s")
|
|
|
|
|
contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Table Cell
|
|
|
|
|
|
|
|
|
|
(defun org-element-table-cell-parser ()
|
|
|
|
|
"Parse table cell at point.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
Return a list whose car is `table-cell' and cdr is a plist
|
2012-07-28 01:02:21 -04:00
|
|
|
|
containing `:begin', `:end', `:contents-begin', `:contents-end'
|
|
|
|
|
and `:post-blank' keywords."
|
2014-04-08 12:46:41 -04:00
|
|
|
|
(looking-at "[ \t]*\\(.*?\\)[ \t]*\\(?:|\\|$\\)")
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let* ((begin (match-beginning 0))
|
|
|
|
|
(end (match-end 0))
|
|
|
|
|
(contents-begin (match-beginning 1))
|
|
|
|
|
(contents-end (match-end 1)))
|
|
|
|
|
(list 'table-cell
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank 0))))
|
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-table-cell-interpreter (_ contents)
|
|
|
|
|
"Interpret table-cell element as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the cell, or nil."
|
|
|
|
|
(concat " " contents " |"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Target
|
|
|
|
|
|
|
|
|
|
(defun org-element-target-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse target at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a target, return a list whose car is `target' and cdr
|
|
|
|
|
a plist with `:begin', `:end', `:value' and `:post-blank' as
|
|
|
|
|
keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the target."
|
|
|
|
|
(save-excursion
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-target-regexp)
|
|
|
|
|
(let ((begin (point))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(value (match-string-no-properties 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'target
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:value value
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-target-interpreter (target _)
|
|
|
|
|
"Interpret TARGET object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(format "<<%s>>" (org-element-property :value target)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Timestamp
|
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(defconst org-element--timestamp-regexp
|
|
|
|
|
(concat org-ts-regexp-both
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\(?:<[0-9]+-[0-9]+-[0-9]+[^>\n]+?\\+[0-9]+[dwmy]>\\)"
|
|
|
|
|
"\\|"
|
|
|
|
|
"\\(?:<%%\\(?:([^>\n]+)\\)>\\)")
|
|
|
|
|
"Regexp matching any timestamp type object.")
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defun org-element-timestamp-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse time stamp at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a time stamp, return a list whose car is `timestamp', and
|
|
|
|
|
cdr a plist with `:type', `:raw-value', `:year-start',
|
|
|
|
|
`:month-start', `:day-start', `:hour-start', `:minute-start',
|
|
|
|
|
`:year-end', `:month-end', `:day-end', `:hour-end',
|
|
|
|
|
`:minute-end', `:repeater-type', `:repeater-value',
|
|
|
|
|
`:repeater-unit', `:warning-type', `:warning-value',
|
2014-04-23 16:04:20 -04:00
|
|
|
|
`:warning-unit', `:begin', `:end' and `:post-blank' keywords.
|
|
|
|
|
Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the beginning of the timestamp."
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(when (looking-at-p org-element--timestamp-regexp)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(let* ((begin (point))
|
|
|
|
|
(activep (eq (char-after) ?<))
|
|
|
|
|
(raw-value
|
|
|
|
|
(progn
|
|
|
|
|
(looking-at "\\([<[]\\(%%\\)?.*?\\)[]>]\\(?:--\\([<[].*?[]>]\\)\\)?")
|
|
|
|
|
(match-string-no-properties 0)))
|
|
|
|
|
(date-start (match-string-no-properties 1))
|
|
|
|
|
(date-end (match-string 3))
|
|
|
|
|
(diaryp (match-beginning 2))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 0))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point))
|
|
|
|
|
(time-range
|
|
|
|
|
(and (not diaryp)
|
|
|
|
|
(string-match
|
|
|
|
|
"[012]?[0-9]:[0-5][0-9]\\(-\\([012]?[0-9]\\):\\([0-5][0-9]\\)\\)"
|
|
|
|
|
date-start)
|
|
|
|
|
(cons (string-to-number (match-string 2 date-start))
|
|
|
|
|
(string-to-number (match-string 3 date-start)))))
|
|
|
|
|
(type (cond (diaryp 'diary)
|
|
|
|
|
((and activep (or date-end time-range)) 'active-range)
|
|
|
|
|
(activep 'active)
|
|
|
|
|
((or date-end time-range) 'inactive-range)
|
|
|
|
|
(t 'inactive)))
|
|
|
|
|
(repeater-props
|
|
|
|
|
(and (not diaryp)
|
|
|
|
|
(string-match "\\([.+]?\\+\\)\\([0-9]+\\)\\([hdwmy]\\)"
|
|
|
|
|
raw-value)
|
|
|
|
|
(list
|
|
|
|
|
:repeater-type
|
|
|
|
|
(let ((type (match-string 1 raw-value)))
|
|
|
|
|
(cond ((equal "++" type) 'catch-up)
|
|
|
|
|
((equal ".+" type) 'restart)
|
|
|
|
|
(t 'cumulate)))
|
|
|
|
|
:repeater-value (string-to-number (match-string 2 raw-value))
|
|
|
|
|
:repeater-unit
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (string-to-char (match-string 3 raw-value))
|
|
|
|
|
(?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year)))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(warning-props
|
|
|
|
|
(and (not diaryp)
|
|
|
|
|
(string-match "\\(-\\)?-\\([0-9]+\\)\\([hdwmy]\\)" raw-value)
|
|
|
|
|
(list
|
|
|
|
|
:warning-type (if (match-string 1 raw-value) 'first 'all)
|
|
|
|
|
:warning-value (string-to-number (match-string 2 raw-value))
|
|
|
|
|
:warning-unit
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (string-to-char (match-string 3 raw-value))
|
|
|
|
|
(?h 'hour) (?d 'day) (?w 'week) (?m 'month) (_ 'year)))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
year-start month-start day-start hour-start minute-start year-end
|
|
|
|
|
month-end day-end hour-end minute-end)
|
|
|
|
|
;; Parse date-start.
|
|
|
|
|
(unless diaryp
|
|
|
|
|
(let ((date (org-parse-time-string date-start t)))
|
|
|
|
|
(setq year-start (nth 5 date)
|
|
|
|
|
month-start (nth 4 date)
|
|
|
|
|
day-start (nth 3 date)
|
|
|
|
|
hour-start (nth 2 date)
|
|
|
|
|
minute-start (nth 1 date))))
|
|
|
|
|
;; Compute date-end. It can be provided directly in time-stamp,
|
|
|
|
|
;; or extracted from time range. Otherwise, it defaults to the
|
|
|
|
|
;; same values as date-start.
|
|
|
|
|
(unless diaryp
|
|
|
|
|
(let ((date (and date-end (org-parse-time-string date-end t))))
|
|
|
|
|
(setq year-end (or (nth 5 date) year-start)
|
|
|
|
|
month-end (or (nth 4 date) month-start)
|
|
|
|
|
day-end (or (nth 3 date) day-start)
|
|
|
|
|
hour-end (or (nth 2 date) (car time-range) hour-start)
|
|
|
|
|
minute-end (or (nth 1 date) (cdr time-range) minute-start))))
|
|
|
|
|
(list 'timestamp
|
|
|
|
|
(nconc (list :type type
|
|
|
|
|
:raw-value raw-value
|
|
|
|
|
:year-start year-start
|
|
|
|
|
:month-start month-start
|
|
|
|
|
:day-start day-start
|
|
|
|
|
:hour-start hour-start
|
|
|
|
|
:minute-start minute-start
|
|
|
|
|
:year-end year-end
|
|
|
|
|
:month-end month-end
|
|
|
|
|
:day-end day-end
|
|
|
|
|
:hour-end hour-end
|
|
|
|
|
:minute-end minute-end
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank)
|
|
|
|
|
repeater-props
|
|
|
|
|
warning-props))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-timestamp-interpreter (timestamp _)
|
|
|
|
|
"Interpret TIMESTAMP object as Org syntax."
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let* ((repeat-string
|
|
|
|
|
(concat
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (org-element-property :repeater-type timestamp)
|
|
|
|
|
(`cumulate "+") (`catch-up "++") (`restart ".+"))
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let ((val (org-element-property :repeater-value timestamp)))
|
|
|
|
|
(and val (number-to-string val)))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (org-element-property :repeater-unit timestamp)
|
|
|
|
|
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(warning-string
|
|
|
|
|
(concat
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (org-element-property :warning-type timestamp)
|
|
|
|
|
(`first "--") (`all "-"))
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let ((val (org-element-property :warning-value timestamp)))
|
|
|
|
|
(and val (number-to-string val)))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (org-element-property :warning-unit timestamp)
|
|
|
|
|
(`hour "h") (`day "d") (`week "w") (`month "m") (`year "y"))))
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(build-ts-string
|
|
|
|
|
;; Build an Org timestamp string from TIME. ACTIVEP is
|
|
|
|
|
;; non-nil when time stamp is active. If WITH-TIME-P is
|
|
|
|
|
;; non-nil, add a time part. HOUR-END and MINUTE-END
|
|
|
|
|
;; specify a time range in the timestamp. REPEAT-STRING is
|
|
|
|
|
;; the repeater string, if any.
|
|
|
|
|
(lambda (time activep &optional with-time-p hour-end minute-end)
|
|
|
|
|
(let ((ts (format-time-string
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(funcall (if with-time-p #'cdr #'car)
|
2013-11-16 04:15:28 -05:00
|
|
|
|
org-time-stamp-formats)
|
|
|
|
|
time)))
|
|
|
|
|
(when (and hour-end minute-end)
|
|
|
|
|
(string-match "[012]?[0-9]:[0-5][0-9]" ts)
|
|
|
|
|
(setq ts
|
|
|
|
|
(replace-match
|
|
|
|
|
(format "\\&-%02d:%02d" hour-end minute-end)
|
|
|
|
|
nil nil ts)))
|
|
|
|
|
(unless activep (setq ts (format "[%s]" (substring ts 1 -1))))
|
|
|
|
|
(dolist (s (list repeat-string warning-string))
|
|
|
|
|
(when (org-string-nw-p s)
|
|
|
|
|
(setq ts (concat (substring ts 0 -1)
|
|
|
|
|
" "
|
|
|
|
|
s
|
|
|
|
|
(substring ts -1)))))
|
|
|
|
|
;; Return value.
|
|
|
|
|
ts)))
|
|
|
|
|
(type (org-element-property :type timestamp)))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase type
|
|
|
|
|
((or `active `inactive)
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let* ((minute-start (org-element-property :minute-start timestamp))
|
|
|
|
|
(minute-end (org-element-property :minute-end timestamp))
|
|
|
|
|
(hour-start (org-element-property :hour-start timestamp))
|
|
|
|
|
(hour-end (org-element-property :hour-end timestamp))
|
|
|
|
|
(time-range-p (and hour-start hour-end minute-start minute-end
|
|
|
|
|
(or (/= hour-start hour-end)
|
|
|
|
|
(/= minute-start minute-end)))))
|
|
|
|
|
(funcall
|
|
|
|
|
build-ts-string
|
|
|
|
|
(encode-time 0
|
|
|
|
|
(or minute-start 0)
|
|
|
|
|
(or hour-start 0)
|
|
|
|
|
(org-element-property :day-start timestamp)
|
|
|
|
|
(org-element-property :month-start timestamp)
|
|
|
|
|
(org-element-property :year-start timestamp))
|
|
|
|
|
(eq type 'active)
|
|
|
|
|
(and hour-start minute-start)
|
|
|
|
|
(and time-range-p hour-end)
|
|
|
|
|
(and time-range-p minute-end))))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
((or `active-range `inactive-range)
|
2013-11-16 04:15:28 -05:00
|
|
|
|
(let ((minute-start (org-element-property :minute-start timestamp))
|
|
|
|
|
(minute-end (org-element-property :minute-end timestamp))
|
|
|
|
|
(hour-start (org-element-property :hour-start timestamp))
|
|
|
|
|
(hour-end (org-element-property :hour-end timestamp)))
|
|
|
|
|
(concat
|
|
|
|
|
(funcall
|
|
|
|
|
build-ts-string (encode-time
|
|
|
|
|
0
|
|
|
|
|
(or minute-start 0)
|
|
|
|
|
(or hour-start 0)
|
|
|
|
|
(org-element-property :day-start timestamp)
|
|
|
|
|
(org-element-property :month-start timestamp)
|
|
|
|
|
(org-element-property :year-start timestamp))
|
|
|
|
|
(eq type 'active-range)
|
|
|
|
|
(and hour-start minute-start))
|
|
|
|
|
"--"
|
|
|
|
|
(funcall build-ts-string
|
|
|
|
|
(encode-time 0
|
|
|
|
|
(or minute-end 0)
|
|
|
|
|
(or hour-end 0)
|
|
|
|
|
(org-element-property :day-end timestamp)
|
|
|
|
|
(org-element-property :month-end timestamp)
|
|
|
|
|
(org-element-property :year-end timestamp))
|
|
|
|
|
(eq type 'active-range)
|
2014-12-03 11:13:44 -05:00
|
|
|
|
(and hour-end minute-end)))))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(_ (org-element-property :raw-value timestamp)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Underline
|
|
|
|
|
|
|
|
|
|
(defun org-element-underline-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse underline object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at an underline object, return a list whose car is
|
|
|
|
|
`underline' and cdr is a plist with `:begin', `:end',
|
|
|
|
|
`:contents-begin' and `:contents-end' and `:post-blank' keywords.
|
|
|
|
|
Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first underscore marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(when (looking-at org-emph-re)
|
|
|
|
|
(let ((begin (match-beginning 2))
|
|
|
|
|
(contents-begin (match-beginning 4))
|
|
|
|
|
(contents-end (match-end 4))
|
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'underline
|
|
|
|
|
(list :begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:contents-begin contents-begin
|
|
|
|
|
:contents-end contents-end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-underline-interpreter (_ contents)
|
|
|
|
|
"Interpret underline object as Org syntax.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
CONTENTS is the contents of the object."
|
|
|
|
|
(format "_%s_" contents))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Verbatim
|
|
|
|
|
|
|
|
|
|
(defun org-element-verbatim-parser ()
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Parse verbatim object at point, if any.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
When at a verbatim object, return a list whose car is `verbatim'
|
|
|
|
|
and cdr is a plist with `:value', `:begin', `:end' and
|
|
|
|
|
`:post-blank' keywords. Otherwise, return nil.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Assume point is at the first equal sign marker."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(unless (bolp) (backward-char 1))
|
2016-12-08 03:44:26 -05:00
|
|
|
|
(when (looking-at org-verbatim-re)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((begin (match-beginning 2))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(value (match-string-no-properties 4))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(post-blank (progn (goto-char (match-end 2))
|
|
|
|
|
(skip-chars-forward " \t")))
|
|
|
|
|
(end (point)))
|
|
|
|
|
(list 'verbatim
|
|
|
|
|
(list :value value
|
|
|
|
|
:begin begin
|
|
|
|
|
:end end
|
|
|
|
|
:post-blank post-blank))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(defun org-element-verbatim-interpreter (verbatim _)
|
|
|
|
|
"Interpret VERBATIM object as Org syntax."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(format "=%s=" (org-element-property :value verbatim)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Parsing Element Starting At Point
|
|
|
|
|
;;
|
|
|
|
|
;; `org-element--current-element' is the core function of this section.
|
|
|
|
|
;; It returns the Lisp representation of the element starting at
|
|
|
|
|
;; point.
|
|
|
|
|
;;
|
|
|
|
|
;; `org-element--current-element' makes use of special modes. They
|
2014-03-17 05:31:37 -04:00
|
|
|
|
;; are activated for fixed element chaining (e.g., `plain-list' >
|
|
|
|
|
;; `item') or fixed conditional element chaining (e.g., `headline' >
|
2012-09-23 09:52:02 -04:00
|
|
|
|
;; `section'). Special modes are: `first-section', `item',
|
2014-01-26 08:09:45 -05:00
|
|
|
|
;; `node-property', `section' and `table-row'.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2014-08-31 10:31:59 -04:00
|
|
|
|
(defun org-element--current-element (limit &optional granularity mode structure)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse the element starting at point.
|
|
|
|
|
|
|
|
|
|
Return value is a list like (TYPE PROPS) where TYPE is the type
|
|
|
|
|
of the element and PROPS a plist of properties associated to the
|
|
|
|
|
element.
|
|
|
|
|
|
|
|
|
|
Possible types are defined in `org-element-all-elements'.
|
|
|
|
|
|
org-element: Fix parsing error in `org-element-context'
* lisp/org-element.el (org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-plain-link-successor, org-element-macro-successor,
org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor): Remove LIMIT argument.
(org-element--parse-objects, org-element--get-next-object-candidates):
Apply signature change to successors.
(org-element-context): Narrow buffer around object containers so
parsing of objects when using this function is done under the same
restrictions as in buffer parsing.
* testing/lisp/test-org-element.el: Add test.
2013-08-30 07:29:51 -04:00
|
|
|
|
LIMIT bounds the search.
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
Optional argument GRANULARITY determines the depth of the
|
|
|
|
|
recursion. Allowed values are `headline', `greater-element',
|
|
|
|
|
`element', `object' or nil. When it is broader than `object' (or
|
|
|
|
|
nil), secondary values will not be parsed, since they only
|
|
|
|
|
contain objects.
|
|
|
|
|
|
2014-08-31 10:31:59 -04:00
|
|
|
|
Optional argument MODE, when non-nil, can be either
|
|
|
|
|
`first-section', `section', `planning', `item', `node-property'
|
|
|
|
|
and `table-row'.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2014-08-31 10:31:59 -04:00
|
|
|
|
If STRUCTURE isn't provided but MODE is set to `item', it will be
|
|
|
|
|
computed.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
This function assumes point is always at the beginning of the
|
|
|
|
|
element it has to parse."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(let ((case-fold-search t)
|
|
|
|
|
;; Determine if parsing depth allows for secondary strings
|
|
|
|
|
;; parsing. It only applies to elements referenced in
|
|
|
|
|
;; `org-element-secondary-value-alist'.
|
|
|
|
|
(raw-secondary-p (and granularity (not (eq granularity 'object)))))
|
|
|
|
|
(cond
|
|
|
|
|
;; Item.
|
2014-08-31 10:31:59 -04:00
|
|
|
|
((eq mode 'item)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-item-parser limit structure raw-secondary-p))
|
|
|
|
|
;; Table Row.
|
2014-08-31 10:31:59 -04:00
|
|
|
|
((eq mode 'table-row) (org-element-table-row-parser limit))
|
2012-09-23 09:52:02 -04:00
|
|
|
|
;; Node Property.
|
2014-08-31 10:31:59 -04:00
|
|
|
|
((eq mode 'node-property) (org-element-node-property-parser limit))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Headline.
|
|
|
|
|
((org-with-limited-levels (org-at-heading-p))
|
|
|
|
|
(org-element-headline-parser limit raw-secondary-p))
|
2012-09-01 16:52:43 -04:00
|
|
|
|
;; Sections (must be checked after headline).
|
2014-08-31 10:31:59 -04:00
|
|
|
|
((eq mode 'section) (org-element-section-parser limit))
|
|
|
|
|
((eq mode 'first-section)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(org-element-section-parser
|
|
|
|
|
(or (save-excursion (org-with-limited-levels (outline-next-heading)))
|
|
|
|
|
limit)))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
;; Planning.
|
2016-11-09 18:25:34 -05:00
|
|
|
|
((and (eq mode 'planning)
|
|
|
|
|
(eq ?* (char-after (line-beginning-position 0)))
|
|
|
|
|
(looking-at org-planning-line-re))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
(org-element-planning-parser limit))
|
2014-09-13 16:43:45 -04:00
|
|
|
|
;; Property drawer.
|
|
|
|
|
((and (memq mode '(planning property-drawer))
|
2016-11-09 18:25:34 -05:00
|
|
|
|
(eq ?* (char-after (line-beginning-position
|
|
|
|
|
(if (eq mode 'planning) 0 -1))))
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(looking-at org-property-drawer-re))
|
|
|
|
|
(org-element-property-drawer-parser limit))
|
2012-09-12 09:40:13 -04:00
|
|
|
|
;; When not at bol, point is at the beginning of an item or
|
|
|
|
|
;; a footnote definition: next item is always a paragraph.
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
((not (bolp)) (org-element-paragraph-parser limit (list (point))))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
;; Clock.
|
2014-08-31 09:39:35 -04:00
|
|
|
|
((looking-at org-clock-line-re) (org-element-clock-parser limit))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Inlinetask.
|
|
|
|
|
((org-at-heading-p)
|
|
|
|
|
(org-element-inlinetask-parser limit raw-secondary-p))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; From there, elements can have affiliated keywords.
|
2013-02-11 08:42:16 -05:00
|
|
|
|
(t (let ((affiliated (org-element--collect-affiliated-keywords limit)))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(cond
|
2013-02-11 08:42:16 -05:00
|
|
|
|
;; Jumping over affiliated keywords put point off-limits.
|
|
|
|
|
;; Parse them as regular keywords.
|
2013-06-25 11:32:26 -04:00
|
|
|
|
((and (cdr affiliated) (>= (point) limit))
|
2013-02-11 08:42:16 -05:00
|
|
|
|
(goto-char (car affiliated))
|
|
|
|
|
(org-element-keyword-parser limit nil))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; LaTeX Environment.
|
2014-07-22 09:09:03 -04:00
|
|
|
|
((looking-at org-element--latex-begin-environment)
|
2012-10-27 08:19:58 -04:00
|
|
|
|
(org-element-latex-environment-parser limit affiliated))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Drawer and Property Drawer.
|
|
|
|
|
((looking-at org-drawer-regexp)
|
2014-09-13 16:43:45 -04:00
|
|
|
|
(org-element-drawer-parser limit affiliated))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Fixed Width
|
|
|
|
|
((looking-at "[ \t]*:\\( \\|$\\)")
|
|
|
|
|
(org-element-fixed-width-parser limit affiliated))
|
|
|
|
|
;; Inline Comments, Blocks, Babel Calls, Dynamic Blocks and
|
|
|
|
|
;; Keywords.
|
|
|
|
|
((looking-at "[ \t]*#")
|
|
|
|
|
(goto-char (match-end 0))
|
2015-02-03 10:16:54 -05:00
|
|
|
|
(cond
|
|
|
|
|
((looking-at "\\(?: \\|$\\)")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-comment-parser limit affiliated))
|
|
|
|
|
((looking-at "\\+BEGIN_\\(\\S-+\\)")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(funcall (pcase (upcase (match-string 1))
|
|
|
|
|
("CENTER" #'org-element-center-block-parser)
|
|
|
|
|
("COMMENT" #'org-element-comment-block-parser)
|
|
|
|
|
("EXAMPLE" #'org-element-example-block-parser)
|
|
|
|
|
("EXPORT" #'org-element-export-block-parser)
|
|
|
|
|
("QUOTE" #'org-element-quote-block-parser)
|
|
|
|
|
("SRC" #'org-element-src-block-parser)
|
|
|
|
|
("VERSE" #'org-element-verse-block-parser)
|
|
|
|
|
(_ #'org-element-special-block-parser))
|
|
|
|
|
limit
|
|
|
|
|
affiliated))
|
|
|
|
|
((looking-at "\\+CALL:")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-babel-call-parser limit affiliated))
|
|
|
|
|
((looking-at "\\+BEGIN:? ")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-dynamic-block-parser limit affiliated))
|
|
|
|
|
((looking-at "\\+\\S-+:")
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-keyword-parser limit affiliated))
|
|
|
|
|
(t
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-paragraph-parser limit affiliated))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Footnote Definition.
|
|
|
|
|
((looking-at org-footnote-definition-re)
|
|
|
|
|
(org-element-footnote-definition-parser limit affiliated))
|
|
|
|
|
;; Horizontal Rule.
|
|
|
|
|
((looking-at "[ \t]*-\\{5,\\}[ \t]*$")
|
|
|
|
|
(org-element-horizontal-rule-parser limit affiliated))
|
2012-10-27 08:23:37 -04:00
|
|
|
|
;; Diary Sexp.
|
|
|
|
|
((looking-at "%%(")
|
|
|
|
|
(org-element-diary-sexp-parser limit affiliated))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Table.
|
2018-11-26 13:50:08 -05:00
|
|
|
|
((or (looking-at "[ \t]*|")
|
|
|
|
|
;; There is no strict definition of a table.el
|
|
|
|
|
;; table. Try to prevent false positive while being
|
|
|
|
|
;; quick.
|
|
|
|
|
(let ((rule-regexp "[ \t]*\\+\\(-+\\+\\)+[ \t]*$")
|
|
|
|
|
(next (line-beginning-position 2)))
|
|
|
|
|
(and (looking-at rule-regexp)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(forward-line)
|
|
|
|
|
(re-search-forward "^[ \t]*\\($\\|[^|]\\)" limit t)
|
|
|
|
|
(and (> (line-beginning-position) next)
|
|
|
|
|
(org-match-line rule-regexp))))))
|
2015-06-28 05:37:13 -04:00
|
|
|
|
(org-element-table-parser limit affiliated))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; List.
|
|
|
|
|
((looking-at (org-item-re))
|
|
|
|
|
(org-element-plain-list-parser
|
2013-05-31 14:13:29 -04:00
|
|
|
|
limit affiliated
|
|
|
|
|
(or structure (org-element--list-struct limit))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Default element: Paragraph.
|
|
|
|
|
(t (org-element-paragraph-parser limit affiliated)))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Most elements can have affiliated keywords. When looking for an
|
|
|
|
|
;; element beginning, we want to move before them, as they belong to
|
|
|
|
|
;; that element, and, in the meantime, collect information they give
|
|
|
|
|
;; into appropriate properties. Hence the following function.
|
|
|
|
|
|
2013-02-11 08:42:16 -05:00
|
|
|
|
(defun org-element--collect-affiliated-keywords (limit)
|
|
|
|
|
"Collect affiliated keywords from point down to LIMIT.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
Return a list whose CAR is the position at the first of them and
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
CDR a plist of keywords and values and move point to the
|
|
|
|
|
beginning of the first line after them.
|
|
|
|
|
|
|
|
|
|
As a special case, if element doesn't start at the beginning of
|
2014-03-17 05:31:37 -04:00
|
|
|
|
the line (e.g., a paragraph starting an item), CAR is current
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
position of point and CDR is nil."
|
|
|
|
|
(if (not (bolp)) (list (point))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(let ((case-fold-search t)
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(origin (point))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; RESTRICT is the list of objects allowed in parsed
|
|
|
|
|
;; keywords value.
|
|
|
|
|
(restrict (org-element-restriction 'keyword))
|
|
|
|
|
output)
|
2013-02-11 08:42:16 -05:00
|
|
|
|
(while (and (< (point) limit) (looking-at org-element--affiliated-re))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(let* ((raw-kwd (upcase (match-string 1)))
|
|
|
|
|
;; Apply translation to RAW-KWD. From there, KWD is
|
|
|
|
|
;; the official keyword.
|
|
|
|
|
(kwd (or (cdr (assoc raw-kwd
|
|
|
|
|
org-element-keyword-translation-alist))
|
|
|
|
|
raw-kwd))
|
|
|
|
|
;; Find main value for any keyword.
|
|
|
|
|
(value
|
|
|
|
|
(save-match-data
|
|
|
|
|
(org-trim
|
|
|
|
|
(buffer-substring-no-properties
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(match-end 0) (line-end-position)))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; PARSEDP is non-nil when keyword should have its
|
|
|
|
|
;; value parsed.
|
|
|
|
|
(parsedp (member kwd org-element-parsed-keywords))
|
|
|
|
|
;; If KWD is a dual keyword, find its secondary
|
|
|
|
|
;; value. Maybe parse it.
|
|
|
|
|
(dualp (member kwd org-element-dual-keywords))
|
|
|
|
|
(dual-value
|
|
|
|
|
(and dualp
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(let ((sec (match-string-no-properties 2)))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(if (or (not sec) (not parsedp)) sec
|
2015-09-10 11:55:26 -04:00
|
|
|
|
(save-match-data
|
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(match-beginning 2) (match-end 2) nil restrict))))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
;; Attribute a property name to KWD.
|
|
|
|
|
(kwd-sym (and kwd (intern (concat ":" (downcase kwd))))))
|
|
|
|
|
;; Now set final shape for VALUE.
|
|
|
|
|
(when parsedp
|
2015-01-27 16:25:15 -05:00
|
|
|
|
(setq value
|
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(match-end 0)
|
|
|
|
|
(progn (end-of-line) (skip-chars-backward " \t") (point))
|
|
|
|
|
nil restrict)))
|
2012-10-28 17:43:50 -04:00
|
|
|
|
(when dualp
|
|
|
|
|
(setq value (and (or value dual-value) (cons value dual-value))))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(when (or (member kwd org-element-multiple-keywords)
|
|
|
|
|
;; Attributes can always appear on multiple lines.
|
|
|
|
|
(string-match "^ATTR_" kwd))
|
|
|
|
|
(setq value (cons value (plist-get output kwd-sym))))
|
|
|
|
|
;; Eventually store the new value in OUTPUT.
|
|
|
|
|
(setq output (plist-put output kwd-sym value))
|
|
|
|
|
;; Move to next keyword.
|
|
|
|
|
(forward-line)))
|
|
|
|
|
;; If affiliated keywords are orphaned: move back to first one.
|
|
|
|
|
;; They will be parsed as a paragraph.
|
|
|
|
|
(when (looking-at "[ \t]*$") (goto-char origin) (setq output nil))
|
|
|
|
|
;; Return value.
|
2012-09-23 03:49:32 -04:00
|
|
|
|
(cons origin output))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; The Org Parser
|
|
|
|
|
;;
|
|
|
|
|
;; The two major functions here are `org-element-parse-buffer', which
|
|
|
|
|
;; parses Org syntax inside the current buffer, taking into account
|
|
|
|
|
;; region, narrowing, or even visibility if specified, and
|
|
|
|
|
;; `org-element-parse-secondary-string', which parses objects within
|
|
|
|
|
;; a given string.
|
|
|
|
|
;;
|
2016-01-24 15:30:39 -05:00
|
|
|
|
;; The (almost) almighty `org-element-map' allows applying a function
|
|
|
|
|
;; on elements or objects matching some type, and accumulating the
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; resulting values. In an export situation, it also skips unneeded
|
|
|
|
|
;; parts of the parse tree.
|
|
|
|
|
|
|
|
|
|
(defun org-element-parse-buffer (&optional granularity visible-only)
|
|
|
|
|
"Recursively parse the buffer and return structure.
|
|
|
|
|
If narrowing is in effect, only parse the visible part of the
|
|
|
|
|
buffer.
|
|
|
|
|
|
|
|
|
|
Optional argument GRANULARITY determines the depth of the
|
|
|
|
|
recursion. It can be set to the following symbols:
|
|
|
|
|
|
|
|
|
|
`headline' Only parse headlines.
|
2017-04-30 15:11:45 -04:00
|
|
|
|
`greater-element' Don't recurse into greater elements except
|
2012-07-28 01:02:21 -04:00
|
|
|
|
headlines and sections. Thus, elements
|
|
|
|
|
parsed are the top-level ones.
|
|
|
|
|
`element' Parse everything but objects and plain text.
|
|
|
|
|
`object' Parse the complete buffer (default).
|
|
|
|
|
|
|
|
|
|
When VISIBLE-ONLY is non-nil, don't parse contents of hidden
|
|
|
|
|
elements.
|
|
|
|
|
|
2017-04-30 15:11:45 -04:00
|
|
|
|
An element or object is represented as a list with the
|
2013-01-20 03:43:58 -05:00
|
|
|
|
pattern (TYPE PROPERTIES CONTENTS), where :
|
|
|
|
|
|
|
|
|
|
TYPE is a symbol describing the element or object. See
|
|
|
|
|
`org-element-all-elements' and `org-element-all-objects' for an
|
|
|
|
|
exhaustive list of such symbols. One can retrieve it with
|
|
|
|
|
`org-element-type' function.
|
|
|
|
|
|
|
|
|
|
PROPERTIES is the list of attributes attached to the element or
|
|
|
|
|
object, as a plist. Although most of them are specific to the
|
|
|
|
|
element or object type, all types share `:begin', `:end',
|
|
|
|
|
`:post-blank' and `:parent' properties, which respectively
|
|
|
|
|
refer to buffer position where the element or object starts,
|
|
|
|
|
ends, the number of white spaces or blank lines after it, and
|
|
|
|
|
the element or object containing it. Properties values can be
|
|
|
|
|
obtained by using `org-element-property' function.
|
|
|
|
|
|
|
|
|
|
CONTENTS is a list of elements, objects or raw strings
|
|
|
|
|
contained in the current element or object, when applicable.
|
|
|
|
|
One can access them with `org-element-contents' function.
|
|
|
|
|
|
|
|
|
|
The Org buffer has `org-data' as type and nil as properties.
|
|
|
|
|
`org-element-map' function can be used to find specific elements
|
|
|
|
|
or objects within the parse tree.
|
|
|
|
|
|
|
|
|
|
This function assumes that current major mode is `org-mode'."
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(org-skip-whitespace)
|
|
|
|
|
(org-element--parse-elements
|
|
|
|
|
(point-at-bol) (point-max)
|
|
|
|
|
;; Start in `first-section' mode so text before the first
|
|
|
|
|
;; headline belongs to a section.
|
|
|
|
|
'first-section nil granularity visible-only (list 'org-data nil))))
|
|
|
|
|
|
|
|
|
|
(defun org-element-parse-secondary-string (string restriction &optional parent)
|
|
|
|
|
"Recursively parse objects in STRING and return structure.
|
|
|
|
|
|
|
|
|
|
RESTRICTION is a symbol limiting the object types that will be
|
|
|
|
|
looked after.
|
|
|
|
|
|
|
|
|
|
Optional argument PARENT, when non-nil, is the element or object
|
|
|
|
|
containing the secondary string. It is used to set correctly
|
2015-03-21 04:43:45 -04:00
|
|
|
|
`:parent' property within the string.
|
|
|
|
|
|
|
|
|
|
If STRING is the empty string or nil, return nil."
|
|
|
|
|
(cond
|
|
|
|
|
((not string) nil)
|
|
|
|
|
((equal string "") nil)
|
|
|
|
|
(t (let ((local-variables (buffer-local-variables)))
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(dolist (v local-variables)
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(if (symbolp v) (makunbound v)
|
2015-11-05 11:47:38 -05:00
|
|
|
|
(set (make-local-variable (car v)) (cdr v)))))
|
2015-03-21 04:43:45 -04:00
|
|
|
|
(insert string)
|
|
|
|
|
(restore-buffer-modified-p nil)
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
(point-min) (point-max) nil restriction parent))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2012-09-30 16:13:47 -04:00
|
|
|
|
(defun org-element-map
|
2015-01-25 06:32:03 -05:00
|
|
|
|
(data types fun &optional info first-match no-recursion with-affiliated)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Map a function on selected elements or objects.
|
|
|
|
|
|
2013-02-16 18:49:13 -05:00
|
|
|
|
DATA is a parse tree, an element, an object, a string, or a list
|
|
|
|
|
of such constructs. TYPES is a symbol or list of symbols of
|
|
|
|
|
elements or objects types (see `org-element-all-elements' and
|
2013-01-20 03:43:58 -05:00
|
|
|
|
`org-element-all-objects' for a complete list of types). FUN is
|
|
|
|
|
the function called on the matching element or object. It has to
|
|
|
|
|
accept one argument: the element or object itself.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
When optional argument INFO is non-nil, it should be a plist
|
|
|
|
|
holding export options. In that case, parts of the parse tree
|
|
|
|
|
not exportable according to that property list will be skipped.
|
|
|
|
|
|
|
|
|
|
When optional argument FIRST-MATCH is non-nil, stop at the first
|
|
|
|
|
match for which FUN doesn't return nil, and return that value.
|
|
|
|
|
|
|
|
|
|
Optional argument NO-RECURSION is a symbol or a list of symbols
|
|
|
|
|
representing elements or objects types. `org-element-map' won't
|
|
|
|
|
enter any recursive element or object whose type belongs to that
|
|
|
|
|
list. Though, FUN can still be applied on them.
|
|
|
|
|
|
2013-01-30 08:42:24 -05:00
|
|
|
|
When optional argument WITH-AFFILIATED is non-nil, FUN will also
|
|
|
|
|
apply to matching objects within parsed affiliated keywords (see
|
|
|
|
|
`org-element-parsed-keywords').
|
|
|
|
|
|
2013-01-20 03:43:58 -05:00
|
|
|
|
Nil values returned from FUN do not appear in the results.
|
2012-09-30 16:13:47 -04:00
|
|
|
|
|
2013-01-20 03:43:58 -05:00
|
|
|
|
|
|
|
|
|
Examples:
|
2013-03-08 09:28:25 -05:00
|
|
|
|
---------
|
2013-01-20 03:43:58 -05:00
|
|
|
|
|
|
|
|
|
Assuming TREE is a variable containing an Org buffer parse tree,
|
|
|
|
|
the following example will return a flat list of all `src-block'
|
|
|
|
|
and `example-block' elements in it:
|
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
(org-element-map tree \\='(example-block src-block) #\\='identity)
|
2013-01-20 03:43:58 -05:00
|
|
|
|
|
|
|
|
|
The following snippet will find the first headline with a level
|
|
|
|
|
of 1 and a \"phone\" tag, and will return its beginning position:
|
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
(org-element-map tree \\='headline
|
|
|
|
|
(lambda (hl)
|
|
|
|
|
(and (= (org-element-property :level hl) 1)
|
|
|
|
|
(member \"phone\" (org-element-property :tags hl))
|
|
|
|
|
(org-element-property :begin hl)))
|
2013-01-20 03:43:58 -05:00
|
|
|
|
nil t)
|
|
|
|
|
|
2013-01-30 08:42:24 -05:00
|
|
|
|
The next example will return a flat list of all `plain-list' type
|
|
|
|
|
elements in TREE that are not a sub-list themselves:
|
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
(org-element-map tree \\='plain-list #\\='identity nil nil \\='plain-list)
|
2013-01-30 08:42:24 -05:00
|
|
|
|
|
|
|
|
|
Eventually, this example will return a flat list of all `bold'
|
|
|
|
|
type objects containing a `latex-snippet' type object, even
|
|
|
|
|
looking into captions:
|
2013-01-20 03:43:58 -05:00
|
|
|
|
|
2015-09-17 19:08:20 -04:00
|
|
|
|
(org-element-map tree \\='bold
|
|
|
|
|
(lambda (b)
|
|
|
|
|
(and (org-element-map b \\='latex-snippet #\\='identity nil t) b))
|
2013-01-30 08:42:24 -05:00
|
|
|
|
nil nil nil t)"
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Ensure TYPES and NO-RECURSION are a list, even of one element.
|
2015-01-25 06:32:03 -05:00
|
|
|
|
(let* ((types (if (listp types) types (list types)))
|
|
|
|
|
(no-recursion (if (listp no-recursion) no-recursion
|
|
|
|
|
(list no-recursion)))
|
|
|
|
|
;; Recursion depth is determined by --CATEGORY.
|
|
|
|
|
(--category
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(catch :--found
|
2015-01-25 06:32:03 -05:00
|
|
|
|
(let ((category 'greater-elements)
|
|
|
|
|
(all-objects (cons 'plain-text org-element-all-objects)))
|
|
|
|
|
(dolist (type types category)
|
|
|
|
|
(cond ((memq type all-objects)
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; If one object is found, the function has
|
|
|
|
|
;; to recurse into every object.
|
|
|
|
|
(throw :--found 'objects))
|
2015-01-25 06:32:03 -05:00
|
|
|
|
((not (memq type org-element-greater-elements))
|
|
|
|
|
;; If one regular element is found, the
|
|
|
|
|
;; function has to recurse, at least, into
|
|
|
|
|
;; every element it encounters.
|
|
|
|
|
(and (not (eq category 'elements))
|
|
|
|
|
(setq category 'elements))))))))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
--acc)
|
|
|
|
|
(letrec ((--walk-tree
|
|
|
|
|
(lambda (--data)
|
|
|
|
|
;; Recursively walk DATA. INFO, if non-nil, is a plist
|
|
|
|
|
;; holding contextual information.
|
|
|
|
|
(let ((--type (org-element-type --data)))
|
|
|
|
|
(cond
|
|
|
|
|
((not --data))
|
|
|
|
|
;; Ignored element in an export context.
|
|
|
|
|
((and info (memq --data (plist-get info :ignore-list))))
|
|
|
|
|
;; List of elements or objects.
|
|
|
|
|
((not --type) (mapc --walk-tree --data))
|
|
|
|
|
;; Unconditionally enter parse trees.
|
|
|
|
|
((eq --type 'org-data)
|
|
|
|
|
(mapc --walk-tree (org-element-contents --data)))
|
|
|
|
|
(t
|
|
|
|
|
;; Check if TYPE is matching among TYPES. If so,
|
|
|
|
|
;; apply FUN to --DATA and accumulate return value
|
|
|
|
|
;; into --ACC (or exit if FIRST-MATCH is non-nil).
|
|
|
|
|
(when (memq --type types)
|
|
|
|
|
(let ((result (funcall fun --data)))
|
|
|
|
|
(cond ((not result))
|
|
|
|
|
(first-match (throw :--map-first-match result))
|
|
|
|
|
(t (push result --acc)))))
|
|
|
|
|
;; If --DATA has a secondary string that can contain
|
|
|
|
|
;; objects with their type among TYPES, look inside.
|
|
|
|
|
(when (and (eq --category 'objects) (not (stringp --data)))
|
|
|
|
|
(dolist (p (cdr (assq --type
|
|
|
|
|
org-element-secondary-value-alist)))
|
|
|
|
|
(funcall --walk-tree (org-element-property p --data))))
|
|
|
|
|
;; If --DATA has any parsed affiliated keywords and
|
|
|
|
|
;; WITH-AFFILIATED is non-nil, look for objects in
|
|
|
|
|
;; them.
|
|
|
|
|
(when (and with-affiliated
|
|
|
|
|
(eq --category 'objects)
|
2016-10-25 07:13:26 -04:00
|
|
|
|
(eq (org-element-class --data) 'element))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(dolist (kwd-pair org-element--parsed-properties-alist)
|
|
|
|
|
(let ((kwd (car kwd-pair))
|
|
|
|
|
(value (org-element-property (cdr kwd-pair) --data)))
|
|
|
|
|
;; Pay attention to the type of parsed
|
|
|
|
|
;; keyword. In particular, preserve order for
|
|
|
|
|
;; multiple keywords.
|
|
|
|
|
(cond
|
|
|
|
|
((not value))
|
|
|
|
|
((member kwd org-element-dual-keywords)
|
|
|
|
|
(if (member kwd org-element-multiple-keywords)
|
|
|
|
|
(dolist (line (reverse value))
|
|
|
|
|
(funcall --walk-tree (cdr line))
|
|
|
|
|
(funcall --walk-tree (car line)))
|
|
|
|
|
(funcall --walk-tree (cdr value))
|
|
|
|
|
(funcall --walk-tree (car value))))
|
|
|
|
|
((member kwd org-element-multiple-keywords)
|
|
|
|
|
(mapc --walk-tree (reverse value)))
|
|
|
|
|
(t (funcall --walk-tree value))))))
|
|
|
|
|
;; Determine if a recursion into --DATA is possible.
|
|
|
|
|
(cond
|
|
|
|
|
;; --TYPE is explicitly removed from recursion.
|
|
|
|
|
((memq --type no-recursion))
|
|
|
|
|
;; --DATA has no contents.
|
|
|
|
|
((not (org-element-contents --data)))
|
|
|
|
|
;; Looking for greater elements but --DATA is
|
|
|
|
|
;; simply an element or an object.
|
|
|
|
|
((and (eq --category 'greater-elements)
|
|
|
|
|
(not (memq --type org-element-greater-elements))))
|
|
|
|
|
;; Looking for elements but --DATA is an object.
|
|
|
|
|
((and (eq --category 'elements)
|
2016-10-25 07:13:26 -04:00
|
|
|
|
(eq (org-element-class --data) 'object)))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; In any other case, map contents.
|
|
|
|
|
(t (mapc --walk-tree (org-element-contents --data))))))))))
|
|
|
|
|
(catch :--map-first-match
|
|
|
|
|
(funcall --walk-tree data)
|
|
|
|
|
;; Return value in a proper order.
|
|
|
|
|
(nreverse --acc)))))
|
2013-01-30 08:42:24 -05:00
|
|
|
|
(put 'org-element-map 'lisp-indent-function 2)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;; The following functions are internal parts of the parser.
|
|
|
|
|
;;
|
|
|
|
|
;; The first one, `org-element--parse-elements' acts at the element's
|
|
|
|
|
;; level.
|
|
|
|
|
;;
|
|
|
|
|
;; The second one, `org-element--parse-objects' applies on all objects
|
2014-09-13 16:34:15 -04:00
|
|
|
|
;; of a paragraph or a secondary string. It calls
|
|
|
|
|
;; `org-element--object-lex' to find the next object in the current
|
|
|
|
|
;; container.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2014-09-13 16:31:06 -04:00
|
|
|
|
(defsubst org-element--next-mode (type parentp)
|
2014-08-31 10:31:59 -04:00
|
|
|
|
"Return next special mode according to TYPE, or nil.
|
2014-09-13 16:31:06 -04:00
|
|
|
|
TYPE is a symbol representing the type of an element or object
|
|
|
|
|
containing next element if PARENTP is non-nil, or before it
|
2014-09-13 16:43:45 -04:00
|
|
|
|
otherwise. Modes can be either `first-section', `item',
|
|
|
|
|
`node-property', `planning', `property-drawer', `section',
|
|
|
|
|
`table-row' or nil."
|
2014-09-13 16:31:06 -04:00
|
|
|
|
(if parentp
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase type
|
|
|
|
|
(`headline 'section)
|
2015-10-16 17:20:57 -04:00
|
|
|
|
(`inlinetask 'planning)
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(`plain-list 'item)
|
|
|
|
|
(`property-drawer 'node-property)
|
|
|
|
|
(`section 'planning)
|
|
|
|
|
(`table 'table-row))
|
|
|
|
|
(pcase type
|
|
|
|
|
(`item 'item)
|
|
|
|
|
(`node-property 'node-property)
|
|
|
|
|
(`planning 'property-drawer)
|
|
|
|
|
(`table-row 'table-row))))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(defun org-element--parse-elements
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(beg end mode structure granularity visible-only acc)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse elements between BEG and END positions.
|
|
|
|
|
|
2014-09-13 16:31:06 -04:00
|
|
|
|
MODE prioritizes some elements over the others. It can be set to
|
|
|
|
|
`first-section', `section', `planning', `item', `node-property'
|
|
|
|
|
or `table-row'.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
When value is `item', STRUCTURE will be used as the current list
|
|
|
|
|
structure.
|
|
|
|
|
|
|
|
|
|
GRANULARITY determines the depth of the recursion. See
|
|
|
|
|
`org-element-parse-buffer' for more information.
|
|
|
|
|
|
|
|
|
|
When VISIBLE-ONLY is non-nil, don't parse contents of hidden
|
|
|
|
|
elements.
|
|
|
|
|
|
|
|
|
|
Elements are accumulated into ACC."
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char beg)
|
2013-05-08 03:56:26 -04:00
|
|
|
|
;; Visible only: skip invisible parts at the beginning of the
|
|
|
|
|
;; element.
|
|
|
|
|
(when (and visible-only (org-invisible-p2))
|
|
|
|
|
(goto-char (min (1+ (org-find-visible)) end)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; When parsing only headlines, skip any text before first one.
|
|
|
|
|
(when (and (eq granularity 'headline) (not (org-at-heading-p)))
|
|
|
|
|
(org-with-limited-levels (outline-next-heading)))
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(let (elements)
|
|
|
|
|
(while (< (point) end)
|
|
|
|
|
;; Find current element's type and parse it accordingly to
|
|
|
|
|
;; its category.
|
|
|
|
|
(let* ((element (org-element--current-element
|
|
|
|
|
end granularity mode structure))
|
|
|
|
|
(type (org-element-type element))
|
|
|
|
|
(cbeg (org-element-property :contents-begin element)))
|
|
|
|
|
(goto-char (org-element-property :end element))
|
|
|
|
|
;; Visible only: skip invisible parts between siblings.
|
|
|
|
|
(when (and visible-only (org-invisible-p2))
|
|
|
|
|
(goto-char (min (1+ (org-find-visible)) end)))
|
|
|
|
|
;; Fill ELEMENT contents by side-effect.
|
|
|
|
|
(cond
|
|
|
|
|
;; If element has no contents, don't modify it.
|
|
|
|
|
((not cbeg))
|
|
|
|
|
;; Greater element: parse it between `contents-begin' and
|
|
|
|
|
;; `contents-end'. Make sure GRANULARITY allows the
|
|
|
|
|
;; recursion, or ELEMENT is a headline, in which case going
|
|
|
|
|
;; inside is mandatory, in order to get sub-level headings.
|
|
|
|
|
((and (memq type org-element-greater-elements)
|
|
|
|
|
(or (memq granularity '(element object nil))
|
|
|
|
|
(and (eq granularity 'greater-element)
|
|
|
|
|
(eq type 'section))
|
|
|
|
|
(eq type 'headline)))
|
|
|
|
|
(org-element--parse-elements
|
|
|
|
|
cbeg (org-element-property :contents-end element)
|
|
|
|
|
;; Possibly switch to a special mode.
|
|
|
|
|
(org-element--next-mode type t)
|
|
|
|
|
(and (memq type '(item plain-list))
|
|
|
|
|
(org-element-property :structure element))
|
|
|
|
|
granularity visible-only element))
|
|
|
|
|
;; ELEMENT has contents. Parse objects inside, if
|
|
|
|
|
;; GRANULARITY allows it.
|
|
|
|
|
((memq granularity '(object nil))
|
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
cbeg (org-element-property :contents-end element) element
|
|
|
|
|
(org-element-restriction type))))
|
|
|
|
|
(push (org-element-put-property element :parent acc) elements)
|
|
|
|
|
;; Update mode.
|
|
|
|
|
(setq mode (org-element--next-mode type nil))))
|
|
|
|
|
;; Return result.
|
|
|
|
|
(apply #'org-element-set-contents acc (nreverse elements)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(defun org-element--object-lex (restriction)
|
|
|
|
|
"Return next object in current buffer or nil.
|
|
|
|
|
RESTRICTION is a list of object types, as symbols, that should be
|
|
|
|
|
looked after. This function assumes that the buffer is narrowed
|
|
|
|
|
to an appropriate container (e.g., a paragraph)."
|
|
|
|
|
(if (memq 'table-cell restriction) (org-element-table-cell-parser)
|
2016-10-26 18:41:19 -04:00
|
|
|
|
(let* ((start (point))
|
|
|
|
|
(limit
|
2017-04-15 11:27:01 -04:00
|
|
|
|
;; Object regexp sometimes needs to have a peek at
|
|
|
|
|
;; a character ahead. Therefore, when there is a hard
|
|
|
|
|
;; limit, make it one more than the true beginning of the
|
|
|
|
|
;; radio target.
|
2016-10-26 18:41:19 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(cond ((not org-target-link-regexp) nil)
|
2016-10-26 18:47:11 -04:00
|
|
|
|
((not (memq 'link restriction)) nil)
|
2016-10-26 18:41:19 -04:00
|
|
|
|
((progn
|
|
|
|
|
(unless (bolp) (forward-char -1))
|
|
|
|
|
(not (re-search-forward org-target-link-regexp nil t)))
|
|
|
|
|
nil)
|
|
|
|
|
;; Since we moved backward, we do not want to
|
|
|
|
|
;; match again an hypothetical 1-character long
|
|
|
|
|
;; radio link before us. Realizing that this can
|
|
|
|
|
;; only happen if such a radio link starts at
|
|
|
|
|
;; beginning of line, we prevent this here.
|
|
|
|
|
((and (= start (1+ (line-beginning-position)))
|
|
|
|
|
(= start (match-end 1)))
|
|
|
|
|
(and (re-search-forward org-target-link-regexp nil t)
|
2017-04-15 11:27:01 -04:00
|
|
|
|
(1+ (match-beginning 1))))
|
|
|
|
|
(t (1+ (match-beginning 1))))))
|
2016-10-26 18:41:19 -04:00
|
|
|
|
found)
|
|
|
|
|
(save-excursion
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(while (and (not found)
|
2016-10-26 18:47:11 -04:00
|
|
|
|
(re-search-forward org-element--object-regexp limit 'move))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(goto-char (match-beginning 0))
|
|
|
|
|
(let ((result (match-string 0)))
|
|
|
|
|
(setq found
|
|
|
|
|
(cond
|
2016-10-25 12:28:37 -04:00
|
|
|
|
((string-prefix-p "call_" result t)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(and (memq 'inline-babel-call restriction)
|
|
|
|
|
(org-element-inline-babel-call-parser)))
|
2016-10-25 12:28:37 -04:00
|
|
|
|
((string-prefix-p "src_" result t)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(and (memq 'inline-src-block restriction)
|
|
|
|
|
(org-element-inline-src-block-parser)))
|
|
|
|
|
(t
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase (char-after)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(?^ (and (memq 'superscript restriction)
|
|
|
|
|
(org-element-superscript-parser)))
|
|
|
|
|
(?_ (or (and (memq 'subscript restriction)
|
|
|
|
|
(org-element-subscript-parser))
|
|
|
|
|
(and (memq 'underline restriction)
|
|
|
|
|
(org-element-underline-parser))))
|
|
|
|
|
(?* (and (memq 'bold restriction)
|
|
|
|
|
(org-element-bold-parser)))
|
|
|
|
|
(?/ (and (memq 'italic restriction)
|
|
|
|
|
(org-element-italic-parser)))
|
|
|
|
|
(?~ (and (memq 'code restriction)
|
|
|
|
|
(org-element-code-parser)))
|
|
|
|
|
(?= (and (memq 'verbatim restriction)
|
|
|
|
|
(org-element-verbatim-parser)))
|
|
|
|
|
(?+ (and (memq 'strike-through restriction)
|
|
|
|
|
(org-element-strike-through-parser)))
|
|
|
|
|
(?@ (and (memq 'export-snippet restriction)
|
|
|
|
|
(org-element-export-snippet-parser)))
|
|
|
|
|
(?{ (and (memq 'macro restriction)
|
|
|
|
|
(org-element-macro-parser)))
|
|
|
|
|
(?$ (and (memq 'latex-fragment restriction)
|
|
|
|
|
(org-element-latex-fragment-parser)))
|
|
|
|
|
(?<
|
|
|
|
|
(if (eq (aref result 1) ?<)
|
|
|
|
|
(or (and (memq 'radio-target restriction)
|
|
|
|
|
(org-element-radio-target-parser))
|
|
|
|
|
(and (memq 'target restriction)
|
|
|
|
|
(org-element-target-parser)))
|
|
|
|
|
(or (and (memq 'timestamp restriction)
|
|
|
|
|
(org-element-timestamp-parser))
|
2016-12-17 05:35:50 -05:00
|
|
|
|
(and (memq 'link restriction)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(org-element-link-parser)))))
|
2014-07-06 17:15:44 -04:00
|
|
|
|
(?\\
|
|
|
|
|
(if (eq (aref result 1) ?\\)
|
|
|
|
|
(and (memq 'line-break restriction)
|
|
|
|
|
(org-element-line-break-parser))
|
|
|
|
|
(or (and (memq 'entity restriction)
|
|
|
|
|
(org-element-entity-parser))
|
|
|
|
|
(and (memq 'latex-fragment restriction)
|
|
|
|
|
(org-element-latex-fragment-parser)))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(?\[
|
|
|
|
|
(if (eq (aref result 1) ?\[)
|
|
|
|
|
(and (memq 'link restriction)
|
|
|
|
|
(org-element-link-parser))
|
|
|
|
|
(or (and (memq 'footnote-reference restriction)
|
|
|
|
|
(org-element-footnote-reference-parser))
|
|
|
|
|
(and (memq 'timestamp restriction)
|
|
|
|
|
(org-element-timestamp-parser))
|
|
|
|
|
(and (memq 'statistics-cookie restriction)
|
|
|
|
|
(org-element-statistics-cookie-parser)))))
|
|
|
|
|
;; This is probably a plain link.
|
2016-12-17 05:35:50 -05:00
|
|
|
|
(_ (and (memq 'link restriction)
|
2016-04-06 05:08:53 -04:00
|
|
|
|
(org-element-link-parser)))))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(or (eobp) (forward-char))))
|
|
|
|
|
(cond (found)
|
2017-04-15 11:27:01 -04:00
|
|
|
|
(limit (forward-char -1)
|
|
|
|
|
(org-element-link-parser)) ;radio link
|
2016-10-26 18:47:11 -04:00
|
|
|
|
(t nil))))))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(defun org-element--parse-objects (beg end acc restriction &optional parent)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Parse objects between BEG and END and return recursive structure.
|
|
|
|
|
|
2016-01-21 12:43:20 -05:00
|
|
|
|
Objects are accumulated in ACC. RESTRICTION is a list of object
|
|
|
|
|
successors which are allowed in the current object.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
2016-01-21 12:43:20 -05:00
|
|
|
|
ACC becomes the parent for all parsed objects. However, if ACC
|
|
|
|
|
is nil (i.e., a secondary string is being parsed) and optional
|
|
|
|
|
argument PARENT is non-nil, use it as the parent for all objects.
|
|
|
|
|
Eventually, if both ACC and PARENT are nil, the common parent is
|
|
|
|
|
the list of objects itself."
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(save-excursion
|
|
|
|
|
(save-restriction
|
|
|
|
|
(narrow-to-region beg end)
|
|
|
|
|
(goto-char (point-min))
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(let (next-object contents)
|
org-element: Fix parsing error in `org-element-context'
* lisp/org-element.el (org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-plain-link-successor, org-element-macro-successor,
org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor): Remove LIMIT argument.
(org-element--parse-objects, org-element--get-next-object-candidates):
Apply signature change to successors.
(org-element-context): Narrow buffer around object containers so
parsing of objects when using this function is done under the same
restrictions as in buffer parsing.
* testing/lisp/test-org-element.el: Add test.
2013-08-30 07:29:51 -04:00
|
|
|
|
(while (and (not (eobp))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(setq next-object (org-element--object-lex restriction)))
|
2016-10-26 18:48:33 -04:00
|
|
|
|
;; Text before any object.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((obj-beg (org-element-property :begin next-object)))
|
|
|
|
|
(unless (= (point) obj-beg)
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(let ((text (buffer-substring-no-properties (point) obj-beg)))
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(push (if acc (org-element-put-property text :parent acc) text)
|
|
|
|
|
contents))))
|
|
|
|
|
;; Object...
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((obj-end (org-element-property :end next-object))
|
|
|
|
|
(cont-beg (org-element-property :contents-begin next-object)))
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(when acc (org-element-put-property next-object :parent acc))
|
|
|
|
|
(push (if cont-beg
|
|
|
|
|
;; Fill contents of NEXT-OBJECT if possible.
|
|
|
|
|
(org-element--parse-objects
|
|
|
|
|
cont-beg
|
|
|
|
|
(org-element-property :contents-end next-object)
|
|
|
|
|
next-object
|
|
|
|
|
(org-element-restriction next-object))
|
|
|
|
|
next-object)
|
|
|
|
|
contents)
|
|
|
|
|
(goto-char obj-end)))
|
2016-10-26 18:48:33 -04:00
|
|
|
|
;; Text after last object.
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(unless (eobp)
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(let ((text (buffer-substring-no-properties (point) end)))
|
2016-01-21 12:43:20 -05:00
|
|
|
|
(push (if acc (org-element-put-property text :parent acc) text)
|
|
|
|
|
contents)))
|
|
|
|
|
;; Result. Set appropriate parent.
|
|
|
|
|
(if acc (apply #'org-element-set-contents acc (nreverse contents))
|
|
|
|
|
(let* ((contents (nreverse contents))
|
|
|
|
|
(parent (or parent contents)))
|
|
|
|
|
(dolist (datum contents contents)
|
|
|
|
|
(org-element-put-property datum :parent parent))))))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;; Towards A Bijective Process
|
|
|
|
|
;;
|
|
|
|
|
;; The parse tree obtained with `org-element-parse-buffer' is really
|
|
|
|
|
;; a snapshot of the corresponding Org buffer. Therefore, it can be
|
|
|
|
|
;; interpreted and expanded into a string with canonical Org syntax.
|
|
|
|
|
;; Hence `org-element-interpret-data'.
|
|
|
|
|
;;
|
|
|
|
|
;; The function relies internally on
|
|
|
|
|
;; `org-element--interpret-affiliated-keywords'.
|
|
|
|
|
|
2012-08-20 04:16:21 -04:00
|
|
|
|
;;;###autoload
|
2015-02-09 06:02:16 -05:00
|
|
|
|
(defun org-element-interpret-data (data)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"Interpret DATA as Org syntax.
|
|
|
|
|
DATA is a parse tree, an element, an object or a secondary string
|
2015-02-09 06:02:16 -05:00
|
|
|
|
to interpret. Return Org syntax as a string."
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(letrec ((fun
|
2016-10-07 18:47:43 -04:00
|
|
|
|
(lambda (data parent)
|
|
|
|
|
(let* ((type (org-element-type data))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Find interpreter for current object or
|
|
|
|
|
;; element. If it doesn't exist (e.g. this is
|
|
|
|
|
;; a pseudo object or element), return contents,
|
|
|
|
|
;; if any.
|
|
|
|
|
(interpret
|
|
|
|
|
(let ((fun (intern
|
|
|
|
|
(format "org-element-%s-interpreter" type))))
|
|
|
|
|
(if (fboundp fun) fun (lambda (_ contents) contents))))
|
|
|
|
|
(results
|
|
|
|
|
(cond
|
|
|
|
|
;; Secondary string.
|
|
|
|
|
((not type)
|
|
|
|
|
(mapconcat (lambda (obj) (funcall fun obj parent))
|
2016-10-07 18:47:43 -04:00
|
|
|
|
data
|
|
|
|
|
""))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Full Org document.
|
|
|
|
|
((eq type 'org-data)
|
|
|
|
|
(mapconcat (lambda (obj) (funcall fun obj parent))
|
2016-10-07 18:47:43 -04:00
|
|
|
|
(org-element-contents data)
|
|
|
|
|
""))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Plain text: return it.
|
2016-10-07 18:47:43 -04:00
|
|
|
|
((stringp data) data)
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Element or object without contents.
|
2016-10-07 18:47:43 -04:00
|
|
|
|
((not (org-element-contents data))
|
|
|
|
|
(funcall interpret data nil))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Element or object with contents.
|
|
|
|
|
(t
|
|
|
|
|
(funcall
|
|
|
|
|
interpret
|
2016-10-07 18:47:43 -04:00
|
|
|
|
data
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Recursively interpret contents.
|
|
|
|
|
(mapconcat
|
2016-10-07 18:47:43 -04:00
|
|
|
|
(lambda (datum) (funcall fun datum data))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(org-element-contents
|
|
|
|
|
(if (not (memq type '(paragraph verse-block)))
|
2016-10-07 18:47:43 -04:00
|
|
|
|
data
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Fix indentation of elements containing
|
|
|
|
|
;; objects. We ignore `table-row'
|
|
|
|
|
;; elements as they are one line long
|
|
|
|
|
;; anyway.
|
|
|
|
|
(org-element-normalize-contents
|
2016-10-07 18:47:43 -04:00
|
|
|
|
data
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; When normalizing first paragraph of
|
|
|
|
|
;; an item or a footnote-definition,
|
|
|
|
|
;; ignore first line's indentation.
|
|
|
|
|
(and (eq type 'paragraph)
|
|
|
|
|
(memq (org-element-type parent)
|
2016-10-07 18:47:43 -04:00
|
|
|
|
'(footnote-definition item))
|
2017-11-09 16:47:35 -05:00
|
|
|
|
(eq data (car (org-element-contents parent)))
|
|
|
|
|
(eq (org-element-property :pre-blank parent)
|
|
|
|
|
0)))))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
""))))))
|
|
|
|
|
(if (memq type '(org-data plain-text nil)) results
|
|
|
|
|
;; Build white spaces. If no `:post-blank' property
|
|
|
|
|
;; is specified, assume its value is 0.
|
2016-10-25 12:19:05 -04:00
|
|
|
|
(let ((blank (or (org-element-property :post-blank data) 0)))
|
|
|
|
|
(if (eq (org-element-class data parent) 'object)
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(concat results (make-string blank ?\s))
|
2016-10-25 07:13:26 -04:00
|
|
|
|
(concat (org-element--interpret-affiliated-keywords data)
|
|
|
|
|
(org-element-normalize-string results)
|
|
|
|
|
(make-string blank ?\n)))))))))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(funcall fun data nil)))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
(defun org-element--interpret-affiliated-keywords (element)
|
|
|
|
|
"Return ELEMENT's affiliated keywords as Org syntax.
|
|
|
|
|
If there is no affiliated keyword, return the empty string."
|
|
|
|
|
(let ((keyword-to-org
|
|
|
|
|
(function
|
|
|
|
|
(lambda (key value)
|
|
|
|
|
(let (dual)
|
|
|
|
|
(when (member key org-element-dual-keywords)
|
|
|
|
|
(setq dual (cdr value) value (car value)))
|
2018-01-28 08:06:33 -05:00
|
|
|
|
(concat "#+" (downcase key)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(and dual
|
|
|
|
|
(format "[%s]" (org-element-interpret-data dual)))
|
|
|
|
|
": "
|
|
|
|
|
(if (member key org-element-parsed-keywords)
|
|
|
|
|
(org-element-interpret-data value)
|
|
|
|
|
value)
|
|
|
|
|
"\n"))))))
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (prop)
|
|
|
|
|
(let ((value (org-element-property prop element))
|
|
|
|
|
(keyword (upcase (substring (symbol-name prop) 1))))
|
|
|
|
|
(when value
|
|
|
|
|
(if (or (member keyword org-element-multiple-keywords)
|
|
|
|
|
;; All attribute keywords can have multiple lines.
|
|
|
|
|
(string-match "^ATTR_" keyword))
|
|
|
|
|
(mapconcat (lambda (line) (funcall keyword-to-org keyword line))
|
org-element: Optimize affiliated keywords parsing
* lisp/org-element.el (org-element-center-block-parser,
org-element-drawer-parser, org-element-dynamic-block-parser,
org-element-footnote-definition-parser,
org-element-plain-list-parser, org-element-quote-block-parser,
org-element-special-block-parser, org-element-babel-call-parser,
org-element-comment-parser, org-element-comment-block-parser,
org-element-example-block-parser, org-element-export-block-parser,
org-element-fixed-width-parser, org-element-horizontal-rule-parser,
org-element-keyword-parser, org-element-latex-environment-parser,
org-element-paragraph-parser, org-element-property-drawer-parser,
org-element-src-block-parser, org-element-table-parser,
org-element-verse-block-parser): Change signature. Now use an
additional argument: affiliated.
(org-element--current-element): Skip affiliated keywords and pass them
as an argument to parsers. It prevents to walk through these
keywords twice: the first time to get to the first line of the
element, and a second time to collect the affiliated keywords.
* contrib/lisp/org-export.el (org-export-get-caption): Update function
since multiple affiliated keywords are now reversed.
* testing/lisp/test-org-element.el: Update tests.
2012-09-20 13:10:39 -04:00
|
|
|
|
(reverse value)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"")
|
|
|
|
|
(funcall keyword-to-org keyword value)))))
|
|
|
|
|
;; List all ELEMENT's properties matching an attribute line or an
|
|
|
|
|
;; affiliated keyword, but ignore translated keywords since they
|
|
|
|
|
;; cannot belong to the property list.
|
2016-07-25 10:34:48 -04:00
|
|
|
|
(cl-loop for prop in (nth 1 element) by 'cddr
|
|
|
|
|
when (let ((keyword (upcase (substring (symbol-name prop) 1))))
|
|
|
|
|
(or (string-match "^ATTR_" keyword)
|
|
|
|
|
(and
|
|
|
|
|
(member keyword org-element-affiliated-keywords)
|
|
|
|
|
(not (assoc keyword
|
|
|
|
|
org-element-keyword-translation-alist)))))
|
|
|
|
|
collect prop)
|
2012-07-28 01:02:21 -04:00
|
|
|
|
"")))
|
|
|
|
|
|
|
|
|
|
;; Because interpretation of the parse tree must return the same
|
|
|
|
|
;; number of blank lines between elements and the same number of white
|
|
|
|
|
;; space after objects, some special care must be given to white
|
|
|
|
|
;; spaces.
|
|
|
|
|
;;
|
|
|
|
|
;; The first function, `org-element-normalize-string', ensures any
|
|
|
|
|
;; string different from the empty string will end with a single
|
|
|
|
|
;; newline character.
|
|
|
|
|
;;
|
|
|
|
|
;; The second function, `org-element-normalize-contents', removes
|
|
|
|
|
;; global indentation from the contents of the current element.
|
|
|
|
|
|
|
|
|
|
(defun org-element-normalize-string (s)
|
|
|
|
|
"Ensure string S ends with a single newline character.
|
|
|
|
|
|
|
|
|
|
If S isn't a string return it unchanged. If S is the empty
|
|
|
|
|
string, return it. Otherwise, return a new string with a single
|
|
|
|
|
newline character at its end."
|
|
|
|
|
(cond
|
|
|
|
|
((not (stringp s)) s)
|
|
|
|
|
((string= "" s) "")
|
|
|
|
|
(t (and (string-match "\\(\n[ \t]*\\)*\\'" s)
|
|
|
|
|
(replace-match "\n" nil nil s)))))
|
|
|
|
|
|
|
|
|
|
(defun org-element-normalize-contents (element &optional ignore-first)
|
|
|
|
|
"Normalize plain text in ELEMENT's contents.
|
|
|
|
|
|
|
|
|
|
ELEMENT must only contain plain text and objects.
|
|
|
|
|
|
|
|
|
|
If optional argument IGNORE-FIRST is non-nil, ignore first line's
|
|
|
|
|
indentation to compute maximal common indentation.
|
|
|
|
|
|
|
|
|
|
Return the normalized element that is element with global
|
2016-01-26 16:53:55 -05:00
|
|
|
|
indentation removed from its contents."
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(letrec ((find-min-ind
|
|
|
|
|
;; Return minimal common indentation within BLOB. This is
|
|
|
|
|
;; done by walking recursively BLOB and updating MIN-IND
|
|
|
|
|
;; along the way. FIRST-FLAG is non-nil when the next
|
|
|
|
|
;; object is expected to be a string that doesn't start
|
|
|
|
|
;; with a newline character. It happens for strings at
|
|
|
|
|
;; the beginnings of the contents or right after a line
|
|
|
|
|
;; break.
|
|
|
|
|
(lambda (blob first-flag min-ind)
|
2017-01-12 08:33:17 -05:00
|
|
|
|
(dolist (datum (org-element-contents blob) min-ind)
|
|
|
|
|
(when first-flag
|
|
|
|
|
(setq first-flag nil)
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(cond
|
2017-01-12 08:33:17 -05:00
|
|
|
|
;; Objects cannot start with spaces: in this
|
|
|
|
|
;; case, indentation is 0.
|
|
|
|
|
((not (stringp datum)) (throw :zero 0))
|
|
|
|
|
((not (string-match
|
|
|
|
|
"\\`\\([ \t]+\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum))
|
|
|
|
|
(throw :zero 0))
|
|
|
|
|
((equal (match-string 2 datum) "\n")
|
|
|
|
|
(put-text-property
|
|
|
|
|
(match-beginning 1) (match-end 1) 'org-ind 'empty datum))
|
|
|
|
|
(t
|
|
|
|
|
(let ((i (string-width (match-string 1 datum))))
|
|
|
|
|
(put-text-property
|
|
|
|
|
(match-beginning 1) (match-end 1) 'org-ind i datum)
|
|
|
|
|
(setq min-ind (min i min-ind))))))
|
|
|
|
|
(cond
|
|
|
|
|
((stringp datum)
|
|
|
|
|
(let ((s 0))
|
|
|
|
|
(while (string-match
|
|
|
|
|
"\n\\([ \t]*\\)\\([^ \t\n]\\|\n\\|\\'\\)" datum s)
|
|
|
|
|
(setq s (match-end 1))
|
|
|
|
|
(cond
|
|
|
|
|
((equal (match-string 1 datum) "")
|
|
|
|
|
(unless (member (match-string 2 datum) '("" "\n"))
|
|
|
|
|
(throw :zero 0)))
|
|
|
|
|
((equal (match-string 2 datum) "\n")
|
|
|
|
|
(put-text-property (match-beginning 1) (match-end 1)
|
|
|
|
|
'org-ind 'empty datum))
|
|
|
|
|
(t
|
|
|
|
|
(let ((i (string-width (match-string 1 datum))))
|
|
|
|
|
(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)
|
|
|
|
|
(setq first-flag t))
|
|
|
|
|
((memq (org-element-type datum) org-element-recursive-objects)
|
|
|
|
|
(setq min-ind
|
|
|
|
|
(funcall find-min-ind datum first-flag min-ind)))))))
|
|
|
|
|
(min-ind
|
|
|
|
|
(catch :zero
|
|
|
|
|
(funcall find-min-ind
|
|
|
|
|
element (not ignore-first) most-positive-fixnum))))
|
2014-02-07 14:00:45 -05:00
|
|
|
|
(if (or (zerop min-ind) (= min-ind most-positive-fixnum)) element
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;; Build ELEMENT back, replacing each string with the same
|
|
|
|
|
;; string minus common indentation.
|
2015-07-31 16:02:15 -04:00
|
|
|
|
(letrec ((build
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(lambda (datum)
|
2015-07-31 16:02:15 -04:00
|
|
|
|
;; Return DATUM with all its strings indentation
|
|
|
|
|
;; shortened from MIN-IND white spaces.
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(setcdr
|
|
|
|
|
(cdr datum)
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (object)
|
|
|
|
|
(cond
|
|
|
|
|
((stringp object)
|
|
|
|
|
(with-temp-buffer
|
|
|
|
|
(insert object)
|
|
|
|
|
(let ((s (point-min)))
|
|
|
|
|
(while (setq s (text-property-not-all
|
|
|
|
|
s (point-max) 'org-ind nil))
|
|
|
|
|
(goto-char s)
|
|
|
|
|
(let ((i (get-text-property s 'org-ind)))
|
|
|
|
|
(delete-region s (progn
|
|
|
|
|
(skip-chars-forward " \t")
|
|
|
|
|
(point)))
|
|
|
|
|
(when (integerp i) (indent-to (- i min-ind))))))
|
|
|
|
|
(buffer-string)))
|
|
|
|
|
((memq (org-element-type object)
|
|
|
|
|
org-element-recursive-objects)
|
|
|
|
|
(funcall build object))
|
|
|
|
|
(t object)))
|
|
|
|
|
(org-element-contents datum)))
|
2015-07-31 16:02:15 -04:00
|
|
|
|
datum)))
|
2016-01-26 16:53:55 -05:00
|
|
|
|
(funcall build element)))))
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
;;; Cache
|
|
|
|
|
;;
|
|
|
|
|
;; Implement a caching mechanism for `org-element-at-point' and
|
|
|
|
|
;; `org-element-context', which see.
|
|
|
|
|
;;
|
|
|
|
|
;; A single public function is provided: `org-element-cache-reset'.
|
|
|
|
|
;;
|
|
|
|
|
;; Cache is enabled by default, but can be disabled globally with
|
|
|
|
|
;; `org-element-use-cache'. `org-element-cache-sync-idle-time',
|
|
|
|
|
;; org-element-cache-sync-duration' and `org-element-cache-sync-break'
|
2018-03-04 20:09:52 -05:00
|
|
|
|
;; can be tweaked to control caching behavior.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Internally, parsed elements are stored in an AVL tree,
|
|
|
|
|
;; `org-element--cache'. This tree is updated lazily: whenever
|
|
|
|
|
;; a change happens to the buffer, a synchronization request is
|
|
|
|
|
;; registered in `org-element--cache-sync-requests' (see
|
|
|
|
|
;; `org-element--cache-submit-request'). During idle time, requests
|
|
|
|
|
;; are processed by `org-element--cache-sync'. Synchronization also
|
|
|
|
|
;; happens when an element is required from the cache. In this case,
|
|
|
|
|
;; the process stops as soon as the needed element is up-to-date.
|
|
|
|
|
;;
|
|
|
|
|
;; A synchronization request can only apply on a synchronized part of
|
|
|
|
|
;; the cache. Therefore, the cache is updated at least to the
|
|
|
|
|
;; location where the new request applies. Thus, requests are ordered
|
|
|
|
|
;; from left to right and all elements starting before the first
|
|
|
|
|
;; request are correct. This property is used by functions like
|
|
|
|
|
;; `org-element--cache-find' to retrieve elements in the part of the
|
|
|
|
|
;; cache that can be trusted.
|
|
|
|
|
;;
|
|
|
|
|
;; A request applies to every element, starting from its original
|
|
|
|
|
;; location (or key, see below). When a request is processed, it
|
|
|
|
|
;; moves forward and may collide the next one. In this case, both
|
|
|
|
|
;; requests are merged into a new one that starts from that element.
|
|
|
|
|
;; As a consequence, the whole synchronization complexity does not
|
|
|
|
|
;; depend on the number of pending requests, but on the number of
|
|
|
|
|
;; elements the very first request will be applied on.
|
|
|
|
|
;;
|
|
|
|
|
;; Elements cannot be accessed through their beginning position, which
|
|
|
|
|
;; may or may not be up-to-date. Instead, each element in the tree is
|
|
|
|
|
;; associated to a key, obtained with `org-element--cache-key'. This
|
|
|
|
|
;; mechanism is robust enough to preserve total order among elements
|
|
|
|
|
;; even when the tree is only partially synchronized.
|
|
|
|
|
|
|
|
|
|
|
2017-01-21 04:40:39 -05:00
|
|
|
|
(defvar org-element-use-cache nil
|
|
|
|
|
"Non-nil when Org parser should cache its results.
|
|
|
|
|
|
|
|
|
|
WARNING: for the time being, using cache sometimes triggers
|
|
|
|
|
freezes. Therefore, it is disabled by default. Activate it if
|
|
|
|
|
you want to help debugging the issue.")
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-06-18 07:22:58 -04:00
|
|
|
|
(defvar org-element-cache-sync-idle-time 0.6
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
"Length, in seconds, of idle time before syncing cache.")
|
|
|
|
|
|
|
|
|
|
(defvar org-element-cache-sync-duration (seconds-to-time 0.04)
|
|
|
|
|
"Maximum duration, as a time value, for a cache synchronization.
|
|
|
|
|
If the synchronization is not over after this delay, the process
|
|
|
|
|
pauses and resumes after `org-element-cache-sync-break'
|
|
|
|
|
seconds.")
|
|
|
|
|
|
2014-06-18 07:22:58 -04:00
|
|
|
|
(defvar org-element-cache-sync-break (seconds-to-time 0.3)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
"Duration, as a time value, of the pause between synchronizations.
|
|
|
|
|
See `org-element-cache-sync-duration' for more information.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Data Structure
|
|
|
|
|
|
|
|
|
|
(defvar org-element--cache nil
|
|
|
|
|
"AVL tree used to cache elements.
|
|
|
|
|
Each node of the tree contains an element. Comparison is done
|
|
|
|
|
with `org-element--cache-compare'. This cache is used in
|
|
|
|
|
`org-element-at-point'.")
|
|
|
|
|
|
|
|
|
|
(defvar org-element--cache-sync-requests nil
|
|
|
|
|
"List of pending synchronization requests.
|
|
|
|
|
|
|
|
|
|
A request is a vector with the following pattern:
|
|
|
|
|
|
2015-06-14 08:52:04 -04:00
|
|
|
|
\[NEXT BEG END OFFSET PARENT PHASE]
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-06-17 17:07:16 -04:00
|
|
|
|
Processing a synchronization request consists of three phases:
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
0. Delete modified elements,
|
|
|
|
|
1. Fill missing area in cache,
|
|
|
|
|
2. Shift positions and re-parent elements after the changes.
|
|
|
|
|
|
|
|
|
|
During phase 0, NEXT is the key of the first element to be
|
2014-06-17 17:07:16 -04:00
|
|
|
|
removed, BEG and END is buffer position delimiting the
|
2014-07-03 16:10:47 -04:00
|
|
|
|
modifications. Elements starting between them (inclusive) are
|
2015-06-14 08:52:04 -04:00
|
|
|
|
removed. So are elements whose parent is removed. PARENT, when
|
2014-07-03 16:10:47 -04:00
|
|
|
|
non-nil, is the parent of the first element to be removed.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
During phase 1, NEXT is the key of the next known element in
|
2014-06-30 11:53:50 -04:00
|
|
|
|
cache and BEG its beginning position. Parse buffer between that
|
|
|
|
|
element and the one before it in order to determine the parent of
|
|
|
|
|
the next element. Set PARENT to the element containing NEXT.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
During phase 2, NEXT is the key of the next element to shift in
|
|
|
|
|
the parse tree. All elements starting from this one have their
|
|
|
|
|
properties relatives to buffer positions shifted by integer
|
|
|
|
|
OFFSET and, if they belong to element PARENT, are adopted by it.
|
|
|
|
|
|
|
|
|
|
PHASE specifies the phase number, as an integer.")
|
|
|
|
|
|
|
|
|
|
(defvar org-element--cache-sync-timer nil
|
|
|
|
|
"Timer used for cache synchronization.")
|
|
|
|
|
|
|
|
|
|
(defvar org-element--cache-sync-keys nil
|
|
|
|
|
"Hash table used to store keys during synchronization.
|
|
|
|
|
See `org-element--cache-key' for more information.")
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-key (element)
|
|
|
|
|
"Return a unique key for ELEMENT in cache tree.
|
|
|
|
|
|
|
|
|
|
Keys are used to keep a total order among elements in the cache.
|
|
|
|
|
Comparison is done with `org-element--cache-key-less-p'.
|
|
|
|
|
|
|
|
|
|
When no synchronization is taking place, a key is simply the
|
|
|
|
|
beginning position of the element, or that position plus one in
|
|
|
|
|
the case of an first item (respectively row) in
|
|
|
|
|
a list (respectively a table).
|
|
|
|
|
|
|
|
|
|
During a synchronization, the key is the one the element had when
|
|
|
|
|
the cache was synchronized for the last time. Elements added to
|
|
|
|
|
cache during the synchronization get a new key generated with
|
|
|
|
|
`org-element--cache-generate-key'.
|
|
|
|
|
|
|
|
|
|
Such keys are stored in `org-element--cache-sync-keys'. The hash
|
|
|
|
|
table is cleared once the synchronization is complete."
|
|
|
|
|
(or (gethash element org-element--cache-sync-keys)
|
|
|
|
|
(let* ((begin (org-element-property :begin element))
|
|
|
|
|
;; Increase beginning position of items (respectively
|
|
|
|
|
;; table rows) by one, so the first item can get
|
|
|
|
|
;; a different key from its parent list (respectively
|
|
|
|
|
;; table).
|
|
|
|
|
(key (if (memq (org-element-type element) '(item table-row))
|
|
|
|
|
(1+ begin)
|
|
|
|
|
begin)))
|
|
|
|
|
(if org-element--cache-sync-requests
|
|
|
|
|
(puthash element key org-element--cache-sync-keys)
|
|
|
|
|
key))))
|
|
|
|
|
|
|
|
|
|
(defun org-element--cache-generate-key (lower upper)
|
|
|
|
|
"Generate a key between LOWER and UPPER.
|
|
|
|
|
|
|
|
|
|
LOWER and UPPER are integers or lists, possibly empty.
|
|
|
|
|
|
|
|
|
|
If LOWER and UPPER are equals, return LOWER. Otherwise, return
|
|
|
|
|
a unique key, as an integer or a list of integers, according to
|
|
|
|
|
the following rules:
|
|
|
|
|
|
|
|
|
|
- LOWER and UPPER are compared level-wise until values differ.
|
|
|
|
|
|
|
|
|
|
- If, at a given level, LOWER and UPPER differ from more than
|
|
|
|
|
2, the new key shares all the levels above with LOWER and
|
2014-06-25 19:11:26 -04:00
|
|
|
|
gets a new level. Its value is the mean between LOWER and
|
2014-06-25 19:08:15 -04:00
|
|
|
|
UPPER:
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(1 2) + (1 4) --> (1 3)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
- If LOWER has no value to compare with, it is assumed that its
|
2014-06-26 15:13:43 -04:00
|
|
|
|
value is `most-negative-fixnum'. E.g.,
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(1 1) + (1 1 2)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-06-26 15:13:43 -04:00
|
|
|
|
is equivalent to
|
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(1 1 m) + (1 1 2)
|
2014-06-26 15:13:43 -04:00
|
|
|
|
|
|
|
|
|
where m is `most-negative-fixnum'. Likewise, if UPPER is
|
|
|
|
|
short of levels, the current value is `most-positive-fixnum'.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
- If they differ from only one, the new key inherits from
|
2014-06-25 19:08:15 -04:00
|
|
|
|
current LOWER level and fork it at the next level. E.g.,
|
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(2 1) + (3 3)
|
2014-06-25 19:08:15 -04:00
|
|
|
|
|
|
|
|
|
is equivalent to
|
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(2 1) + (2 M)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-06-25 19:08:15 -04:00
|
|
|
|
where M is `most-positive-fixnum'.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
- If the key is only one level long, it is returned as an
|
2014-06-25 19:08:15 -04:00
|
|
|
|
integer:
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2016-10-31 05:01:33 -04:00
|
|
|
|
(1 2) + (3 2) --> 2
|
2014-06-25 19:08:15 -04:00
|
|
|
|
|
|
|
|
|
When they are not equals, the function assumes that LOWER is
|
|
|
|
|
lesser than UPPER, per `org-element--cache-key-less-p'."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(if (equal lower upper) lower
|
|
|
|
|
(let ((lower (if (integerp lower) (list lower) lower))
|
|
|
|
|
(upper (if (integerp upper) (list upper) upper))
|
2014-06-25 19:08:15 -04:00
|
|
|
|
skip-upper key)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(catch 'exit
|
2014-06-25 19:08:15 -04:00
|
|
|
|
(while t
|
2014-06-26 15:13:43 -04:00
|
|
|
|
(let ((min (or (car lower) most-negative-fixnum))
|
2014-06-25 19:08:15 -04:00
|
|
|
|
(max (cond (skip-upper most-positive-fixnum)
|
|
|
|
|
((car upper))
|
|
|
|
|
(t most-positive-fixnum))))
|
2014-06-26 15:13:43 -04:00
|
|
|
|
(if (< (1+ min) max)
|
2014-06-26 16:00:27 -04:00
|
|
|
|
(let ((mean (+ (ash min -1) (ash max -1) (logand min max 1))))
|
|
|
|
|
(throw 'exit (if key (nreverse (cons mean key)) mean)))
|
2014-06-26 15:13:43 -04:00
|
|
|
|
(when (and (< min max) (not skip-upper))
|
|
|
|
|
;; When at a given level, LOWER and UPPER differ from
|
|
|
|
|
;; 1, ignore UPPER altogether. Instead create a key
|
|
|
|
|
;; between LOWER and the greatest key with the same
|
|
|
|
|
;; prefix as LOWER so far.
|
|
|
|
|
(setq skip-upper t))
|
|
|
|
|
(push min key)
|
|
|
|
|
(setq lower (cdr lower) upper (cdr upper)))))))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-key-less-p (a b)
|
|
|
|
|
"Non-nil if key A is less than key B.
|
|
|
|
|
A and B are either integers or lists of integers, as returned by
|
|
|
|
|
`org-element--cache-key'."
|
|
|
|
|
(if (integerp a) (if (integerp b) (< a b) (<= a (car b)))
|
|
|
|
|
(if (integerp b) (< (car a) b)
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(while (and a b)
|
|
|
|
|
(cond ((car-less-than-car a b) (throw 'exit t))
|
|
|
|
|
((car-less-than-car b a) (throw 'exit nil))
|
|
|
|
|
(t (setq a (cdr a) b (cdr b)))))
|
2014-06-23 17:45:00 -04:00
|
|
|
|
;; If A is empty, either keys are equal (B is also empty) and
|
|
|
|
|
;; we return nil, or A is lesser than B (B is longer) and we
|
|
|
|
|
;; return a non-nil value.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
2014-06-23 17:45:00 -04:00
|
|
|
|
;; If A is not empty, B is necessarily empty and A is greater
|
|
|
|
|
;; than B (A is longer). Therefore, return nil.
|
|
|
|
|
(and (null a) b)))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
(defun org-element--cache-compare (a b)
|
|
|
|
|
"Non-nil when element A is located before element B."
|
|
|
|
|
(org-element--cache-key-less-p (org-element--cache-key a)
|
|
|
|
|
(org-element--cache-key b)))
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-root ()
|
|
|
|
|
"Return root value in cache.
|
|
|
|
|
This function assumes `org-element--cache' is a valid AVL tree."
|
|
|
|
|
(avl-tree--node-left (avl-tree--dummyroot org-element--cache)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Tools
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-active-p ()
|
|
|
|
|
"Non-nil when cache is active in current buffer."
|
|
|
|
|
(and org-element-use-cache
|
2015-09-01 15:32:47 -04:00
|
|
|
|
org-element--cache
|
2016-01-31 18:17:39 -05:00
|
|
|
|
(derived-mode-p 'org-mode)))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
(defun org-element--cache-find (pos &optional side)
|
|
|
|
|
"Find element in cache starting at POS or before.
|
|
|
|
|
|
|
|
|
|
POS refers to a buffer position.
|
|
|
|
|
|
|
|
|
|
When optional argument SIDE is non-nil, the function checks for
|
|
|
|
|
elements starting at or past POS instead. If SIDE is `both', the
|
|
|
|
|
function returns a cons cell where car is the first element
|
|
|
|
|
starting at or before POS and cdr the first element starting
|
|
|
|
|
after POS.
|
|
|
|
|
|
|
|
|
|
The function can only find elements in the synchronized part of
|
|
|
|
|
the cache."
|
|
|
|
|
(let ((limit (and org-element--cache-sync-requests
|
|
|
|
|
(aref (car org-element--cache-sync-requests) 0)))
|
|
|
|
|
(node (org-element--cache-root))
|
|
|
|
|
lower upper)
|
|
|
|
|
(while node
|
|
|
|
|
(let* ((element (avl-tree--node-data node))
|
|
|
|
|
(begin (org-element-property :begin element)))
|
|
|
|
|
(cond
|
|
|
|
|
((and limit
|
|
|
|
|
(not (org-element--cache-key-less-p
|
|
|
|
|
(org-element--cache-key element) limit)))
|
|
|
|
|
(setq node (avl-tree--node-left node)))
|
|
|
|
|
((> begin pos)
|
|
|
|
|
(setq upper element
|
|
|
|
|
node (avl-tree--node-left node)))
|
|
|
|
|
((< begin pos)
|
|
|
|
|
(setq lower element
|
|
|
|
|
node (avl-tree--node-right node)))
|
|
|
|
|
;; We found an element in cache starting at POS. If `side'
|
|
|
|
|
;; is `both' we also want the next one in order to generate
|
|
|
|
|
;; a key in-between.
|
|
|
|
|
;;
|
|
|
|
|
;; If the element is the first row or item in a table or
|
|
|
|
|
;; a plain list, we always return the table or the plain
|
|
|
|
|
;; list.
|
|
|
|
|
;;
|
|
|
|
|
;; In any other case, we return the element found.
|
|
|
|
|
((eq side 'both)
|
|
|
|
|
(setq lower element)
|
|
|
|
|
(setq node (avl-tree--node-right node)))
|
|
|
|
|
((and (memq (org-element-type element) '(item table-row))
|
|
|
|
|
(let ((parent (org-element-property :parent element)))
|
|
|
|
|
(and (= (org-element-property :begin element)
|
|
|
|
|
(org-element-property :contents-begin parent))
|
|
|
|
|
(setq node nil
|
|
|
|
|
lower parent
|
|
|
|
|
upper parent)))))
|
|
|
|
|
(t
|
|
|
|
|
(setq node nil
|
|
|
|
|
lower element
|
|
|
|
|
upper element)))))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(pcase side
|
|
|
|
|
(`both (cons lower upper))
|
|
|
|
|
(`nil lower)
|
|
|
|
|
(_ upper))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2017-01-12 16:56:30 -05:00
|
|
|
|
(defun org-element--cache-put (element)
|
|
|
|
|
"Store ELEMENT in current buffer's cache, if allowed."
|
|
|
|
|
(when (org-element--cache-active-p)
|
|
|
|
|
(when org-element--cache-sync-requests
|
|
|
|
|
;; During synchronization, first build an appropriate key for
|
|
|
|
|
;; the new element so `avl-tree-enter' can insert it at the
|
|
|
|
|
;; right spot in the cache.
|
|
|
|
|
(let ((keys (org-element--cache-find
|
|
|
|
|
(org-element-property :begin element) 'both)))
|
|
|
|
|
(puthash element
|
|
|
|
|
(org-element--cache-generate-key
|
|
|
|
|
(and (car keys) (org-element--cache-key (car keys)))
|
|
|
|
|
(cond ((cdr keys) (org-element--cache-key (cdr keys)))
|
|
|
|
|
(org-element--cache-sync-requests
|
|
|
|
|
(aref (car org-element--cache-sync-requests) 0))))
|
|
|
|
|
org-element--cache-sync-keys)))
|
|
|
|
|
(avl-tree-enter org-element--cache element)))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-04-19 15:45:57 -04:00
|
|
|
|
(defsubst org-element--cache-remove (element)
|
|
|
|
|
"Remove ELEMENT from cache.
|
|
|
|
|
Assume ELEMENT belongs to cache and that a cache is active."
|
2017-01-12 16:56:30 -05:00
|
|
|
|
(avl-tree-delete org-element--cache element))
|
2014-04-19 15:45:57 -04:00
|
|
|
|
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
;;;; Synchronization
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-set-timer (buffer)
|
|
|
|
|
"Set idle timer for cache synchronization in BUFFER."
|
|
|
|
|
(when org-element--cache-sync-timer
|
|
|
|
|
(cancel-timer org-element--cache-sync-timer))
|
|
|
|
|
(setq org-element--cache-sync-timer
|
|
|
|
|
(run-with-idle-timer
|
|
|
|
|
(let ((idle (current-idle-time)))
|
|
|
|
|
(if idle (time-add idle org-element-cache-sync-break)
|
|
|
|
|
org-element-cache-sync-idle-time))
|
|
|
|
|
nil
|
|
|
|
|
#'org-element--cache-sync
|
|
|
|
|
buffer)))
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-interrupt-p (time-limit)
|
|
|
|
|
"Non-nil when synchronization process should be interrupted.
|
|
|
|
|
TIME-LIMIT is a time value or nil."
|
|
|
|
|
(and time-limit
|
|
|
|
|
(or (input-pending-p)
|
|
|
|
|
(time-less-p time-limit (current-time)))))
|
|
|
|
|
|
|
|
|
|
(defsubst org-element--cache-shift-positions (element offset &optional props)
|
|
|
|
|
"Shift ELEMENT properties relative to buffer positions by OFFSET.
|
|
|
|
|
|
|
|
|
|
Properties containing buffer positions are `:begin', `:end',
|
|
|
|
|
`:contents-begin', `:contents-end' and `:structure'. When
|
|
|
|
|
optional argument PROPS is a list of keywords, only shift
|
|
|
|
|
properties provided in that list.
|
|
|
|
|
|
|
|
|
|
Properties are modified by side-effect."
|
|
|
|
|
(let ((properties (nth 1 element)))
|
|
|
|
|
;; Shift `:structure' property for the first plain list only: it
|
|
|
|
|
;; 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 (plist-get properties :parent))
|
|
|
|
|
'item)))
|
|
|
|
|
(dolist (item (plist-get properties :structure))
|
2016-07-25 10:34:48 -04:00
|
|
|
|
(cl-incf (car item) offset)
|
|
|
|
|
(cl-incf (nth 6 item) offset)))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(dolist (key '(:begin :contents-begin :contents-end :end :post-affiliated))
|
|
|
|
|
(let ((value (and (or (not props) (memq key props))
|
|
|
|
|
(plist-get properties key))))
|
|
|
|
|
(and value (plist-put properties key (+ offset value)))))))
|
|
|
|
|
|
2014-07-20 11:50:23 -04:00
|
|
|
|
(defun org-element--cache-sync (buffer &optional threshold future-change)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
"Synchronize cache with recent modification in BUFFER.
|
2014-06-17 17:36:29 -04:00
|
|
|
|
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
When optional argument THRESHOLD is non-nil, do the
|
|
|
|
|
synchronization for all elements starting before or at threshold,
|
|
|
|
|
then exit. Otherwise, synchronize cache for as long as
|
|
|
|
|
`org-element-cache-sync-duration' or until Emacs leaves idle
|
2014-06-17 17:36:29 -04:00
|
|
|
|
state.
|
|
|
|
|
|
2014-07-20 11:50:23 -04:00
|
|
|
|
FUTURE-CHANGE, when non-nil, is a buffer position where changes
|
|
|
|
|
not registered yet in the cache are going to happen. It is used
|
|
|
|
|
in `org-element--cache-submit-request', where cache is partially
|
2014-06-17 17:36:29 -04:00
|
|
|
|
updated before current modification are actually submitted."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(let ((inhibit-quit t) request next)
|
|
|
|
|
(when org-element--cache-sync-timer
|
|
|
|
|
(cancel-timer org-element--cache-sync-timer))
|
|
|
|
|
(catch 'interrupt
|
|
|
|
|
(while org-element--cache-sync-requests
|
|
|
|
|
(setq request (car org-element--cache-sync-requests)
|
|
|
|
|
next (nth 1 org-element--cache-sync-requests))
|
2014-06-14 11:27:45 -04:00
|
|
|
|
(org-element--cache-process-request
|
|
|
|
|
request
|
|
|
|
|
(and next (aref next 0))
|
|
|
|
|
threshold
|
|
|
|
|
(and (not threshold)
|
|
|
|
|
(time-add (current-time)
|
2014-06-17 17:36:29 -04:00
|
|
|
|
org-element-cache-sync-duration))
|
2014-07-20 11:50:23 -04:00
|
|
|
|
future-change)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Request processed. Merge current and next offsets and
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; transfer ending position.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(when next
|
2016-07-25 10:34:48 -04:00
|
|
|
|
(cl-incf (aref next 3) (aref request 3))
|
2014-07-17 09:46:42 -04:00
|
|
|
|
(aset next 2 (aref request 2)))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(setq org-element--cache-sync-requests
|
|
|
|
|
(cdr org-element--cache-sync-requests))))
|
|
|
|
|
;; If more requests are awaiting, set idle timer accordingly.
|
|
|
|
|
;; Otherwise, reset keys.
|
|
|
|
|
(if org-element--cache-sync-requests
|
|
|
|
|
(org-element--cache-set-timer buffer)
|
|
|
|
|
(clrhash org-element--cache-sync-keys))))))
|
|
|
|
|
|
2014-06-17 17:36:29 -04:00
|
|
|
|
(defun org-element--cache-process-request
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(request next threshold time-limit future-change)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
"Process synchronization REQUEST for all entries before NEXT.
|
|
|
|
|
|
|
|
|
|
REQUEST is a vector, built by `org-element--cache-submit-request'.
|
|
|
|
|
|
|
|
|
|
NEXT is a cache key, as returned by `org-element--cache-key'.
|
|
|
|
|
|
|
|
|
|
When non-nil, THRESHOLD is a buffer position. Synchronization
|
|
|
|
|
stops as soon as a shifted element begins after it.
|
|
|
|
|
|
|
|
|
|
When non-nil, TIME-LIMIT is a time value. Synchronization stops
|
|
|
|
|
after this time or when Emacs exits idle state.
|
|
|
|
|
|
2014-07-20 11:50:23 -04:00
|
|
|
|
When non-nil, FUTURE-CHANGE is a buffer position where changes
|
|
|
|
|
not registered yet in the cache are going to happen. See
|
|
|
|
|
`org-element--cache-submit-request' for more information.
|
2014-06-17 17:36:29 -04:00
|
|
|
|
|
2014-06-14 11:27:45 -04:00
|
|
|
|
Throw `interrupt' if the process stops before completing the
|
|
|
|
|
request."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(catch 'quit
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(when (= (aref request 5) 0)
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; Phase 0.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Delete all elements starting after BEG, but not after buffer
|
2015-06-14 08:52:04 -04:00
|
|
|
|
;; position END or past element with key NEXT. Also delete
|
|
|
|
|
;; elements contained within a previously removed element
|
|
|
|
|
;; (stored in `last-container').
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
|
|
|
|
;; At each iteration, we start again at tree root since
|
|
|
|
|
;; a deletion modifies structure of the balanced tree.
|
|
|
|
|
(catch 'end-phase
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(while t
|
|
|
|
|
(when (org-element--cache-interrupt-p time-limit)
|
|
|
|
|
(throw 'interrupt nil))
|
|
|
|
|
;; Find first element in cache with key BEG or after it.
|
|
|
|
|
(let ((beg (aref request 0))
|
|
|
|
|
(end (aref request 2))
|
|
|
|
|
(node (org-element--cache-root))
|
|
|
|
|
data data-key last-container)
|
|
|
|
|
(while node
|
|
|
|
|
(let* ((element (avl-tree--node-data node))
|
|
|
|
|
(key (org-element--cache-key element)))
|
|
|
|
|
(cond
|
|
|
|
|
((org-element--cache-key-less-p key beg)
|
|
|
|
|
(setq node (avl-tree--node-right node)))
|
|
|
|
|
((org-element--cache-key-less-p beg key)
|
|
|
|
|
(setq data element
|
|
|
|
|
data-key key
|
|
|
|
|
node (avl-tree--node-left node)))
|
|
|
|
|
(t (setq data element
|
|
|
|
|
data-key key
|
|
|
|
|
node nil)))))
|
|
|
|
|
(if data
|
|
|
|
|
(let ((pos (org-element-property :begin data)))
|
|
|
|
|
(if (if (or (not next)
|
|
|
|
|
(org-element--cache-key-less-p data-key next))
|
|
|
|
|
(<= pos end)
|
|
|
|
|
(and last-container
|
|
|
|
|
(let ((up data))
|
|
|
|
|
(while (and up (not (eq up last-container)))
|
|
|
|
|
(setq up (org-element-property :parent up)))
|
|
|
|
|
up)))
|
|
|
|
|
(progn (when (and (not last-container)
|
|
|
|
|
(> (org-element-property :end data)
|
|
|
|
|
end))
|
|
|
|
|
(setq last-container data))
|
|
|
|
|
(org-element--cache-remove data))
|
|
|
|
|
(aset request 0 data-key)
|
|
|
|
|
(aset request 1 pos)
|
|
|
|
|
(aset request 5 1)
|
|
|
|
|
(throw 'end-phase nil)))
|
|
|
|
|
;; No element starting after modifications left in
|
|
|
|
|
;; cache: further processing is futile.
|
|
|
|
|
(throw 'quit t))))))
|
|
|
|
|
(when (= (aref request 5) 1)
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; Phase 1.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; Phase 0 left a hole in the cache. Some elements after it
|
|
|
|
|
;; could have parents within. For example, in the following
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; buffer:
|
|
|
|
|
;;
|
|
|
|
|
;; - item
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
;; Paragraph1
|
|
|
|
|
;;
|
|
|
|
|
;; Paragraph2
|
|
|
|
|
;;
|
|
|
|
|
;; if we remove a blank line between "item" and "Paragraph1",
|
|
|
|
|
;; everything down to "Paragraph2" is removed from cache. But
|
|
|
|
|
;; the paragraph now belongs to the list, and its `:parent'
|
|
|
|
|
;; property no longer is accurate.
|
|
|
|
|
;;
|
|
|
|
|
;; Therefore we need to parse again elements in the hole, or at
|
|
|
|
|
;; least in its last section, so that we can re-parent
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; subsequent elements, during phase 2.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Note that we only need to get the parent from the first
|
|
|
|
|
;; element in cache after the hole.
|
|
|
|
|
;;
|
2014-07-20 11:49:36 -04:00
|
|
|
|
;; When next key is lesser or equal to the current one, delegate
|
|
|
|
|
;; phase 1 processing to next request in order to preserve key
|
|
|
|
|
;; order among requests.
|
|
|
|
|
(let ((key (aref request 0)))
|
|
|
|
|
(when (and next (not (org-element--cache-key-less-p key next)))
|
|
|
|
|
(let ((next-request (nth 1 org-element--cache-sync-requests)))
|
|
|
|
|
(aset next-request 0 key)
|
|
|
|
|
(aset next-request 1 (aref request 1))
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(aset next-request 5 1))
|
2014-07-20 11:49:36 -04:00
|
|
|
|
(throw 'quit t)))
|
2014-07-20 11:50:23 -04:00
|
|
|
|
;; Next element will start at its beginning position plus
|
|
|
|
|
;; offset, since it hasn't been shifted yet. Therefore, LIMIT
|
|
|
|
|
;; contains the real beginning position of the first element to
|
|
|
|
|
;; shift and re-parent.
|
|
|
|
|
(let ((limit (+ (aref request 1) (aref request 3))))
|
|
|
|
|
(cond ((and threshold (> limit threshold)) (throw 'interrupt nil))
|
|
|
|
|
((and future-change (>= limit future-change))
|
|
|
|
|
;; Changes are going to happen around this element and
|
|
|
|
|
;; they will trigger another phase 1 request. Skip the
|
|
|
|
|
;; current one.
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(aset request 5 2))
|
2014-07-20 11:50:23 -04:00
|
|
|
|
(t
|
|
|
|
|
(let ((parent (org-element--parse-to limit t time-limit)))
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(aset request 4 parent)
|
|
|
|
|
(aset request 5 2))))))
|
2014-07-17 09:46:42 -04:00
|
|
|
|
;; Phase 2.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
|
|
|
|
;; Shift all elements starting from key START, but before NEXT, by
|
|
|
|
|
;; OFFSET, and re-parent them when appropriate.
|
|
|
|
|
;;
|
|
|
|
|
;; Elements are modified by side-effect so the tree structure
|
|
|
|
|
;; remains intact.
|
|
|
|
|
;;
|
|
|
|
|
;; Once THRESHOLD, if any, is reached, or once there is an input
|
|
|
|
|
;; pending, exit. Before leaving, the current synchronization
|
|
|
|
|
;; request is updated.
|
|
|
|
|
(let ((start (aref request 0))
|
2014-06-17 17:07:16 -04:00
|
|
|
|
(offset (aref request 3))
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(parent (aref request 4))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(node (org-element--cache-root))
|
|
|
|
|
(stack (list nil))
|
|
|
|
|
(leftp t)
|
|
|
|
|
exit-flag)
|
|
|
|
|
;; No re-parenting nor shifting planned: request is over.
|
|
|
|
|
(when (and (not parent) (zerop offset)) (throw 'quit t))
|
|
|
|
|
(while node
|
|
|
|
|
(let* ((data (avl-tree--node-data node))
|
|
|
|
|
(key (org-element--cache-key data)))
|
|
|
|
|
(if (and leftp (avl-tree--node-left node)
|
|
|
|
|
(not (org-element--cache-key-less-p key start)))
|
|
|
|
|
(progn (push node stack)
|
|
|
|
|
(setq node (avl-tree--node-left node)))
|
|
|
|
|
(unless (org-element--cache-key-less-p key start)
|
|
|
|
|
;; We reached NEXT. Request is complete.
|
|
|
|
|
(when (equal key next) (throw 'quit t))
|
|
|
|
|
;; Handle interruption request. Update current request.
|
|
|
|
|
(when (or exit-flag (org-element--cache-interrupt-p time-limit))
|
|
|
|
|
(aset request 0 key)
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(aset request 4 parent)
|
2014-06-14 11:27:45 -04:00
|
|
|
|
(throw 'interrupt nil))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Shift element.
|
|
|
|
|
(unless (zerop offset)
|
2017-01-12 16:56:30 -05:00
|
|
|
|
(org-element--cache-shift-positions data offset))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(let ((begin (org-element-property :begin data)))
|
2014-07-17 12:11:49 -04:00
|
|
|
|
;; Update PARENT and re-parent DATA, only when
|
|
|
|
|
;; necessary. Propagate new structures for lists.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(while (and parent
|
|
|
|
|
(<= (org-element-property :end parent) begin))
|
|
|
|
|
(setq parent (org-element-property :parent parent)))
|
2014-07-17 12:11:49 -04:00
|
|
|
|
(cond ((and (not parent) (zerop offset)) (throw 'quit nil))
|
|
|
|
|
((and parent
|
|
|
|
|
(let ((p (org-element-property :parent data)))
|
|
|
|
|
(or (not p)
|
|
|
|
|
(< (org-element-property :begin p)
|
|
|
|
|
(org-element-property :begin parent)))))
|
|
|
|
|
(org-element-put-property data :parent parent)
|
|
|
|
|
(let ((s (org-element-property :structure parent)))
|
|
|
|
|
(when (and s (org-element-property :structure data))
|
|
|
|
|
(org-element-put-property data :structure s)))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Cache is up-to-date past THRESHOLD. Request
|
|
|
|
|
;; interruption.
|
|
|
|
|
(when (and threshold (> begin threshold)) (setq exit-flag t))))
|
|
|
|
|
(setq node (if (setq leftp (avl-tree--node-right node))
|
|
|
|
|
(avl-tree--node-right node)
|
|
|
|
|
(pop stack))))))
|
|
|
|
|
;; We reached end of tree: synchronization complete.
|
|
|
|
|
t)))
|
|
|
|
|
|
|
|
|
|
(defun org-element--parse-to (pos &optional syncp time-limit)
|
|
|
|
|
"Parse elements in current section, down to POS.
|
|
|
|
|
|
|
|
|
|
Start parsing from the closest between the last known element in
|
|
|
|
|
cache or headline above. Return the smallest element containing
|
|
|
|
|
POS.
|
|
|
|
|
|
|
|
|
|
When optional argument SYNCP is non-nil, return the parent of the
|
|
|
|
|
element containing POS instead. In that case, it is also
|
|
|
|
|
possible to provide TIME-LIMIT, which is a time value specifying
|
2014-06-14 11:27:45 -04:00
|
|
|
|
when the parsing should stop. The function throws `interrupt' if
|
|
|
|
|
the process stopped before finding the expected result."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(catch 'exit
|
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(goto-char pos)
|
|
|
|
|
(let* ((cached (and (org-element--cache-active-p)
|
|
|
|
|
(org-element--cache-find pos nil)))
|
|
|
|
|
(begin (org-element-property :begin cached))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
element next mode)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(cond
|
|
|
|
|
;; Nothing in cache before point: start parsing from first
|
|
|
|
|
;; element following headline above, or first element in
|
|
|
|
|
;; buffer.
|
|
|
|
|
((not cached)
|
|
|
|
|
(when (org-with-limited-levels (outline-previous-heading))
|
2014-08-31 13:11:29 -04:00
|
|
|
|
(setq mode 'planning)
|
|
|
|
|
(forward-line))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(skip-chars-forward " \r\t\n")
|
2014-08-31 13:11:29 -04:00
|
|
|
|
(beginning-of-line))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Cache returned exact match: return it.
|
|
|
|
|
((= pos begin)
|
|
|
|
|
(throw 'exit (if syncp (org-element-property :parent cached) cached)))
|
|
|
|
|
;; There's a headline between cached value and POS: cached
|
|
|
|
|
;; value is invalid. Start parsing from first element
|
|
|
|
|
;; following the headline.
|
|
|
|
|
((re-search-backward
|
|
|
|
|
(org-with-limited-levels org-outline-regexp-bol) begin t)
|
|
|
|
|
(forward-line)
|
|
|
|
|
(skip-chars-forward " \r\t\n")
|
2014-08-31 10:31:59 -04:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(setq mode 'planning))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Check if CACHED or any of its ancestors contain point.
|
|
|
|
|
;;
|
|
|
|
|
;; If there is such an element, we inspect it in order to know
|
|
|
|
|
;; if we return it or if we need to parse its contents.
|
|
|
|
|
;; Otherwise, we just start parsing from current location,
|
|
|
|
|
;; which is right after the top-most element containing
|
|
|
|
|
;; CACHED.
|
|
|
|
|
;;
|
|
|
|
|
;; As a special case, if POS is at the end of the buffer, we
|
|
|
|
|
;; want to return the innermost element ending there.
|
|
|
|
|
;;
|
|
|
|
|
;; Also, if we find an ancestor and discover that we need to
|
|
|
|
|
;; parse its contents, make sure we don't start from
|
|
|
|
|
;; `:contents-begin', as we would otherwise go past CACHED
|
|
|
|
|
;; again. Instead, in that situation, we will resume parsing
|
|
|
|
|
;; from NEXT, which is located after CACHED or its higher
|
|
|
|
|
;; ancestor not containing point.
|
|
|
|
|
(t
|
|
|
|
|
(let ((up cached)
|
|
|
|
|
(pos (if (= (point-max) pos) (1- pos) pos)))
|
|
|
|
|
(goto-char (or (org-element-property :contents-begin cached) begin))
|
|
|
|
|
(while (let ((end (org-element-property :end up)))
|
|
|
|
|
(and (<= end pos)
|
|
|
|
|
(goto-char end)
|
|
|
|
|
(setq up (org-element-property :parent up)))))
|
|
|
|
|
(cond ((not up))
|
|
|
|
|
((eobp) (setq element up))
|
|
|
|
|
(t (setq element up next (point)))))))
|
|
|
|
|
;; Parse successively each element until we reach POS.
|
|
|
|
|
(let ((end (or (org-element-property :end element)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(org-with-limited-levels (outline-next-heading))
|
|
|
|
|
(point))))
|
2014-08-31 10:31:59 -04:00
|
|
|
|
(parent element))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(while t
|
2014-02-21 05:37:08 -05:00
|
|
|
|
(when syncp
|
|
|
|
|
(cond ((= (point) pos) (throw 'exit parent))
|
|
|
|
|
((org-element--cache-interrupt-p time-limit)
|
2014-06-14 11:27:45 -04:00
|
|
|
|
(throw 'interrupt nil))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(unless element
|
|
|
|
|
(setq element (org-element--current-element
|
2014-08-31 10:31:59 -04:00
|
|
|
|
end 'element mode
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(org-element-property :structure parent)))
|
|
|
|
|
(org-element-put-property element :parent parent)
|
|
|
|
|
(org-element--cache-put element))
|
|
|
|
|
(let ((elem-end (org-element-property :end element))
|
|
|
|
|
(type (org-element-type element)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Skip any element ending before point. Also skip
|
2014-02-21 05:37:08 -05:00
|
|
|
|
;; element ending at point (unless it is also the end of
|
|
|
|
|
;; buffer) since we're sure that another element begins
|
|
|
|
|
;; after it.
|
|
|
|
|
((and (<= elem-end pos) (/= (point-max) elem-end))
|
2014-09-13 16:31:06 -04:00
|
|
|
|
(goto-char elem-end)
|
|
|
|
|
(setq mode (org-element--next-mode type nil)))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; A non-greater element contains point: return it.
|
2014-02-21 05:37:08 -05:00
|
|
|
|
((not (memq type org-element-greater-elements))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(throw 'exit element))
|
|
|
|
|
;; Otherwise, we have to decide if ELEMENT really
|
|
|
|
|
;; contains POS. In that case we start parsing from
|
2014-02-21 05:37:08 -05:00
|
|
|
|
;; contents' beginning.
|
|
|
|
|
;;
|
|
|
|
|
;; If POS is at contents' beginning but it is also at
|
|
|
|
|
;; the beginning of the first item in a list or a table.
|
|
|
|
|
;; In that case, we need to create an anchor for that
|
|
|
|
|
;; list or table, so return it.
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;;
|
2014-02-21 05:37:08 -05:00
|
|
|
|
;; Also, if POS is at the end of the buffer, no element
|
|
|
|
|
;; can start after it, but more than one may end there.
|
|
|
|
|
;; Arbitrarily, we choose to return the innermost of
|
|
|
|
|
;; such elements.
|
|
|
|
|
((let ((cbeg (org-element-property :contents-begin element))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(cend (org-element-property :contents-end element)))
|
2014-02-21 05:37:08 -05:00
|
|
|
|
(when (or syncp
|
|
|
|
|
(and cbeg cend
|
|
|
|
|
(or (< cbeg pos)
|
|
|
|
|
(and (= cbeg pos)
|
|
|
|
|
(not (memq type '(plain-list table)))))
|
|
|
|
|
(or (> cend pos)
|
|
|
|
|
(and (= cend pos) (= (point-max) pos)))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(goto-char (or next cbeg))
|
2014-02-21 05:37:08 -05:00
|
|
|
|
(setq next nil
|
2014-09-13 16:31:06 -04:00
|
|
|
|
mode (org-element--next-mode type t)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
parent element
|
2014-02-21 05:37:08 -05:00
|
|
|
|
end cend))))
|
|
|
|
|
;; Otherwise, return ELEMENT as it is the smallest
|
|
|
|
|
;; element containing POS.
|
|
|
|
|
(t (throw 'exit element))))
|
|
|
|
|
(setq element nil)))))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Staging Buffer Changes
|
|
|
|
|
|
2014-06-25 17:48:21 -04:00
|
|
|
|
(defconst org-element--cache-sensitive-re
|
|
|
|
|
(concat
|
|
|
|
|
org-outline-regexp-bol "\\|"
|
2015-04-05 15:38:10 -04:00
|
|
|
|
"\\\\end{[A-Za-z0-9*]+}[ \t]*$" "\\|"
|
2014-06-25 17:48:21 -04:00
|
|
|
|
"^[ \t]*\\(?:"
|
|
|
|
|
"#\\+\\(?:BEGIN[:_]\\|END\\(?:_\\|:?[ \t]*$\\)\\)" "\\|"
|
2015-04-05 15:38:10 -04:00
|
|
|
|
"\\\\begin{[A-Za-z0-9*]+}" "\\|"
|
2014-07-25 14:37:37 -04:00
|
|
|
|
":\\(?:\\w\\|[-_]\\)+:[ \t]*$"
|
2014-06-25 17:48:21 -04:00
|
|
|
|
"\\)")
|
|
|
|
|
"Regexp matching a sensitive line, structure wise.
|
|
|
|
|
A sensitive line is a headline, inlinetask, block, drawer, or
|
|
|
|
|
latex-environment boundary. When such a line is modified,
|
|
|
|
|
structure changes in the document may propagate in the whole
|
|
|
|
|
section, possibly making cache invalid.")
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
(defvar org-element--cache-change-warning nil
|
|
|
|
|
"Non-nil when a sensitive line is about to be changed.
|
|
|
|
|
It is a symbol among nil, t and `headline'.")
|
|
|
|
|
|
|
|
|
|
(defun org-element--cache-before-change (beg end)
|
|
|
|
|
"Request extension of area going to be modified if needed.
|
|
|
|
|
BEG and END are the beginning and end of the range of changed
|
|
|
|
|
text. See `before-change-functions' for more information."
|
2014-06-25 17:48:21 -04:00
|
|
|
|
(when (org-element--cache-active-p)
|
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((bottom (save-excursion (goto-char end) (line-end-position))))
|
|
|
|
|
(setq org-element--cache-change-warning
|
|
|
|
|
(save-match-data
|
|
|
|
|
(if (and (org-with-limited-levels (org-at-heading-p))
|
|
|
|
|
(= (line-end-position) bottom))
|
|
|
|
|
'headline
|
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(re-search-forward
|
|
|
|
|
org-element--cache-sensitive-re bottom t)))))))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
(defun org-element--cache-after-change (beg end pre)
|
|
|
|
|
"Update buffer modifications for current buffer.
|
|
|
|
|
BEG and END are the beginning and end of the range of changed
|
|
|
|
|
text, and the length in bytes of the pre-change text replaced by
|
|
|
|
|
that range. See `after-change-functions' for more information."
|
2014-06-23 06:28:11 -04:00
|
|
|
|
(when (org-element--cache-active-p)
|
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(goto-char beg)
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(save-match-data
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(let ((top (point))
|
|
|
|
|
(bottom (save-excursion (goto-char end) (line-end-position))))
|
2014-06-25 17:48:21 -04:00
|
|
|
|
;; Determine if modified area needs to be extended, according
|
|
|
|
|
;; to both previous and current state. We make a special
|
|
|
|
|
;; case for headline editing: if a headline is modified but
|
|
|
|
|
;; not removed, do not extend.
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(when (pcase org-element--cache-change-warning
|
|
|
|
|
(`t t)
|
|
|
|
|
(`headline
|
2014-06-25 17:48:21 -04:00
|
|
|
|
(not (and (org-with-limited-levels (org-at-heading-p))
|
|
|
|
|
(= (line-end-position) bottom))))
|
2015-08-17 04:58:57 -04:00
|
|
|
|
(_
|
2014-06-25 17:48:21 -04:00
|
|
|
|
(let ((case-fold-search t))
|
|
|
|
|
(re-search-forward
|
|
|
|
|
org-element--cache-sensitive-re bottom t))))
|
|
|
|
|
;; Effectively extend modified area.
|
|
|
|
|
(org-with-limited-levels
|
2014-06-23 06:28:11 -04:00
|
|
|
|
(setq top (progn (goto-char top)
|
|
|
|
|
(when (outline-previous-heading) (forward-line))
|
|
|
|
|
(point)))
|
|
|
|
|
(setq bottom (progn (goto-char bottom)
|
|
|
|
|
(if (outline-next-heading) (1- (point))
|
|
|
|
|
(point))))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
;; Store synchronization request.
|
|
|
|
|
(let ((offset (- end beg pre)))
|
2014-06-23 06:28:11 -04:00
|
|
|
|
(org-element--cache-submit-request top (- bottom offset) offset)))))
|
|
|
|
|
;; Activate a timer to process the request during idle time.
|
|
|
|
|
(org-element--cache-set-timer (current-buffer))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2014-06-17 18:11:44 -04:00
|
|
|
|
(defun org-element--cache-for-removal (beg end offset)
|
|
|
|
|
"Return first element to remove from cache.
|
|
|
|
|
|
|
|
|
|
BEG and END are buffer positions delimiting buffer modifications.
|
|
|
|
|
OFFSET is the size of the changes.
|
|
|
|
|
|
|
|
|
|
Returned element is usually the first element in cache containing
|
|
|
|
|
any position between BEG and END. As an exception, greater
|
|
|
|
|
elements around the changes that are robust to contents
|
|
|
|
|
modifications are preserved and updated according to the
|
|
|
|
|
changes."
|
|
|
|
|
(let* ((elements (org-element--cache-find (1- beg) 'both))
|
|
|
|
|
(before (car elements))
|
|
|
|
|
(after (cdr elements)))
|
|
|
|
|
(if (not before) after
|
2014-07-20 13:22:00 -04:00
|
|
|
|
(let ((up before)
|
|
|
|
|
(robust-flag t))
|
|
|
|
|
(while up
|
2015-04-05 18:37:49 -04:00
|
|
|
|
(if (let ((type (org-element-type up)))
|
|
|
|
|
(and (or (memq type '(center-block dynamic-block quote-block
|
|
|
|
|
special-block))
|
|
|
|
|
;; Drawers named "PROPERTIES" are probably
|
|
|
|
|
;; a properties drawer being edited. Force
|
|
|
|
|
;; parsing to check if editing is over.
|
|
|
|
|
(and (eq type 'drawer)
|
|
|
|
|
(not (string=
|
|
|
|
|
(org-element-property :drawer-name up)
|
|
|
|
|
"PROPERTIES"))))
|
|
|
|
|
(let ((cbeg (org-element-property :contents-begin up)))
|
|
|
|
|
(and cbeg
|
|
|
|
|
(<= cbeg beg)
|
|
|
|
|
(> (org-element-property :contents-end up) end)))))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
;; UP is a robust greater element containing changes.
|
2014-06-30 17:33:20 -04:00
|
|
|
|
;; We only need to extend its ending boundaries.
|
|
|
|
|
(org-element--cache-shift-positions
|
|
|
|
|
up offset '(:contents-end :end))
|
2014-07-20 13:22:00 -04:00
|
|
|
|
(setq before up)
|
|
|
|
|
(when robust-flag (setq robust-flag nil)))
|
|
|
|
|
(setq up (org-element-property :parent up)))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
;; We're at top level element containing ELEMENT: if it's
|
|
|
|
|
;; altered by buffer modifications, it is first element in
|
|
|
|
|
;; cache to be removed. Otherwise, that first element is the
|
|
|
|
|
;; following one.
|
2014-07-20 13:22:00 -04:00
|
|
|
|
;;
|
|
|
|
|
;; As a special case, do not remove BEFORE if it is a robust
|
|
|
|
|
;; container for current changes.
|
|
|
|
|
(if (or (< (org-element-property :end before) beg) robust-flag) after
|
|
|
|
|
before)))))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(defun org-element--cache-submit-request (beg end offset)
|
|
|
|
|
"Submit a new cache synchronization request for current buffer.
|
|
|
|
|
BEG and END are buffer positions delimiting the minimal area
|
|
|
|
|
where cache data should be removed. OFFSET is the size of the
|
|
|
|
|
change, as an integer."
|
2014-07-03 16:08:10 -04:00
|
|
|
|
(let ((next (car org-element--cache-sync-requests))
|
|
|
|
|
delete-to delete-from)
|
2014-06-17 18:11:44 -04:00
|
|
|
|
(if (and next
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(zerop (aref next 5))
|
2014-07-03 16:08:10 -04:00
|
|
|
|
(> (setq delete-to (+ (aref next 2) (aref next 3))) end)
|
|
|
|
|
(<= (setq delete-from (aref next 1)) end))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
;; Current changes can be merged with first sync request: we
|
|
|
|
|
;; can save a partial cache synchronization.
|
|
|
|
|
(progn
|
2016-07-25 10:34:48 -04:00
|
|
|
|
(cl-incf (aref next 3) offset)
|
2014-07-03 16:08:10 -04:00
|
|
|
|
;; If last change happened within area to be removed, extend
|
|
|
|
|
;; boundaries of robust parents, if any. Otherwise, find
|
|
|
|
|
;; first element to remove and update request accordingly.
|
|
|
|
|
(if (> beg delete-from)
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(let ((up (aref next 4)))
|
2014-07-03 16:08:10 -04:00
|
|
|
|
(while up
|
|
|
|
|
(org-element--cache-shift-positions
|
|
|
|
|
up offset '(:contents-end :end))
|
|
|
|
|
(setq up (org-element-property :parent up))))
|
|
|
|
|
(let ((first (org-element--cache-for-removal beg delete-to offset)))
|
|
|
|
|
(when first
|
|
|
|
|
(aset next 0 (org-element--cache-key first))
|
|
|
|
|
(aset next 1 (org-element-property :begin first))
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(aset next 4 (org-element-property :parent first))))))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
;; Ensure cache is correct up to END. Also make sure that NEXT,
|
|
|
|
|
;; if any, is no longer a 0-phase request, thus ensuring that
|
|
|
|
|
;; phases are properly ordered. We need to provide OFFSET as
|
|
|
|
|
;; optional parameter since current modifications are not known
|
|
|
|
|
;; yet to the otherwise correct part of the cache (i.e, before
|
|
|
|
|
;; the first request).
|
2014-07-20 11:50:23 -04:00
|
|
|
|
(when next (org-element--cache-sync (current-buffer) end beg))
|
2014-06-17 18:11:44 -04:00
|
|
|
|
(let ((first (org-element--cache-for-removal beg end offset)))
|
2014-07-03 16:10:47 -04:00
|
|
|
|
(if first
|
|
|
|
|
(push (let ((beg (org-element-property :begin first))
|
|
|
|
|
(key (org-element--cache-key first)))
|
|
|
|
|
(cond
|
|
|
|
|
;; When changes happen before the first known
|
2014-07-17 12:08:06 -04:00
|
|
|
|
;; element, re-parent and shift the rest of the
|
|
|
|
|
;; cache.
|
2015-06-14 08:52:04 -04:00
|
|
|
|
((> beg end) (vector key beg nil offset nil 1))
|
2014-07-03 16:10:47 -04:00
|
|
|
|
;; Otherwise, we find the first non robust
|
|
|
|
|
;; element containing END. All elements between
|
|
|
|
|
;; FIRST and this one are to be removed.
|
|
|
|
|
((let ((first-end (org-element-property :end first)))
|
|
|
|
|
(and (> first-end end)
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(vector key beg first-end offset first 0))))
|
2014-07-03 16:10:47 -04:00
|
|
|
|
(t
|
|
|
|
|
(let* ((element (org-element--cache-find end))
|
|
|
|
|
(end (org-element-property :end element))
|
|
|
|
|
(up element))
|
|
|
|
|
(while (and (setq up (org-element-property :parent up))
|
|
|
|
|
(>= (org-element-property :begin up) beg))
|
|
|
|
|
(setq end (org-element-property :end up)
|
|
|
|
|
element up))
|
2015-06-14 08:52:04 -04:00
|
|
|
|
(vector key beg end offset element 0)))))
|
2014-07-03 16:10:47 -04:00
|
|
|
|
org-element--cache-sync-requests)
|
|
|
|
|
;; No element to remove. No need to re-parent either.
|
|
|
|
|
;; Simply shift additional elements, if any, by OFFSET.
|
|
|
|
|
(when org-element--cache-sync-requests
|
2016-07-25 10:34:48 -04:00
|
|
|
|
(cl-incf (aref (car org-element--cache-sync-requests) 3)
|
|
|
|
|
offset)))))))
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;; Public Functions
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-element-cache-reset (&optional all)
|
|
|
|
|
"Reset cache in current buffer.
|
|
|
|
|
When optional argument ALL is non-nil, reset cache in all Org
|
2014-04-19 08:38:25 -04:00
|
|
|
|
buffers."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(interactive "P")
|
|
|
|
|
(dolist (buffer (if all (buffer-list) (list (current-buffer))))
|
|
|
|
|
(with-current-buffer buffer
|
2016-01-31 18:17:39 -05:00
|
|
|
|
(when (and org-element-use-cache (derived-mode-p 'org-mode))
|
2015-11-05 11:47:38 -05:00
|
|
|
|
(setq-local org-element--cache
|
|
|
|
|
(avl-tree-create #'org-element--cache-compare))
|
|
|
|
|
(setq-local org-element--cache-sync-keys
|
2016-01-31 18:19:37 -05:00
|
|
|
|
(make-hash-table :weakness 'key :test #'eq))
|
2015-11-05 11:47:38 -05:00
|
|
|
|
(setq-local org-element--cache-change-warning nil)
|
|
|
|
|
(setq-local org-element--cache-sync-requests nil)
|
|
|
|
|
(setq-local org-element--cache-sync-timer nil)
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(add-hook 'before-change-functions
|
|
|
|
|
#'org-element--cache-before-change nil t)
|
|
|
|
|
(add-hook 'after-change-functions
|
|
|
|
|
#'org-element--cache-after-change nil t)))))
|
|
|
|
|
|
2014-04-19 08:38:25 -04:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-element-cache-refresh (pos)
|
|
|
|
|
"Refresh cache at position POS."
|
|
|
|
|
(when (org-element--cache-active-p)
|
|
|
|
|
(org-element--cache-sync (current-buffer) pos)
|
|
|
|
|
(org-element--cache-submit-request pos pos 0)
|
|
|
|
|
(org-element--cache-set-timer (current-buffer))))
|
|
|
|
|
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
|
|
|
|
|
;;; The Toolbox
|
|
|
|
|
;;
|
|
|
|
|
;; The first move is to implement a way to obtain the smallest element
|
|
|
|
|
;; containing point. This is the job of `org-element-at-point'. It
|
|
|
|
|
;; basically jumps back to the beginning of section containing point
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
;; and proceed, one element after the other, with
|
2012-08-08 07:55:18 -04:00
|
|
|
|
;; `org-element--current-element' until the container is found. Note:
|
|
|
|
|
;; When using `org-element-at-point', secondary values are never
|
|
|
|
|
;; parsed since the function focuses on elements, not on objects.
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;
|
|
|
|
|
;; At a deeper level, `org-element-context' lists all elements and
|
|
|
|
|
;; objects containing point.
|
|
|
|
|
;;
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; `org-element-nested-p' and `org-element-swap-A-B' may be used
|
|
|
|
|
;; internally by navigation and manipulation tools.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-element-at-point ()
|
|
|
|
|
"Determine closest element around point.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
Return value is a list like (TYPE PROPS) where TYPE is the type
|
|
|
|
|
of the element and PROPS a plist of properties associated to the
|
|
|
|
|
element.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
Possible types are defined in `org-element-all-elements'.
|
|
|
|
|
Properties depend on element or object type, but always include
|
|
|
|
|
`:begin', `:end', `:parent' and `:post-blank' properties.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
As a special case, if point is at the very beginning of the first
|
|
|
|
|
item in a list or sub-list, returned element will be that list
|
|
|
|
|
instead of the item. Likewise, if point is at the beginning of
|
|
|
|
|
the first row of a table, returned element will be the table
|
|
|
|
|
instead of the first row.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
When point is at the end of the buffer, return the innermost
|
|
|
|
|
element ending there."
|
org-element: Implement lazy cache synchronization
* lisp/org-element.el (org-element-cache-sync-idle-time): Change
default value.
(org-element-cache-sync-duration, org-element-cache-sync-break,
org-element--cache-sync-requests, org-element--cache-sync-timer,
org-element--cache-sync-keys, org-element--cache-default-key,
org-element--cache-change-warning): New variables.
(org-element-cache-merge-changes-threshold,
org-element--cache-status): Removed variables.
(org-element--cache-key, org-element--cache-generate-key,
org-element--cache-key-less-p, org-element--cache-find,
org-element--cache-set-timer, org-element--cache-process-request,
org-element--cache-submit-request, org-element--parse-to,
org-element--cache-interrupt-p, org-element--cache-put,
org-element--cache-active-p): New functions.
(org-element--cache-compare): Adapt to new keys in AVL tree.
(org-element--cache-pending-changes-p,
org-element--cache-cancel-changes, org-element--cache-mapc,
org-element-cache-get, org-element-cache-put): Removed functions.
(org-element--cache-before-change): Use new variables.
(org-element--cache-after-change): Renamed from
`org-element--cache-record-change'.
(org-element-cache-get): Change signature.
(org-element-cache-put): Rewrite function. Use new tools.
(org-element-cache-reset): Adapt to new variables.
(org-element--cache-sync): Rewrite function.
* lisp/ox.el (org-export--generate-copy-script): Do not copy through
new cache-related variables.
(org-export-ignored-local-variables): New variable.
* testing/lisp/test-org-element.el (test-org-element/cache): New test.
Now only the part of the cache that needs to be accessed is updated
synchronously. Otherwise, it happens on idle time.
2014-01-30 19:14:44 -05:00
|
|
|
|
(org-with-wide-buffer
|
|
|
|
|
(let ((origin (point)))
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(cond
|
|
|
|
|
;; Within blank lines at the beginning of buffer, return nil.
|
|
|
|
|
((bobp) nil)
|
|
|
|
|
;; Within blank lines right after a headline, return that
|
|
|
|
|
;; headline.
|
|
|
|
|
((org-with-limited-levels (org-at-heading-p))
|
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(org-element-headline-parser (point-max) t))
|
|
|
|
|
;; Otherwise parse until we find element containing ORIGIN.
|
|
|
|
|
(t
|
|
|
|
|
(when (org-element--cache-active-p)
|
|
|
|
|
(if (not org-element--cache) (org-element-cache-reset)
|
|
|
|
|
(org-element--cache-sync (current-buffer) origin)))
|
|
|
|
|
(org-element--parse-to origin))))))
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun org-element-context (&optional element)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
"Return smallest element or object around point.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
Return value is a list like (TYPE PROPS) where TYPE is the type
|
|
|
|
|
of the element or object and PROPS a plist of properties
|
|
|
|
|
associated to it.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
Possible types are defined in `org-element-all-elements' and
|
|
|
|
|
`org-element-all-objects'. Properties depend on element or
|
|
|
|
|
object type, but always include `:begin', `:end', `:parent' and
|
|
|
|
|
`:post-blank'.
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
As a special case, if point is right after an object and not at
|
|
|
|
|
the beginning of any other object, return that object.
|
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
Optional argument ELEMENT, when non-nil, is the closest element
|
|
|
|
|
containing point, as returned by `org-element-at-point'.
|
|
|
|
|
Providing it allows for quicker computation."
|
|
|
|
|
(catch 'objects-forbidden
|
|
|
|
|
(org-with-wide-buffer
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let* ((pos (point))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(element (or element (org-element-at-point)))
|
2016-02-11 03:47:54 -05:00
|
|
|
|
(type (org-element-type element))
|
|
|
|
|
(post (org-element-property :post-affiliated element)))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; If point is inside an element containing objects or
|
|
|
|
|
;; a secondary string, narrow buffer to the container and
|
|
|
|
|
;; proceed with parsing. Otherwise, return ELEMENT.
|
|
|
|
|
(cond
|
|
|
|
|
;; At a parsed affiliated keyword, check if we're inside main
|
|
|
|
|
;; or dual value.
|
2016-02-11 03:47:54 -05:00
|
|
|
|
((and post (< pos post))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(let ((case-fold-search t)) (looking-at org-element--affiliated-re))
|
|
|
|
|
(cond
|
|
|
|
|
((not (member-ignore-case (match-string 1)
|
|
|
|
|
org-element-parsed-keywords))
|
|
|
|
|
(throw 'objects-forbidden element))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
((< (match-end 0) pos)
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(narrow-to-region (match-end 0) (line-end-position)))
|
|
|
|
|
((and (match-beginning 2)
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(>= pos (match-beginning 2))
|
|
|
|
|
(< pos (match-end 2)))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(narrow-to-region (match-beginning 2) (match-end 2)))
|
|
|
|
|
(t (throw 'objects-forbidden element)))
|
|
|
|
|
;; Also change type to retrieve correct restrictions.
|
|
|
|
|
(setq type 'keyword))
|
|
|
|
|
;; At an item, objects can only be located within tag, if any.
|
|
|
|
|
((eq type 'item)
|
|
|
|
|
(let ((tag (org-element-property :tag element)))
|
2016-02-11 03:47:54 -05:00
|
|
|
|
(if (or (not tag) (/= (line-beginning-position) post))
|
|
|
|
|
(throw 'objects-forbidden element)
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(beginning-of-line)
|
|
|
|
|
(search-forward tag (line-end-position))
|
|
|
|
|
(goto-char (match-beginning 0))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(if (and (>= pos (point)) (< pos (match-end 0)))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(narrow-to-region (point) (match-end 0))
|
|
|
|
|
(throw 'objects-forbidden element)))))
|
|
|
|
|
;; At an headline or inlinetask, objects are in title.
|
|
|
|
|
((memq type '(headline inlinetask))
|
2016-10-28 18:38:15 -04:00
|
|
|
|
(let ((case-fold-search nil))
|
|
|
|
|
(goto-char (org-element-property :begin element))
|
|
|
|
|
(looking-at org-complex-heading-regexp)
|
|
|
|
|
(let ((end (match-end 4)))
|
|
|
|
|
(if (not end) (throw 'objects-forbidden element)
|
|
|
|
|
(goto-char (match-beginning 4))
|
|
|
|
|
(when (looking-at org-comment-string)
|
|
|
|
|
(goto-char (match-end 0)))
|
|
|
|
|
(if (>= (point) end) (throw 'objects-forbidden element)
|
|
|
|
|
(narrow-to-region (point) end))))))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; At a paragraph, a table-row or a verse block, objects are
|
|
|
|
|
;; located within their contents.
|
|
|
|
|
((memq type '(paragraph table-row verse-block))
|
|
|
|
|
(let ((cbeg (org-element-property :contents-begin element))
|
|
|
|
|
(cend (org-element-property :contents-end element)))
|
|
|
|
|
;; CBEG is nil for table rules.
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(if (and cbeg cend (>= pos cbeg)
|
|
|
|
|
(or (< pos cend) (and (= pos cend) (eobp))))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(narrow-to-region cbeg cend)
|
|
|
|
|
(throw 'objects-forbidden element))))
|
|
|
|
|
(t (throw 'objects-forbidden element)))
|
|
|
|
|
(goto-char (point-min))
|
org-element: Rewrite object parsing algorithm
* lisp/org-element.el (org-element-all-successors,
org-element-object-successor-alist): Remove variables.
(org-element-object-restrictions): Update value.
(org-element-bold-parser, org-element-code-parser,
org-element-entity-parser, org-element-export-snippet-parser,
org-element-footnote-reference-parser,
org-element-inline-babel-call-parser,
org-element-inline-src-block-parser, org-element-italic-parser,
org-element-latex-fragment-parser, org-element-line-break-parser,
org-element-link-parser, org-element-macro-parser,
org-element-radio-target-parser, org-element-statistics-cookie-parser,
org-element-strike-through-parser, org-element-subscript-parser,
org-element-superscript-parser, org-element-target-parser,
org-element-timestamp-parser, org-element-underline-parser,
org-element-verbatim-parser): Return nil when syntax at point is not
of the expected type.
(org-element-text-markup-successor,
org-element-latex-or-entity-successor,
org-element-export-snippet-successor,
org-element-footnote-reference-successor,
org-element-inline-babel-call-successor,
org-element-inline-src-block-successor,
org-element-line-break-successor, org-element-link-successor,
org-element-macro-successor, org-element-radio-target-successor,
org-element-statistics-cookie-successor,
org-element-sub/superscript-successor,
org-element-table-cell-successor, org-element-target-successor,
org-element-timestamp-successor,
org-element--get-next-object-candidates): Remove functions.
(org-element-timestamp-regexp, org-element--object-regexp): New
variables.
(org-element--object-lex): New function.
(org-element--parse-objects, org-element-context): Make use of new
tools.
This patch simplifies a lot object parsing and should improve
significantly `org-element-context''s speed.
http://permalink.gmane.org/gmane.emacs.orgmode/83872
2014-03-26 19:04:04 -04:00
|
|
|
|
(let ((restriction (org-element-restriction type))
|
|
|
|
|
(parent element)
|
2017-01-12 16:56:30 -05:00
|
|
|
|
last)
|
|
|
|
|
(catch 'exit
|
|
|
|
|
(while t
|
|
|
|
|
(let ((next (org-element--object-lex restriction)))
|
|
|
|
|
(when next (org-element-put-property next :parent parent))
|
|
|
|
|
;; Process NEXT, if any, in order to know if we need to
|
|
|
|
|
;; skip it, return it or move into it.
|
|
|
|
|
(if (or (not next) (> (org-element-property :begin next) pos))
|
|
|
|
|
(throw 'exit (or last parent))
|
|
|
|
|
(let ((end (org-element-property :end next))
|
|
|
|
|
(cbeg (org-element-property :contents-begin next))
|
|
|
|
|
(cend (org-element-property :contents-end next)))
|
|
|
|
|
(cond
|
|
|
|
|
;; Skip objects ending before point. Also skip
|
|
|
|
|
;; objects ending at point unless it is also the
|
|
|
|
|
;; end of buffer, since we want to return the
|
|
|
|
|
;; innermost object.
|
|
|
|
|
((and (<= end pos) (/= (point-max) end))
|
|
|
|
|
(goto-char end)
|
|
|
|
|
;; For convenience, when object ends at POS,
|
|
|
|
|
;; without any space, store it in LAST, as we
|
|
|
|
|
;; will return it if no object starts here.
|
|
|
|
|
(when (and (= end pos)
|
|
|
|
|
(not (memq (char-before) '(?\s ?\t))))
|
|
|
|
|
(setq last next)))
|
|
|
|
|
;; If POS is within a container object, move into
|
|
|
|
|
;; that object.
|
|
|
|
|
((and cbeg cend
|
|
|
|
|
(>= pos cbeg)
|
|
|
|
|
(or (< pos cend)
|
|
|
|
|
;; At contents' end, if there is no
|
|
|
|
|
;; space before point, also move into
|
|
|
|
|
;; object, for consistency with
|
|
|
|
|
;; convenience feature above.
|
|
|
|
|
(and (= pos cend)
|
|
|
|
|
(or (= (point-max) pos)
|
|
|
|
|
(not (memq (char-before pos)
|
|
|
|
|
'(?\s ?\t)))))))
|
|
|
|
|
(goto-char cbeg)
|
|
|
|
|
(narrow-to-region (point) cend)
|
|
|
|
|
(setq parent next)
|
|
|
|
|
(setq restriction (org-element-restriction next)))
|
|
|
|
|
;; Otherwise, return NEXT.
|
|
|
|
|
(t (throw 'exit next)))))))))))))
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2017-10-15 04:27:53 -04:00
|
|
|
|
(defun org-element-lineage (datum &optional types with-self)
|
2014-11-16 10:49:18 -05:00
|
|
|
|
"List all ancestors of a given element or object.
|
2014-11-16 07:13:52 -05:00
|
|
|
|
|
2017-10-15 04:27:53 -04:00
|
|
|
|
DATUM is an object or element.
|
2014-11-16 07:13:52 -05:00
|
|
|
|
|
2017-10-15 04:27:53 -04:00
|
|
|
|
Return ancestors from the closest to the farthest. When optional
|
|
|
|
|
argument TYPES is a list of symbols, return the first element or
|
|
|
|
|
object in the lineage whose type belongs to that list instead.
|
2014-11-16 07:13:52 -05:00
|
|
|
|
|
|
|
|
|
When optional argument WITH-SELF is non-nil, lineage includes
|
2017-10-15 04:27:53 -04:00
|
|
|
|
DATUM itself as the first element, and TYPES, if provided, also
|
2014-11-16 07:13:52 -05:00
|
|
|
|
apply to it.
|
|
|
|
|
|
2017-10-15 04:27:53 -04:00
|
|
|
|
When DATUM is obtained through `org-element-context' or
|
2014-11-16 07:13:52 -05:00
|
|
|
|
`org-element-at-point', only ancestors from its section can be
|
2017-10-15 04:27:53 -04:00
|
|
|
|
found. There is no such limitation when DATUM belongs to a full
|
2014-11-16 07:13:52 -05:00
|
|
|
|
parse tree."
|
2017-10-15 04:27:53 -04:00
|
|
|
|
(let ((up (if with-self datum (org-element-property :parent datum)))
|
2014-11-16 07:13:52 -05:00
|
|
|
|
ancestors)
|
|
|
|
|
(while (and up (not (memq (org-element-type up) types)))
|
|
|
|
|
(unless types (push up ancestors))
|
|
|
|
|
(setq up (org-element-property :parent up)))
|
|
|
|
|
(if types up (nreverse ancestors))))
|
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(defun org-element-nested-p (elem-A elem-B)
|
|
|
|
|
"Non-nil when elements ELEM-A and ELEM-B are nested."
|
|
|
|
|
(let ((beg-A (org-element-property :begin elem-A))
|
|
|
|
|
(beg-B (org-element-property :begin elem-B))
|
|
|
|
|
(end-A (org-element-property :end elem-A))
|
|
|
|
|
(end-B (org-element-property :end elem-B)))
|
|
|
|
|
(or (and (>= beg-A beg-B) (<= end-A end-B))
|
|
|
|
|
(and (>= beg-B beg-A) (<= end-B end-A)))))
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(defun org-element-swap-A-B (elem-A elem-B)
|
|
|
|
|
"Swap elements ELEM-A and ELEM-B.
|
|
|
|
|
Assume ELEM-B is after ELEM-A in the buffer. Leave point at the
|
|
|
|
|
end of ELEM-A."
|
|
|
|
|
(goto-char (org-element-property :begin elem-A))
|
|
|
|
|
;; There are two special cases when an element doesn't start at bol:
|
|
|
|
|
;; the first paragraph in an item or in a footnote definition.
|
|
|
|
|
(let ((specialp (not (bolp))))
|
|
|
|
|
;; Only a paragraph without any affiliated keyword can be moved at
|
|
|
|
|
;; ELEM-A position in such a situation. Note that the case of
|
|
|
|
|
;; a footnote definition is impossible: it cannot contain two
|
|
|
|
|
;; paragraphs in a row because it cannot contain a blank line.
|
Many small code improvements
* lisp/org-capture.el (org-capture-member): Make obsolete; the old
definition was identical to ‘org-capture-get’ anyway.
(org-capture-mode-map): Move the calls to ‘define-key’ up to where the
variable is defined.
(org-capture-mode-hook): Small docstring tweak.
(org-capture-mode): Fix typo in mode lighter.
(org-capture-set-target-location, org-capture-place-item):
(org-capture-place-plain-text, org-capture-narrow):
(org-capture-empty-lines-after):
(org-capture-import-remember-templates): ‘if’ without else -> ‘when’
* lisp/org-colview.el (org-columns-edit-value): Change an error to a
user-error.
(org-columns-uncompile-format): Improve docstring.
* lisp/org-compat.el (org-remove-from-invisibility-spec): Make
obsolete, the underlying emacs function exists since 1997, commit 31aa282e.
(org-in-invisibility-spec-p, org-count-lines): ‘if’ without else -> ‘when’.
* lisp/org-element.el (org-element-swap-A-B):
* lisp/org-entities.el (org-entities-create-table):
* lisp/org-list.el (org-insert-item):
* lisp/org-macs.el (org-with-point-at, org-base-buffer):
(org-preserve-local-variables, org-overlay-display):
(org-overlay-before-string): ‘if’ without else -> ‘when’.
* lisp/org-eshell.el (org-eshell-open): Fix docstring typo.
* lisp/org-pcomplete.el (pcomplete/org-mode/file-option/language):
(pcomplete/org-mode/file-option/startup):
(pcomplete/org-mode/file-option/options):
(pcomplete/org-mode/file-option/infojs_opt):
(pcomplete/org-mode/link, pcomplete/org-mode/tex):
(pcomplete/org-mode/todo, pcomplete/org-mode/searchhead):
(pcomplete/org-mode/tag, pcomplete/org-mode/prop): Avoid the formerly
misspelled ‘pcomplete-uniqify-list’ function. It has a defalias in
emacs >= 27; we add our own for older emacsen.
(pcomplete/org-mode/file-option/bind): ‘if’ without else -> ‘when’.
* lisp/org-protocol.el (org-protocol-capture):
(org-protocol-convert-query-to-plist): ‘if’ without else -> ‘when’.
(org-protocol-do-capture): Pacify byte compiler, simplify conditional
logic.
* lisp/org-table.el (org-table-create-with-table.el): Simplify conditional
logic.
(org-table-create, org-table-convert-region, org-table-next-field):
(org-table-beginning-of-field, org-table-end-of-field):
* lisp/org-w3m.el (org-w3m-copy-for-org-mode): ‘if’ without else ->
‘when’.
* lisp/org.el (org-babel-do-load-languages, org-previous-link):
(org-refile): Use ‘(foo ...)’ instead of ‘(funcall 'foo ...)’.
(org-add-log-note): Convert a long cond into a cl-case.
(org-priority): Improve docstring, show a deprecation warning if the
‘show’ argument is passed (which was previously silently ignored).
Also, use ?\s instead of ?\ as a character literal for space.
(org-fast-tag-insert): Fix docstring typo.
(org-fill-element): ‘if’ without else -> ‘when’.
(org-on-target-p): Remove ancient compatibility alias.
2018-05-09 21:02:35 -04:00
|
|
|
|
(when (and specialp
|
|
|
|
|
(or (not (eq (org-element-type elem-B) 'paragraph))
|
|
|
|
|
(/= (org-element-property :begin elem-B)
|
|
|
|
|
(org-element-property :contents-begin elem-B))))
|
|
|
|
|
(error "Cannot swap elements"))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; In a special situation, ELEM-A will have no indentation. We'll
|
|
|
|
|
;; give it ELEM-B's (which will in, in turn, have no indentation).
|
|
|
|
|
(let* ((ind-B (when specialp
|
|
|
|
|
(goto-char (org-element-property :begin elem-B))
|
2018-05-08 19:26:31 -04:00
|
|
|
|
(current-indentation)))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(beg-A (org-element-property :begin elem-A))
|
|
|
|
|
(end-A (save-excursion
|
|
|
|
|
(goto-char (org-element-property :end elem-A))
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(point-at-eol)))
|
|
|
|
|
(beg-B (org-element-property :begin elem-B))
|
|
|
|
|
(end-B (save-excursion
|
|
|
|
|
(goto-char (org-element-property :end elem-B))
|
|
|
|
|
(skip-chars-backward " \r\t\n")
|
|
|
|
|
(point-at-eol)))
|
2015-01-29 18:20:01 -05:00
|
|
|
|
;; Store inner overlays responsible for visibility status.
|
|
|
|
|
;; We also need to store their boundaries as they will be
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; removed from buffer.
|
|
|
|
|
(overlays
|
|
|
|
|
(cons
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(delq nil
|
|
|
|
|
(mapcar (lambda (o)
|
|
|
|
|
(and (>= (overlay-start o) beg-A)
|
|
|
|
|
(<= (overlay-end o) end-A)
|
|
|
|
|
(list o (overlay-start o) (overlay-end o))))
|
|
|
|
|
(overlays-in beg-A end-A)))
|
|
|
|
|
(delq nil
|
|
|
|
|
(mapcar (lambda (o)
|
|
|
|
|
(and (>= (overlay-start o) beg-B)
|
|
|
|
|
(<= (overlay-end o) end-B)
|
|
|
|
|
(list o (overlay-start o) (overlay-end o))))
|
|
|
|
|
(overlays-in beg-B end-B)))))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
;; Get contents.
|
|
|
|
|
(body-A (buffer-substring beg-A end-A))
|
|
|
|
|
(body-B (delete-and-extract-region beg-B end-B)))
|
|
|
|
|
(goto-char beg-B)
|
|
|
|
|
(when specialp
|
|
|
|
|
(setq body-B (replace-regexp-in-string "\\`[ \t]*" "" body-B))
|
Remove final parts of XEmacs compatibility code
* lisp/org-compat.el: Declare `org-add-hook', `org-decompose-region',
`org-detach-overlay', `org-file-equal-p', `org-float-time',
`org-indent-line-to', `org-indent-to-column', `org-looking-at-p',
`org-looking-back', `org-propertize', `org-re' and
`org-select-frame-set-input-focus' as obsolete.
(org-overlay-display, org-overlay-before-string, org-find-overlays):
Move to "org.el"
(org-xemacs-key-equivalents, org-xemacs-p): Remove variables.
(org-region-active-p): Drop XEmacs support.
(org-xemacs-without-invisibility): Remove macro.
(org-get-x-clipboard-compat): Remove function.
* lisp/org-macs.el (org-match-string-no-properties): Remove function.
* lisp/ob-core.el:
* lisp/org-agenda.el:
* lisp/org-archive.el:
* lisp/org-clock.el:
* lisp/org-colview.el:
* lisp/org-crypt.el:
* lisp/org-element.el:
* lisp/org-faces.el:
* lisp/org-feed.el:
* lisp/org-footnote.el:
* lisp/org-habit.el:
* lisp/org-id.el:
* lisp/org-indent.el:
* lisp/org-inlinetask.el:
* lisp/org-lint.el:
* lisp/org-list.el:
* lisp/org-mouse.el:
* lisp/org-pcomplete.el:
* lisp/org-src.el:
* lisp/org-table.el:
* lisp/org-timer.el:
* lisp/org.el:
* lisp/ox-ascii.el:
* lisp/ox-odt.el:
* lisp/ox.el:
* contrib/lisp/org-notify.el:
* contrib/lisp/ox-taskjuggler.el:
* contrib/lisp/org-wikinodes.el:
* testing/lisp/test-org-src.el:
* testing/lisp/test-org.el: Silence byte-compiler.
2016-05-26 06:18:00 -04:00
|
|
|
|
(indent-to-column ind-B))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(insert body-A)
|
|
|
|
|
;; Restore ex ELEM-A overlays.
|
|
|
|
|
(let ((offset (- beg-B beg-A)))
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(dolist (o (car overlays))
|
|
|
|
|
(move-overlay (car o) (+ (nth 1 o) offset) (+ (nth 2 o) offset)))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(goto-char beg-A)
|
|
|
|
|
(delete-region beg-A end-A)
|
|
|
|
|
(insert body-B)
|
|
|
|
|
;; Restore ex ELEM-B overlays.
|
2015-01-29 18:20:01 -05:00
|
|
|
|
(dolist (o (cdr overlays))
|
|
|
|
|
(move-overlay (car o) (- (nth 1 o) offset) (- (nth 2 o) offset))))
|
2014-01-04 18:37:37 -05:00
|
|
|
|
(goto-char (org-element-property :end elem-B)))))
|
org-element: Implement caching for dynamic parser
* lisp/org-element.el (org-element-use-cache, org-element--cache,
org-element--cache-sync-idle-time,
org-element--cache-merge-changes-threshold, org-element--cache-status,
org-element--cache-opening-line, org-element--cache-closing-line): New
variables.
(org-element-cache-reset, org-element--cache-pending-changes-p,
org-element--cache-push-change, org-element--cache-cancel-changes,
org-element--cache-get-key, org-element-cache-get,
org-element-cache-put, org-element--shift-positions,
org-element--cache-before-change, org-element--cache-record-change,
org-element--cache-sync): New functions.
(org-element-at-point, org-element-context): Use cache when possible.
* lisp/org.el (org-mode, org-set-modules): Reset cache.
* lisp/org-footnote.el (org-footnote-section): Reset cache.
* testing/lisp/test-org-element.el: Update tests.
This patch gives a boost to `org-element-at-point' and, to a lesser
extent, to `org-element-context'.
2013-10-27 06:09:17 -04:00
|
|
|
|
|
2013-10-27 06:03:05 -04:00
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
(provide 'org-element)
|
2012-10-02 02:50:46 -04:00
|
|
|
|
|
|
|
|
|
;; Local variables:
|
|
|
|
|
;; generated-autoload-file: "org-loaddefs.el"
|
|
|
|
|
;; End:
|
|
|
|
|
|
2012-07-28 01:02:21 -04:00
|
|
|
|
;;; org-element.el ends here
|