Giter Site home page Giter Site logo

yasnippet's Introduction

Build Status

Intro

YASnippet is a template system for Emacs. It allows you to type an abbreviation and automatically expand it into function templates. Bundled language templates include: 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 most TextMate templates to YASnippet. Watch a demo on YouTube.

Installation

Manual install from Git

Clone this repository somewhere

$ cd ~/.emacs.d/plugins
$ git clone --recursive https://github.com/joaotavora/yasnippet

Add the following in your .emacs file:

(add-to-list 'load-path
              "~/.emacs.d/plugins/yasnippet")
(require 'yasnippet)
(yas-global-mode 1)

Add your own snippets to ~/.emacs.d/snippets by placing files there or invoking yas-new-snippet.

Install with package-install

In a recent emacs M-x list-packages is the recommended way to list and install packages. It's available from GNU ELPA. If you need a very recent snapshot, you can get it from GNU-devel ELPA as well as MELPA (see http://melpa.org/#installing).

Install with el-get

El-get is another nice way to get the most recent version, too. See https://github.com/dimitri/el-get for instructions.

Use yas-minor-mode on a per-buffer basis

To use YASnippet as a non-global minor mode, don't call yas-global-mode; instead call yas-reload-all to load the snippet tables and then call yas-minor-mode from the hooks of major-modes where you want YASnippet enabled.

(yas-reload-all)
(add-hook 'prog-mode-hook #'yas-minor-mode)

Where are the snippets?

YASnippet no longer bundles snippets directly, but it's very easy to get some!

  1. yasnippet-snippets - a snippet collection package maintained by AndreaCrotti.

    It can be installed with M-x package-install RET yasnippet-snippets if you have added MELPA to your package sources.

  2. yasmate a tool which is dedicated to converting textmate bundles into yasnippet snippets.

    To use these snippets you have to run the tool first, so see its doc), and then point the yas-snippet-dirs variable to the .../yasmate/snippets subdir.

  3. textmate-to-yas.el

    This is another textmate bundle converting tool using Elisp instead of Ruby.

Naturally, you can point yas-snippet-dirs to good snippet collections out there. If you have created snippets for a mode, or multiple modes, consider creating a repository to host them, then tell users that it should be added like this to yas-snippet-dirs:

(setq yas-snippet-dirs
      '("~/.emacs.d/snippets"                 ;; personal snippets
        "/path/to/some/collection/"           ;; foo-mode and bar-mode snippet collection
        "/path/to/yasnippet/yasmate/snippets" ;; the yasmate collection
        ))

(yas-global-mode 1) ;; or M-x yas-reload-all if you've started YASnippet already.

Manual, issues etc

There's comprehensive documentation on using and customising YASnippet.

There's a list of support issues, with solutions to common problems and practical snippet examples.

The Github issue tracker is where most YASnippet-related discussion happens. Nevertheless, since YASnippet is a part of Emacs, you may alternatively report bugs to Emacs via M-x report-emacs-bug or sending an email to [email protected], putting "yasnippet" somewhere in the subject.

Important note regarding bug reporting

Your bug reports are very valuable.

The most important thing when reporting bugs is making sure that we have a way to reproduce the problem exactly like it happened to you.

To do this, we need to rule out interference from external factors like other Emacs extensions or your own customisations.

Here's an example report that "sandboxes" an Emacs session just for reproducing a bug.

$ emacs --version
Emacs 24.3
$ cd /tmp/
$ git clone https://github.com/joaotavora/yasnippet.git yasnippet-bug
$ cd yasnippet-bug
$ git log -1 --oneline
6053db0 Closes #527: Unbreak case where yas-fallback-behaviour is a list
$ HOME=$PWD emacs -L . # This "sandboxes" your emacs, melpa configuration, etc

