初稿: 2018-08-09 Thu 09:45
最終更新日: 2018-12-14 Fri 20:44
ホーム | 文書トップ | 目次

org-element-parse-buffer
org記法のパース

 1: (defun org-element-parse-buffer (&optional granularity visible-only)
 2:   "Recursively parse the buffer and return structure.
 3: If narrowing is in effect, only parse the visible part of the
 4: buffer.
 5: 
 6: Optional argument GRANULARITY determines the depth of the
 7: recursion.  It can be set to the following symbols:
 8: 
 9: `headline'          Only parse headlines.
10: `greater-element'   Don't recurse into greater elements except
11:             headlines and sections.  Thus, elements
12:             parsed are the top-level ones.
13: `element'           Parse everything but objects and plain text.
14: `object'            Parse the complete buffer (default).
15: 
16: When VISIBLE-ONLY is non-nil, don't parse contents of hidden
17: elements.
18: 
19: An element or object is represented as a list with the
20: pattern (TYPE PROPERTIES CONTENTS), where :
21: 
22:   TYPE is a symbol describing the element or object.  See
23:   `org-element-all-elements' and `org-element-all-objects' for an
24:   exhaustive list of such symbols.  One can retrieve it with
25:   `org-element-type' function.
26: 
27:   PROPERTIES is the list of attributes attached to the element or
28:   object, as a plist.  Although most of them are specific to the
29:   element or object type, all types share `:begin', `:end',
30:   `:post-blank' and `:parent' properties, which respectively
31:   refer to buffer position where the element or object starts,
32:   ends, the number of white spaces or blank lines after it, and
33:   the element or object containing it.  Properties values can be
34:   obtained by using `org-element-property' function.
35: 
36:   CONTENTS is a list of elements, objects or raw strings
37:   contained in the current element or object, when applicable.
38:   One can access them with `org-element-contents' function.
39: 
40: The Org buffer has `org-data' as type and nil as properties.
41: `org-element-map' function can be used to find specific elements
42: or objects within the parse tree.
43: 
44: This function assumes that current major mode is `org-mode'."
45:   (save-excursion
46:     (goto-char (point-min))
47:     (org-skip-whitespace)
48:     (org-element--parse-elements
49:      (point-at-bol) (point-max)
50:      ;; Start in `first-section' mode so text before the first
51:      ;; headline belongs to a section.
52:      'first-section nil granularity visible-only (list 'org-data nil))))

日付: 2018-08-09 Thu 09:45

著者: conao

Created: 2018-12-14 Fri 21:04

Validate