• Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    HTML
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A number of new custom blocks and link types for Emacs' Org-mode ^_^

A unified interface for Emacs' Org-mode block & link types (•̀ᴗ•́)و

Which is used to obtain 30 new custom blocks and 34 link types ¯\_(ツ)_/¯

Abstract

The aim is to write something once using Org-mode markup then generate the markup for multiple backends. That is, write once, generate many!

In particular, we are concerned with ‘custom’, or ‘special’, blocks which delimit how a particular region of text is supposed to be formatted according to the possible export backends. In some sense, special blocks are meta-blocks. Rather than writing text in, say, LaTeX environments using LaTeX commands or in HTML div's using HTML tags, we promote using Org-mode markup in special blocks —Org markup cannot be used explicitly within HTML or LaTeX environments.

Special blocks, like centre and quote, allow us to use Org-mode as the primary interface regardless of whether the final result is an HTML or PDF article; sometime we need to make our own special blocks to avoid a duplication of effort. However, this can be difficult and may require familiarity with relatively advanced ELisp concepts, such as macros and hooks; as such, users may not be willing to put in the time and instead use ad-hoc solutions.

We present a new macro, defblock, which is similar in-spirit to Lisp's standard except that where the latter defines functions, ours defines new special blocks for Emacs' Org-mode —as well as, simultaneously, defining new Org link types. Besides the macro, the primary contribution of this effort is an interface for special blocks that admits arguments and is familar to Org users —namely, we ‘try to reuse’ the familiar src-block interface, including header-args, but for special blocks.

It is hoped that the ease of creating custom special blocks will be a gateway for many Emacs users to start using Lisp.

**

A 5-page PDF covering ELisp fundamentals

** can be found here.

This article is featured in EmacsConf2020, with slides here: No pictures, instead we use this system to make the slides have a variety of styling information; i.e., we write Org and the result looks nice. “Look ma, no HTML required!”

img

Table of Contents

  1. Installation Instructions
  2. Minimal working example
  3. Bye!

The full article may be read as a PDF or as HTML —or visit the repo. Installation instructions are .

Installation Instructions

Manually or using quelpa:

;; ⟨0⟩ Download the org-special-block-extras.el file manually or using quelpa
(quelpa '(org-special-block-extras :fetcher github :repo
"alhassy/org-special-block-extras"))

