emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Including Yasnippet to Emacs


From: João Távora
Subject: Re: Including Yasnippet to Emacs
Date: Mon, 17 Mar 2014 17:15:20 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Stefan <address@hidden> writes:

> João has a snippet.el in the works, which is yet-another of those
> snippet systems, but this one is designed as a "Lispish core, such that
> yasnippet.el can be provided as a layer on top of it.  He's been writing
> it with a fair bit a bitching^H^H^H^H^H^H^Hreview from me, and if all
> goes well it could be included in 24.5.

Yes, check out the `snippet-engine' branch of
github.com/capitaomorte/yasnippet. Look for files snippet.el and
snippet-tests.el.

Bear in mind it's a work in progress, but the `define-snippet' macro
which is defined there should give you the full power of yasnippet's
textmate-like templates with a lispy interface, so you can do this

    (define-snippet printf ()
      "printf (\""
      (&field 1 "%s")
      (&mirror 1 (if (string-match "%" field-string) "\"," "\")"))
      (&field 2)
      (&mirror 1 (if (string-match "%" field-string) "\)" "")))

Instead of

     printf ("${1:%s}\\n"${1:$(if (string-match "%" yas-text) "," "\);")
     }$2${1:$(if (string-match "%" yas-text) "\);" "")}

As Stefan said, yasnippet.el will continue to accept the latter, but it
will define snippets on top of the former.

The above is already working more or less nicely, but Stefan's
nags^H^H^H^Hhelp convinced me to provide an even more powerful
alternative, so that you can use a new macro, call it
`expanding-snippet', to introduce a dynamic environment where `&field'
and `&mirror' are local macros. That way you can decide the structure of
your snippet at runtime, with some (minor) disadvantages like losing
compile-time checking of some snippet consistency.

This is what I'm working on right now. There is also a list of TODO's at
the top of snippet.el, and help is welcome.

João





reply via email to

[Prev in Thread] Current Thread [Next in Thread]