(require 'yasnippet)
(yas-global-mode 1)

When I open a foo-mode file I don't see foo-mode under the "YASnippet" menu!
OR
When loading yasnippet I see "Error: failed to frobnicate"!

Using emacs -Q or temporarily moving your .emacs init file to the side is another way to achieve good reproducibility.

Here's a another example of a bug report. It has everything needed for a successful analysis and speedy resolution.

Also, don't forget to state the Emacs version (use M-x emacs-version) and the yasnippet version you are using (if using the latest from github, do git log -1 in the dir).

Any more info is welcome, but don't just paste a backtrace or an error message string you got, unless we ask for it.

Finally, thank you very much for using YASnippet!

yasnippet's People

Contributors

barak avatar dgutov avatar eggert avatar ignisf avatar jimeh avatar joaotavora avatar knu avatar mineo avatar monnier avatar notetiene avatar npostavs avatar philhudson avatar phst avatar pierretechoueyres avatar pluskid avatar r3n4ud avatar randymorris avatar rnkn avatar rolandwalker avatar rwc9u avatar snikulov avatar spwhitton avatar syohex avatar tarsius avatar thisirs avatar tkf avatar treese avatar vitovan avatar wasamasa avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yasnippet's Issues

Default Ruby snippets insert an extra empty line

The Ruby snippets all have a single line-feed (\n) character at the end of them. This is a bit annoying when you insert a snippet between two lines, cause you always endup with an extra empty line after the inserted snippet code.

Deal with multiple minor-mode conflict

Some other minor-mode is also defining key bindings: this might conflict
with yas/minor-mode (e.g. orgtbl ?). Try to deal with this problem.

Google Code Info:
Issue #: 13
Author: [email protected]
Created On: 2008-03-21T12:09:44.000Z
Closed On: 2008-04-02T05:06:19.000Z

Snippet broken after leaving snippet entry field

What steps will reproduce the problem?

  1. Expand a snippet such as div for html-mode
  2. Move out of the snippet entry field using C-n or some such
  3. Try to expand an unrelated snippet

What is the expected output? What do you see instead?
The second snippet should expand as normal but instead I get the error
message "Not in a snippet field."

What version of the product are you using? On what operating system?
0.2.2
GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) of 2007-06-02 on RELEASE

Please provide any additional information below.

Google Code Info:
Issue #: 6
Author: [email protected]
Created On: 2008-03-13T17:45:16.000Z
Closed On: 2008-03-15T10:43:02.000Z

Handle escape properly

I'm wondering the current way to handle escapes ($, ` and ) may cause
problems in some cases. Try a better way.

Google Code Info:
Issue #: 12
Author: [email protected]
Created On: 2008-03-20T15:38:01.000Z
Closed On:

yas/expand is not issued after finished expanding uncompletely

What steps will reproduce the problem?

  1. Go out of the field groups, for example, using arrow keys, while some
    field grops remain without modification.
  2. Next time, you can't expand snippet with your trigger key, until you
    return to the last snippets remain to be uncompletely expanded and finished
    expanding by pushing the trigger key.

What version of the product are you using? On what operating system?

yasnippet:

I tried recent revs of yasnippet.el to confirm where the bug thrown into.
It seems between rev. 161 and 162.

Emacs:

GNU Emacs 23.0.51.1 (i686-pc-linux-gnu, multi-tty) of 2008-03-04

Google Code Info:
Issue #: 9
Author: [email protected]
Created On: 2008-03-16T17:07:57.000Z
Closed On: 2008-04-10T04:52:33.000Z

Error on expansion of snippets in python-mode(def, defm, main)

Hi,
When I try to expand 'def' or 'defm' or 'class' in python-mode using
yasnippet.el, I get some errors.

  • What steps will reproduce the problem?
  • Start Emacs and open any .py file.
  • Input "def" or "defm" or "class" and press TAB.
  • What is the expected output? What do you see instead?
    Expected output is
    --- output begin
    def name(self, ):
    """
    """
    --- output end