;; ⟨1⟩ Have this always active in Org buffers
(add-hook #'org-mode-hook #'org-special-block-extras-mode)

;; ⟨1′⟩ Or use: “M-x org-special-block-extras-mode” to turn it on/off

Or with use-package:

(use-package org-special-block-extras
  :ensure t
  :hook (org-mode . org-special-block-extras-mode)
  ;; All relevant Lisp functions are prefixed ‘o-’; e.g., `o-docs-insert'.
  :custom
    (o-docs-libraries
     '("~/org-special-block-extras/documentation.org")
     "The places where I keep my ‘#+documentation’")))

Then, provide support for a new type of special block, say re-using the src blocks that, say, folds up all such blocks in HTML export, by declaring the following.

(o-defblock src (lang nil) (title nil exports nil file nil)
  "Fold-away all ‘src’ blocks as ‘<details>’ HTML export.
If a block has a ‘:title’, use that to title the ‘<details>’."
  (format "<details> <summary> %s </summary> <pre> %s </pre></details>"
          (or title (concat "Details; " lang))
          raw-contents))

Minimal working example

The following example showcases the prominent features of this library.

#+begin_parallel
[[color:orange][Are you excited to learn some Lisp?]] [[blue:Yes!]]

Pop-quiz: How does doc:apply work?
#+end_parallel

#+begin_details Answer
link-here:solution
Syntactically, ~(apply f '(x0 ... xN)) = (f x0 ... xN)~.

[[remark:Musa][Ain't that cool?]]

#+begin_spoiler aqua
That is, [[color:magenta][we can ((apply)) a function to a list of arguments!]]
#+end_spoiler

#+end_details

#+html: <br>
#+begin_box
octoicon:report Note that kbd:C-x_C-e evaluates a Lisp form!
#+end_box

#+LATEX_HEADER: \usepackage{multicol}
#+LATEX_HEADER: \usepackage{tcolorbox}
#+latex: In the LaTeX output, we have a glossary.

show:GLOSSARY

badge:Thanks|for_reading
tweet:https://github.com/alhassy/org-special-block-extras
badge:|buy_me_a coffee|gray|https://www.buymeacoffee.com/alhassy|buy-me-a-coffee

Here is what it looks like as HTML (left) and LaTeX (right):

img

The above section, , presents a few puzzles to get you comfortable with defblock ;-)

Bye!

More Repositories

1

emacs.d

My Emacs configuration, literately 😄
Emacs Lisp
384
star
2

ElispCheatSheet

Quick reference to the core language of Emacs ---Editor MACroS.
221
star
3

JavaScriptCheatSheet

Quick reference to the tremendously accessible high-level language of the web ^_^
207
star
4

CheatSheet

Pretty cheat sheets, or ``reference cards'', obtainable from Org files.
TeX
160
star
5

gentle-intro-to-reflection

A slow-paced introduction to reflection in Agda. ---Tactics!
Agda
85
star
6

next-700-module-systems

PhD research ;; What's the difference between a typeclass/trait and a record/class/struct? Nothing really, or so I argue.
HTML
80
star
7

OCamlCheatSheet

Reference of basic commands to get comfortable with OCaml.
77
star
8

CatsCheatSheet

This project is to contain a listing of common theorems in elementary category theory.
70
star
9

PrologCheatSheet

Basics of relational programming with Prolog —PROgramming in LOGic ^_^
Prolog
64
star
10

PythonCheatSheet

Quick reference to a tremendously accessible high-level language ---executable pseudocode!
45
star
11

repl-driven-development

Press "C-x C-e" to send any piece of code (in any language) to a REPL in the background, within Emacs!
Emacs Lisp
44
star
12

AgdaCheatSheet

Basics of the dependently-typed functional language Agda ^_^
Agda
37
star
13

ob-latex-as-png

Inline arbitrary LaTeX snippets as PNGs in Emacs (•̀ᴗ•́)و
Emacs Lisp
28
star
14

HaskellCheatSheet

A reference sheet for the basics of the mind-expanding Haskell language ^_^
27
star
15

holy-books

An Emacs interface to the Quran and the Bible: Org-mode links, tooltips, and Lisp look-ups
Emacs Lisp
23
star
16

FSharpCheatSheet

Reference sheet of the basics of F# ^_^
21
star
17

OzCheatSheet

Basics of the Oz/Mozart language ^_^
17
star
18

org-agda-mode

An Emacs mode for working with Agda code in an Org-mode like fashion, more or less.
Emacs Lisp
16
star
19

ClojureCheatSheet

Quick reference to a modern Lisp :-)
15
star
20

CoqCheatSheet

Reference sheet for the Coq language.
15
star
21

easy-extensibility

Making VSCode extensions ON-THE-FLY, without the ceremony of creating a new node project!
JavaScript
14
star
22

lf

A Language Features library for Emacs Lisp
Emacs Lisp
12
star
23

multistage-programming-taha

A Haskell implementation of the code within Walid Taha's ``A Gentle Introduction to Multi-stage Programming''
Haskell
10
star
24

alhassy.github.io

My personal blog (•̀ᴗ•́)و
HTML
7
star
25

RustCheatSheet

Rust ≈ C + OCaml
6
star
26

RubyCheatSheet

Reference of basic commands to get comfortable with Ruby ---Pure OOP!
HTML
6
star
27

AngularJSCheatSheet

A reference for the accessible JS framework that gives HTML: {{Variables}}, Conditionals, Loops, etc!
6
star
28

CCheatSheet

Basics of the tremendously ubiquitous C language that permeates most of computing!
3
star
29

interactive-way-to-c

Learning C program proving using Emacs --reminiscent of Coq proving with Proof General.
3
star
30

CalcCheck

Abridged lecture notes for CompSci/SfwrEng 2DM3 2020 and documentation on CalcCheck
2
star
31

design-patterns-higher-order

Notes & implementations of the code within Jeremy Gibbons' ``Design Patterns as Higher-Order Datatype-Generic Programs''; notably focus on multibranching trees and their BDS.
Java
2
star
32

delta-hacks-ML-workshop

DeltaHacks 2020 Workshop on Supervised Machine Learning
HTML
1
star
33

VueCheatSheet

A reference for the accessible JS framework that gives HTML: {{Variables}}, Conditionals, Loops, etc!
1
star
34

spacemacs

My Spacemacs Configuration ---Literately 😊
1
star