From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: joaotavora@gmail.com (=?iso-8859-1?Q?Jo=E3o_T=E1vora?=) Newsgroups: gmane.emacs.devel Subject: Re: Including Yasnippet to Emacs Date: Mon, 17 Mar 2014 17:15:20 +0000 Message-ID: References: <20140317041012.GA24472@debian> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1395076543 19874 80.91.229.3 (17 Mar 2014 17:15:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Mar 2014 17:15:43 +0000 (UTC) Cc: Danil Orlov , emacs-devel@gnu.org To: Stefan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Mar 17 18:15:53 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WPb8b-0003EI-3f for ged-emacs-devel@m.gmane.org; Mon, 17 Mar 2014 18:15:45 +0100 Original-Received: from localhost ([::1]:59297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPb8a-0000D4-HN for ged-emacs-devel@m.gmane.org; Mon, 17 Mar 2014 13:15:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPb8M-0008U1-HJ for emacs-devel@gnu.org; Mon, 17 Mar 2014 13:15:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPb8H-0000Vw-T2 for emacs-devel@gnu.org; Mon, 17 Mar 2014 13:15:30 -0400 Original-Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:37711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPb8H-0000VX-M0 for emacs-devel@gnu.org; Mon, 17 Mar 2014 13:15:25 -0400 Original-Received: by mail-we0-f181.google.com with SMTP id q58so4884935wes.12 for ; Mon, 17 Mar 2014 10:15:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=uPtD70WNSaMh+wTWOgQOFnRSMYYJYHQM4Wgxdbj6NIo=; b=fEmUzd4IO1Joh9ajHPc3+KCiSQigqlqArBRYcp5O8IaEcWhS+KTqTVHICCTtuqZ2S9 SSOvOuLUGZv79iHLxHtuXdzA1Tam0X1Md16/NkLbcVbdRJSfECJOF7oKbfdBWK2jczbI AasLqa2K4WMhTVfkyqBw9Vx70+hWF/35p6TaGfhzpijGSFJhR7fI9F8ClOyXhmZxvzBf MNrHQ58g8hiSS+ZigFh0UODL4Dz+YWbZE1IW+bsy0F/XB2akJZ7icKOBbTu1agM+M8iS hslfsNFETiX+yEUtPOF+/0LCMlk8u0+txd1759NlNplP65ez5V44QHLUHhPPh17twumC vyJA== X-Received: by 10.180.89.102 with SMTP id bn6mr10717944wib.28.1395076524392; Mon, 17 Mar 2014 10:15:24 -0700 (PDT) Original-Received: from BELMONTE.yourcompany.com (a81-84-241-129.static.cpe.netcabo.pt. [81.84.241.129]) by mx.google.com with ESMTPSA id f7sm39970587wjb.7.2014.03.17.10.15.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Mar 2014 10:15:23 -0700 (PDT) In-Reply-To: (Stefan's message of "Mon, 17 Mar 2014 10:45:29 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:170452 Archived-At: Stefan writes: > Jo=E3o 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=E3o