Add basic support for Literate Programming (#1370)

This commit is contained in:
Koustubh Sinkar 2022-06-13 08:44:05 +02:00 committed by GitHub
parent 109a04d62a
commit debb2d511f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 0 deletions

View file

@ -4,6 +4,7 @@
### New features
* Add a module to enable Literate Programming
* Add a Racket module.
* Add a Lua module.
* Auto-install `racket-mode` if needed.

View file

@ -0,0 +1,17 @@
# Prelude Literate Programming
Prelude's `prelude-literate-programming` module enables some
additional functionality for `org-mode` - the parent mode the native
markdown language of Emacs.
It also enables viewing and interaction of Python Notebooks within Emacs.
Here are some features it provides:
* syntax highlighting of code blocks in Emacs Orgmode
* executing code blocks and printing their output in the org file
* viewing python notebooks within Emacs
* Using Emacs to interact with python notebooks and other remote compute engines
It makes an attempt to enable [literate programming](http://www.literateprogramming.com/knuthweb.pdf)
from within emacs

View file

@ -0,0 +1,99 @@
;;; prelude-literate-programming.el --- Emacs Prelude: Literate Programming Support
;;
;; Author: Koustubh Sinkar
;; Version: 1.0.0
;; Keywords: literate programming
;; This file is not part of GNU Emacs.
;;; Commentary:
;; Prelude configuration for literate programming
;;; License:
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
;; as published by the Free Software Foundation; either version 3
;; of the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Code:
(defvar prelude-ipynb-packages
'(code-cells ; file mode for code-cells
ein ; Emacs Ipython Notebook (Jupyter Client)
elpy ; emacs python development environment
))
(defvar prelude-ob-packages
'(ob-async ; asynchronous execution of code-blocks
ob-ipython ; for python and ipython
ob-tmux ; for shell
ob-deno ; for javascript
ob-typescript
))
(prelude-require-packages
(append prelude-ipynb-packages prelude-ob-packages))
(setq prelude-ob-loader-list
'((python . t)
(ipython . t)
(shell . t)
(js . t)
(typescript . t)
;; Include other languages here...
))
;; Run/highlight code using babel in org-mode
(org-babel-do-load-languages
'org-babel-load-languages prelude-ob-loader-list)
;; Syntax highlight in #+BEGIN_SRC blocks
(setq org-src-fontify-natively t)
;; Don't prompt before running code in org
(setq org-confirm-babel-evaluate nil)
;; Fix an incompatibility between the ob-async and ob-ipython packages
(setq ob-async-no-async-languages-alist '("ipython"))
(defvar org-babel-language-list
'(ob-cfengine3
ob-clojurescript
ob-coffee
ob-dao
ob-diagrams
ob-elixir
ob-elm
ob-go
ob-graphql
ob-http
ob-ipython
ob-julia-vterm
ob-kotlin
ob-mongo
ob-prolog
ob-restclient
ob-rust
ob-sml
ob-sql-mode
ob-translate
ob-typescript
ob-uart
))
;;; TODO Write a function to enable org-babel for each function
(provide 'prelude-literate-programming)
;;; prelude-literate-programming.el ends here

View file

@ -79,6 +79,7 @@
(require 'prelude-js)
;; (require 'prelude-latex)
(require 'prelude-lisp) ;; Common setup for Lisp-like languages
;; (require 'prelude-literate-programming) ;; Setup for Literate Programming
(require 'prelude-lsp) ;; Base setup for the Language Server Protocol
;; (require 'prelude-lua)
;; (require 'prelude-ocaml)