Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ An Emacs Lisp reader in Nix. Yes, it's /necessary/.
- *fromOrgModeBabelElisp* /text/ (string)

~fromElisp~, but for Org mode babel files. Runs ~fromElisp~ on the
result of tangling all Elisp code blocks with ~:tangle yes~
set. Tangling is done internally, not by Org mode.
result of tangling all Elisp code blocks that are set to be
tangled (e.g. ~:tangle yes~ or a file name/path). Tangling is done
internally, not by Org mode.

- *parseOrgModeBabelElisp* /text/ (string)

~parseElisp~, but for Org mode babel files. Runs ~parseElisp~ on the
result of tangling all Elisp code blocks with ~:tangle yes~
set. Tangling is done internally, not by Org mode.
result of tangling all Elisp code blocks that are set to be
tangled (e.g. ~:tangle yes~ or a file name/path). Tangling is done
internally, not by Org mode.

*** Other functions

Expand Down Expand Up @@ -120,22 +122,23 @@ An Emacs Lisp reader in Nix. Yes, it's /necessary/.

- *tokenizeOrgModeBabelElisp* /text/ (string)

Run tokenizeElisp' on all Elisp code blocks (with ~:tangle yes~
set) from Org mode babel text /text/.
Run tokenizeElisp' on all Elisp code blocks that are set to be
tangled (e.g. ~:tangle yes~ or a file name/path) from Org mode
babel text /text/.

- *tokenizeOrgModeBabelElisp'* /defaultArgs/ (attrs) /text/ (string)

An alternate version of ~tokenizeOrgModeBabelElisp~ which allows
the specification of default arguments for Org babel
headers. Currently only ~:tangle~ is supported.

- *parseOrgBabelElisp'* /defaultArgs/ (attrs) /text/ (string)
- *parseOrgModeBabelElisp'* /defaultArgs/ (attrs) /text/ (string)

An alternate version of ~parseOrgBabelElisp~ which allows
An alternate version of ~parseOrgModeBabelElisp~ which allows
the specification of default arguments for Org babel
headers. Currently only ~:tangle~ is supported.

- *fromOrgBabelElisp'* /defaultArgs/ (attrs) /text/ (string)
- *fromOrgModeBabelElisp'* /defaultArgs/ (attrs) /text/ (string)

An alternate version of ~fromOrgModeBabelElisp~ which allows
the specification of default arguments for Org babel
Expand Down
18 changes: 12 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -717,21 +717,27 @@ let
}
(stringToCharacters text)).acc;

# Run tokenizeElisp' on all Elisp code blocks (with `:tangle yes`
# set) from an Org mode babel text. If the block doesn't have a
# `tangle` attribute, it's determined by `defaultArgs`.
# Run tokenizeElisp' on all Elisp code blocks that are set to be
# tangled from an Org mode babel text. A block is tangled if its
# `:tangle` argument is `yes`, `t`, or any file name/path string. It
# is skipped if the argument is `no` or `nil`. If the block
# doesn't have a `tangle` attribute, it's determined by `defaultArgs`.
tokenizeOrgModeBabelElisp' = let
isElisp = lib.flip elem [ "elisp" "emacs-lisp" ];
doTangle = lib.flip elem [ "yes" ''"yes"'' ];
in defaultArgs: text:
let
codeBlocks =
filter
(block:
let
tangle = toLower (block.flags.":tangle" or defaultArgs.":tangle" or "no");
tangle = block.flags.":tangle" or defaultArgs.":tangle" or "no";
language = toLower block.language;
in isElisp language && doTangle tangle)
doTangle =
if isString tangle then
toLower tangle != "no"
else
tangle != [];
in isElisp language && doTangle)
(parseOrgModeBabel text);
in
foldl'
Expand Down