diff --git a/new-style/ck-ref.html b/new-style/ck-ref.html new file mode 100644 index 0000000..b642b3c --- /dev/null +++ b/new-style/ck-ref.html @@ -0,0 +1,373 @@ + + + + + + +Reference + + + + + + +
+

Reference

+
+

Table of Contents

+ +
+ +
+

Interactive functions

+
+
+
+

yas-load-snippet-buffer-and-close (table &optional kill)

+
+

+Load and save the snippet, then quit-window if saved. +Loading is performed by yas-load-snippet-buffer. If the +snippet is new, ask the user whether (and where) to save it. If +the snippet already has a file, just save it. +

+ +

+The prefix argument kill is passed to quit-window. +

+ +

+Don't use this from a Lisp program, call yas-load-snippet-buffer +and kill-buffer instead. +

+
+
+ +
+

yas-load-directory (top-level-dir &optional use-jit interactive)

+
+

+Load snippets in directory hierarchy top-level-dir. +

+ +

+Below top-level-dir each directory should be a mode name. +

+ +

+With prefix argument use-jit do jit-loading of snippets. +

+
+
+ +
+

yas-describe-table-by-namehash ()

+
+

+Display snippet tables by namehash. +

+
+
+ +
+

yas-tryout-snippet (&optional debug)

+
+

+Test current buffer's snippet template in other buffer. +debug is for debugging the YASnippet engine itself. +

+
+
+
+
+

Customization variables

+
+
+
+

yas-expand-only-for-last-commands

+
+

+List of last-command values to restrict tab-triggering to, or nil. +

+ +

+Leave this set at nil (the default) to be able to trigger an +expansion simply by placing the cursor after a valid tab trigger, +using whichever commands. +

+ +

+Optionally, set this to something like (self-insert-command) if +you to wish restrict expansion to only happen when the last +letter of the snippet tab trigger was typed immediately before +the trigger key itself. +

+
+
+ +
+

yas-wrap-around-region

+
+

+What to insert for snippet's $0 field. +

+ +

