Skip to content

Commit debb2d5

Browse files
authored
Add basic support for Literate Programming (#1370)
1 parent 109a04d commit debb2d5

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### New features
66

7+
* Add a module to enable Literate Programming
78
* Add a Racket module.
89
* Add a Lua module.
910
* Auto-install `racket-mode` if needed.

docs/modules/literate-programming.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Prelude Literate Programming
2+
3+
Prelude's `prelude-literate-programming` module enables some
4+
additional functionality for `org-mode` - the parent mode the native
5+
markdown language of Emacs.
6+
7+
It also enables viewing and interaction of Python Notebooks within Emacs.
8+
9+
Here are some features it provides:
10+
11+
* syntax highlighting of code blocks in Emacs Orgmode
12+
* executing code blocks and printing their output in the org file
13+
* viewing python notebooks within Emacs
14+
* Using Emacs to interact with python notebooks and other remote compute engines
15+
16+
It makes an attempt to enable [literate programming](http://www.literateprogramming.com/knuthweb.pdf)
17+
from within emacs
+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
;;; prelude-literate-programming.el --- Emacs Prelude: Literate Programming Support
2+
;;
3+
;; Author: Koustubh Sinkar
4+
;; Version: 1.0.0
5+
;; Keywords: literate programming
6+
7+
;; This file is not part of GNU Emacs.
8+
9+
;;; Commentary:
10+
11+
;; Prelude configuration for literate programming
12+
13+
;;; License:
14+
15+
;; This program is free software; you can redistribute it and/or
16+
;; modify it under the terms of the GNU General Public License
17+
;; as published by the Free Software Foundation; either version 3
18+
;; of the License, or (at your option) any later version.
19+
;;
20+
;; This program is distributed in the hope that it will be useful,
21+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
;; GNU General Public License for more details.
24+
;;
25+
;; You should have received a copy of the GNU General Public License
26+
;; along with GNU Emacs; see the file COPYING. If not, write to the
27+
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28+
;; Boston, MA 02110-1301, USA.
29+
30+
;;; Code:
31+
32+
(defvar prelude-ipynb-packages
33+
'(code-cells ; file mode for code-cells
34+
ein ; Emacs Ipython Notebook (Jupyter Client)
35+
elpy ; emacs python development environment
36+
))
37+
38+
(defvar prelude-ob-packages
39+
'(ob-async ; asynchronous execution of code-blocks
40+
ob-ipython ; for python and ipython
41+
ob-tmux ; for shell
42+
ob-deno ; for javascript
43+
ob-typescript
44+
))
45+
46+
47+
(prelude-require-packages
48+
(append prelude-ipynb-packages prelude-ob-packages))
49+
50+
(setq prelude-ob-loader-list
51+
'((python . t)
52+
(ipython . t)
53+
(shell . t)
54+
(js . t)
55+
(typescript . t)
56+
;; Include other languages here...
57+
))
58+
59+
;; Run/highlight code using babel in org-mode
60+
(org-babel-do-load-languages
61+
'org-babel-load-languages prelude-ob-loader-list)
62+
63+
;; Syntax highlight in #+BEGIN_SRC blocks
64+
(setq org-src-fontify-natively t)
65+
66+
;; Don't prompt before running code in org
67+
(setq org-confirm-babel-evaluate nil)
68+
69+
;; Fix an incompatibility between the ob-async and ob-ipython packages
70+
(setq ob-async-no-async-languages-alist '("ipython"))
71+
72+
(defvar org-babel-language-list
73+
'(ob-cfengine3
74+
ob-clojurescript
75+
ob-coffee
76+
ob-dao
77+
ob-diagrams
78+
ob-elixir
79+
ob-elm
80+
ob-go
81+
ob-graphql
82+
ob-http
83+
ob-ipython
84+
ob-julia-vterm
85+
ob-kotlin
86+
ob-mongo
87+
ob-prolog
88+
ob-restclient
89+
ob-rust
90+
ob-sml
91+
ob-sql-mode
92+
ob-translate
93+
ob-typescript
94+
ob-uart
95+
))
96+
;;; TODO Write a function to enable org-babel for each function
97+
98+
(provide 'prelude-literate-programming)
99+
;;; prelude-literate-programming.el ends here

sample/prelude-modules.el

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
(require 'prelude-js)
8080
;; (require 'prelude-latex)
8181
(require 'prelude-lisp) ;; Common setup for Lisp-like languages
82+
;; (require 'prelude-literate-programming) ;; Setup for Literate Programming
8283
(require 'prelude-lsp) ;; Base setup for the Language Server Protocol
8384
;; (require 'prelude-lua)
8485
;; (require 'prelude-ocaml)

0 commit comments

Comments
 (0)