[[!meta title="Powering-up Special Blocks"]] [[!meta copyright="Copyright © 2020 Musa Al-hassy"]] Back to the [[schedule]] Previous: On why most of the best features in eev look like 5-minute hacks Next: Incremental Parsing with emacs-tree-sitter # Powering-up Special Blocks Sunday, Nov 29 2020, 9:33 AM - 9:53 AM Musa Al-hassy Users will generally only make use of a few predefined \`special blocks', such as \`example, centre, quote', and will not bother with the effort required to make new ones. When new encapsulating notions are required, users will either fallback on HTML or LaTeX specific solutions, usually littered with \`#+ATTR' clauses to pass around configurations or parameters. Efforts have been exerted to mitigate the trouble of producing new special blocks. However, the issue of passing parameters is still handled in a clumsy fashion; e.g., by having parameters be expressed in a special block's content using specific keywords. We present a novel approach to making special blocks in a familiar fashion and their use also in a familiar fashion. We achieve the former by presenting \`\`defblock'', an anaphoric macro exceedingly similar to \`\`defun'', and for the latter we mimic the usual \`\`src''-block syntax for argument passing to support special blocks. For instance, here is a sample declaration. (defblock stutter () (reps 2) "Output the CONTENTS of the block REPS many times" (org-parse (s-repeat reps contents))) Here is an invocation that passes an *optional* argument; which defaults to 2 when not given.
Emacs for the win ⌣̈