Yasnippet is a great template system for Emacs.
Below are my template codes for Yasnippet.
#name : do { ... } while (...)
# --
do
{
$0
} while (${1:condition});
#name : else if (...) { ... }
# --
} else if (${1:condition}) {
$0
#name : for (...; ...; ...) { ... }
# --
for (${1:int i = 0}; ${2:i < N}; ${3:++i})
{
$0
}
#name : if (...) { ... }
# --
if (${1:condition})
{
$0
}
#name : if (...) { ... } else { ... }
# --
if (${1:condition}) {
$2
} else {
$0
}
#name : if (...) { ... } else if (...) { ... }
# --
if (${1:condition}) {
$2
} else if (${3:condition}) {
$0
}
#name : if (...) { ... } else if (...) { ... } else { ... }
# --
if (${1:condition}) {
$2
} else if (${3:condition}) {
$4
} else {
$0
}
#name : #include <...>
# --
#include <$1>
#name : #include "..."
# --
#include "$1"
#name: int main(argc, argv) { ... }
# --
int main(int argc, char *argv[]) {
$0
return 0;
}
#name : #ifndef XXX; #define XXX; #endif
# --
#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
#define $1
$0
#endif /* $1 */
#name : println (...)
# --
println("${1:var}" + $1);
#name : struct ... { ... }
# --
struct ${1:name}
{
$0
};
#name : switch (...) { ...}
# --
switch(${1:condition}) {
case ${2:condition}:
$3
break;
default:
$0
break;
}
#name : (ad-activate ...)
# --
(ad-activate '${1:Function})
#name : (ad-deactivate ...)
# --
(ad-deactivate '${1:Function})
#name : (autoload '... "..." "..." ...)
# --
(autoload '${1:function-name} "${2:file-name}" "${3:document}" ${0:interactive})
#name : ;;; ### ... ### ...
# --
;;; ### $1 ###
;;; --- $2
$0
#name : Add change logs
# --
;; `(format-time-string "%Y/%m/%d")`
;; * `user-full-name`:
;; * $0
;;
#name : Add change logs with details
# --
;; ${1:Date}
;; * ${2:Name}:
;; * $0
;;
#name : (global-set-key (kbd "...") ...)
# --
(global-set-key (kbd "${1:some-key}") ${0:some-command})
#name : (global-unset-key ...)
# --
(global-unset-key (kbd ${0:key-value}))
#name : (add-hook ... ...)
# --
(add-hook '${1:hook} ${0:function})
#name : ((= c ...) (...))
# --
((= c ?${1:char}) (${0:command}))
#name : (if ... ... ...)
# --
(if ${1:conditional}
${2:then})
#name : (define-key ... (kbd "...") ...)
# --
(define-key ${1:some-mode-map} (kbd "${2:some-key}") ${0:some-command})
#name : ;;;;;;;;;;;;;;;;;;;; ... ;;;;;;;;;;;;;;;;;;;;
# --
;;;;;;;;;;;;;;;;;;;; $1 ;;;;;;;;;;;;;;;;;;;;
$0
#name : (provide '...)
# --
(provide '${0:library-name})
#name : (require '...)
# --
(require '${0:library-name})
#name : (setq ... ...)
# --
(setq ${1:variable-name} ${0:variable-value})
#name : (lazy-set-key ...)
# --
(lazy-set-key ${0:rest})
#name : ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ... ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# --
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; $1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$0
#name : (add-to-list ... ...)
# --
(add-to-list ${1:list-var} ${0:element})
#name : (unless ... ...)
# --
(unless ${1:conditional}
${0:body})
#name : (lazy-unset-key ... ...)
# --
(lazy-unset-key '("${1:key-list}")$0)
#name : (defalias ... ...)
# --
(defalias ${1:symbol} ${0:define})
#name : (defadvice ... ... ...)
# --
(defadvice ${1:function-name} (${2:args})
"${3:advice-document}"
(${0:advice-body})
)
#name : (defcustom ... ... ... ...)
# --
(defcustom ${1:symbol} ${2:value}
"${3:doc}"
${0:body})
#name : (defconst ... ... "...")
# --
(defconst ${1:symbol} ${2:initvalue}
"${0:document}")
#name : (defface ... ... ... ...)
# --
(defface ${1:face}
${2:spec}
"${3:doc}"
${0:args})
#name : (defun ... (...) "..." ...)
# --
(defun ${1:Function Name} ($2)
"${3:Function document}"
$0)
#name : (defun anything-* () ... (interactive) (anything 'anything-*))
# --
(defun anything-${1:name} ()
"${2:document}"
(interactive)
(anything 'anything-$0))
#name : (defun function-name () ... (interactive) ...)
# --
(defun ${1:function-name} ($2)
"${3:Function documantion}."
(interactive)
$0)
#name : (defgroup ... ... ... ...)
# --
(defgroup ${1:Group-Name} ${2:Group-value}
"${3:Group-doc}"
$0)
#name : (define-minor-mode ... ... ... ... ... ...)
# --
(define-minor-mode ${1:mode-name}
"${2:Document}"
:init-value ${3:init-value}
:lighter "${4:highlight-name}"
:keymap ${5:keymap}
:group '${6:group})
#name : (defun test () "Just for test" (interactive) ...)
# --
(defun test ()
"Just for test"
(interactive)
$0
)
#name : (defvar ... ... "...")
# --
(defvar ${1:variable-name} ${2:variable-varlue}
"${0:document}")
#name : (defvar anything-c-source-* '((name . "...") ...))
# --
(defvar anything-c-source-${1:name}
'((name . "${2:describe}")
$0))
#name : (dolist (... (...)) (add-to-alist '... ...))
# --
(dolist (${1:elt-cons} '(${2:elt-cons-list}))
(add-to-alist '${0:alist} $1))
#name : (dolist (hook (list ... )) (add-hook hook '...))
# --
(dolist (hook (list
${1:mode-list}
))
(add-hook hook '${0:mode-hook}))
#name : (dolist (hooked (list ...)) (add-hook '... hooked))
# --
(dolist (hooked (list
${1:mode-list}
))
(add-hook '${0:mode-hook} hooked))
#name : (eval-after-load ... ...)
# --
(eval-after-load ${1:file-name}
${0:form})
#name : A elisp file header
# --
;;; ${1:filename}.el --- ${2:Simple description}
;; Filename: $1.el
;; Description: $2
;; Author: `user-full-name` <`user-mail-address`>
;; Maintainer: `user-full-name` <`user-mail-address`>
;; Copyright (C) `(format-time-string "%Y")`, `user-full-name`, all rights reserved.
;; Created: `(format-time-string "%Y-%m-%d %T")`
;; Version: 0.1
;; Last-Updated: `(format-time-string "%Y-%m-%d %T")`
;; By: `user-full-name`
;; URL: http://www.emacswiki.org/emacs/download/$1.el
;; Keywords: $3
;; Compatibility: `(substring (emacs-version) 0 (string-match " (" (emacs-version))))`
;;
;; Features that might be required by this library:
;;
;; $4
;;
;;; This file is NOT part of GNU Emacs
;;; 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, 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; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;;
;; $2
;; $5
;;; Installation:
;;
;; Put $1.el to your load-path.
;; The load-path is usually ~/elisp/.
;; It's set in your ~/.emacs like this:
;; (add-to-list 'load-path (expand-file-name "~/elisp"))
;;
;; And the following to your ~/.emacs startup file.
;;
;; (require '$1)
;;
;; ${6:No need more.}
;;; Customize:
;;
;; $7
;;
;; All of the above can customize by:
;; M-x customize-group RET $1 RET
;;
;;; Change log:
;;
;; `(format-time-string "%Y/%m/%d")`
;; * First released.
;;
;;; Acknowledgements:
;;
;; $8
;;
;;; TODO
;;
;; $9
;;
;;; Require
$10
;;; Code:
$0
(provide '$1)
;;; $1.el ends here
#name : (lambda () (interactive) (...))
# --
(lambda () (interactive) ($0))
#name : (let ... ...)
# --
(let (${1:varlist})
${0:body})
#name : (remove-hook ... ...)
# --
(remove-hook '${1:Hook} '${2:Function})
#name : {- | ... -}
# --
{- | ${0:comment} -}
#name : ... :: ... -> ...
# --
${1:name} :: $2
$1 $0
#name : = ...
# --
= ${0:content}
#name : | ...
# --
| ${0:content}
#name : import ...
# --
import ${0:content}
#name : | otherwise = ...
# --
| otherwise = ${0:content}
#name : `...`
# --
\`${1:content}\` ${0:get here}
#name : where ...
# --
where ${0:content}
-----------------------------------------------------------------------------
-- |
-- Module : ${1:Module Name}
-- Copyright : (c) ${2:Andy Stewart} 2008
-- License : GPL
--
-- Maintainer : ${3:lazycat.manatee@gmail.com}
-- Stability : experimental
-- Portability : non-portable (not tested)
--
-- ${4:Simple Describe}
--
-- * Changlelog:
--
-- ${5:Today}
-- First released.
--
-- * TODO
--
-- $6
--
-----------------------------------------------------------------------------
#name : module ... where
# --
module ${1:module-name} (${0:module-interface}) where
#name : [url name]
# --
[${1:url} ${2:name}]$0
#name : [[name]]
# --
[[${1:name}]]$0
#name : _underline-
# --
_${1:name}_$0
#name : *Bold*
# --
*${1:*}${2:name}*$1$0
#name : ''Bold''
# --
''${1:name}''$0
#name : /italic/
# --
/${1:name}/$0
#name : [new] dialog [new]
# --
[new]
$0
[new]
#name : Add entire yaoddmuse template code.
# --
==What is `yaoddmuse-pagename` ?==
`yaoddmuse-pagename` is a mode that ${1:Describe}.
==Install==
Put Lisp:${2:package-name}.el in your load-path, add
{{{
(require '$2)
}}}
in ~/.emacs
==Usage==
${3:Usage}
==Customize==
All below option can customize by: M-x customize-group RET $2 RET
${4:Customize}
#name : Add entire yaoddmuse template code.
# --
==What is `yaoddmuse-pagename` ?==
`yaoddmuse-pagename` is a mode that ${1:Describe}.
==Why the need for `yaoddmuse-pagename` ?==
${2:Why}.
==Install==
Put Lisp:${3:package-name}.el in your load-path, add
{{{
(require '$3)
}}}
in ~/.emacs
==Usage==
${4:Usage}
==Customize==
All below option can customize by: M-x customize-group RET $3 RET
${5:Customize}
#name : ==Heading Name==
# --
=${1:=}${2:name}=$1$0
#name : [[image:ImagePage]]
# --
[[image:${1:PageName}]]$0
#name : Here is a screenshot: ImageName
# --
Here is a screenshot: $0
#name : Lisp:file.el
# --
Lisp:${1:FileName}.el$0
#name : -- yaoddmuse-username
# --
-- `yaoddmuse-username`
#name : [new:UTC time:2009-02-26 17:07 UTC] -- UserName
# --
[new:`yaoddmuse-username`:`(format-time-string "%Y-%m-%d %H:%M")` UTC]
$0 -- `yaoddmuse-username`
#name : Insert yaoddmuse page name
# --
`yaoddmuse-pagename`
#name : <pre> ... </pre>
# --
<pre>
$0
</pre>
#name : {{{source code}}}
# --
{{{
$0
}}}
#name : <tag>content</tag>
# --
<${1:tag}>${1:name}</$1>$0
#name : Insert yaoddmuse wiki name
# --
`yaoddmuse-wikiname`