From cfae0c5da1a188782136eb3a9219c34d285bd32a Mon Sep 17 00:00:00 2001 From: Heitor Augusto <44377258+HeitorAugustoLN@users.noreply.github.com> Date: Sat, 25 Jul 2026 08:44:02 +0000 Subject: [PATCH] Fix `:tangle` to support any file name or path Previously, `tokenizeOrgModeBabelElisp'` only recognized `yes` or `"yes"` as valid arguments for the `:tangle` header. This prevented the parser from correctly tangling blocks that specified an output file path (e.g., `:tangle init.el`). Update the `doTangle` logic to accept any string value (file name/path) as long as it is not explicitly `no` or `nil`. --- README.org | 21 ++++++++++++--------- default.nix | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/README.org b/README.org index fe425d9..b780bb2 100644 --- a/README.org +++ b/README.org @@ -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 @@ -120,8 +122,9 @@ 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) @@ -129,13 +132,13 @@ An Emacs Lisp reader in Nix. Yes, it's /necessary/. 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 diff --git a/default.nix b/default.nix index c90adff..71c1698 100644 --- a/default.nix +++ b/default.nix @@ -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'