Skip to content

Commit c63fb85

Browse files
committed
splitting yasnippet into starter-kit-yasnippet.org
This way yasnippet may be optionally loaded, but is not required by default.
1 parent 9ce2397 commit c63fb85

File tree

2 files changed

+62
-48
lines changed

2 files changed

+62
-48
lines changed

starter-kit-yasnippet.org

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#+TITLE: Starter Kit Eshell
2+
#+OPTIONS: toc:nil num:nil ^:nil
3+
4+
This is part of the [[file:starter-kit.org][Emacs Starter Kit]].
5+
6+
* Starter Kit Eshell
7+
[[http://code.google.com/p/yasnippet/][yasnippet]] is yet another snippet expansion system for Emacs. It is
8+
inspired by TextMate's templating syntax.
9+
- watch the [[http://www.youtube.com/watch?v=vOj7btx3ATg][video on YouTube]]
10+
- see the [[http://yasnippet.googlecode.com/svn/trunk/doc/index.html][intro and tutorial]]
11+
12+
Install yasnippet.
13+
#+begin_src emacs-lisp
14+
(unless (or (null starter-kit-packages) package-archive-contents)
15+
(package-refresh-contents))
16+
17+
(let ((package 'yasnippet))
18+
(unless (or (starter-kit-loadable-p package) (package-installed-p package))
19+
(package-install package)))
20+
21+
;; If `yasnippet-bundle' has previously been installed through ELPA,
22+
;; delete it before installing the new `yasnippet'
23+
(let ((yas-bundle-desc (assq 'yasnippet-bundle package-alist)))
24+
(when yas-bundle-desc
25+
(package-delete "yasnippet-bundle"
26+
(package-version-join
27+
(package-desc-vers (cdr yas-bundle-desc))))))
28+
#+end_src
29+
30+
Load the yasnippet bundle.
31+
#+begin_src emacs-lisp
32+
(add-to-list 'load-path
33+
(expand-file-name "yasnippet"
34+
(expand-file-name "src"
35+
starter-kit-dir)))
36+
(require 'yasnippet)
37+
(yas-global-mode 1)
38+
#+end_src
39+
40+
Load the snippets defined in the =./snippets/= directory.
41+
#+begin_src emacs-lisp
42+
(yas/load-directory (expand-file-name "snippets" starter-kit-dir))
43+
#+end_src
44+
45+
The latest version of yasnippets doesn't play well with Org-mode, the
46+
following function allows these two to play nicely together.
47+
#+begin_src emacs-lisp
48+
(defun yas/org-very-safe-expand ()
49+
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
50+
51+
(defun yas/org-setup ()
52+
;; yasnippet (using the new org-cycle hooks)
53+
(make-variable-buffer-local 'yas/trigger-key)
54+
(setq yas/trigger-key [tab])
55+
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
56+
(define-key yas/keymap [tab] 'yas/next-field))
57+
58+
(add-hook 'org-mode-hook #'yas/org-setup)
59+
#+end_src

starter-kit.org

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,10 @@ interested in the actual code implementing the starter kit.
288288
("melpa" . "http://melpa.milkbox.net/packages/")))
289289
(package-initialize)
290290

291-
(defvar starter-kit-packages
292-
(list 'yasnippet)
293-
"Libraries that should be installed by default.")
291+
(defvar starter-kit-packages nil
292+
"Libraries that should be installed by default (currently none).")
294293

295-
;; If `yasnippet-bundle' has previously been installed through ELPA,
296-
;; delete it before installing the new `yasnippet'
297-
(let ((yas-bundle-desc (assq 'yasnippet-bundle package-alist)))
298-
(when yas-bundle-desc
299-
(package-delete "yasnippet-bundle"
300-
(package-version-join
301-
(package-desc-vers (cdr yas-bundle-desc))))))
302-
303-
(unless package-archive-contents
294+
(unless (or (null starter-kit-packages) package-archive-contents)
304295
(package-refresh-contents))
305296
(dolist (package starter-kit-packages)
306297
(unless (or (starter-kit-loadable-p package) (package-installed-p package))
@@ -397,42 +388,6 @@ everyone using the starter kit.
397388
(starter-kit-load "starter-kit-registers.org")
398389
#+end_src
399390

400-
- [[http://code.google.com/p/yasnippet/][yasnippet]] is yet another snippet expansion system for Emacs. It is
401-
inspired by TextMate's templating syntax.
402-
- watch the [[http://www.youtube.com/watch?v=vOj7btx3ATg][video on YouTube]]
403-
- see the [[http://yasnippet.googlecode.com/svn/trunk/doc/index.html][intro and tutorial]]
404-
405-
load the yasnippet bundle
406-
#+begin_src emacs-lisp
407-
(add-to-list 'load-path
408-
(expand-file-name "yasnippet"
409-
(expand-file-name "src"
410-
starter-kit-dir)))
411-
(require 'yasnippet)
412-
(yas-global-mode 1)
413-
#+end_src
414-
415-
load the snippets defined in the =./snippets/= directory
416-
#+begin_src emacs-lisp
417-
(yas/load-directory (expand-file-name "snippets" starter-kit-dir))
418-
#+end_src
419-
420-
The latest version of yasnippets doesn't play well with Org-mode, the
421-
following function allows these two to play nicely together.
422-
#+begin_src emacs-lisp
423-
(defun yas/org-very-safe-expand ()
424-
(let ((yas/fallback-behavior 'return-nil)) (yas/expand)))
425-
426-
(defun yas/org-setup ()
427-
;; yasnippet (using the new org-cycle hooks)
428-
(make-variable-buffer-local 'yas/trigger-key)
429-
(setq yas/trigger-key [tab])
430-
(add-to-list 'org-tab-first-hook 'yas/org-very-safe-expand)
431-
(define-key yas/keymap [tab] 'yas/next-field))
432-
433-
(add-hook 'org-mode-hook #'yas/org-setup)
434-
#+end_src
435-
436391
** Load User/System Specific Files
437392
*** System/User specific customizations
438393
You can keep system- or user-specific customizations here in either

0 commit comments

Comments
 (0)