Add scripts for dumping the org-mode ast to investigate how emacs parses various inputs.

This commit is contained in:
Tom Alexander 2023-03-19 14:07:23 -04:00
parent bf3464c65c
commit 4e7d7d3bcf
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 51 additions and 0 deletions

1
org_mode_samples/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.tree.txt

View File

@ -0,0 +1,8 @@
(defun org-dump-ast (outpath)
(let
((parsed-tree (format "%s" (org-element-parse-buffer))))
(with-temp-file outpath
(insert parsed-tree)
)
)
)

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
INPUT_FILE="$1"
OUTPUT_FILE="$2"
INIT_SCRIPT=$(cat <<EOF
(progn
(org-mode)
(org-dump-ast "$OUTPUT_FILE")
)
EOF
)
exec emacs -q --no-site-file --no-splash --batch --load "$DIR/common.el" --insert "$INPUT_FILE" --eval "$INIT_SCRIPT"

View File

@ -0,0 +1,22 @@
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
OUT=out
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
.PHONY: all
all: paragraphs.tree.txt
.PHONY: clean
clean:
> rm -rf *.tree.txt
%.tree.txt: %.org
> ../dump_org_ast.bash $< $@

View File

@ -0,0 +1,3 @@
1. foo
2. bar
(message "%s" (org-element-parse-buffer))