├── .gitignore
├── .travis.yml
├── Cask
├── README.md
├── common-lisp-snippets.el
└── snippets
└── lisp-mode
├── assert
├── case
├── ccase
├── cond
├── ctypecase
├── defclass
├── defconstant
├── defgeneric
├── define-compiler-macro
├── define-condition
├── define-symbol-macro
├── defmacro
├── defmethod
├── defpackage
├── defparameter
├── defstruct
├── defsystem
├── deftype
├── defun
├── defvar
├── destructuring-bind
├── do
├── do_
├── dolist
├── dotimes
├── ecase
├── etypecase
├── flet
├── format
├── gnugpl
├── if
├── in-package
├── labels
├── let
├── mapc
├── mapcar
├── mitlic
└── typecase
/.gitignore:
--------------------------------------------------------------------------------
1 | *-autoloads.el
2 | *.elc
3 | *~
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | env:
2 | matrix:
3 | - EVM_EMACS=emacs-24.5-travis
4 | - EVM_EMACS=emacs-25.3-travis
5 | - EVM_EMACS=emacs-26.1-travis
6 |
7 | before_install:
8 | - git clone https://github.com/rejeep/evm.git $HOME/.evm
9 | - export PATH=$HOME/.evm/bin:$PATH
10 | - evm config path /tmp
11 | - evm install $EVM_EMACS --use --skip
12 |
13 | install:
14 | - curl -fsSkL https://raw.github.com/cask/cask/master/go | python
15 | - export PATH=/home/travis/.cask/bin:$PATH
16 | - cask install
17 |
18 | script:
19 | - cask build 2>&1 >/dev/null | grep "Error" | wc -l | grep "0"
20 |
21 | notifications:
22 | email: false
23 |
--------------------------------------------------------------------------------
/Cask:
--------------------------------------------------------------------------------
1 | (source gnu)
2 | (source melpa)
3 |
4 | (package-file "common-lisp-snippets.el")
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Yasnippets for Common Lisp
2 |
3 | [](http://www.gnu.org/licenses/gpl-3.0.txt)
4 | [](https://melpa.org/#/common-lisp-snippets)
5 | [](https://travis-ci.org/mrkkrp/common-lisp-snippets)
6 |
7 | This is a collection of Yasnippets for Common Lisp. It includes snippets for
8 | top-level forms and (as a bonus) headers for popular free-software licenses:
9 | GNU GPL and MIT License.
10 |
11 | ## Installation
12 |
13 | To use these snippets you need to install
14 | the [Yasnippet](https://github.com/capitaomorte/yasnippet) package. Once you
15 | have Yasnippet installed, place contents of this repository on your load
16 | path, so Emacs can see it and add the following to your configuration file:
17 |
18 | ```emacs-lisp
19 | (require 'common-lisp-snippets)
20 | ```
21 |
22 | It's now available via MELPA: M-x package-install RET
23 | common-lisp-snippets RET—and you are done!
24 |
25 | ## Usage
26 |
27 | To insert a snippet, type its name and press ↹ Tab or
28 | C-i, for example:
29 |
30 | ```common-lisp
31 | defsystem
32 | ⇒
33 | (asdf:defsystem :system-name
34 | :version "0.1.0"
35 | :description "description"
36 | :author "user-full-name "
37 | :serial t
38 | :license "GNU GPL, version 3"
39 | :components ((:file "file.lisp"))
40 | :depends-on (#:alexandria))
41 |
42 | ```
43 |
44 | …you can move through the fields pressing ↹ Tab and edit or
45 | delete them. Some fields, like `:author` try to guess their values.
46 |
47 | As a special bonus, there are snippets to insert headers of files that
48 | contain information about the software license (`gnugpl` and `mitlic`), they
49 | are smart too.
50 |
51 | ## Contributions
52 |
53 | There are some stylistic conventions:
54 |
55 | * Name files without extensions.
56 |
57 | * Start every file with this preamble:
58 |
59 | ```
60 | # -*- mode: snippet -*-
61 | # contributor: your name
62 | # name: readable name of the snippet
63 | # key: what user needs to enter
64 | # --
65 | ```
66 |
67 | The first line is needed to activate mode for snippet editing in Emacs,
68 | Yasnippet ships with it.
69 |
70 | * Make sure your files don't have an empty line at the end. This is
71 | important, because it will be inserted when your snippet is expanded.
72 | `snippet-mode` takes care of this, setting `require-final-newline` to
73 | `nil`, just make sure you haven't put it there manually.
74 |
75 | ## License
76 |
77 | Copyright © 2015–2017 Mark Karpov
78 |
79 | Distributed under GNU GPL, version 3.
80 |
--------------------------------------------------------------------------------
/common-lisp-snippets.el:
--------------------------------------------------------------------------------
1 | ;;; common-lisp-snippets.el --- Yasnippets for Common Lisp -*- lexical-binding: t; -*-
2 | ;;
3 | ;; Copyright © 2015–2017 Mark Karpov
4 | ;;
5 | ;; Author: Mark Karpov
6 | ;; URL: https://github.com/mrkkrp/common-lisp-snippets
7 | ;; Version: 0.1.2
8 | ;; Package-Requires: ((yasnippet "0.8.0"))
9 | ;; Keywords: snippets
10 | ;;
11 | ;; This file is not part of GNU Emacs.
12 | ;;
13 | ;; This program is free software: you can redistribute it and/or modify it
14 | ;; under the terms of the GNU General Public License as published by the
15 | ;; Free Software Foundation, either version 3 of the License, or (at your
16 | ;; option) any later version.
17 | ;;
18 | ;; This program is distributed in the hope that it will be useful, but
19 | ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
21 | ;; Public License for more details.
22 | ;;
23 | ;; You should have received a copy of the GNU General Public License along
24 | ;; with this program. If not, see .
25 |
26 | ;;; Commentary:
27 |
28 | ;; This is a collection of Yasnippets for Common Lisp. It includes snippets
29 | ;; for top-level forms and (as a bonus) headers for popular free-software
30 | ;; licenses: GNU GPL and MIT License.
31 |
32 | ;;; Code:
33 |
34 | (require 'yasnippet)
35 |
36 | (defvar common-lisp-snippets-root
37 | (file-name-directory (or load-file-name (buffer-file-name)))
38 | "Root directory of Common Lisp snippets.")
39 |
40 | ;;;###autoload
41 | (defun common-lisp-snippets-initialize ()
42 | "Initialize Common Lisp snippets, so Yasnippet can see them."
43 | (let ((dir (expand-file-name "snippets" common-lisp-snippets-root)))
44 | (when (boundp 'yas-snippet-dirs)
45 | (add-to-list 'yas-snippet-dirs dir t))
46 | (yas-load-directory dir)))
47 |
48 | ;;;###autoload
49 | (eval-after-load 'yasnippet
50 | '(common-lisp-snippets-initialize))
51 |
52 | (provide 'common-lisp-snippets)
53 |
54 | ;;; common-lisp-snippets.el ends here
55 |
--------------------------------------------------------------------------------
/snippets/lisp-mode/assert:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Toni Querol
3 | # name: assert
4 | # key: assert
5 | # --
6 | (assert ${1:assertion} (${2:vars-to-change})
7 | "${3:string}"
8 | ${4:mentioned-vars})
--------------------------------------------------------------------------------
/snippets/lisp-mode/case:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: case
4 | # key: case
5 | # --
6 | (case ${1:key-form}
7 | (${2:match} ${3:result})${4:
8 | (t ${5:otherwise})})
--------------------------------------------------------------------------------
/snippets/lisp-mode/ccase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ccase
4 | # key: ccase
5 | # --
6 | (ccase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/cond:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: cond
4 | # key: cond
5 | # --
6 | (cond (${1:test} ${2:then})
7 | (t ${3:else}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/ctypecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ctypecase
4 | # key: ctypecase
5 | # --
6 | (ctypecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/defclass:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defclass
4 | # key: defclass
5 | # --
6 | (defclass ${1:name} (${2:parents})
7 | ($0)${3:
8 | (:documentation "${4:doc}")})
--------------------------------------------------------------------------------
/snippets/lisp-mode/defconstant:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defconstant
4 | # key: defconstant
5 | # --
6 | (defconstant +${1:name}+ ${2:nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defgeneric:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defgeneric
4 | # key: defgeneric
5 | # --
6 | (defgeneric ${1:name} (${2:args})${3:
7 | (:documentation "${4:doc}")})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-compiler-macro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-compiler-macro
4 | # key: define-compiler-macro
5 | # --
6 | (define-compiler-macro ${1:name} (${2:args})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-condition:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-condition
4 | # key: define-condition
5 | # --
6 | (define-condition ${1:name} (${2:parents})
7 | ($0)${3:
8 | (:documentation "${4:doc}")})
--------------------------------------------------------------------------------
/snippets/lisp-mode/define-symbol-macro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: define-symbol-macro
4 | # key: define-symbol-macro
5 | # --
6 | (define-symbol-macro ${1:name} ${2:expansion})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defmacro:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defmacro
4 | # key: defmacro
5 | # --
6 | (defmacro ${1:name} (${2:args }${3:&body body})${4:
7 | "${5:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defmethod:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defmethod
4 | # key: defmethod
5 | # --
6 | (defmethod ${1:name} (${2:args})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defpackage:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defpackage
4 | # key: defpackage
5 | # --
6 | (defpackage :${1:package}${2:
7 | (:nicknames ${3:nicks})}${4:
8 | (:use ${5:packages})}${6:
9 | (:shadow ${7:packages})}${8:
10 | (:export ${9:packages})}${10:
11 | (:documentation "${11:doc}")})
12 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defparameter:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defparameter
4 | # key: defparameter
5 | # --
6 | (defparameter *${1:name}* ${2:nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/defstruct:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defstruct
4 | # key: defstruct
5 | # --
6 | (defstruct ${1:name}${2:
7 | "${3:doc}"}
8 | ($0))
--------------------------------------------------------------------------------
/snippets/lisp-mode/defsystem:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defsystem
4 | # key: defsystem
5 | # --
6 | (asdf:defsystem :${1:system}${2:
7 | :version "${3:0.1.0}"}${4:
8 | :description "${5:description}"}${6:
9 | :author "${7:`user-full-name` <`user-mail-address`>}"}${8:
10 | :serial t}${10:
11 | :license "${11:GNU GPL, version 3}"}${12:
12 | :components (${13:(:file "file.lisp")})}${14:
13 | :depends-on (${15:#:alexandria})})
14 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/deftype:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: deftype
4 | # key: deftype
5 | # --
6 | (deftype ${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defun:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defun
4 | # key: defun
5 | # --
6 | (defun ${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/defvar:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: defvar
4 | # key: defvar
5 | # --
6 | (defvar *${1:name}*${2: nil}${3:
7 | "${4:doc}"})
8 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/destructuring-bind:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: destructuring-bind
4 | # key: dbind
5 | # --
6 | (destructuring-bind (${1:vars}) ${2:value}
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/do:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: do
4 | # key: do
5 | # --
6 | (do (${1:vars})
7 | (${2:end-test-form}${3: result})
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/do_:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: do*
4 | # key: do*
5 | # --
6 | (do* (${1:vars})
7 | (${2:end-test-form}${3: result})
8 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/dolist:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: dolist
4 | # key: dolist
5 | # --
6 | (dolist (${1:var} ${2:list}${3: result})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/dotimes:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: dotimes
4 | # key: dotimes
5 | # --
6 | (dotimes (${1:var} ${2:count}${3: result})
7 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/ecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: ecase
4 | # key: ecase
5 | # --
6 | (ecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/etypecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: etypecase
4 | # key: etypecase
5 | # --
6 | (etypecase ${1:key-form}
7 | (${2:match} ${3:result}))
--------------------------------------------------------------------------------
/snippets/lisp-mode/flet:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Toni Querol
3 | # name: flet
4 | # key: flet
5 | # --
6 | (flet ((${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | ${5:body}))
9 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/format:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: format
4 | # key: format
5 | # --
6 | (format ${1:nil} ${2:str} $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/gnugpl:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: GNU GPL 3 Header
4 | # key: gnugpl
5 | # --
6 | ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; -*-
7 | ;;;
8 | ;;; ${1:description}
9 | ;;;
10 | ;;; Copyright © ${2:`(format-time-string "%Y")`} `user-full-name` <`user-mail-address`>
11 | ;;;
12 | ;;; ${3:This program$(prog1 yas-text (fill-paragraph))} is free software:
13 | ;;; you can redistribute it and/or modify it under the terms of the GNU
14 | ;;; General Public License as published by the Free Software Foundation,
15 | ;;; either version 3 of the License, or (at your option) any later version.
16 | ;;;
17 | ;;; ${3:$(prog1 yas-text (fill-paragraph))} is distributed in the hope that
18 | ;;; it will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 | ;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | ;;; GNU General Public License for more details.
21 | ;;;
22 | ;;; You should have received a copy of the GNU General Public License along
23 | ;;; with this program. If not, see .
24 |
25 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/if:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: if
4 | # key: if
5 | # --
6 | (if ${1:test} ${2:then}${3: else})
7 |
--------------------------------------------------------------------------------
/snippets/lisp-mode/in-package:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: in-package
4 | # key: in-package
5 | # --
6 | (in-package #:${1:package})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/labels:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Toni Querol
3 | # name: labels
4 | # key: labels
5 | # --
6 | (labels ((${1:name} (${2:args})${3:
7 | "${4:doc}"}
8 | ${5:body}))
9 | $0)
--------------------------------------------------------------------------------
/snippets/lisp-mode/let:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # name: let
3 | # key: let
4 | # --
5 | (let ((${1:var} ${2:val}))
6 | $0)
7 |
--------------------------------------------------------------------------------
/snippets/lisp-mode/mapc:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: mapc
4 | # key: mapc
5 | # --
6 | (mapc ${1:fnc} ${2:list})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/mapcar:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: mapcar
4 | # key: mapcar
5 | # --
6 | (mapcar ${1:fnc} ${2:list})
7 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/mitlic:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: MIT License Header
4 | # key: mitlic
5 | # --
6 | ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; -*-
7 | ;;;
8 | ;;; ${1:description}
9 | ;;;
10 | ;;; Copyright © ${2:`(format-time-string "%Y")`} `user-full-name` <`user-mail-address`>
11 | ;;;
12 | ;;; Permission is hereby granted, free of charge, to any person obtaining a
13 | ;;; copy of this software and associated documentation files (the
14 | ;;; "Software"), to deal in the Software without restriction, including
15 | ;;; without limitation the rights to use, copy, modify, merge, publish,
16 | ;;; distribute, sublicense, and/or sell copies of the Software, and to
17 | ;;; permit persons to whom the Software is furnished to do so, subject to
18 | ;;; the following conditions:
19 | ;;;
20 | ;;; The above copyright notice and this permission notice shall be included
21 | ;;; in all copies or substantial portions of the Software.
22 | ;;;
23 | ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 | ;;; OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 | ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 | ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 | ;;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 | ;;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 | ;;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 |
31 | $0
--------------------------------------------------------------------------------
/snippets/lisp-mode/typecase:
--------------------------------------------------------------------------------
1 | # -*- mode: snippet -*-
2 | # contributor: Mark Karpov
3 | # name: typecase
4 | # key: typecase
5 | # --
6 | (typecase ${1:key-form}
7 | (${2:match} ${3:result})${4:
8 | (t ${5:otherwise})})
--------------------------------------------------------------------------------