Permalink
Browse files

Add project archetype for snippets package

  • Loading branch information...
1 parent d7ab6e1 commit 316c6604171079050103da04c60d79f67fd47823 @magnars committed Jun 24, 2013
@@ -0,0 +1,13 @@
+(defun create-emacs-snippets (target name website major-mode)
+ (interactive "sSnippets for (short name): \nsSnippets for (full name): \nsWebsite: \naMajor mode: ")
+ (pa-with-new-project (format "%s-snippets" target) "emacs-snippets"
+ ((cons "__target__" target)
+ (cons "__name__" name)
+ (cons "__website__" website)
+ (cons "__major-mode__" (format "%S" major-mode))
+ (cons "__year__" (format-time-string "%Y")))
+ (pa-sh "carton package")))
+
+(pa-declare-project-archetype "emacs-snippets" 'create-emacs-snippets)
+
+(provide 'emacs-snippets-archetype)
@@ -0,0 +1,3 @@
+(source "melpa" "http://melpa.milkbox.net/packages/")
+
+(package-file "__target__-snippets.el")
@@ -0,0 +1,45 @@
+# __target__-snippets.el
+
+Yasnippets for [__name__](__website__).
+
+## Installation
+
+I highly recommend installing __target__-snippets through elpa.
+
+It's available on [melpa](http://melpa.milkbox.net/):
+
+ M-x package-install __target__-snippets
+
+You can also install the dependencies on your own, and just dump
+__target__-snippets in your path somewhere:
+
+ - <a href="https://github.com/magnars/s.el">s.el</a>
+ - <a href="https://github.com/magnars/dash.el">dash.el</a>
+
+## Usage
+
+TODO: Write some stuff about available snippets.
+
+## Setup
+
+Well, you'll have to require it. You'll also need
+[yasnippets](https://github.com/capitaomorte/yasnippet) of course.
+
+ (require '__target__-snippets)
+
+## License
+
+Copyright (C) __year__ Magnar Sveen
+
+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 this program. If not, see <http://www.gnu.org/licenses/>.
@@ -0,0 +1,71 @@
+;;; __target__-snippets.el --- Yasnippets for __name__
+
+;; Copyright (C) __year__ Magnar Sveen
+
+;; Author: Magnar Sveen <magnars@gmail.com>
+;; Keywords: snippets
+;; Version: 0.1.0
+;; Package-Requires: ((s "1.4.0") (dash "1.2.0"))
+
+;; 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Yasnippets for [__name__](__website__).
+;;
+;; Please visit README.md for more commentary.
+
+;;; Code:
+
+;;;###autoload
+(defun __target__-snippets-show-docs-at-point ()
+ (interactive)
+ (__target__-snippets/show-docs (__target__-snippets/closest-__target__-identifer)))
+
+(defvar __target__-snippets/docstrings
+ '(("key" . "docstring")
+ ("key" . "docstring")))
+
+(defvar __target__-snippets/docstrings-regexp
+ (regexp-opt (-map 'car __target__-snippets/docstrings)))
+
+(defun -aget (alist key)
+ (cdr (assoc key alist)))
+
+(defun __target__-snippets/show-docs (id)
+ (message (-aget __target__-snippets/docstrings id))
+ nil)
+
+(defun __target__-snippets/closest-__target__-identifer ()
+ (save-excursion
+ (search-forward " ")
+ (search-backward-regexp __target__-snippets/docstrings-regexp)
+ (match-string-no-properties 0)))
+
+(setq __target__-snippets-root (file-name-directory (or load-file-name
+ (buffer-file-name))))
+
+;;;###autoload
+(defun __target__-snippets-initialize ()
+ (let ((snip-dir (expand-file-name "snippets" __target__-snippets-root)))
+ (when (boundp 'yas-snippet-dirs)
+ (add-to-list 'yas-snippet-dirs snip-dir t))
+ (yas/load-directory snip-dir)))
+
+;;;###autoload
+(eval-after-load "yasnippet"
+ '(__target__-snippets-initialize))
+
+(provide '__target__-snippets)
+;;; __target__-snippets.el ends here
@@ -0,0 +1,6 @@
+# -*- mode: snippet -*-
+# name: example
+# key: example
+# --
+example`
+(__target__-snippets/show-docs "example")`

0 comments on commit 316c660

Please sign in to comment.