+If set to a character, insert contents of corresponding register. +If non-nil insert region contents. This can be overridden on a +per-snippet basis. A value of cua is considered equivalent to +`?0' for backwards compatibility. +

+
+
+ +
+

yas-new-snippet-default

+
+

+Default snippet to use when creating a new snippet. +If nil, don't use any snippet. +

+
+
+
+
+
+

Validate

+
+ + diff --git a/new-style/example-snippet.html b/new-style/example-snippet.html new file mode 100644 index 0000000..4967340 --- /dev/null +++ b/new-style/example-snippet.html @@ -0,0 +1,40 @@ + + + + + *Org Src snippet-development.org[ snippet ]* + + + +
+# contributor: pluskid <pluskid@gmail.com>
+# name: __...__
+# --
+__${init}__
+ + diff --git a/new-style/faq.html b/new-style/faq.html new file mode 100644 index 0000000..0214560 --- /dev/null +++ b/new-style/faq.html @@ -0,0 +1,395 @@ + + + + + + +Frequently Asked Questions + + + + + + +
+ +
+
+

Frequently Asked Questions

+
+

Table of Contents

+ +
+ +
+

Why is there an extra newline?

+
+

+If there is a newline at the end of a snippet definition file, +YASnippet will add a newline when expanding that snippet. When editing +or saving a snippet file, please be careful not to accidentally add a +terminal newline. +

+ +

+Note that 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 automatically. +

+
+
+ +
+

Why doesn't TAB navigation work with flyspell

+
+

+A workaround is to inhibit flyspell overlays while the snippet is +active: +

+ +
+
(add-hook 'flyspell-incorrect-hook
+          #'(lambda (dummy1 dummy2 dymmy3)
+              (and yas-active-field-overlay
+                   (overlay-buffer yas-active-field-overlay))))
+
+
+ +

+This is apparently related to overlay priorities. For some reason, the +keymap property of flyspell's overlays always takes priority over the +same property in YASnippet's overlays, even if one sets the latter's +priority property to something big. If you know emacs-lisp and can +solve this problem, drop a line in the +discussion group. +

+
+
+ +
+

How do I use alternative keys, i.e. not TAB?

+
+

+Edit the keymaps yas-minor-mode-map and +yas-keymap as you would any other keymap: +

+ +
+
(define-key yas-minor-mode-map (kbd "<tab>") nil)
+(define-key yas-minor-mode-map (kbd "TAB") nil)
+(define-key yas-minor-mode-map (kbd "<the new key>") yas-maybe-expand)
+
+;;keys for navigation
+(define-key yas-keymap [(tab)]       nil)
+(define-key yas-keymap (kbd "TAB")   nil)
+(define-key yas-keymap [(shift tab)] nil)
+(define-key yas-keymap [backtab]     nil)
+(define-key yas-keymap (kbd "<new-next-field-key>") 'yas-next-field-or-maybe-expand)
+(define-key yas-keymap (kbd "<new-prev-field-key>") 'yas-prev)
+
+
+
+
+ +
+

How do I turn off the minor mode where in some buffers?

+
+

+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. +

+
+
+ +
+

How do I define an abbrev key containing characters not supported by the filesystem?

+
+
    +
  • Note: This question applies if you're still defining snippets +whose key is the filename. This is behavior still provided by +version 0.6 for backward compatibilty, but is somewhat +deprecated…
  • +
+ +

+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>
+
+
+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/images/bg-content-left.png b/new-style/images/bg-content-left.png new file mode 100644 index 0000000..a64b346 Binary files /dev/null and b/new-style/images/bg-content-left.png differ diff --git a/new-style/images/bg-content-right.png b/new-style/images/bg-content-right.png new file mode 100644 index 0000000..f07ebb5 Binary files /dev/null and b/new-style/images/bg-content-right.png differ diff --git a/new-style/images/bg-content.png b/new-style/images/bg-content.png new file mode 100644 index 0000000..d55828e Binary files /dev/null and b/new-style/images/bg-content.png differ diff --git a/new-style/images/bg-navigation-item-hover.png b/new-style/images/bg-navigation-item-hover.png new file mode 100644 index 0000000..c783d71 Binary files /dev/null and b/new-style/images/bg-navigation-item-hover.png differ diff --git a/new-style/images/bg-navigation-item.png b/new-style/images/bg-navigation-item.png new file mode 100644 index 0000000..d2452ac Binary files /dev/null and b/new-style/images/bg-navigation-item.png differ diff --git a/new-style/images/bg-navigation.png b/new-style/images/bg-navigation.png new file mode 100644 index 0000000..18b9559 Binary files /dev/null and b/new-style/images/bg-navigation.png differ diff --git a/new-style/images/body.png b/new-style/images/body.png new file mode 100644 index 0000000..b361e7b Binary files /dev/null and b/new-style/images/body.png differ diff --git a/new-style/images/customization-group.png b/new-style/images/customization-group.png new file mode 100644 index 0000000..b10827f Binary files /dev/null and b/new-style/images/customization-group.png differ diff --git a/new-style/images/dropdown-menu.png b/new-style/images/dropdown-menu.png new file mode 100644 index 0000000..57d482e Binary files /dev/null and b/new-style/images/dropdown-menu.png differ diff --git a/new-style/images/external.png b/new-style/images/external.png new file mode 100644 index 0000000..419c06f Binary files /dev/null and b/new-style/images/external.png differ diff --git a/new-style/images/ido-menu.png b/new-style/images/ido-menu.png new file mode 100644 index 0000000..df392c5 Binary files /dev/null and b/new-style/images/ido-menu.png differ diff --git a/new-style/images/menu-1.png b/new-style/images/menu-1.png new file mode 100644 index 0000000..d2e6a51 Binary files /dev/null and b/new-style/images/menu-1.png differ diff --git a/new-style/images/menu-2.png b/new-style/images/menu-2.png new file mode 100644 index 0000000..abb8a72 Binary files /dev/null and b/new-style/images/menu-2.png differ diff --git a/new-style/images/menu-groups.png b/new-style/images/menu-groups.png new file mode 100644 index 0000000..fcedda8 Binary files /dev/null and b/new-style/images/menu-groups.png differ diff --git a/new-style/images/menu-parent.png b/new-style/images/menu-parent.png new file mode 100644 index 0000000..f0fa10c Binary files /dev/null and b/new-style/images/menu-parent.png differ diff --git a/new-style/images/minor-mode-indicator.png b/new-style/images/minor-mode-indicator.png new file mode 100644 index 0000000..3743455 Binary files /dev/null and b/new-style/images/minor-mode-indicator.png differ diff --git a/new-style/images/x-menu.png b/new-style/images/x-menu.png new file mode 100644 index 0000000..3bc9a15 Binary files /dev/null and b/new-style/images/x-menu.png differ diff --git a/new-style/index.html b/new-style/index.html new file mode 100644 index 0000000..ffec7fe --- /dev/null +++ b/new-style/index.html @@ -0,0 +1,327 @@ + + + + + + +Yet another snippet extension + + + + + + +
+ +
+
+

Yet another snippet extension

+

+The YASnippet documentation has been split into separate parts: +

+ +
    +
  1. +README +

    + +

    +Contains an introduction, installation instructions and other important +notes. +

  2. + +
  3. +Organizing Snippets +

    + +

    +Describes ways to organize your snippets in the hard disk. +

  4. + +
  5. +Expanding Snippets +

    + +

    +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… +

  6. + +
  7. +Writing Snippets +

    + +

    +Describes the YASnippet definition syntax, which is very close (but +not equivalent) to Textmate's. Includes a section about converting +TextMate snippets. +

  8. + +
  9. +The YASnippet menu +

    + +

    +Explains how to use the YASnippet menu to explore, learn and modify +snippets. +

  10. + +
  11. +Frequently asked questions +

    + +

    +Answers to frequently asked questions. +

  12. + +
  13. +YASnippet Symbol Reference +

    + +

    +An automatically generated listing of all YASnippet commands, +(customization) variables, and functions. +

  14. +
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/snippet-development.html b/new-style/snippet-development.html new file mode 100644 index 0000000..d66cf87 --- /dev/null +++ b/new-style/snippet-development.html @@ -0,0 +1,989 @@ + + + + + + +Writing snippets + + + + + + +
+ +
+
+

Writing snippets

+
+

Table of Contents

+ +
+ +
+

Snippet development

+
+
+
+

Quickly finding snippets

+
+

+There are some ways you can quickly find a snippet file or create a new one: +

+ +
    +
  • +M-x yas-new-snippet, key bindind: C-c & C-n +

    + +

    +Creates a new buffer with a template for making a new snippet. The +buffer is in snippet-mode (see below). When you are done editing +the new snippet, use C-c C-c to save it. +

  • + +
  • +M-x yas-visit-snippet-file, key binding: C-c & C-v +

    + +

    +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. +

+
+
+ +
+

Using the snippet-mode major mode

+
+

+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. +

+ +

+Three commands are defined in this mode: +

+ +
    +
  • +M-x yas-load-snippet-buffer, key binding: C-c C-l +

    + +

    +Prompts for a snippet table (with a default based on snippet's +major mode) and loads the snippet currently being edited. +

  • + +
  • +M-x yas-load-snippet-buffer-and-close, key binding: C-c C-c + +

    + +

    +Like yas-load-snippet-buffer, but also saves the snippet and +calls quit-window. The destination is decided based on the +chosen snippet table and snippet collection directly (defaulting to +the first directory in yas-snippet-dirs (see Organizing Snippets +for more detail on how snippets are organized). +

  • + +
  • +M-x yas-tryout-snippet, key binding: C-c C-t +

    + +

    +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. +

  • +
+ +

+There are also snippets for writing snippets: vars, $f and $m +:-). +

+
+
+
+ +
+

File content

+
+

+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: +

+
+ +
+

# key: snippet abbrev

+
+

+This is the probably the most important directive, it's the +abbreviation you type to expand a snippet just before hitting the key +that runs yas-expand. If you don't specify this, +the snippet will not be expandable through the trigger mechanism. +

+
+
+ +
+

# name: snippet name

+
+

+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. +

+
+
+ +
+

# condition: snippet condition

+
+

+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 +

+
+
+ +
+

# group: snippet menu grouping

+
+

+When expanding/visiting snippets from the menu-bar menu, snippets for a +given mode can be grouped into sub-menus . This is useful if one has too +many snippets for a mode which will make the menu too long. +

+ +

+The # group: property only affect menu construction (See +the YASnippet menu) and the same effect can be +achieved by grouping snippets into sub-directories and using the +.yas-make-groups special file (for this see +Organizing Snippets +

+ +

+Refer to the bundled snippets for ruby-mode for examples on the +# group: directive. Group can also be nested, e.g. +control structure.loops tells that the snippet is under the loops +group which is under the control structure group. +

+
+
+ +
+

# expand-env: expand environment

+
+

+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
+         /     \
+        /-------\
+        |       |
+        |  +-+  |
+        |  | |  |
+        +--+-+--+
+
+
+
+
+ +
+

# binding: direct keybinding

+
+

+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. +

+
+
+ +
+

# type: snippet or command

+
+

+If the type directive is set to command, the body of the snippet +is interpreted as lisp code to be evaluated when the snippet is +triggered. +

+ +

+If it's snippet (the default when there is no type directive), the +snippet body will be parsed according to the Template Syntax, +described below. +

+
+
+ +
+

# uuid: unique identifier

+
+

+This provides to a way to identify a snippet, independent of its name. +Loading a second snippet file with the same uuid would replace the +previous snippet. +

+
+
+ +
+

# 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: +

+ +
+
#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. +

+
+ +
+

Note: backquote expressions should not modify the buffer

+
+

+Please note that the lisp forms in backquotes should not modify the +buffer, doing so will trigger a warning. For example, instead of +doing +

+ +
+
Timestamp: `(insert (current-time-string))`
+
+
+ +

+do this: +

+
+
Timestamp: `(current-time-string)`
+
+
+ +

+The warning may be suppressed with the following code in your init file: +

+
+
(add-to-list 'warning-suppress-types '(yasnippet backquote-change))
+
+
+
+
+
+ + +
+

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: +

+ +
+
<div$1>
+    $0
+</div>
+
+
+
+
+
+

Placeholder fields

+
+

+Tab stops can have default values – a.k.a placeholders. The syntax is +like this: +

+ +
+
${N:default value}
+
+
+ +

+They act as the default value for a tab stop. But when you first +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. +

+
+
+ +
+

Mirrors

+
+

+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. +

+
+
+ +
+

Mirrors with transformations

+
+

+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 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 yas-text)}:($1)aValue
+{
+    [$2 autorelease];
+    $2 = [aValue retain];
+}
+$0
+
+
+ +

+Look at ${2:$(capitalize yas-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 yas-text) ?\=)}
+${1:Title}
+${1:$(make-string (string-width yas-text) ?\=)}
+
+$0
+
+
+
+
+ +
+

Fields with transformations

+
+

+From version 0.6 on, you can also have lisp transformation inside +fields. These work mostly like mirror transformations. However, they +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. +

+
+
+ +
+

Choosing fields value from a list and other tricks

+
+

+As mentioned, the field transformation is invoked just after you enter +the field, and with some useful variables bound, notably +yas-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 +

+
+
+ +
+

Nested placeholder fields

+
+

+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. +

+
+
+ +
+

Indentation markers

+
+

+If yas-indent-line is not set to 'auto, it's still possible to +indent specific lines by adding an indentation marker, $>, somewhere +on the line. +

+
+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/snippet-expansion.html b/new-style/snippet-expansion.html new file mode 100644 index 0000000..d2ffbbf --- /dev/null +++ b/new-style/snippet-expansion.html @@ -0,0 +1,747 @@ + + + + + + +Expanding snippets + + + + + + +
+ +
+
+

Expanding snippets

+
+

Table of Contents

+ +
+

+This section 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 +

+ +
+

Triggering expansion

+
+

+You can use YASnippet to expand snippets in different ways: +

+ +
    +
  • When yas-minor-mode is active: +
      +
    • Type the snippet's trigger key then calling yas-expand +(bound to TAB by default).
    • + +
    • Use the snippet's keybinding.
    • + +
    • By expanding directly from the "YASnippet" menu in the menu-bar
    • + +
    • Using hippie-expand
    • +
  • + +
  • Call yas-insert-snippet (use M-x yas-insert-snippet or its +keybinding C-c & C-s).
  • + +
  • Use m2m's excellent auto-complete +TODO: example for this
  • + +
  • Expanding from emacs-lisp code
  • +
+
+ +
+

Trigger key

+
+

+yas-expand tries to expand a snippet abbrev (also known as +snippet key) before point. YASnippet also provides a conditional +binding for this command: the variable yas-maybe-expand contains a +special value which, when bound in a keymap, tells Emacs to call +yas-expand if and only if there is a snippet abbrev before point. +If there is no snippet to expand, Emacs will behave as if yas-expand +is unbound and so will run whatever command is bound to that key +normally. +

+ +

+When yas-minor-mode is enabled, it binds yas-maybe-expand to TAB +and <tab> by default, however, you can freely remove those bindings: +

+ +
+
(define-key yas-minor-mode-map (kbd "<tab>") nil)
+(define-key yas-minor-mode-map (kbd "TAB") nil)
+
+
+ +

+And set your own: +

+ +
+
;; Bind `SPC' to `yas-expand' when snippet expansion available (it
+;; will still call `self-insert-command' otherwise).
+(define-key yas-minor-mode-map (kbd "SPC") yas-maybe-expand)
+;; Bind `C-c y' to `yas-expand' ONLY.
+(define-key yas-minor-mode-map (kbd "C-c y") #'yas-expand)
+
+
+ + +

+To enable the YASnippet minor mode in all buffers globally use the +command yas-global-mode. This will enable a modeline indicator, +yas: +

+ + +
+

minor-mode-indicator.png +

+
+ +

+When you use yas-global-mode you can also selectively disable +YASnippet in some buffers by calling yas-minor-mode with a negative +argument in the buffer's mode hook. +

+
+ +
+

Fallback behaviour

+
+

+YASnippet used to support a more complicated way of sharing +keybindings before yas-maybe-expand was added. This is now +obsolete. +

+
+
+
+ +
+

Insert at point

+
+

+The command yas-insert-snippet lets you insert snippets at point +for your 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. +

+
+ +
+

Inserting region or register contents into snippet

+
+

+It's often useful to inject already written text in the middle of a +snippet. The variable yas-wrap-around-region when to t substitute +the region contents into the $0 placeholder of a snippet expanded by +yas-insert-snippet. Setting it to a character value (e.g. ?0) +will insert the contents of corresponding register. +

+ +

+Older (versions 0.9.1 and below) of Yasnippet, supported a setting of +cua that is equivalent to ?0 but only worked with cua-mode +turned on. This setting is still supported for backwards +compatibility, but is now entirely equivalent to ?0. +

+
+
+
+ +
+

Snippet keybinding

+
+

+See the section of the # binding: directive in +Writing Snippets. +

+
+
+ +
+

Expanding from the menu

+
+

+See the YASnippet Menu. +

+
+
+ +
+

Expanding with hippie-expand

+
+

+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. +

+
+
+ +
+

Expanding from emacs-lisp code

+
+

+Sometimes you might want to expand a snippet directly from your own +elisp code. You should call yas-expand-snippet instead of +yas-expand in this case. yas-expand-snippet takes a string in +snippet template syntax, if you want to expand an existing snippet you +can use yas-lookup-snippet to find its contents by name. +

+ +

+As with expanding from the menubar, the condition system and multiple +candidates doesn't affect expansion (the condition system does affect +yas-lookup-snippet though). 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 and +yas-lookup-snippet for more information. +

+
+
+
+ +
+

Controlling expansion

+
+
+
+

Eligible snippets

+
+

+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 list of extra modes +

    + +

    +Use yas-activate-extra-mode to +consider snippet tables whose name does not correspond to a major +mode. Typically, you call this from a minor mode hook, for example: +

  • +
+ +
+
;; When entering rinari-minor-mode, consider also the snippets in the
+;; snippet table "rails-mode"
+(add-hook 'rinari-minor-mode-hook
+          #'(lambda ()
+              (yas-activate-extra-mode 'rails-mode)))
+
+
+ + +
+
+ +
+

The condition system

+
+

+Consider this scenario: you are an old Emacs hacker. You like the +abbrev-way and bind yas-expand 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-syntax-comment-or-string-p)). But how about while, for, +etc? Writing the same condition for all the snippets is just boring. +So you can instead set yas-buffer-local-condition to (not +(python-syntax-comment-or-string-p)) in python-mode-hook. +

+ +

+Then, what if you really want some particular snippet to expand even +inside a comment? Set yas-buffer-local-condition like this +

+ +
+
(add-hook 'python-mode-hook
+          (lambda ()
+            (setq yas-buffer-local-condition
+                  '(if (python-syntax-comment-or-string-p)
+                       '(require-snippet-condition . force-in-comment)
+                     t))))
+
+
+ +

+… and for a snippet that you want to expand in comments, specify a +condition which evaluates to the symbol force-in-comment. Then it +can be expanded as you expected, while other snippets like if still +can't expanded in comments. +

+ +

+For the full set of possible conditions, see the documentation for +yas-buffer-local-condition. +

+
+
+ +
+

Multiples snippet with the same key

+
+

+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. +

+
+ +
+

Use the X window system

+
+ +
+

x-menu.png +

+
+ +

+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: +

+ +
    +
  • It usually looks beautiful. E.g. when you compile Emacs with gtk +support, this menu will be rendered with your gtk theme.
  • +
  • Your window system may or may not allow to you use C-n, C-p to +navigate this menu.
  • +
  • This function can't be used when in a terminal.
  • +
+
+
+ +
+

Minibuffer prompting

+
+ +
+

ido-menu.png +

+
+ +

+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. +

+
+
+ +
+

Use dropdown-menu.el

+
+ +
+

dropdown-menu.png +

+
+ +

+The function yas-dropdown-prompt can also be placed in the +yas-prompt-functions list. +

+ +

+This works in both window system and terminal and is customizable, you +can use C-n, C-p to navigate, q to quit and even press 6 as a +shortcut to select the 6th candidate. +

+
+
+ +
+

Roll your own

+
+

+See the documentation on variable yas-prompt-functions +

+
+
+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/snippet-menu.html b/new-style/snippet-menu.html new file mode 100644 index 0000000..db4f77c --- /dev/null +++ b/new-style/snippet-menu.html @@ -0,0 +1,379 @@ + + + + + + +YASnippet menu + + + + + + +
+ +
+
+

YASnippet menu

+
+

Table of Contents

+ +
+

+When yas-minor-mode is active, YASnippet will setup a menu just after +the "Buffers" menu in the menubar. +

+ +

+In this menu, you can find +

+ + + + +
+

menu-1.png +

+
+ +
+

Loading snippets from menu

+
+

+Invoking "Load snippets…" from the menu invokes yas-load-directory +and prompts you for a snippet directory hierarchy to load. +

+ +

+Also useful is the "Reload everything" item to invoke yas-reload-all +which uncondionally reloads all the snippets directories defined in +yas-snippet-dirs and rebuilds the menus. +

+
+
+ +
+

Snippet menu behavior

+
+

+YASnippet will list in this section all the loaded snippet definitions +organized by snippet table name. +

+ +

+You can use this section to explore currently loaded snippets. If you +click on one of them, the default behavior is to expand it, +unconditionally, inside the current buffer. +

+ +

+You can however, customize variable yas-visit-from-menu to be t +which will take you to the snippet definition file when you select it +from the menu. +

+ +

+If you want the menu show only snippet tables whose name corresponds to +a "real" major mode. You do this by setting yas-use-menu to +'real-modes. +

+ +

+Finally, to have the menu show only the tables for the currently active +mode, set yas-use-menu to abbreviate. +

+ +

+These customizations can also be found in the menu itself, under the +"Snippet menu behavior" submenu. +

+
+
+ +
+

Controlling indenting

+
+

+The "Indenting" submenu contains options to control the values of +yas-indent-line and yas-also-auto-indent-first-line. See +Writing snippets. +

+
+
+ +
+

Prompting method

+
+

+The "Prompting method" submenu contains options to control the value of +yas-prompt-functions. See Expanding snippets. +

+
+
+ +
+

Misc

+
+

+The "Misc" submenu contains options to control the values of more +variables. +

+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/snippet-organization.html b/new-style/snippet-organization.html new file mode 100644 index 0000000..e5e4934 --- /dev/null +++ b/new-style/snippet-organization.html @@ -0,0 +1,455 @@ + + + + + + +Organizing snippets + + + + + + +
+ +
+
+

Organizing snippets

+
+

Table of Contents

+ +
+ +
+

Basic structure

+
+

+Snippet collections can be stored in plain text files. They are +arranged by sub-directories naming snippet tables. These mostly +name Emacs major mode names. +

+ +
+.
+|-- c-mode
+|   `-- printf
+|-- java-mode
+|   `-- println
+`-- text-mode
+    |-- email
+    `-- time
+
+ +

+The collections are loaded into snippet tables which the +triggering mechanism (see Expanding Snippets) looks up and +(hopefully) causes the right snippet to be expanded for you. +

+
+
+ +
+

Setting up yas-snippet-dirs

+
+

+The emacs variable yas-snippet-dirs tells YASnippet +which collections to consider. It's used when you activate +yas-global-mode or call +yas-reload-all interactively. +

+ +

+The default considers: +

+ +
    +
  • a personal collection that lives in ~/.emacs.d/snippets
  • +
  • the bundled collection, taken as a relative path to yasnippet.el localtion
  • +
+ +

+When you come across other snippet collections, do the following to try them +out: +

+ +
+
;; Develop in ~/emacs.d/mysnippets, but also
+;; try out snippets in ~/Downloads/interesting-snippets
+(setq yas-snippet-dirs '("~/emacs.d/mysnippets"
+                           "~/Downloads/interesting-snippets"))
+
+;; OR, keeping YASnippet defaults try out ~/Downloads/interesting-snippets
+(setq yas-snippet-dirs (append yas-snippet-dirs
+                               '("~/Downloads/interesting-snippets")))
+
+
+ +

+Collections appearing earlier in the list override snippets with same names +appearing in collections later in the list. yas-new-snippet always stores +snippets in the first collection. +

+
+
+ +
+

The .yas-parents file

+
+

+It's very useful to have certain modes share snippets between +themselves. To do this, choose a mode subdirectory and place a +.yas-parents containing a whitespace-separated list of other mode +names. When you reload those modes become parents of the original +mode. +

+ +
+.
+|-- 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
+
+
+
+ + +
+

TODO The .yas-make-groups file

+
+

+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 menu is organized much more +cleanly: +

+ + +
+

menu-groups.png +

+
+ +

+Another 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
+   `-- ...
+
+ +

+Yet another way to create a nice snippet menu is to write into +.yas-make-groups a menu definition. TODO +

+
+
+ +
+

The .yas-setup.el file

+
+

+If there is file named .yas-setup.el in a mode's snippet +subdirectory, it is loaded along with the snippets. Utility +functions used by the snippets can be put here. +

+
+
+ +
+

The .yas-compiled-snippet.el file

+
+

+You may compile a top-level snippet directory with the +yas-compile-directory function, which will create a +.yas-compiled-snippets.el file under each mode subdirectory, +which contains definitions for all snippets in the subdirectory. +Compilation helps improve loading time. +

+ +

+Alternatively, you may compile all directories in the list +yas-snippet-dirs with the yas-recompile-all function. +

+
+
+ +
+

The .yas-skip file

+
+

+A .yas-skip file in a mode's snippet subdirectory tells YASnippet +not to load snippets from there. +

+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/snippet-reference.html b/new-style/snippet-reference.html new file mode 100644 index 0000000..d4d7ce6 --- /dev/null +++ b/new-style/snippet-reference.html @@ -0,0 +1,1934 @@ + + + + + + +Reference + + + + + + +
+ +
+
+

Reference

+
+

Table of Contents

+
+ +
+
+ +
+

Interactive functions

+
+
+
+

yas-load-snippet-buffer-and-close (table &optional kill)

+
+

+Load and save the snippet, then quit-window if saved. +Loading is performed by yas-load-snippet-buffer. If the +snippet is new, ask the user whether (and where) to save it. If +the snippet already has a file, just save it. +

+ +

+The prefix argument kill is passed to quit-window. +

+ +

+Don't use this from a Lisp program, call yas-load-snippet-buffer +and kill-buffer instead. +

+
+
+ +
+

yas-expand-from-trigger-key (&optional field)

+
+

+Expand a snippet before point. +

+ +

+If no snippet expansion is possible, fall back to the behaviour +defined in yas-fallback-behavior. +

+ +

+Optional argument field is for non-interactive use and is an +object satisfying yas--field-p to restrict the expansion to. +

+
+
+ +
+

yas-skip-and-clear-or-delete-char (&optional field)

+
+

+Clears unmodified field if at field start, skips to next tab. +

+ +

+Otherwise deletes a character normally by calling delete-char. +

+
+
+ +
+

yas-global-mode (&optional arg)

+
+

+Toggle Yas minor mode in all buffers. +With prefix arg, enable Yas-Global mode if arg is positive; +otherwise, disable it. If called from Lisp, enable the mode if +arg is omitted or nil. +

+ +

+Yas minor mode is enabled in all buffers where +yas-minor-mode-on would do it. +See yas-minor-mode for more information on Yas minor mode. +

+
+
+ +
+

yas-recompile-all ()

+
+

+Compile every dir in yas-snippet-dirs. +

+
+
+ +
+

yas-visit-snippet-file ()

+
+

+Choose a snippet to edit, selection like yas-insert-snippet. +

+ +

+Only success if selected snippet was loaded from a file. Put the +visited file in snippet-mode. +

+
+
+ +
+

yas-deactivate-extra-mode (mode)

+
+

+Deactivates the snippets for the given mode in the buffer. +

+
+
+ +
+

yas-prev-field ()

+
+

+Navigate to prev field. If there's none, exit the snippet. +

+
+
+ +
+

yas-load-snippet-buffer (table &optional interactive)

+
+

+Parse and load current buffer's snippet definition into table. +table is a symbol name passed to yas--table-get-create. When +called interactively, prompt for the table name. +Return the yas--template object created +

+
+
+ +
+

yas-exit-all-snippets ()

+
+

+Exit all snippets. +

+
+
+ +
+

yas-next-field (&optional arg)

+
+

+Navigate to the argth next field. +

+ +

+If there's none, exit the snippet. +

+
+
+ +
+

yas-abort-snippet (&optional snippet)

+
+

+warning: no doc for symbol yas-abort-snippet +

+
+
+ +
+

yas-describe-tables (&optional with-nonactive)

+
+

+Display snippets for each table. +

+
+
+ +
+

yas-expand-from-keymap ()

+
+

+Expand/run snippets from keymaps, possibly falling back to original binding. +

+
+
+ + +
+

yas-new-snippet (&optional no-template)

+
+

+Pops a new buffer for writing a snippet. +

+ +

+Expands a snippet-writing snippet, unless the optional prefix arg +no-template is non-nil. +

+
+
+ +
+

yas-reload-all (&optional no-jit interactive)

+
+

+Reload all snippets and rebuild the YASnippet menu. +

+ +

+When no-jit is non-nil force immediate reload of all known +snippets under yas-snippet-dirs, otherwise use just-in-time +loading. +

+ +

+When called interactively, use just-in-time loading when given a +prefix argument. +

+
+
+ +
+

yas-next-field-or-maybe-expand ()

+
+

+Try to expand a snippet at a key before point. +

+ +

+Otherwise delegate to yas-next-field. +

+
+
+ +
+

yas-activate-extra-mode (mode)

+
+

+Activates the snippets for the given mode in the buffer. +

+ +

+The function can be called in the hook of a minor mode to +activate snippets associated with that mode. +

+
+
+ +
+

yas-insert-snippet (&optional no-condition)

+
+

+Choose a snippet to expand, pop-up a list of choices according +to yas-prompt-functions. +

+ +

+With prefix argument no-condition, bypass filtering of snippets +by condition. +

+
+
+ +
+

yas-expand (&optional field)

+
+

+Expand a snippet before point. If no snippet +expansion is possible, defer to yas-fallback-behavior (which see). +

+ +

+Optional argument field is for non-interactive use and is an +object satisfying yas--field-p to restrict the expansion to. +

+
+
+ +
+

yas-minor-mode (&optional arg)

+
+

+Toggle YASnippet mode. +

+ +

+When YASnippet mode is enabled, yas-expand, normally bound to +the tab key, expands snippets of code depending on the major +mode. +

+ +

+With no argument, this command toggles the mode. +positive prefix argument turns on the mode. +Negative prefix argument turns off the mode. +

+ +

+Key bindings: +

+
+key             binding
+---             -------
+
+C-c		Prefix Command
+
+C-c &		Prefix Command
+
+C-c & C-n	yas-new-snippet
+C-c & C-s	yas-insert-snippet
+C-c & C-v	yas-visit-snippet-file
+
+
+
+
+ + +
+

yas-direct-keymaps-reload ()

+
+

+Force reload the direct keybinding for active snippet tables. +

+
+
+ +
+

yas-exit-snippet (snippet)

+
+

+Goto exit-marker of snippet. +

+
+
+ +
+

yas-about ()

+
+

+warning: no doc for symbol yas-about +

+
+
+ +
+

yas-minor-mode-on ()

+
+

+Turn on YASnippet minor mode. +

+ +

+Honour yas-dont-activate-functions, which see. +

+
+
+ +
+

yas-skip-and-clear-field (&optional field)

+
+

+Clears unmodified field if at field start, skips to next tab. +

+
+
+ +
+

yas-compile-directory (top-level-dir)

+
+

+Create .yas-compiled-snippets.el files under subdirs of top-level-dir. +

+ +

+This works by stubbing a few functions, then calling +yas-load-directory. +

+
+
+ +
+

yas-load-directory (top-level-dir &optional use-jit interactive)

+
+

+Load snippets in directory hierarchy top-level-dir. +

+ +

+Below top-level-dir each directory should be a mode name. +

+ +

+With prefix argument use-jit do jit-loading of snippets. +

+
+
+ +
+

yas-describe-table-by-namehash ()

+
+

+Display snippet tables by namehash. +

+
+
+ +
+

yas-tryout-snippet (&optional debug)

+
+

+Test current buffer's snippet template in other buffer. +debug is for debugging the YASnippet engine itself. +

+
+
+
+
+

Customization variables

+
+
+
+

yas-expand-only-for-last-commands

+
+

+List of last-command values to restrict tab-triggering to, or nil. +

+ +

+Leave this set at nil (the default) to be able to trigger an +expansion simply by placing the cursor after a valid tab trigger, +using whichever commands. +

+ +

+Optionally, set this to something like (self-insert-command) if +you to wish restrict expansion to only happen when the last +letter of the snippet tab trigger was typed immediately before +the trigger key itself. +

+
+
+ +
+

yas-wrap-around-region

+
+

+What to insert for snippet's $0 field. +

+ +

+If set to a character, insert contents of corresponding register. +If non-nil insert region contents. This can be overridden on a +per-snippet basis. A value of cua is considered equivalent to +`?0' for backwards compatibility. +

+
+
+ +
+

yas-new-snippet-default

+
+

+Default snippet to use when creating a new snippet. +If nil, don't use any snippet. +

+
+
+ +
+

yas-choose-keys-first

+
+

+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. +

+
+
+ +
+

yas-triggers-in-field

+
+

+If non-nil, allow stacked expansions (snippets inside snippets). +

+ +

+Otherwise yas-next-field-or-maybe-expand just moves on to the +next field +

+
+
+ +
+

yas-use-menu

+
+

+Display a YASnippet menu in the menu bar. +

+ +

+When non-nil, submenus for each snippet table will be listed +under the menu "Yasnippet". +

+ +
    +
  • If set to abbreviate, only the current major-mode
  • +
+

+menu and the modes set in yas--extra-modes are listed. +

+ +
    +
  • If set to full, every submenu is listed
  • + +
  • If set to nil, hide the menu.
  • +
+ +

+Any other non-nil value, every submenu is listed. +

+
+
+ +
+

yas-snippet-dirs ()

+
+

+Return variable yas-snippet-dirs as list of strings. +

+
+
+ +
+

yas-buffer-local-condition

+
+

+Snippet expanding condition. +

+ +

+This variable is a Lisp form which is evaluated every time a +snippet expansion is attempted: +

+ +
    +
  • If it evaluates to nil, no snippets can be expanded.
  • + +
  • If it evaluates to the a cons (require-snippet-condition +. requirement) + +
      +
    • Snippets bearing no "# condition:" directive are not +considered
    • + +
    • Snippets bearing conditions that evaluate to nil (or +produce an error) won't be considered.
    • + +
    • If the snippet has a condition that evaluates to non-nil +result: + +
        +
      • If requirement is t, the snippet is considered
      • + +
      • If requirement is eq result, the snippet is +considered
      • + +
      • Otherwise, the snippet is not considered.
      • +
    • +
  • + +
  • If it evaluates to the symbol always, all snippets are +considered for expansion, regardless of any conditions.
  • + +
  • If it evaluates to t or some other non-nil value + +
      +
    • Snippet bearing no conditions, or conditions that +evaluate to non-nil, are considered for expansion.
    • + +
    • Otherwise, the snippet is not considered.
    • +
  • +
+ +

+Here's an example preventing snippets from being expanded from +inside comments, in python-mode only, with the exception of +snippets returning the symbol force-in-comment in their +conditions. +

+ +

+(add-hook 'python-mode-hook + (lambda () + (setq yas-buffer-local-condition + '(if (python-syntax-comment-or-string-p) + '(require-snippet-condition . force-in-comment) + t)))) +

+
+
+ +
+

yas-choose-tables-first

+
+

+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 +

+
+
+ +
+

yas-overlay-priority

+
+

+Priority to use for yasnippets overlays. +This is useful to control whether snippet navigation bindings +override bindings from other packages (e.g., company-mode). +

+
+
+ +
+

yas-snippet-revival

+
+

+Non-nil means re-activate snippet fields after undo/redo. +

+
+
+ +
+

yas-good-grace

+
+

+If non-nil, don't raise errors in elisp evaluation. +

+ +

+This affects both the inline elisp in snippets and the hook +variables such as yas-after-exit-snippet-hook. +

+ +

+If this variable's value is inline, an error string "[yas] +error" is returned instead of raising the error. If this +variable's value is hooks, a message is output to according to +yas-verbosity-level. If this variable's value is t, both are +active. +

+
+
+ +
+

yas-visit-from-menu

+
+

+If non-nil visit snippets's files from menu, instead of expanding them. +

+ +

+This can only work when snippets are loaded from files. +

+
+
+ +
+

yas-prompt-functions

+
+

+Functions to prompt for keys, templates, etc interactively. +

+ +

+These functions are called with the following arguments: +

+ +
    +
  • prompt: A string to prompt the user
  • + +
  • choices: a list of strings or objects.
  • + +
  • optional display-fn : A function that, when applied to each of
  • +
+

+the objects in choices will return a string. +

+ +

+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). +

+ +
    +
  • To signal that your particular style of prompting is
  • +
+

+unavailable at the moment, you can also have the function return +nil. +

+ +
    +
  • To signal that the user quit the prompting process, you can
  • +
+

+signal quit with +

+
+
(signal 'quit "user quit!")
+
+
+
+
+ + +
+

yas-trigger-symbol

+
+

+The text that will be used in menu to represent the trigger. +

+
+
+ +
+

yas-also-indent-empty-lines

+
+

+Non-nil means also indent empty lines according to mode. +

+
+
+ +
+

yas-also-auto-indent-first-line

+
+

+Non-nil means also auto indent first line according to mode. +

+ +

+Naturally this is only valid when yas-indent-line is auto. +

+
+
+ +
+

yas-indent-line

+
+

+Controls indenting applied to a recent snippet expansion. +

+ +

+The following values are possible: +

+ +
    +
  • fixed Indent the snippet to the current column;
  • + +
  • auto Indent each line of the snippet with indent-according-to-mode
  • +
+ +

+Every other value means don't apply any snippet-side indentation +after expansion (the manual per-line "$>" indentation still +applies). +

+
+
+ +
+

yas-alias-to-yas/prefix-p

+
+

+If non-nil make aliases for the old style yas/ prefixed symbols. +It must be set to nil before loading yasnippet to take effect. +

+
+
+
+
+

Useful functions

+
+
+
+

yas-expand-snippet (snippet &optional start end expand-env)

+
+

+Expand snippet at current point. +

+ +

+Text between start and end will be deleted before inserting +template. expand-env is a list of (sym value) let-style dynamic +bindings considered when expanding the snippet. If omitted, use +snippet's expand-env field. +

+ +

+snippet may be a snippet structure (e.g., as returned by +yas-lookup-snippet), or just a snippet body (which is a string +for normal snippets, and a list for command snippets). +

+
+
+ +
+

yas-define-snippets (mode snippets)

+
+

+Define snippets for mode. +

+ +

+snippets is a list of snippet definitions, each taking the +following form +

+ +

+(key template name condition group expand-env load-file keybinding uuid save-file) +

+ +

+Within these, only key and template are actually mandatory. +

+ +

+template might be a Lisp form or a string, depending on whether +this is a snippet or a snippet-command. +

+ +

+condition, expand-env and keybinding are Lisp forms, they have +been yas--read-lisp-ed and will eventually be +yas--eval-for-string-ed. +

+ +

+The remaining elements are strings. +

+ +

+file is probably of very little use if you're programatically +defining snippets. +

+ +

+uuid is the snippet's "unique-id". Loading a second snippet +file with the same uuid would replace the previous snippet. +

+ +

+You can use yas--parse-template to return such lists based on +the current buffers contents. +

+
+
+ +
+

yas-completing-prompt (prompt choices &optional display-fn completion-fn)

+
+

+warning: no doc for symbol yas-completing-prompt +

+
+
+ +
+

yas-inside-string ()

+
+

+Return non-nil if the point is inside a string according to font-lock. +

+
+
+ +
+

yas-lookup-snippet (name &optional mode noerror)

+
+

+Get the snippet named name in mode's tables. +

+ +

+mode defaults to the current buffer's major-mode. If noerror +is non-nil, then don't signal an error if there isn't any snippet +called name. +

+ +

+Honours yas-buffer-local-condition. +

+
+
+ +
+

yas-x-prompt (prompt choices &optional display-fn)

+
+

+Display choices in a x-window prompt. +

+
+
+ +
+

yas-global-mode-enable-in-buffers ()

+
+

+warning: no doc for symbol yas-global-mode-enable-in-buffers +

+
+
+ +
+

yas-selected-text ()

+
+

+Return yas-selected-text if that exists and is non-empty, else nil. +

+
+
+ +
+

yas-field-value (number)

+
+

+Get the string for field with number. +

+ +

+Use this in primary and mirror transformations to get the text of +other fields. +

+
+
+ +
+

yas-global-mode-cmhh ()

+
+

+warning: no doc for symbol yas-global-mode-cmhh +

+
+
+ +
+

yas-escape-text (text)

+
+

+Escape text for snippet. +

+
+
+ +
+

yas-dropdown-prompt (_prompt choices &optional display-fn)

+
+

+warning: no doc for symbol yas-dropdown-prompt +

+
+
+ +
+

yas-shortest-key-until-whitespace (_start-point)

+
+

+Like yas-longest-key-from-whitespace but take the shortest key. +

+
+
+ +
+

yas-substr (str pattern &optional subexp)

+
+

+Search pattern in str and return subexpth match. +

+ +

+If found, the content of subexp group subexp (default 0) is + returned, or else the original str will be returned. +

+
+
+ +
+

yas-ido-prompt (prompt choices &optional display-fn)

+
+

+warning: no doc for symbol yas-ido-prompt +

+
+
+ +
+

yas-maybe-ido-prompt (prompt choices &optional display-fn)

+
+

+warning: no doc for symbol yas-maybe-ido-prompt +

+
+
+ +
+

yas-snippet-mode-buffer-p ()

+
+

+Return non-nil if current buffer should be in snippet-mode. +Meaning it's visiting a file under one of the mode directories in +yas-snippet-dirs. +

+
+
+ +
+

yas-no-prompt (_prompt choices &optional _display-fn)

+
+

+warning: no doc for symbol yas-no-prompt +

+
+
+ +
+

yas-longest-key-from-whitespace (start-point)

+
+

+As yas-key-syntaxes element, look for longest key between point and whitespace. +

+ +

+A newline will be considered whitespace even if the mode syntax +marks it as something else (typically comment ender). +

+
+
+ +
+

yas-try-key-from-whitespace (_start-point)

+
+

+As yas-key-syntaxes element, look for whitespace delimited key. +

+ +

+A newline will be considered whitespace even if the mode syntax +marks it as something else (typically comment ender). +

+
+
+ +
+

yas-choose-value (&rest possibilities)

+
+

+Prompt for a string in possibilities and return it. +

+ +

+The last element of possibilities may be a list of strings. +

+
+
+ +
+

yas-global-mode-check-buffers ()

+
+

+warning: no doc for symbol yas-global-mode-check-buffers +

+
+
+ +
+

yas-minor-mode-set-explicitly ()

+
+

+warning: no doc for symbol yas-minor-mode-set-explicitly +

+
+
+ +
+

yas-define-menu (mode menu &optional omit-items)

+
+

+Define a snippet menu for mode according to menu, omitting omit-items. +

+ +

+menu is a list, its elements can be: +

+ +
    +
  • (yas-item uuid) : Creates an entry the snippet identified with +uuid. The menu entry for a snippet thus identified is +permanent, i.e. it will never move (be reordered) in the menu.
  • + +
  • (yas-separator) : Creates a separator
  • + +
  • (yas-submenu name submenu) : Creates a submenu with name, +submenu has the same form as menu. name is also added to the +list of groups of the snippets defined thereafter.
  • +
+ +

+omit-items is a list of snippet uuids that will always be +omitted from mode's menu, even if they're manually loaded. +

+
+
+ +
+

yas-current-field ()

+
+

+Return the currently active field. +

+
+
+ +
+

yas-unimplemented (&optional missing-feature)

+
+

+warning: no doc for symbol yas-unimplemented +

+
+
+ +
+

yas-define-condition-cache (func doc &rest body)

+
+

+Define a function func with doc doc and body body. +body is executed at most once every snippet expansion attempt, to check +expansion conditions. +

+ +

+It doesn't make any sense to call func programatically. +

+
+
+ +
+

yas-active-keys ()

+
+

+Return all active trigger keys for current buffer and point. +

+
+
+ +
+

yas-text ()

+
+

+Return yas-text if that exists and is non-empty, else nil. +

+
+
+ +
+

yas-next-field-will-exit-p (&optional arg)

+
+

+Return non-nil if (yas-next-field arg) would exit the current snippet. +

+
+
+ +
+

yas-active-snippets (&optional beg end)

+
+

+Return a sorted list of active snippets. +The most recently-inserted snippets are returned first. +

+ +

+Only snippets overlapping the region begend are returned. +Overlapping has the same meaning as described in overlays-in. +If end is omitted, it defaults to (1+ beg). If beg is omitted, +it defaults to point. A non-nil, non-buffer position beg is +equivalent to a range covering the whole buffer. +

+
+
+ +
+

yas-verify-value (possibilities)

+
+

+Verify that the current field value is in possibilities. +Otherwise signal yas-exception. +

+
+
+ +
+

yas-default-from-field (number)

+
+

+warning: no doc for symbol yas-default-from-field +

+
+
+ +
+

yas-key-to-value (alist)

+
+

+warning: no doc for symbol yas-key-to-value +

+
+
+ +
+

yas-throw (text)

+
+

+Signal yas-exception with text as the reason. +

+
+
+ +
+

yas-hippie-try-expand (first-time?)

+
+

+Integrate with hippie expand. +

+ +

+Just put this function in hippie-expand-try-functions-list. +

+
+
+ +
+

yas-maybe-load-snippet-buffer ()

+
+

+Added to after-save-hook in snippet-mode. +

+
+
+
+
+

Useful variables

+
+
+
+

yas-key-syntaxes

+
+

+Syntaxes and functions to help look for trigger keys before point. +

+ +

+Each element in this list specifies how to skip buffer positions +backwards and look for the start of a trigger key. +

+ +

+Each element can be either a string or a function receiving the +original point as an argument. A string element is simply passed +to skip-syntax-backward whereas a function element is called +with no arguments and should also place point before the original +position. +

+ +

+The string between the resulting buffer position and the original +point is matched against the trigger keys in the active snippet +tables. +

+ +

+If no expandable snippets are found, the next element is the list +is tried, unless a function element returned the symbol again, +in which case it is called again from the previous position and +may once more reposition point. +

+ +

+For example, if yas-key-syntaxes has the value ("w" "w_"), +trigger keys composed exclusively of "word"-syntax characters +are looked for first. Failing that, longer keys composed of +"word" or "symbol" syntax are looked for. Therefore, +triggering after +

+ +

+foo-bar +

+ +

+will, according to the "w" element first try "barbaz". If +that isn't a trigger key, "foo-barbaz" is tried, respecting the +second "w_" element. Notice that even if "baz" is a trigger +key for an active snippet, it won't be expanded, unless a +function is added to yas-key-syntaxes that eventually places +point between "bar" and "baz". +

+ +

+See also Info node (elisp) Syntax Descriptors. +

+
+
+ +
+

yas-modified-p

+
+

+Non-nil if field has been modified by user or transformation. +

+
+
+ +
+

yas-dont-activate-functions

+
+

+Special hook to control which buffers yas-global-mode affects. +Functions are called with no argument, and should return non-nil to prevent +yas-global-mode from enabling yasnippet in this buffer. +

+ +

+In Emacsen < 24, this variable is buffer-local. Because +yas-minor-mode-on is called by yas-global-mode after +executing the buffer's major mode hook, setting this variable +there is an effective way to define exceptions to the "global" +activation behaviour. +

+ +

+In Emacsen >= 24, only the global value is used. To define +per-mode exceptions to the "global" activation behaviour, call +yas-minor-mode with a negative argument directily in the major +mode's hook. +

+
+
+ +
+

yas-before-expand-snippet-hook

+
+

+Hooks to run just before expanding a snippet. +

+
+
+ +
+

yas-maybe-skip-and-clear-field

+
+

+A conditional key definition. +This can be used as a key definition in keymaps to bind a key to +yas-skip-and-clear-field only when at the beginning of an +unmodified snippey field. +

+
+
+ +
+

yas-keymap

+
+

+The active keymap while a snippet expansion is in progress. +

+
+
+ +
+

yas-verbosity

+
+

+Log level for yas--message 4 means trace most anything, 0 means nothing. +

+
+
+ +
+

yas-minor-mode-hook

+
+

+Hook run after entering or leaving yas-minor-mode. +No problems result if this variable is not bound. +add-hook automatically binds it. (This is true for all hook variables.) +

+
+
+ +
+

yas-minor-mode-major-mode

+
+

+warning: no doc for symbol yas-minor-mode-major-mode +

+
+
+ +
+

yas-not-string-or-comment-condition

+
+

+Disables snippet expansion in strings and comments. +To use, set yas-buffer-local-condition to this value. +

+
+
+ +
+

yas-after-exit-snippet-hook

+
+

+Hooks to run after a snippet exited. +

+ +

+The hooks will be run in an environment where some variables bound to +proper values: +

+ +

+yas-snippet-beg : The beginning of the region of the snippet. +

+ +

+yas-snippet-end : Similar to beg. +

+ +

+Attention: These hooks are not run when exiting nested/stacked snippet expansion! +

+
+
+ +
+

yas-maybe-expand

+
+

+A conditional key definition. +This can be used as a key definition in keymaps to bind a key to +yas-expand only when there is a snippet available to be +expanded. +

+
+
+ +
+

yas-after-reload-hook

+
+

+Hooks run after yas-reload-all. +

+
+
+ +
+

yas-new-snippet-buffer-name

+
+

+warning: no doc for symbol yas-new-snippet-buffer-name +

+
+
+ +
+

yas-snippet-end

+
+

+End position of the last snippet committed. +

+
+
+ +
+

yas-minor-mode-map

+
+

+The keymap used when yas-minor-mode is active. +

+
+
+ +
+

yas-global-mode-hook

+
+

+Hook run after entering or leaving yas-global-mode. +No problems result if this variable is not bound. +add-hook automatically binds it. (This is true for all hook variables.) +

+
+
+ +
+

yas-snippet-beg

+
+

+Beginning position of the last snippet committed. +

+
+
+ +
+

yas-moving-away-p

+
+

+Non-nil if user is about to exit field. +

+
+
+ +
+

yas-maybe-expand-from-keymap

+
+

+warning: no doc for symbol yas-maybe-expand-from-keymap +

+
+
+ +
+

yas-global-mode-buffers

+
+

+warning: no doc for symbol yas-global-mode-buffers +

+
+
+
+
+
+

Generated by Emacs 26.0.90 (Org mode 9.1.2) from 0.12.2-37-gdc6d7d2 (2018-02-18 12:46:06)

+

Validate

+
+ + diff --git a/new-style/stylesheets/manual.css b/new-style/stylesheets/manual.css new file mode 100644 index 0000000..6bfb6ae --- /dev/null +++ b/new-style/stylesheets/manual.css @@ -0,0 +1,70 @@ +.center { margin-left: auto; margin-right: auto; text-align: center; } +.current { + font-weight: bold; + background-color: #E0E8F0; +} + +body { background-color: #E4F0F4 } +div#content { + max-width: 20cm; + margin-left: auto; + margin-right: auto; +} + +nav li { + vertical-align: top; + + display: inline; + list-style-type: none; + padding: 0.5em; +} +nav > ul > li { + display: inline-block; +} +#snippet-submenu { + padding: 0; +} +li.border { + border: solid; + border-width: 1px; +} + +pre, code{ background-color: #F3F5F7; } +code { + /* http://neugierig.org/software/chromium/notes/2009/09/monospace-fonts-workaround.html */ + font-family: WorkAroundWebKitAndMozilla, monospace; + white-space: nowrap; +} + +/* Styles for htmlize.el fontification. */ + +.org-comment { color: #005000; } /* font-lock-comment-face */ +.org-keyword { font-weight: bold; } /* font-lock-keyword-face */ +.org-string { color: #8b0000; } /* font-lock-string-face */ +.org-warning { color: #ff8c00; + font-weight: bold; } /* warning */ +.org-warning-1 { color: #ff0000; + font-weight: bold; } /* font-lock-warning-face */ +.org-preprocessor { color: #483d8b; } /* font-lock-preprocessor-face */ +.org-constant { color: #008b8b; } /* font-lock-constant-face */ +.org-function-name { color: #0000ff; } /* font-lock-function-name-face */ +.org-type { color: #228b22; } /* font-lock-type-face */ +.org-variable-name { color: #a0522d; } /* font-lock-variable-name-face */ + +.org-rst-adornment { color: #a020f0; } /* rst-adornment */ +.org-rst-block { color: #a020f0; } /* rst-block */ +.org-rst-comment { color: #b22222; } /* rst-comment */ +.org-rst-definition { color: #0000ff; } /* rst-definition */ +.org-rst-directive { color: #483d8b; } /* rst-directive */ +.org-rst-emphasis1 { font-style: italic; } /* rst-emphasis1 */ +.org-rst-emphasis2 { font-weight: bold; } /* rst-emphasis2 */ +.org-rst-external { color: #228b22; } /* rst-external */ +.org-rst-level-1 { background-color: #d9d9d9; } /* rst-level-1 */ +.org-rst-level-2 { background-color: #c7c7c7; } /* rst-level-2 */ +.org-rst-level-3 { background-color: #b5b5b5; } /* rst-level-3 */ +.org-rst-level-4 { background-color: #a3a3a3; } /* rst-level-4 */ +.org-rst-level-5 { background-color: #919191; } /* rst-level-5 */ +.org-rst-level-6 { background-color: #7f7f7f; } /* rst-level-6 */ +.org-rst-literal { color: #8b2252; } /* rst-literal */ +.org-rst-reference { color: #a0522d; } /* rst-reference */ +.org-rst-transition { color: #a020f0; } /* rst-transition */