sml layer: move it to !lang, add bindings and convert README to org

This commit is contained in:
syl20bnr 2015-07-03 23:07:55 -04:00
parent 918c0cf4da
commit 225167465a
6 changed files with 105 additions and 89 deletions

View file

@ -0,0 +1,44 @@
#+TITLE: SML contribution layer for Spacemacs
[[file:img/sml.png]]
* Table of Contents :TOC@4:
- [[#description][Description]]
- [[#install][Install]]
- [[#key-bindings][Key Bindings]]
- [[#form-completion][Form Completion]]
- [[#repl][REPL]]
* Description
Adds support for the [[http://www.smlnj.org][SML]] programming language.
* Install
To use this contribution add it to your =~/.spacemacs=
#+BEGIN_SRC elisp
(setq-default dotspacemacs-configuration-layers '(sml))
#+END_SRC
* Key Bindings
** Form Completion
| Key Binding | Description |
|-------------+-------------------------------------------------------------------------------------------|
| ~M-SPC~ | Inserts a space and completes the form before the cursor. |
| ~\vert~ | Inserts a pipe and adds a double arrow or copies the function name. Generally just works. |
** REPL
| Key Binding | Description |
|-------------+-------------------------------------------------------------------|
| ~SPC m s b~ | Send buffer to REPL |
| ~SPC m s B~ | Send buffer to REPL and switch to REPL buffer in `insert state` |
| ~SPC m s f~ | Send function to REPL |
| ~SPC m s F~ | Send function to REPL and switch to REPL buffer in `insert state` |
| ~SPC m s i~ | Run the sml REPL or switch to it if the REPL is already running |
| ~SPC m s r~ | Send region to REPL |
| ~SPC m s R~ | Send region to REPL and switch to REPL buffer in `insert state` |
| ~SPC m s s~ | Run the sml REPL or switch to it if the REPL is already running |

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

View file

@ -0,0 +1,61 @@
;;; packages.el --- sml Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Keith Simmons & Contributors
;;
;; Author: Keith Simmons <keith@the-simmons.net>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq sml-packages
'(
sml-mode
ob-sml
))
(defun sml/init-sml-mode ()
(use-package sml-mode
:mode ("\\.\\(sml\\|sig\\)\\'" . sml-mode)
:defer t
:commands run-sml
:config
(progn
(defun spacemacs/sml-prog-proc-send-buffer-and-focus ()
"Send buffer to REPL and switch to it in `insert state'."
(interactive)
(sml-prog-proc-send-buffer t)
(evil-insert-state))
(defun spacemacs/sml-prog-proc-send-region-and-focus (start end)
"Send region to REPL and switch to it in `insert state'."
(interactive "r")
(sml-prog-proc-send-region start end t)
(evil-insert-state))
(defun spacemacs/sml-send-function-and-focus ()
"Send function at point to REPL and switch to it in `insert state'."
(interactive)
(sml-send-function t)
(evil-insert-state))
(evil-leader/set-key-for-mode 'sml-mode
;; REPL
"msb" 'sml-prog-proc-send-buffer
"msB" 'spacemacs/sml-prog-proc-send-buffer-and-focus
"msf" 'sml-send-function
"msF" 'spacemacs/sml-send-function-and-focus
"msi" 'run-sml
"msr" 'sml-prog-proc-send-region
"msR" 'spacemacs/sml-prog-proc-send-region-and-focus
"mss" 'run-sml)
(define-key sml-mode-map (kbd "M-<SPC>") 'sml-electric-space)
(define-key sml-mode-map (kbd "|") 'sml-electric-pipe))))
(defun sml/init-ob-sml ()
(use-package ob-sml
:defer t
:init
(org-babel-do-load-languages 'org-babel-do-load-languages '(sml . t))))

View file

@ -1,45 +0,0 @@
# SML contribution layer for Spacemacs
![logo_sml](img/sml.jpeg)
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
**Table of Contents**
- [SML contribution layer for Spacemacs](#sml-contribution-layer-for-spacemacs)
- [Description](#description)
- [Install](#install)
- [Key Bindings](#key-bindings)
- [Form Completion](#form-completion)
- [REPL](#repl)
<!-- markdown-toc end -->
## Description
Adds support for the [SML](http://www.smlnj.org) programming language.
## Install
To use this contribution add it to your `~/.spacemacs`
```elisp
(setq-default dotspacemacs-configuration-layers '(sml))
```
## Key Bindings
### Form Completion
Key Binding | Description
-----------------|------------------------------------------------------------------------------------------
<kbd>M-SPC</kbd> | Inserts a space and completes the form before the cursor.
<kbd>\|</kbd> | Inserts a \| and adds a double arrow or copies the function name. Generally just works.
### REPL
Key Binding | Description
----------------------|-----------------------------------------------------------------
<kbd>SPC m s b</kbd> | Send buffer to REPL and switch to REPL buffer in `insert state`
<kbd>SPC m s r</kbd> | Send region to REPL and switch to REPL buffer in `insert state`
<kbd>SPC m s s</kbd> | Run the sml REPL or switch to it if the REPL is already running

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

View file

@ -1,44 +0,0 @@
;;; packages.el --- sml Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Keith Simmons & Contributors
;;
;; Author: Keith Simmons <keith@the-simmons.net>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq sml-packages
'(
sml-mode
ob-sml
)
"List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")
(defvar sml-excluded-packages '()
"List of packages to exclude.")
(defun sml/init-sml-mode ()
(use-package sml-mode
:mode ("\\.\\(sml\\|sig\\)\\'" . sml-mode)
:defer t
:commands run-sml
:config
(progn
(evil-leader/set-key-for-mode 'sml-mode
;; REPL
"msb" 'sml-prog-proc-send-buffer
"msr" 'sml-prog-proc-send-region
"mss" 'run-sml)
(define-key sml-mode-map (kbd "M-<SPC>") 'sml-electric-space)
(define-key sml-mode-map (kbd "|") 'sml-electric-pipe))))
(defun sml/init-ob-sml ()
(use-package ob-sml
:config
(org-babel-do-load-languages
'org-babel-do-load-languages
'(sml . t))))