diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0ea2107 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "extensions/yasnippet"] + path = extensions/yasnippet + url = https://github.com/capitaomorte/yasnippet.git diff --git a/epy-editing.el b/epy-editing.el index fe70bd6..b8a2b09 100644 --- a/epy-editing.el +++ b/epy-editing.el @@ -1,4 +1,4 @@ -;; ibuffer by default +0;95;c;; ibuffer by default (global-set-key (kbd "C-x C-b") 'ibuffer) ;; Ido mode with fuzzy matching @@ -25,14 +25,12 @@ (defun epy-django-snippets () "Load django snippets" (interactive) - (yas/load-directory (concat epy-install-dir "snippets/django")) - ) + (add-to-list 'yas-snippet-dirs (concat epy-install-dir "snippets/django"))) - -(yas/initialize) -(yas/load-directory (concat epy-install-dir "extensions/yasnippet/snippets")) -(setq yas/prompt-functions '(yas/dropdown-prompt yas/ido-prompt yas/x-prompt)) -(setq yas/wrap-around-region 'cua) +(yas-global-mode 1) +(add-to-list 'yas-snippet-dirs (concat epy-install-dir "extensions/yasnippet/snippets")) +(setq yas-prompt-functions '(yas-dropdown-prompt yas-ido-prompt yas-x-prompt)) +(setq yas-wrap-around-region 'cua) ;; Eproject project management with emacs ;; (require 'eproject) diff --git a/epy-init.el b/epy-init.el index cbf8b3f..1bf92b3 100644 --- a/epy-init.el +++ b/epy-init.el @@ -11,6 +11,7 @@ (add-to-list 'load-path epy-install-dir) (require 'epy-setup) (require 'epy-python) +(load-file (concat epy-install-dir "epy-completion.el")) (require 'epy-completion) (require 'epy-editing) (require 'epy-nose) diff --git a/extensions/yasnippet b/extensions/yasnippet new file mode 160000 index 0000000..be2f815 --- /dev/null +++ b/extensions/yasnippet @@ -0,0 +1 @@ +Subproject commit be2f815c43deb74e0f809ed47debc4aa2e67ea1e diff --git a/extensions/yasnippet/README b/extensions/yasnippet/README deleted file mode 100644 index e716140..0000000 --- a/extensions/yasnippet/README +++ /dev/null @@ -1,8 +0,0 @@ -YASnippet re-design and re-writing of my original extension -smart-snippet. The goal is ease of use and full features. - -For detailed document, you can either download the document -release of YASnippet or view it directly online: - -http://pluskid.lifegoo.com/upload/project/yasnippet/doc/index.html - diff --git a/extensions/yasnippet/Rakefile b/extensions/yasnippet/Rakefile deleted file mode 100644 index 7625d13..0000000 --- a/extensions/yasnippet/Rakefile +++ /dev/null @@ -1,79 +0,0 @@ -# -*- Ruby -*- - -require 'fileutils' - -def find_version - File.read("yasnippet.el") =~ /;; Package-version: *([0-9.]+[a-z]?) *$/ - $version = $1 -end -find_version -FileUtils.mkdir_p('pkg') - -desc "generate bundle file for classic snippets." -task :bundle do - sh 'emacs --batch -l yasnippet.el --eval "(yas/compile-bundle)"' - sh "tar czf pkg/yasnippet-bundle-#{$version}.el.tgz yasnippet-bundle.el" -end - -desc "generate bundle file for textmate snippets." -task :textmate_bundle do - sh 'emacs --batch -l yasnippet.el --eval "(yas/compile-textmate-bundle)"' - sh "tar czf pkg/yasnippet-textmate-bundle-#{$version}.el.tgz yasnippet-textmate-bundle.el" -end - -desc "convert some textmate bundles to yasnippets" -task :convert_bundles do - sh 'for bundle in html ruby rails; do ./extras/textmate_import.rb -d extras/bundles/$bundle-bundle -o extras/imported/$bundle-mode -q ; done' -end - -desc "create a release package" -task :package do - release_dir = "pkg/yasnippet-#{$version}" - FileUtils.mkdir_p(release_dir) - files = ['extras', 'snippets', 'yasnippet.el', 'dropdown-list.el'] - FileUtils.cp_r files, release_dir - FileUtils.rm_r Dir[release_dir + "/**/.svn"] - FileUtils.cd 'pkg' - sh "tar cjf yasnippet-#{$version}.tar.bz2 yasnippet-#{$version}" - FileUtils.cd ".." -end - -desc "create a release package and upload it to google code" -task :release => [:bundle, :package, 'doc:archive'] do - sh "googlecode_upload.py -s \"YASnippet Release #{$version}\"" + - " -p yasnippet -l \"Featured,Type-Package,OpSys-All\"" + - " pkg/yasnippet-#{$version}.tar.bz2" - sh "googlecode_upload.py -s \"YASnippet Bundle #{$version}\"" + - " -p yasnippet -l \"Featured,Type-Package,OpSys-All\"" + - " pkg/yasnippet-bundle-#{$version}.el.tgz" - sh "googlecode_upload.py -s \"YASnippet Document #{$version}\"" + - " -p yasnippet -l \"Featured,Type-Docs,OpSys-All\"" + - " pkg/yasnippet-doc-#{$version}.tar.bz2" - FileUtils.cp "yasnippet-bundle.el", "pkg/yasnippet-bundle-#{$version}.el" - sh "echo for ELPA | mutt -a pkg/yasnippet-bundle-#{$version}.el -s " + - "'YASnippet bundle v#{$version}' elpa@tromey.com" -end - -rule '.html' => '.rst' do |t| - sh "doc/compile-doc.py #{t.source} > #{t.name}" -end -desc "Generate document" -task :doc => FileList['doc/*.rst'].ext('html') - -namespace :doc do - task :archive do - release_dir = "pkg/yasnippet-#{$version}" - FileUtils.mkdir_p(release_dir) - sh "tar cjf pkg/yasnippet-doc-#{$version}.tar.bz2 " + - "--exclude=doc/.svn --exclude=doc/images/.svn doc/*.html doc/images" - end -end - -desc "Compile yasnippet.el into yasnippet.elc" - -rule '.elc' => '.el' do |t| - sh "emacs --batch -L . --eval \"(byte-compile-file \\\"#{t.source}\\\")\"" -end -task :compile => FileList["yasnippet.el", "dropdown-list.el"].ext('elc') - -task :default => :doc diff --git a/extensions/yasnippet/doc/changelog.html b/extensions/yasnippet/doc/changelog.html deleted file mode 100644 index 7a0f2c3..0000000 --- a/extensions/yasnippet/doc/changelog.html +++ /dev/null @@ -1,381 +0,0 @@ - - - -
- - -- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-If you have a newline at the end of the snippet definition file, then -YASnippet will add a newline when you expanding a snippet. Please -don't add a newline at the end if you don't want it when you saving -the snippet file.
-Note some editors will automatically add a newline for you. In Emacs, -if you set require-final-newline to t, it will add the final -newline for you automatically.
-First check the mode line to see if there's yas. If not, then try -M-x yas/minor-mode to manually turn on the minor mode and try to -expand the snippet again. If it works, then, you can add the following -code to your .emacs before loading YASnippet:
-(add-hook 'the-major-mode-hook 'yas/minor-mode-on)
-
where the-major-mode is the major mode in which yas/minor-mode -isn't enabled by default.
-From YASnippet 0.6 you can also use the command M-x -yas/global-mode to turn on YASnippet automatically for all major -modes.
-If yas/minor-mode is on but the snippet still not expanded. Then -try to see what command is bound to the TAB key: press C-h k -and then press TAB. Emacs will show you the result.
-You'll see a buffer prompted by Emacs saying that TAB runs the -command .... Alternatively, you might see <tab> runs the command -..., note the difference between TAB and <tab> where the -latter has priority. If you see <tab> bound to a command other -than yas/expand, (e.g. in org-mode) you can try the following -code to work around:
-(add-hook 'org-mode-hook
- (let ((original-command (lookup-key org-mode-map [tab])))
- `(lambda ()
- (setq yas/fallback-behavior
- '(apply ,original-command))
- (local-set-key [tab] 'yas/expand))))
-
replace org-mode-hook and org-mode-map with the major mode -hook you are dealing with (Use C-h m to see what major mode you -are in).
-As an alternative, you can also try
-(defun yas/advise-indent-function (function-symbol)
- (eval `(defadvice ,function-symbol (around yas/try-expand-first activate)
- ,(format
- "Try to expand a snippet before point, then call `%s' as usual"
- function-symbol)
- (let ((yas/fallback-behavior nil))
- (unless (and (interactive-p)
- (yas/expand))
- ad-do-it)))))
-
-(yas/advise-indent-function 'ruby-indent-line)
-
To advise the modes indentation function bound to TAB, (in this case -ruby-indent-line) to first try to run yas/expand.
-If the output of C-h k RET <tab> tells you that <tab> is -indeed bound to yas/expand but YASnippet still doesn't work, check -your configuration and you may also ask for help on the discussion -group. See this -particular thread for -quite some solutions and alternatives.
-Don't forget to attach the information on what command is bound to TAB -as well as the mode information (Can be obtained by C-h m).
-The best way, since version 0.6.1c, is to set the default value of the -variable yas/dont-activate to a lambda function like so:
-(set-default 'yas/dont-activate
- #'(lambda ()
- (and yas/root-directory
- (null (yas/get-snippet-tables)))))
-
This is also the default value starting for that version. It skips the -minor mode in buffers where it is not applicable (no snippet tables), -but only once you have setup your yas/root-directory.
-For example, you want to define a snippet by the key < which is -not a valid character for filename on Windows. This means you can't -use the filename as a trigger key in this case.
-You should rather use the # key: directive to specify the key of -the defined snippet explicitly and name your snippet with an arbitrary -valid filename, lt.yasnippet for example, using < for the -# key: directive:
-#key: <
-#name: <...></...>
-# --
-<${1:div}>$0</$1>
-
- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-Contents
- -YASnippet is a template system for Emacs. It allows you to type an -abbreviation and automatically expand it into function -templates. Bundled language templates includes: C, C++, C#, Perl, -Python, Ruby, SQL, LaTeX, HTML, CSS and more.
-The snippet syntax is inspired from TextMate's syntax, you can even -import -import most TextMate templates. YASnippet is a re-write of the -extension smart-snippet. Both are original creations of pluskid.
-Watch the demo at YouTube (download a higher -resolution version: yasnippet.avi).
-There are two archives you can download. To quickly tryout YASnippet, -download the simpler "bundle" version. If you plan to modify the -bundled templates and/or build your own, download the "normal" -package.
-That's it. Now open any one of your language file, you'll see a menu -YASnippet. you can pull the menu to insert a template. Or, you can -type the a trigger key then press TAB to expand it.
-To have Emacs load YASnippet automatically when it starts, put the -following in your ~/.emacs file:
----(add-to-list 'load-path - "~/.emacs.d/plugins") -(require 'yasnippet-bundle) -
The youtube video -demonstrates this quick installation.
-To install YASnippet as a normal emacs package, download and unpack -the latest yasnippet-x.y.z.tar.bz2. You'll get a directory named -yasnippet-x.y.z, which you can put it in your -~/.emacs.d/plugins and add the following in your .emacs file:
----(add-to-list 'load-path - "~/.emacs.d/plugins/yasnippet-x.y.z") -(require 'yasnippet) ;; not yasnippet-bundle -(yas/initialize) -(yas/load-directory "~/.emacs.d/plugins/yasnippet-x.y.z/snippets") -
Please refer to the documentation for full customization, or use the -customization group.
-Since version 0.6, YASnippet contains more functionality. You don't -need to know all of it to use it successfully, but you it can improve -your snippeting experience.
-Hence this section has been split into separate documents:
- --Describes ways to organize your snippets in the hard disk (or not -organize them at all and just use yasnippet-bundle.el.- -
-- -Describes how YASnippet chooses snippets for expansion at point.
-Maybe, you'll want some snippets to be expanded in a particular -mode, or only under certain conditions, or be prompted using -ido, etc...
-
-Describes the YASnippet definition syntax, which is very close (but -not equivalent) to Textmate's. Includes a section about converting -TextMate snippets.- -
-Explains how to use the YASnippet menu to explore, learn and modify -snippets.-
Thank you very much for using YASnippet!
- -- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-Contents
- -There are some ways you can quickly find a snippet file:
-M-x yas/new-snippet
-Prompts you for a snippet name, then tries to guess a suitable -directory to store it, prompting you for creation if it does not -exist. Finally, places you in a new buffer set to snippet-mode -so you can write your snippet.
-M-x yas/find-snippets
-Lets you find the snippet file in the directory the snippet was -loaded from (if it exists) like find-file-other-window. The -directory searching logic is similar to M-x yas/new-snippet.
-M-x yas/visit-snippet-file
-Prompts you for possible snippet expansions like -yas/insert-snippet, but instead of expanding it, takes you -directly to the snippet definition's file, if it exists.
-Once you find this file it will be set to snippet-mode (see ahead) -and you can start editing your snippet.
-There is a major mode snippet-mode to edit snippets. You can set -the buffer to this mode with M-x snippet-mode. It provides -reasonably useful syntax highlighting.
-Two commands are defined in this mode:
-M-x yas/load-snippet-buffer
---When editing a snippet, this loads the snippet into the correct -mode and menu. Bound to C-c C-c by default while in -snippet-mode.
-
M-x yas/tryout-snippet
---When editing a snippet, this opens a new empty buffer, sets it to -the appropriate major mode and inserts the snippet there, so you -can see what it looks like. This is bound to C-c C-t while in -snippet-mode.
-
There are also snippets for writing snippets: vars, $f and -$m :-).
-A file defining a snippet generally contains the template to be -expanded.
-Optionally, if the file contains a line of # --, the lines above -it count as comments, some of which can be directives (or meta -data). Snippet directives look like # property: value and tweak -certain snippets properties described below. If no # -- is found, -the whole file is considered the snippet template.
-Here's a typical example:
-#contributor : pluskid <pluskid@gmail.com>
-#name : __...__
-# --
-__${init}__
-
Here's a list of currently supported directives:
-This is the probably the most important directive, it's the -abbreviation you type to expand a snippet just before hitting -yas/trigger-key.
-If you don't specify this it will default to the name of the file the -snippet is being loaded from, unless YASnippet is ignoring file names -as triggers (see yas/ignore-filenames-as-triggers in Organizing -snippets), in which case this snippet -will not be expandable through the key mechanism.
-Sometimes the key of a snippet is non-ASCII or not valid filename -(e.g. contains /). One can then define the key property which -will overwrite the filename as the key to expand the snippet.
-This is a one-line description of the snippet. It will be displayed in -the menu. It's a good idea to select a descriptive name for a -snippet -- especially distinguishable among similar snippets.
-If you omit this name it will default to the file name the snippet was -loaded from.
-This is a piece of Emacs-lisp code. If a snippet has a condition, then it -will only be expanded when the condition code evaluate to some non-nil -value.
-See also yas/buffer-local-condition in Expanding snippets
-This is another piece of Emacs-lisp code in the form of a let -varlist form, i.e. a list of lists assigning values to variables. It -can be used to override variable values while the snippet is being -expanded.
-Interesting variables to override are yas/wrap-around-region and -yas/indent-line (see Expanding Snippets).
-As an example, you might normally have yas/indent-line set to -'auto and yas/wrap-around-region set to t, but for this -particularly brilliant piece of ASCII art these values would mess up -your hard work. You can then use:
-# name : ASCII home
-# expand-env: ((yas/indent-line 'fixed) (yas/wrap-around-region 'nil))
-# --
- welcome to my
- X humble
- / \ home,
- / \ $0
- / \
- /-------\
- | |
- | +-+ |
- | | | |
- +--+-+--+
-
You can use this directive to expand a snippet directly from a normal -Emacs keybinding. The keybinding will be registered in the Emacs -keymap named after the major mode the snippet is active -for.
-Additionally a variable yas/prefix is set to to the prefix -argument you normally use for a command. This allows for small -variations on the same snippet, for example in this "html-mode" -snippet.
-#name : <p>...</p>
-#binding: "C-c C-c C-m"
-# --
-<p>`(when yas/prefix "\n")`$0`(when yas/prefix "\n")`</p>
-
This binding will be recorded in the keymap html-mode-map. To -expand a paragraph tag newlines, just press "C-u C-c C-c -C-m". Omitting the "C-u" will expand the paragraph tag without -newlines.
-To override the keymap choice based on the major mode name. Use a cons -cell where the first element specifies the name of the keymap where -you want to record the keybinding.
-#name : <p>...</p>
-#binding: (rinari-minor-mode-map . "C-c C-c C-m")
-# --
-<p>`(when yas/prefix "\n")`$0`(when yas/prefix "\n")`</p>
-
Note: this feature is still experimental, it might go away, be -changed in future release, and should be used with caution: It is easy -to override important keybindings for many basic modes and it is hard -to undefine them. For the moment, the variable -yas/active-keybindings can tell you what snippet keybindings are -active and the function yas/kill-snippet-keybindings will attempt -to undefine all the keybindings.
-This is optional and has no effect whatsoever on snippet -functionality, but it looks nice.
-The syntax of the snippet template is simple but powerful, very -similar to TextMate's.
-Arbitrary text can be included as the content of a template. They are -usually interpreted as plain text, except $ and `. You need to -use \ to escape them: \$ and \`. The \ itself may also -needed to be escaped as \\ sometimes.
-Emacs-Lisp code can be embedded inside the template, written inside -back-quotes (`). The lisp forms are evaluated when the snippet is -being expanded. The evaluation is done in the same buffer as the -snippet being expanded.
-Here's an example for c-mode to calculate the header file guard -dynamically:
-#ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_}
-#define $1
-
-$0
-
-#endif /* $1 */
-
From version 0.6, snippets expansions are run with some special -Emacs-lisp variables bound. One of this is yas/selected-text. You -can therefore define a snippet like:
-for ($1;$2;$3) {
- `yas/selected-text`$0
-}
-
to "wrap" the selected region inside your recently inserted -snippet. Alternatively, you can also customize the variable -yas/wrap-around-region to t which will do this automatically.
-Tab stops are fields that you can navigate back and forth by TAB -and S-TAB. They are written by $ followed with a -number. $0 has the special meaning of the exit point of a -snippet. That is the last place to go when you've traveled all the -fields. Here's a typical example:
-<div$1>
- $0
-</div>
-
Tab stops can have default values -- a.k.a placeholders. The syntax is -like this:
-${N:default value}
-
They acts as the default value for a tab stop. But when you firstly -type at a tab stop, the default value will be replaced by your -typing. The number can be omitted if you don't want to create -mirrors or transformations for this field.
-We refer the tab stops with placeholders as a field. A field can have -mirrors. Its mirrors will get updated when you change the text of a -field. Here's an example:
-\begin{${1:enumerate}}
- $0
-\end{$1}
-
When you type "document" at ${1:enumerate}, the word -"document" will also be inserted at \end{$1}. The best -explanation is to see the screencast(YouTube or avi video).
-The tab stops with the same number to the field act as its mirrors. If -none of the tab stops has an initial value, the first one is selected -as the field and others mirrors.
-If the value of an ${n:-construct starts with and contains $(, -then it is interpreted as a mirror for field n with a -transformation. The mirror's text content is calculated according to -this transformation, which is Emacs-lisp code that gets evaluated in -an environment where the variable text (or yas/text) is bound -to the text content (string) contained in the field n.Here's an -example for Objective-C:
-- (${1:id})${2:foo}
-{
- return $2;
-}
-
-- (void)set${2:$(capitalize text)}:($1)aValue
-{
- [$2 autorelease];
- $2 = [aValue retain];
-}
-$0
-
Look at ${2:$(capitalize text)}, it is a mirror with -transformation instead of a field. The actual field is at the first -line: ${2:foo}. When you type text in ${2:foo}, the -transformation will be evaluated and the result will be placed there -as the transformed text. So in this example, if you type "baz" in the -field, the transformed text will be "Baz". This example is also -available in the screencast.
-Another example is for rst-mode. In reStructuredText, the document -title can be some text surrounded by "===" below and above. The "===" -should be at least as long as the text. So
-=====
-Title
-=====
-
is a valid title but
-===
-Title
-===
-
is not. Here's an snippet for rst title:
-${1:$(make-string (string-width text) ?\=)}
-${1:Title}
-${1:$(make-string (string-width text) ?\=)}
-
-$0
-
From version 0.6 on, you can also have lisp transformation inside -fields. These work mostly mirror transformations but are evaluated -when you first enter the field, after each change you make to the -field and also just before you exit the field.
-The syntax is also a tiny bit different, so that the parser can -distinguish between fields and mirrors. In the following example
-#define "${1:mydefine$(upcase yas/text)}"
-
mydefine gets automatically upcased to MYDEFINE once you enter -the field. As you type text, it gets filtered through the -transformation every time.
-Note that to tell this kind of expression from a mirror with a -transformation, YASnippet needs extra text between the : and the -transformation's $. If you don't want this extra-text, you can use -two $'s instead.
-#define "${1:$$(upcase yas/text)}"
-
Please note that as soon as a transformation takes place, it changes -the value of the field and sets it its internal modification state to -true. As a consequence, the auto-deletion behaviour of normal -fields does not take place. This is by design.
-As mentioned, the field transformation is invoked just after you enter -the field, and with some useful variables bound, notably -yas/field-modified-p and yas/moving-away-p. Because of this -feature you can place a transformation in the primary field that lets -you select default values for it.
-The yas/choose-value does this work for you. For example:
-<div align="${2:$$(yas/choose-value '("right" "center" "left"))}">
- $0
-</div>
-
See the definition of yas/choose-value to see how it was written -using the two variables.
-Here's another use, for LaTeX-mode, which calls reftex-label just as -you enter snippet field 2. This one makes use of yas/modified-p -directly.
-\section{${1:"Titel der Tour"}}%
-\index{$1}%
-\label{{2:"waiting for reftex-label call..."$(unless yas/modified-p (reftex-label nil 'dont-
-insert))}}%
-
The function yas/verify-value has another neat trick, and makes -use of yas/moving-away-p. Try it and see! Also, check out this -thread
-From version 0.6 on, you can also have nested placeholders of the type:
-<div${1: id="${2:some_id}"}>$0</div>
-
This allows you to choose if you want to give this div an id -attribute. If you tab forward after expanding it will let you change -"some_id" to whatever you like. Alternatively, you can just press -C-d (which executes yas/skip-and-clear-or-delete-char) and go -straight to the exit marker.
-By the way, C-d will only clear the field if you cursor is at the -beginning of the field and it hasn't been changed yet. Otherwise, it -performs the normal Emacs delete-char command.
-The key bound to yas/expand when function yas/minor-mode is -active.
-Value is a string that is converted to the internal Emacs key -representation using read-kbd-macro.
-Default value is "TAB".
-The key to navigate to next field when a snippet is active.
-Value is a string that is converted to the internal Emacs key -representation using read-kbd-macro.
-Can also be a list of keys.
-Default value is "TAB".
-The key to navigate to previous field when a snippet is active.
-Value is a string that is converted to the internal Emacs key -representation using read-kbd-macro.
-Can also be a list of keys.
-Default value is ("<backtab>" "<S-tab>)".
-The key to clear the currently active field.
-Value is a string that is converted to the internal Emacs key -representation using read-kbd-macro.
-Can also be a list of keys.
-Default value is "C-d".
-If non-nil, don't raise errors in inline Emacs-lisp evaluation inside -snippet definitions. An error string "[yas] error" is returned instead.
-The variable yas/indent-line controls the indenting. It is bound -to 'auto by default, which causes your snippet to be indented -according to the mode of the buffer it was inserted in.
-Another variable yas/also-auto-indent-first-line, when non-nil -does exactly that :-).
-To use the hard-coded indentation in your snippet template, set this -variable to fixed.
-To control indentation on a per-snippet basis, see also the directive -# expand-env: in Writing Snippets.
-For backward compatibility with earlier versions of YASnippet, you can -also place a $> in your snippet, an (indent-according-to-mode) -will be executed there to indent the line. This only takes effect when -yas/indent-line is set to something other than 'auto.
-for (${int i = 0}; ${i < 10}; ${++i})
-{$>
-$0$>
-}$>
-
If non-nil, YASnippet will try to expand the snippet's exit marker -around the currently selected region. When this variable is set to t, -this has the same effect has using the `yas/selected-text` inline -evaluation.
-Because on most systems starting to type deletes the currently region, -this works mostly with the yas/insert-snippet command.
-However, when the value is of this variable is cua YASnippet will -additionally look-up any recently selected that you deleted by starting -typing. This allows you select a region, type a snippet key (deleting -the region), then press yas/trigger-key to see the deleted region -spring back to life inside your new snippet.
-If non-nil, yas/next-field-key can trigger stacked expansions, -that is a snippet expansion inside another snippet -expansion. Otherwise, yas/next-field-key just tries to move on to -the next field.
-Non-nil means re-activate snippet fields after undo/redo.
-These hooks are called, respectively, before the insertion of a -snippet and after exiting the snippet. If you find any strange but -functional use for them, that's probably a design flaw in YASnippet, -so let us know.
-There are a couple of tools that take TextMate's ".tmSnippet" xml -files and create YASnippet definitions:
----
-- a python script by Jeff Wheeler
-- a ruby tool -, textmate_import.rb adapted from Rob Christie's, -which I have uploaded to the repository.
-
In this section, i'll shortly cover the second option.
-Download the textmate_import.rb tool and the TextMate -bundle you're interested in.
-$ curl -O http://yasnippet.googlecode.com/svn/trunk/extras/textmate_import.rb
-$ svn export http://svn.textmate.org/trunk/Bundles/HTML.tmbundle/
-
Then invoke textmate_import.rb like this:
-$ ./textmate_import.rb -d HTML.tmbundle/Snippets/ -o html-mode -g HTML.tmbundle/info.plist
-
You should end up with a html-mode subdir containing snippets -exported from textmate.
-$ tree html-mode # to view dir contents, if you have 'tree' installed
-
The -g is optional but helps the tool figure out the grouping. -According to Organizing Snippets, don't forget to touch -.yas-make-groups and .yas-ignore-filename-triggers inside the -html-mode dir.
-Also try textmate_import.rb --help for a list of options.
-Please note that snippet importation is not yet perfect. You'll -probably have some adjustments to some/many snippets. Please -contribute these adjustments to the google group or, better yet, patch -the textmate_import.rb to automatically perform them and submit -that.
- - - -...
- #binding: "C-c C-c C-m" - # -- -`(when yas/prefix "\n")`$0`(when yas/prefix "\n")`
- -This binding will be recorded in the keymap ``html-mode-map``. To -expand a paragraph tag newlines, just press "C-u C-c C-c -C-m". Omitting the "C-u" will expand the paragraph tag without -newlines. - -To override the keymap choice based on the major mode name. Use a cons -cell where the first element specifies the name of the keymap where -you want to record the keybinding. - -.. sourcecode:: text - - #name :...
- #binding: (rinari-minor-mode-map . "C-c C-c C-m") - # -- -`(when yas/prefix "\n")`$0`(when yas/prefix "\n")`
- -**Note**: this feature is still **experimental**, it might go away, be -changed in future release, and should be used with caution: It is easy -to override important keybindings for many basic modes and it is hard -to undefine them. For the moment, the variable -``yas/active-keybindings`` can tell you what snippet keybindings are -active and the function ``yas/kill-snippet-keybindings`` will attempt -to undefine all the keybindings. - -``# contributor:`` snippet author ---------------------------------------------------- - -This is optional and has no effect whatsoever on snippet -functionality, but it looks nice. - - -Template syntax -=============== - -The syntax of the snippet template is simple but powerful, very -similar to TextMate's. - -Plain Text ----------- - -Arbitrary text can be included as the content of a template. They are -usually interpreted as plain text, except ``$`` and `````. You need to -use ``\`` to escape them: ``\$`` and ``\```. The ``\`` itself may also -needed to be escaped as ``\\`` sometimes. - -Embedded Emacs-lisp code ------------------------- - -Emacs-Lisp code can be embedded inside the template, written inside -back-quotes (`````). The lisp forms are evaluated when the snippet is -being expanded. The evaluation is done in the same buffer as the -snippet being expanded. - -Here's an example for ``c-mode`` to calculate the header file guard -dynamically: - -.. sourcecode:: text - - #ifndef ${1:_`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H_} - #define $1 - - $0 - - #endif /* $1 */ - -From version 0.6, snippets expansions are run with some special -Emacs-lisp variables bound. One of this is ``yas/selected-text``. You -can therefore define a snippet like: - -.. sourcecode:: text - - for ($1;$2;$3) { - `yas/selected-text`$0 - } - -to "wrap" the selected region inside your recently inserted -snippet. Alternatively, you can also customize the variable -``yas/wrap-around-region`` to ``t`` which will do this automatically. - -Tab stop fields ---------------- - -Tab stops are fields that you can navigate back and forth by ``TAB`` -and ``S-TAB``. They are written by ``$`` followed with a -number. ``$0`` has the special meaning of the *exit point* of a -snippet. That is the last place to go when you've traveled all the -fields. Here's a typical example: - -.. sourcecode:: text - -- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-Contents
- -You can use YASnippet to expand snippets in different ways:
-When yas/minor-mode is enabled, the keybinding taken from -yas/trigger-key will take effect.
-yas/trigger-key invokes yas/expand, which tries to expand a -snippet abbrev (also known as snippet key) before point.
-The default key is "TAB", however, you can freely set it to some -other key.
-To enable the YASnippet minor mode in all buffers globally use the -command yas/global-mode.
-When you use yas/global-mode you can also selectively disable -YASnippet in some buffers by setting the buffer-local variable -yas/dont-active in the buffer's mode hook.
-Trouble when using or understanding the yas/trigger-key is easily -the most controversial issue in YASsnippet. See the FAQ.
-yas/fallback-behaviour is a customization variable bound to -'call-other-command by default. If yas/expand failed to find -any suitable snippet to expand, it will disable the minor mode -temporarily and find if there's any other command bound the -yas/trigger-key.
-If found, the command will be called. Usually this works very well -- -when there's a snippet, expand it, otherwise, call whatever command -originally bind to the trigger key.
-However, you can change this behavior by customizing the -yas/fallback-behavior variable. If you set this variable to -'return-nil, it will return nil instead of trying to call the -original command when no snippet is found.
-The command M-x yas/insert-snippet lets you insert snippets at -point for you current major mode. It prompts you for the snippet -key first, and then for a snippet template if more than one template -exists for the same key.
-The list presented contains the snippets that can be inserted at -point, according to the condition system. If you want to see all -applicable snippets for the major mode, prefix this command with -C-u.
-The prompting methods used are again controlled by -yas/prompt-functions.
-See the section of the # binding: directive in Writing -Snippets.
-To integrate with hippie-expand, just put -yas/hippie-try-expand in -hippie-expand-try-functions-list. This probably makes more sense -when placed at the top of the list, but it can be put anywhere you -prefer.
-Sometimes you might want to expand a snippet directly from you own -elisp code. You should call yas/expand-snippet instead of -yas/expand in this case.
-As with expanding from the menubar, the condition system and multiple -candidates doesn't affect expansion. In fact, expanding from the -YASnippet menu has the same effect of evaluating the follow code:
-(yas/expand-snippet template)
-
See the internal documentation on yas/expand-snippet for more -information.
-YASnippet does quite a bit of filtering to find out which snippets are -eligible for expanding at the current cursor position.
-In particular, the following things matter:
-Currently loaded snippets tables
-These are loaded from a directory hierarchy in your file system. See -Organizing Snippets. They are named after major modes like -html-mode, ruby-mode, etc...
-Major mode of the current buffer
-If the currrent major mode matches one of the loaded snippet tables, -then all that table's snippets are considered for expansion. Use -M-x describe-variable RET major-mode RET to find out which major -mode you are in currently.
-Parent tables
-Snippet tables defined as the parent of some other eligible table -are also considered. This works recursively, i.e. parents of parents -of eligible tables are also considered.
-Buffer-local yas/mode-symbol variable
-This can be used to consider snippet tables whose name does not -correspond to a major mode. If you set this variable to a name , -like rinari-minor-mode, you can have some snippets expand only -in that minor mode. Naturally, you want to set this conditionally, -i.e. only when entering that minor mode, so using a hook is a good -idea.
-;; When entering rinari-minor-mode, consider also the snippets in the
-;; snippet table "rails-mode"
-(add-hook 'rinari-minor-mode-hook
- #'(lambda ()
- (setq yas/mode-symbol 'rails-mode)))
-
Buffer-local yas/buffer-local-condition variable
-This variable provides finer grained control over what snippets can -be expanded in the current buffer. The default value won't let you -expand snippets inside comments or string literals for example. See -The condition system for more info.
-Consider this scenario: you are an old Emacs hacker. You like the -abbrev-way and set yas/trigger-key to "SPC". However, -you don't want if to be expanded as a snippet when you are typing -in a comment block or a string (e.g. in python-mode).
-If you use the # condition : directive (see Writing Snippets) -you could just specify the condition for if to be (not -(python-in-string/comment)). But how about while, for, -etc. ? Writing the same condition for all the snippets is just -boring. So has a buffer local variable -yas/buffer-local-condition. You can set this variable to (not -(python-in-string/comment)) in python-mode-hook.
-Then, what if you really want some particular snippet to expand even -inside a comment? This is also possible! But let's stop telling the -story and look at the rules:
-In the mentioned scenario, set yas/buffer-local-condition like -this
-(add-hook 'python-mode-hook
- '(lambda ()
- (setq yas/buffer-local-condition
- '(if (python-in-string/comment)
- '(require-snippet-condition . force-in-comment)
- t))))
-
... and specify the condition for a snippet that you're going to -expand in comment to be evaluated to the symbol -force-in-comment. Then it can be expanded as you expected, while -other snippets like if still can't expanded in comment.
-The rules outlined above can return more than -one snippet to be expanded at point.
-When there are multiple candidates, YASnippet will let you select -one. The UI for selecting multiple candidate can be customized through -yas/prompt-functions , which defines your preferred methods of -being prompted for snippets.
-You can customize it with M-x customize-variable RET -yas/prompt-functions RET. Alternatively you can put in your -emacs-file:
-(setq yas/prompt-functions '(yas/x-prompt yas/dropdown-prompt))
-
Currently there are some alternatives solution with YASnippet.
-The function yas/x-prompt can be used to show a popup menu for you -to select. This menu will be part of you native window system widget, -which means:
-You can use functions yas/completing-prompt for the classic emacs -completion method or yas/ido-prompt for a much nicer looking -method. The best way is to try it. This works in a terminal.
-See below for the documentation on variable yas/prompt-functions
-You can write a function and add it to the yas/prompt-functions -list. These functions are called with the following arguments:
-The return value of any function you put here should be one of -the objects in CHOICES, properly formatted with DISPLAY-FN (if -that is passed).
-How to act when yas/expand does not expand a snippet.
-return-nil means return nil. (i.e. do nothing)
-An entry (apply COMMAND . ARGS) means interactively call COMMAND, if -ARGS is non-nil, call COMMAND non-interactively with ARGS as -arguments.
-If non-nil, prompt for snippet key first, then for template.
-Otherwise prompts for all possible snippet names.
-This affects yas/insert-snippet and yas/visit-snippet-file.
-If non-nil, and multiple eligible snippet tables, prompts user for -tables first.
-Otherwise, user chooses between the merging together of all -eligible tables.
-This affects yas/insert-snippet, yas/visit-snippet-file
-The default searching strategy is quite powerful. For example, in -c-mode, bar, foo_bar, "#foo_bar" can all be recognized -as a snippet key. Furthermore, the searching is in that order. In -other words, if bar is found to be a key to some valid snippet, -then that snippet is expanded and replaces the bar. Snippets -pointed to by foo_bar and "#foobar won't be considered.
-However, this strategy can also be customized easily from the -yas/key-syntaxes variable. It is a list of syntax rules, the -default value is ("w" "w_" "w_." "^ "). Which means search the -following thing until found one:
-But you'd better keep the default value unless you want to understand -how Emacs's syntax rules work...
-- Important: This documentation applies to - the SVN trunk of YASnippet, which you - get here. Documentation - for other versions can be found here. -
-Contents
- -Snippet definitions are stored in files in the filesystem. Unless you -use the simpler bundle version), these -are arranged so that YASnippet can load them into snippet -tables. The triggering mechanisms (see Expanding snippets) will -look up these snippet tables and (hopefully) expand the snippet you -intended.
-The non-bundle version of YASnippet, once unpacked, comes with a full -directory of snippets, which you can copy somewhere and use. You can -also create or download more directories.
-Once these directories are in place reference them in the variable -yas/root-directory and load them with yas/load-directory:
-;; Develop and keep personal snippets under ~/emacs.d/mysnippets
-(setq yas/root-directory "~/emacs.d/mysnippets")
-
-;; Load the snippets
-(yas/load-directory yas/root-directory)
-
The point in using yas/root-directory (as opposed to calling -yas/load-directory directly) is considering "~/emacs.d/mysnippets" -for snippet development, so you can use commands like -yas/new-snippet and others described in section Writing -Snippets.
-You can make this variable a list and store more items into it:
-;; Develop in ~/emacs.d/mysnippets, but also
-;; try out snippets in ~/Downloads/interesting-snippets
-(setq yas/root-directory '("~/emacs.d/mysnippets"
- "~/Downloads/interesting-snippets"))
-
-;; Map `yas/load-directory' to every element
-(mapc 'yas/load-directory yas/root-directory)
-
In this last example, the all the directories are loaded and their -snippets considered for expansion. However development still happens -in the first element, "~/emacs.d/mysnippets".
-Once you've setup yas/root-directory , you can store snippets -inside sub-directories of these directories.
-Snippet definitions are put in plain text files. They are arranged by -sub-directories, and the snippet tables are named after these directories.
-The name corresponds to the Emacs mode where you want expansion to -take place. For example, snippets for c-mode are put in the -c-mode sub-directory. You can also skip snippet storage altogether -and use the bundle (see YASnippet bundle).
-Here is an excerpt of a directory hierarchy containing snippets -for some modes:
-$ tree
-.
-`-- text-mode
- |-- cc-mode
- | |-- c-mode
- | | `-- printf
- | |-- for
- | |-- java-mode
- | | `-- println
- | `-- while
- |-- email
- |-- perl-mode
- | |-- cperl-mode
- | `-- for
- `-- time
-
A parent directory acts as a parent table of any of its -sub-directories. This is one of the ways different Emacs major modes -can share snippet definitions. As you can see above, c-mode and -java-mode share the same parent cc-mode and its while -snipepts, while all modes are share the time snippet from -text-mode.
-This can be also used to as an alias -- cperl-mode is an empty -directory whose parent is perl-mode.
-An alternate (and preferred) way of setting up parent tables consists -of placing a plain text file .yas-parents inside one of the -sub-directories. By doing this, you avoid complex directory -nesting. In the .yas-parents file you just write -whitespace-separated names of modes. This allows more flexibility and -readability of your snippet hierarchy.
-$ tree
-.
-|-- c-mode
-| |-- .yas-parents # contains "cc-mode text-mode"
-| `-- printf
-|-- cc-mode
-| |-- for
-| `-- while
-|-- java-mode
-| |-- .yas-parents # contains "cc-mode text-mode"
-| `-- println
-`-- text-mode
- |-- email
- `-- time
-
If you place an empty plain text file .yas-make-groups inside one -of the mode directories, the names of these sub-directories are -considered groups of snippets and The YASnippet Menu is organized -much more cleanly, as you can see in the image.
-Another alternative way to achieve this is to place a # group: -directive inside the snippet definition. See Writing Snippets.
-$ tree ruby-mode/
-ruby-mode/
-|-- .yas-make-groups
-|-- collections
-| |-- each
-| `-- ...
-|-- control structure
-| |-- forin
-| `-- ...
-|-- definitions
-| `-- ...
-`-- general
- `-- ...
-
Normally, file names act as the snippet expansion abbreviation (also -known as the snippet key or snippet trigger, see Expanding -Snippets).
-However, if you customize the variable -yas/ignore-filenames-as-triggers to be true or place an empty -file .yas-ignore-filename-triggers you can use much more -descriptive file names. This is useful if many snippets within a mode -share the same trigger key.
-$ tree rails-mode/
-rails-mode/
-|-- .yas-make-groups
-|-- .yas-ignore-filename-triggers
-|-- Insert ERb's <% __ %> or <%= __ %>.yasnippet
-|-- asserts
-| |-- assert(var = assigns(%3Avar)).yasnippet
-| |-- assert_difference.yasnippet
-| |-- assert_no_difference.yasnippet
-| |-- assert_redirected_to (nested path plural).yasnippet
-| |-- assert_redirected_to (nested path).yasnippet
-| |-- assert_redirected_to (path plural).yasnippet
-| |-- assert_redirected_to (path).yasnippet
-| |-- assert_rjs.yasnippet
-| `-- assert_select.yasnippet
-
The most convenient way to define snippets for YASnippet is to put -them in a directory arranged by the mode and use -yas/load-directory to load them.
-However, this might slow down the Emacs start-up speed if you have many -snippets. You can use yas/define-snippets to define a bunch of -snippets for a particular mode in an Emacs-lisp file.
-Since this is hard to maintain, there's a better way: define your -snippets in directory and then call M-x yas/compile-bundle to -compile it into a bundle file when you modified your snippets.
-The release bundle of YASnippet is produced by -yas/compile-bundle. The bundle uses yas/define-snippets to -define snippets. This avoids the IO and parsing overhead when loading -snippets.
-Further more, the generated bundle is a stand-alone file not depending -on yasnippet.el. The released bundles of YASnippet are all -generated this way.
-See the internal documentation for these functions
-Root directory that stores the snippets for each major mode.
-If you set this from your .emacs, can also be a list of strings, -for multiple root directories. If you make this a list, the first -element is always the user-created snippets directory. Other -directories are used for bulk reloading of all snippets using -yas/reload-all
-If non-nil, don't derive tab triggers from filenames.
-This means a snippet without a # key: directive wont have a tab -trigger.
- - - -...
-# --
-
- $0
-
\ No newline at end of file
diff --git a/extensions/yasnippet/snippets/html-mode/code.class b/extensions/yasnippet/snippets/html-mode/code.class
deleted file mode 100644
index b910eb7..0000000
--- a/extensions/yasnippet/snippets/html-mode/code.class
+++ /dev/null
@@ -1,6 +0,0 @@
-#contributor : Jimmy Wu ...
-# --
-
- $0
-
\ No newline at end of file
diff --git a/extensions/yasnippet/snippets/html-mode/div b/extensions/yasnippet/snippets/html-mode/div
deleted file mode 100644
index 1c9c0c8..0000000
--- a/extensions/yasnippet/snippets/html-mode/div
+++ /dev/null
@@ -1,3 +0,0 @@
-#name : ...
-# -- -$1
\ No newline at end of file diff --git a/extensions/yasnippet/snippets/html-mode/pre b/extensions/yasnippet/snippets/html-mode/pre deleted file mode 100644 index 58e77cf..0000000 --- a/extensions/yasnippet/snippets/html-mode/pre +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu...-# -- -
- $0 -\ No newline at end of file diff --git a/extensions/yasnippet/snippets/html-mode/quote b/extensions/yasnippet/snippets/html-mode/quote deleted file mode 100644 index 694185b..0000000 --- a/extensions/yasnippet/snippets/html-mode/quote +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu
...-# -- -
- $1 -\ No newline at end of file diff --git a/extensions/yasnippet/snippets/html-mode/script.javascript b/extensions/yasnippet/snippets/html-mode/script.javascript deleted file mode 100644 index 807f0ea..0000000 --- a/extensions/yasnippet/snippets/html-mode/script.javascript +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Jimmy Wu
...
-# --
-
- $0
-
\ No newline at end of file
diff --git a/extensions/yasnippet/snippets/nxml-mode/div b/extensions/yasnippet/snippets/nxml-mode/div
deleted file mode 100644
index 90fbc2e..0000000
--- a/extensions/yasnippet/snippets/nxml-mode/div
+++ /dev/null
@@ -1,4 +0,0 @@
-#contributor : Anders Bach Nielsen ...
-# -- -$1
\ No newline at end of file diff --git a/extensions/yasnippet/snippets/nxml-mode/pre b/extensions/yasnippet/snippets/nxml-mode/pre deleted file mode 100644 index b92cabb..0000000 --- a/extensions/yasnippet/snippets/nxml-mode/pre +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen...-# -- -
- $0 -\ No newline at end of file diff --git a/extensions/yasnippet/snippets/nxml-mode/quote b/extensions/yasnippet/snippets/nxml-mode/quote deleted file mode 100644 index 5e17c98..0000000 --- a/extensions/yasnippet/snippets/nxml-mode/quote +++ /dev/null @@ -1,6 +0,0 @@ -#contributor : Anders Bach Nielsen
...-# -- -
- $1 -\ No newline at end of file diff --git a/extensions/yasnippet/snippets/nxml-mode/span b/extensions/yasnippet/snippets/nxml-mode/span deleted file mode 100644 index 69d5332..0000000 --- a/extensions/yasnippet/snippets/nxml-mode/span +++ /dev/null @@ -1,4 +0,0 @@ -#contributor : Anders Bach Nielsen