--- What do we see instead
def name(self, ):
"""
(error in elisp evaluation: Invalid escape character syntax)
--- end

  • What version of the product are you using? On what operating system?
    Emacs 21.4.1 in CentOS 5.1(x86_64), yasnippet 0.5.5

I appriceiate any advices.
Thank you.

Google Code Info:
Issue #: 32
Author: [email protected]
Created On: 2008-07-25T09:45:41.000Z
Closed On: 2008-08-01T07:54:10.000Z

#key in the template file.

I have added a another key support to snippet template file called as #key.
Some templates may will be named with characters unsupported by the
filesystem. The key if defined used as the template trigger.

For example: template named lt

key : <

name : <...></...>

--

<${1:div}>$0</$1>

Google Code Info:
Issue #: 43
Author: [email protected]
Created On: 2008-12-09T16:15:29.000Z
Closed On: 2008-12-09T16:55:56.000Z

No global snippets are available.

What steps will reproduce the problem?

  1. I have following directory layout:
    .emacs.d
    +-> conf
    +-> snippets
    +-> c-mode
    | +-> php-mode
    +-> fundamental-mode
    | +-> css-mode
    +-> text-mode
    | +-> ...
    ...

  2. It is possible to create snippets for the whole text-mode tree or the
    whole fundamental-mode tree, but not for all subtrees.

  3. For example email would be a candidate for a global snippet. I want to
    insert my email address in .c files and in .el files. Now there is only the
    option to copy the files.

Another issue is the fact, that modes must be listed explicity before
snippets are applied. (I guess this is the same problem)
For example:

  1. I have a snippet email in my directory .emacs.d/conf/snippets/c-mode and
    the folder .emacs.d/conf/snippets/c-mode/php-mode exists.
  2. Then the snippet will work in php-mode.
  3. If I delete or do not create the folder php-mode inside c-mode then the
    snippet will not work.

What is the expected output? What do you see instead?
It would be nice if snippets in .emacs.d/conf/snippets (in my scenario) are
globally available and modes do not need to be put explicitly in the tree
to inherit snippets.

What version of the product are you using? On what operating system?
Version 0.5.5 on Windows Vista

Please provide any additional information below.
I guess the key would be to look recursively what modes the currend mode
extends and look for snippets there.

Google Code Info:
Issue #: 34
Author: [email protected]
Created On: 2008-08-02T00:10:20.000Z
Closed On: 2008-08-07T12:46:37.000Z

[svn repo] indent-according-to-mode does not work properly due to narrowing

In yas/expand-snippet (narrow-to-region start start) hides indentation of
the line where a template is being expanded. This indentation is taken into
account by c-indent-line. For example:
template
if (${1:condition}) {
$0$&gt;
}$>
expands to:
if (condition) {
_
}

I suggest you to swap 'Step 13' and 'Step 14' in yas/expand-snippet and use
(overlay-end ...) as a limit for (re-search-forward ...):

    ;; Step 13: remove the trigger key
    (widen)
    (delete-char length)

    ;; Step 14: Do necessary indenting
    (save-excursion
      (let ((ovst (overlay-start (yas/snippet-overlay snippet)))
            (oven (overlay-end (yas/snippet-overlay snippet))))
        (when (and ovst oven)
          (goto-char ovst)
          (while (re-search-forward "$>" oven t)
            (replace-match "")
            (indent-according-to-mode)))))

Google Code Info:
Issue #: 46
Author: [email protected]
Created On: 2008-12-11T20:22:14.000Z
Closed On: 2008-12-12T05:20:31.000Z

c-after-change is preventing insert-behind-hook of yasnippet get called

What steps will reproduce the problem?

  1. Install Emacs 22.1.1 under Linux
  2. Install yasnippet
  3. Open a new .cpp file and expand the `class' snippet.
  4. Type the class name.

What is the expected output? What do you see instead?
It should move the overlay when I type behind the field. But it didn't: the
insert-behind-hook is not being called after text is inserted.

set after-change-functions' to '() can fix this problem. but not proper way. Maybe I need to investigatec-after-change' and
jit-lock-after-change' (and event').

Google Code Info:
Issue #: 3
Author: [email protected]
Created On: 2008-03-10T07:27:33.000Z
Closed On: 2008-03-10T10:45:20.000Z

Conflict with color-scheme-select

What steps will reproduce the problem?

  1. load yasnippet
  2. load color-scheme
  3. M-x color-scheme-select

output: face-attribute: Invalid face: dropdown-list

expected output: a list of color themes to pick from

What version of the product are you using? On what operating system?

color-schemes 6.6.0
emacs 22.2.2
yasnippet 0.5.1

yasnippet works fine. color-themes also works fine (I can choose from
different themes manually). but there seems to be a conflict between the
color-scheme-select function and yasnippet. the function is supposed to
draw a list in a buffer but it does not and this ONLY happens when
yasnippet is active. other modes do not interfere with it. i couldn't
figure out what the problem is. do you have any idea?

Google Code Info:
Issue #: 23
Author: [email protected]
Created On: 2008-04-29T12:35:19.000Z
Closed On: 2008-05-07T01:44:05.000Z

Provide after-exit-hook (and maybe similar hooks)

Sometimes you want to call a function before or after exit the snippet. For
example: call indent-region after exit the snippet. Maybe three level
should be supported:

  • Global hook
  • Local to buffer
  • Local to each snippet

Google Code Info:
Issue #: 8
Author: [email protected]
Created On: 2008-03-15T10:35:13.000Z
Closed On: 2008-03-20T15:56:58.000Z

Executing lisp code after TAB

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

I use MSF abbrevs since long for LATEX templates. I could replace it with
YASnippets (especially the compilation to one file etc.) if the elisp would
be (optionally) executed after going to the next field with TAB instead of
entering a single key.

e.g.:

# --
\section{${1:Name}}%
\index{${1:$(reftex-label)}}%

The reftex funktion takes a (depending on the files) long time to evaluate
the input $1, which makes the template useless to work with. msf abbrev
evaluates after finishing the field with tab, so the function is called once.

So my proposal would be to add some switch (or command) to have this behaviour.

Thank you

What version of the product are you using? On what operating system?

Please provide any additional information below.

Google Code Info:
Issue #: 31
Author: [email protected]
Created On: 2008-07-18T09:53:15.000Z
Closed On:

Support groups of snippets

Whether and it is possible to make a grouping of snippets like in TextMate or emacs-rails mode?

An example for ruby-mode:

YASnippet:
ruby-mode:
general:
all?
any?
...
rails controller:
before_filter
after_filter
...
rails model:
belong_to
has_many
...

Google Code Info:
Issue #: 30
Author: [email protected]
Created On: 2008-07-09T22:11:59.000Z
Closed On: 2009-01-28T07:06:02.000Z

Overlay mess up due to ctrl-/

What steps will reproduce the problem?

  1. snippet "once" in CC-mode, type on $1
  2. Alt-/, hippie-expand partially
  3. Ctrl-/, cancel expand
  4. type something, the whole format is messed up. The overlay seems wrong.

What is the expected output? What do you see instead?

  • No garbage output.

What version of the product are you using? On what operating system?

  • latest one. Win32 and linux

Please provide any additional information below.

Google Code Info:
Issue #: 33
Author: [email protected]
Created On: 2008-07-31T22:18:49.000Z
Closed On: 2008-09-01T15:10:03.000Z

Return nil when can't find snippet to expand

willert:

it would be great if yas/expand' would returnnil" when it wasn't
able to find a expand a key. This would make it trivial to write a
function like `yas-or-dabbrev-expand" or something similar and I can't
see no harm in doing so.

Google Code Info:
Issue #: 17
Author: [email protected]
Created On: 2008-04-02T05:07:16.000Z
Closed On: 2008-04-10T05:33:21.000Z

is this a bug in c++-mode?

in c++-mode, if class B is a sub class, yasnippet will be:

class B : public A
{
public:
B : public A();
~B : public A();
}

Google Code Info:
Issue #: 41
Author: [email protected]
Created On: 2008-12-03T05:00:19.000Z
Closed On: 2008-12-12T05:44:11.000Z

Write comparation between different template extensions for Emacs

quote:

So, could you explain in what yasnippet differ from msfabbrev ?
Are you aware of anything like a comparative chart of all the
available modes ?

Why did you feel the need to rewrite smart-snippet ? How does it
work internally ? Why did you need to write your own templating
system (serious question since I find it is pretty closed to what
Msf Abbrev does).

Answer those questions.

Google Code Info:
Issue #: 11
Author: [email protected]
Created On: 2008-03-19T01:41:51.000Z
Closed On:

Nested extensions support

It would be really nice if I could have recursive extension support

ifeTAB {
ifeTAB --> 2nd level
} else {
1st level
}

This is especially useful for class declarations in high level languages
such as c#...

Google Code Info:
Issue #: 26
Author: [email protected]
Created On: 2008-05-06T23:32:51.000Z
Closed On: 2008-07-15T12:09:20.000Z

pabbrev seems to conflict with yas

What steps will reproduce the problem?

  1. enable pabbrev Mode
  2. enable YAS mode
  3. Start typing, when pabbrev offers up a completion, hit tab. The offered
    up completion by pabbrev changes faces, and tab no longer pabbrev expands.

With yas mode off, pabbrev works again.

Emacs v 22.0.99.1 on Windows (Using EmacsW32 V 1.51)

Google Code Info:
Issue #: 37
Author: [email protected]
Created On: 2008-09-02T22:20:31.000Z
Closed On: 2009-02-05T15:47:15.000Z

Error occurs when multiple candidates exist

  • What steps will reproduce the problem?

Multiple candedates of snippets cause a fatal error on Emacs in term.

  • What is the expected output? What do you see instead?

I'm using emacs with -nw option and expected the first of the candidate is
inserted when there're multiple candidates of snippets.

However, in html-mode, after typing "doctype: and issueing `yas/expand', I
got an error message below:

Wrong type argument: char-or-string-p, [cl-struct-yas/template "" "Doctype HTML 4.01\

Strict"]

  • What version of the product are you using? On what operating system?

yasnippet: rev.149
Emacs: GNU Emacs 23.0.51.1 (i686-pc-linux-gnu, multi-tty) of 2008-03-04,
and on a terminal (emacs -nw)

Google Code Info:
Issue #: 7
Author: [email protected]
Created On: 2008-03-14T19:20:42.000Z
Closed On: 2008-03-15T10:31:21.000Z

Recursive snippet-editing

It would be really nice to have yasnippet work recursively. That is, when
editing a snippet 'tab' would, instead of just skipping to the next
snippet, first try to see if there is a new snippet in the current field,
and if so, insert that and start a 'stacked' snippet editing process.

I dont know if it's clear what I mean, but maybe this use case explains it
better:

There's two snippets:
'if' inserts a regular 'if' statement
'testx' insert 'test_for_x()'

ideally, when I want to insert the code
if (test_for_x()) {
// do something
}

I would type 'if', press tab (inserts the 'if' snippet'), type 'testx',
press tab (would insert the 'x' snippet!), and press tab again would jump
inside the curly braces of the if, exiting the snippet.

Google Code Info:
Issue #: 38
Author: scherpenisse
Created On: 2008-10-10T15:09:25.000Z
Closed On: 2009-07-31T00:02:12.000Z

Emacs 23 win empty overlay issue

Emacs version: GNU Emacs 23.0.0.1 (i386-mingw-nt5.1.2600) of 2007-08-18 on TPAD
Yasnippet version: 0.5.7

Definition of snippet:

name : class ... { ... }

--

class ${1:Name} {
$1();
void ConstructL(${2:args});
public:

$1 *NewL($2);
$1 *NewLC($2);

virtual ~$1();
protected:

private:

};

now, when i'm doing class and delete all text in 1st item (name), all
next inserts seems wrong:

i.e, i enter - i see:
a - aa
s - asaa
d - asdasaa

The problem seems to be that when overlay is empty (i mean begin == end)
then inserting symbol at the beginning not makes overlay to grow.
I fixed it with this solution, maybe there is better...

Google Code Info:
Issue #: 48
Author: [email protected]
Created On: 2008-12-15T18:10:12.000Z
Closed On: 2008-12-25T15:16:59.000Z

Snippets doesn't work in terminal (-nw) mode

What steps will reproduce the problem?

  1. Open 'emacs -nw'
  2. Open arbitrary file in f.e. mode c
  3. Type snippet name and TAB key

What is the expected output? What do you see instead?
Expecting snippet body, nothing happens instead.

What version of the product are you using? On what operating system?
yasnippet v 0.5.2, Ubuntu 7.04

Please provide any additional information below.
YASnippet menu is seen in menu bar. yas/expand command works so maybe it's
just keybindings issue. In window mode everything is ok

Google Code Info:
Issue #: 22
Author: [email protected]
Created On: 2008-04-25T20:54:22.000Z
Closed On: 2008-04-27T05:16:16.000Z

yasnippet 0.5.7 conflict with cedet?

emacs23 in Windows(EmacsW32) and MacOS X(Emacs.app),

I loaded cedet, then load yasnippet 0.5.7, then open a .cpp file(major mode
is c++-mode), input "class" and press TAB, can not expand.

if I use menu YASnippet -> c++-mode -> class, emacs will report
"yas/register-snippet: Wrong type argument: hash-table-p, nil" in Message
buffer.

Google Code Info:
Issue #: 47
Author: [email protected]
Created On: 2008-12-12T06:53:07.000Z
Closed On: 2008-12-12T15:24:08.000Z

Allow transform on first mirror and make the first miror without transform the primary field in that case

What steps will reproduce the problem?

  1. make template for a function with doxygen comment
  2. try to make a transformed field for the @param lines

What is the expected output? What do you see instead?

yasnippet will jump to the transformed field instead of the one without
transform later in the snippet, obviously jumping to the first
non-transformed field instead would be preferable.

What version of the product are you using? On what operating system?

yasnippet 0.5.6 on Gnu Emacs 23.0.60

Please provide any additional information below.

Google Code Info:
Issue #: 35
Author: [email protected]
Created On: 2008-08-17T17:09:57.000Z
Closed On: 2009-07-25T21:20:14.000Z

continuous input two snippet

What steps will reproduce the problem?

  1. if
  2. connect /* three args */

What is the expected output? What do you see instead?
expected: if (connect ( a, b, c) ) {
}
instead: if (connect (a,struct sockaddr *ADDR,socklen_t LENGTH)
<after 3th tab cursor>) {
}
What version of the product are you using? On what operating system?
0.5
Please provide any additional information below.

  1. when i pressed 3th , the cursor is before ") {}", not in
    "sockaddr *ADDR".
  2. after input second , the line will break between "connect()" and
    "{}"

Google Code Info:
Issue #: 19
Author: [email protected]
Created On: 2008-04-12T14:32:06.000Z
Closed On: 2008-05-07T01:55:30.000Z

python-mode def and class snippets

python-mode def and class snippets

Google Code Info:
Issue #: 4
Author: orestis
Created On: 2008-03-11T15:36:04.000Z
Closed On: 2008-03-13T03:01:07.000Z

Certain snippets don't work properly with fci-mode enabled.

The and cls snippet and similar don't work properly with fci-mode enabled. The generated class name that's auto-inserted by the snippet gets inserted right at the end of the snippet, so you endup with:

class 

endMyAwesomeClass

Instead of:

class MyAwesomeClass

end

Aside from that, Yasnippet now works great for me with fci-mode :)

Snippet condition is evaluated twice

What steps will reproduce the problem?

  1. Define snippet "test" in text-mode folder as below (also attached):

condition: (progn (message "hello!") (insert "foo") nil)

--

content

  1. eval (yas/load-directory "~/lisp/snippets")
  2. Get to text-mode buffer, type "test" and press TAB

What is the expected output? What do you see instead?

Expect to see "testfoo", with one "hello!" message in Messages. Actually
see "contentfoofoo" with two "hello!" messages in Messages. So in
addition to being evaluated twice, it's "succeeding" when it shouldn't
(because it returns nil).

What version of the product are you using? On what operating system?

0.4.4
GNU Emacs 22.1.92.1 (i386-mingw-nt6.0.6000) of 2008-03-17 on SLAG

Google Code Info:
Issue #: 15
Author: [email protected]
Created On: 2008-03-25T00:43:35.000Z
Closed On: 2008-04-10T04:41:04.000Z

Killing a snippet leaves garbage overlays behind

What steps will reproduce the problem?

  1. insert a c 'for' snippet
    2.C-a C-k to "give up"
    3.start typing sthg else, green overlays appears

Just wondering if you already took care of this, the version I use is svn from a couple weeks
ago. I'll upload a patch that fixes it and goes well with your very nice coding style, tomorrow,
tonight I'm just trying out typing in iPhone hehehe.

Keep up the amazing work !

Please provide any additional information

Google Code Info:
Issue #: 28
Author: [email protected]
Created On: 2008-05-27T00:26:15.000Z
Closed On: 2008-09-01T15:05:21.000Z

':' or '>' keys in c++-mode would break the snippet

Steps to reproduce,

  1. type 'once' in c++ mode, and followed a tab
  2. input 'test', and input '<' and '>'
    Then another 'test<>' is committed
  3. type 'beginend' in c++ mode, and followed a tab
  4. input 'a', and ':'
    Then the cursor moves to 'e'

see
http://groups.google.com/group/smart-snippet/browse_thread/thread/a0b89a0ecdfea7e1?hl=en

Google Code Info:
Issue #: 27
Author: [email protected]
Created On: 2008-05-22T03:59:11.000Z
Closed On: 2009-01-15T07:24:29.000Z

snippet-local exit-hook

Quote from rubikitch's mail:

I want snippet-local yas/after-exit-snippet-hook.
Then I hacked up it using condition system.

(defvar yas/after-expand-sexp nil)
(defmacro yas/after-expand (&rest body)
 `(progn
    (setq yas/after-expand-sexp
          '(progn
             (save-restriction
               (narrow-to-region yas/snippet-beg yas/snippet-end)
               (goto-char yas/snippet-beg)
               ,@body
               (setq yas/snippet-end (point-max))
               (goto-char (point-max)))))
    t))
(setq yas/before-expand-snippet-hook nil)
(add-hook 'yas/after-exit-snippet-hook
         (lambda ()
           (eval yas/after-expand-sexp)
           (setq yas/after-expand-sexp nil)))

(defun yas/delete (regexp)
 (while (re-search-forward regexp nil t)
   (replace-match "")))

Rationale: I want to write snippets for Mocha, such as `mock' and `stub'.
Mock synopsis is "$1.expects(:$2).with($3).returns($4).times($5)".
`with', `returns' and `times' are optional.

mock = mock()
mock.expects(:method).returns(1)
mock = mock()
mock.expects(:method).with(1,2).returns(3)
mock = mock()
mock.expects(:method).with(1,2).returns(3).times(2)

So I wrote the snippet like this:

#name : mock
#condition: (yas/after-expand (yas/delete "\\.[a-zA-Z0-9]+(IGNORE)"))
# --
${1:mock} = mock()
$1.expects(:${2:method}).with(${3:IGNORE}).returns(${4:IGNORE}).times(${5:IGNORE})

For readability, a new snippet variable should be introduced, such as `after'.
Google Code Info:
Issue #: 25
Author: [email protected]
Created On: 2008-05-03T16:32:12.000Z
Closed On: 

YASnippet get confused when a field get deleted

What steps will reproduce the problem?

  1. expand a field
  2. type something in a field
  3. backspace until delete all text in the field

What is the expected output? What do you see instead?
I expect the field still exist. But it seems to be disappeared.

Google Code Info:
Issue #: 10
Author: [email protected]
Created On: 2008-03-17T01:22:16.000Z
Closed On: 2008-03-17T01:30:54.000Z

Apply transformations on any tab, not only on mirrors

What steps will reproduce the problem?

  1. Create a template like the one attached
  2. Try to use it

What is the expected output? What do you see instead?
Expected output: upcased text
What I see: the text i inputed, without any transformation

What version of the product are you using? On what operating system?
Version 0.5.6 on Linux

Please provide any additional information below.
I guess that feature is just not implemented.

Google Code Info:
Issue #: 36
Author: [email protected]
Created On: 2008-08-30T12:58:00.000Z
Closed On: 2009-07-24T15:06:59.000Z

Python-mode "class" snippet doesn't work into svn trunk

What steps will reproduce the problem?

  1. try to use class snippet in python mode from svn
  2. create some args for init method

What is the expected output?
def init(self, a, b):
"""

    Arguments:
    - `a`:
    - `b`:
    """
    self._a = a
    self._b = b

What do you see instead?
def init(self, a, b):
"""

    Arguments:
    - `a`:
    - `b`:
    """
    self._a = a
    self._b = bself._a = a
    self._a = a
    self._a = aself._a = a

What version of the product are you using? On what operating system?
Emacs 22.3 on Linux.

Please provide any additional information below.
This problem introduced into revision 281.

Google Code Info:
Issue #: 40
Author: [email protected]
Created On: 2008-11-25T09:30:03.000Z
Closed On: 2008-12-11T05:30:34.000Z

Let different modes share some common snippets

One way is to support meta-information for modes:
{{{
import * from common-mode; // import all
import while from common-mode; // import only `while'
import while from common-mode as while2; // import and alias
}}}

Another way is to use complex directory hierarchy:
{{{
common-mode/
for
while
c-mode/
struct
c++-mode/
class
template
}}}

Thanks to Dieken@newsmth.

Google Code Info:
Issue #: 2
Author: [email protected]
Created On: 2008-03-09T02:08:37.000Z
Closed On: 2008-03-10T13:33:00.000Z

Do indenting before expanding

Add a variable (buffer local) to control the behavior of optionally doing
indenting before expands a snippet.

Google Code Info:
Issue #: 16
Author: [email protected]
Created On: 2008-03-26T04:55:26.000Z
Closed On: 2008-09-02T13:07:52.000Z

Suggestions

Hi!

I thought it would be better if we continued or discussion from
smart-snippet here.

I have tried it some more, and I really like it! I have found some things I
don't like though. Maybe you are working on them, but I will mention them
anyway.

  1. Say I have the following snippet:

name : do if condition

--

if ${1:condition}

When I expand it I will at the end automaticly end up on a new line when
entered a condition. Sure I can do this:
if ${1:condition}$0

But it would have been more nice if you by default ended up after the last
character on the same row and instead do this:

name : do if condition

--

if ${1:condition}
$0

when you want to end up on the next row. I guess you more often want to en
up on the same line as the last char. At least I do. One example is shown
in point 3 where it actually can be seen as a bug.

  1. Say I have more than one snippet with the same name. Then I get the nice
    menu. But it would have been even more nice if the first row in the menu
    was selected.

  2. Say I have this:
    Model.find(:all)
    and now wants to add a condition (which I have a snippet for). Since the
    snippet behave like in point 1 I will get this:
    Model.find(:all, :conditions => ''
    )

with the right parenthesis on the next row.

  1. I have discovered that lines with no text on wont get indented. This
    snippet will for example not indent line number 2 (the line with this on: $0).
    if ${1:condition}
    $0
    end

Other than the things mentioned above it's really nice!

Google Code Info:
Issue #: 1
Author: [email protected]
Created On: 2008-03-07T20:00:31.000Z
Closed On: 2008-05-07T01:50:09.000Z

Snippet files with diacritics not recognized properly

Hi!

What steps will reproduce the problem?

  1. Create a snippet file with diacritics in its name. Eg.
    "snippets/text-mode/html-mode/hě".
    Contents of the file:

    $0

  2. Start Emacs and open some HTML file.
  3. Write "hě" and press TAB.

What is the expected output? What do you see instead?
Expected output is

. But it does nothing.

What version of the product are you using? On what operating system?
yasnippet 0.5.2, Emacs 22.1.1., Microsoft Windows XP Professional SP2 CZ.
Also not working with same yasnippet and emacs on Ubuntu Gutsy server.

Please provide any additional information below.

  • snippets with diacritics in their name work if defined in elisp code.
    Eg.: (yas/define 'html-mode "hě" "

    $0

    " nil) works.
  • Snippets with diacritics are useful for people, who write non-English
    documents. The example above: the letter 'ě' is in czech layout on the same
    position as '2' on english layout.

Google Code Info:
Issue #: 24
Author: [email protected]
Created On: 2008-04-30T14:53:22.000Z
Closed On: 2009-01-21T02:23:28.000Z

Error on expansion of snippets in html-mode

Hi!

As you might now Emacs has a cool feature in html-mode so that when you for
example do a "u-tag" Emacs will show an underline on the word in it. And if
you do a "h1-tag" Emacs will make it a bit larger and bold.

I have noticed that you cannot expand snippet when in one of those special
tags.
For example if I have:

My name %%{cursor here}

(%% is an expansion for <%= %>)

If I then try to expand I'll get this:
[yas]error in condition evaluation: Wrong type argument: stringp, (bold
underline)

Google Code Info:
Issue #: 21
Author: [email protected]
Created On: 2008-04-22T18:35:08.000Z
Closed On: 2008-04-23T01:53:25.000Z

minor mode can't be deactivaed by mode-hooks

What steps will reproduce the problem?

  1. define a major-mode-hook to deactivate yasnippet
  2. load that major-mode

What is the expected output? What do you see instead?
yasnippet deactivaed but it stays activated

What version of the product are you using? On what operating system?
0.5.5 linux emacs-22.2.50.1

Please provide any additional information below.
here is the code I'm trying to make work

(add-hook 'lisp-mode-hook
'(lambda ()
(yas/minor-mode -1)))

Google Code Info:
Issue #: 29
Author: [email protected]
Created On: 2008-06-07T17:10:44.000Z
Closed On: 2008-08-07T12:44:07.000Z

"Bug", question and problem

Hi!

I have one problem, one question and "maybe" one bug. I don't know if it's
a bug or not but I don't like the behavior.

Bug)

# name : :conditions => {}
# --

:conditions => { :${1:attribute} => ${2:value} }

I want to use the name attribute, so I press TAB. But what if I have (I do)
a snippet for the ":" character. Then this would expand again to something
like this (in my case):
:conditions => { :symbol => attribute => value }

(":" is a snippet for ":symbol => ")

Maybe not a bug. But it would be nice to be able to turn off snippet
expansions when in a snippet expansion.

Problem)
The problem is about dropdown-menu.el
Maybe this is a bug to. I don't know. But when I use this, expand a snippet
and have several Emacs windows. All other windows than the one you are
working in disappears until I have chosen a snippet.

And also how do you chose a snippet you are on? I have only succeded that
by presses the number of it. The RETURN key would be the logic choise, but
nope...

Question)
A while ago I read somewhere about sharing snippets between modes. But I
cant find it now.

Thanks!

Google Code Info:
Issue #: 14
Author: [email protected]
Created On: 2008-03-23T21:10:20.000Z
Closed On: 2008-03-24T12:39:43.000Z

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.