I use org-babel with [:noweb] argument for literate programming.
But soon I find the macro functionality is absent in this system.
For example, I have
#+name: example
#+BEGIN_SRC ruby :tangle yes :noweb yes
dir = "~"
Find.find(dir) do |path|
if <<path is a file>>
puts path
end
end
#+END_SRC
#+name: path is a file
#+BEGIN_SRC ruby :tangle no :noweb yes
FileTest.file?(path)
#+END_SRC
But with macro functionality, the program can be more flexible:
#+name: example
#+BEGIN_SRC ruby :tangle yes :noweb yes
dir = "~"
Find.find(dir) do |path|
if <<is_a_file?(path)>>
puts path
end
end
#+END_SRC
#+name: is_a_file?
#+BEGIN_SRC ruby :tangle no :noweb yes :noweb-macro file-path
FileTest.file?(file-path)
#+END_SRC
In [is_a_file?] block, I use argument [:noweb-macro] to indicate this block
is a macro with
one argument.
When expanding block [example], <<is_a_file?(path)>> will be expanded to
[FileTest.file?(path)].
As a result, The src-block [is_a_file?] achieves better abstraction.
I have tried native macro replacement of org({{{is_a_file?(path)}}}), but
it doesn't work well in src-block.
So, is this feature valuable?