Charles M Magid | 19 Dec 2011 16:24
Picon
Gravatar

Feature request for extras/textmate_import.rb

Yasnippet  is cool.

I thought of a feature which might make the resulting rails snippets
more useful.

I started converting the snippets by hand but realized this might be
useful to a greater audience.

Please see video demo for explanation of my request:
http://www.youtube.com/watch?v=blB4AkFTVs8

Best,

::Charles

--

-- 
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet@...
To unsubscribe from this group, send email to smart-snippet+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.

João Távora | 20 Dec 2011 02:58
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

Nice video, but what exactly is the feature you are requesting?
textmate_import.rb imports directly from textmate bundles, so if this
snippet layout isn't available in a particular bundle, it won't be
imported, although you might convince the author of the textmate
bundle to support that...

In other words the point is that I do not want to hand-tweak the
snippets directly, only tweak the textmate-import.rb tool and the
.yas-setup.el files to provide a smoother importation.

This behaviour exists in the "t." snippets of the textmate rails
bundle, I guess the author only thought it useful there. You can also
use the menu to check out which validations are available.

Thanks,
João Távora

On Mon, Dec 19, 2011 at 3:24 PM, Charles M Magid <cmmagid@...> wrote:
> Yasnippet  is cool.
>
> I thought of a feature which might make the resulting rails snippets
> more useful.
>
> I started converting the snippets by hand but realized this might be
> useful to a greater audience.
>
> Please see video demo for explanation of my request:
> http://www.youtube.com/watch?v=blB4AkFTVs8
>
> Best,
(Continue reading)

João Távora | 20 Dec 2011 03:09
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

I notice that in your github fork,
https://github.com/ChasManRors/yasnippet, you have generated the
extras/imported snippets and checked them into version control.

In general you should consider carefully if you want to put generated
code into version control, see http://producingoss.com/en/vc.html for
a discussion on the matter:

"Don't keep generated files under version control. They are not truly
editable data, since they are produced programmatically from other
files. For example, some build systems create configure based on the
template configure.in. To make a change to the configure, one would
edit configure.in and then regenerate; thus, only the template
configure.in is an "editable file." Just version the templates—if you
version the result files as well, people will inevitably forget to
regenerate when they commit a change to a template, and the resulting
inconsistencies will cause no end of confusion.[16]"

In our context, in the long run there is a much greater effort in
maintaining these snippet files as there is adjusting the
code-generating tool and .yas-setup.el templates. The second approach
is the one I've taken in textmate-import.rb. Before that I was
actually incurring in the same mistake as you (although you might not
consider a mistake).

Thanks,
João Távora

On Tue, Dec 20, 2011 at 1:58 AM, João Távora <joaotavora@...> wrote:
> Nice video, but what exactly is the feature you are requesting?
(Continue reading)

Charles Magid | 20 Dec 2011 18:30
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

Please see inlined responses.

On Dec 19, 2011, at 9:09 PM, João Távora wrote:

> I notice that in your github fork,
> https://github.com/ChasManRors/yasnippet, you have generated the
> extras/imported snippets and checked them into version control.
> 
> In general you should consider carefully if you want to put generated
> code into version control, see http://producingoss.com/en/vc.html for
> a discussion on the matter:

I don't do that with code compiled by gcc.  But I do check in the compiled version of gcc I use to generate my app. 
Over many years of a well selling system even the compilers are no longer available.  So one has to have
everything needed to rebuild the system the customer has and is willing to pay for modifications too.  Even
if it is 15 years old.
> 
> "Don't keep generated files under version control. They are not truly
> editable data, since they are produced programmatically from other
> files. For example, some build systems create configure based on the
> template configure.in. To make a change to the configure, one would
> edit configure.in and then regenerate; thus, only the template
> configure.in is an "editable file." Just version the templates—if you
> version the result files as well, people will inevitably forget to
> regenerate when they commit a change to a template, and the resulting
> inconsistencies will cause no end of confusion.[16]"

Yep.

> 
(Continue reading)

Charles Magid | 20 Dec 2011 18:30
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

Hey João,

Thanks you for taking the time to read my comments.   I inlined a few new ones below.

On Dec 19, 2011, at 8:58 PM, João Távora wrote:

Nice video, but what exactly is the feature you are requesting?

Common prefixes have a common short key (like t.) to allow user to choose from related snippets.  An option to .yas-setup.el.   Currently I'm using emacs macros to post process the tmbundle for rails snippets from drnic.  For example:  

The snippets not only have the # key: <originally defined key, mostly unique for each snippet>  But will also have the "# key val."  So that a user looking for model validation snippets has a good chance of finding exactly what he wants by typing val.[tab]
Note the menu yasnippets > rails-mode take up about 4 screens at 1152 x 720 on my system.  Even the 20 or so val.[tab] completions
is a bit much but I think more tractable.

The snippets:
validates.yasnippet
validates_acceptance_of if.yasnippet
validates_acceptance_of.yasnippet
validates_associated (va).yasnippet
validates_associated if (vaif).yasnippet
validates_confirmation_of (vc).yasnippet
validates_confirmation_of if (vcif).yasnippet
validates_exclusion_of (ve).yasnippet
validates_exclusion_of if (veif).yasnippet
validates_format_of if.yasnippet
validates_format_of.yasnippet
validates_inclusion_of if.yasnippet
validates_inclusion_of.yasnippet
validates_length_of (vl).yasnippet
validates_length_of if.yasnippet
validates_numericality_of if.yasnippet
validates_numericality_of.yasnippet
validates_presence_of (vp).yasnippet
validates_presence_of if (vpif) 2.yasnippet
validates_uniqueness_of (vu).yasnippet
validates_uniqueness_of if (vuif).yasnippet

I experimented with grouping instead of using the expansion but the expansion seems much more useful.

textmate_import.rb imports directly from textmate bundles, so if this
snippet layout isn't available in a particular bundle, it won't be
imported, although you might convince the author of the textmate
bundle to support that...

Nice idea.  But if I can convince you to make bundle conversion friendlier then all imported bundles will benefit, not just the rails one from drnic.


In other words the point is that I do not want to hand-tweak the
snippets directly,

Nor do I but I am currently doing what could much more easily be done by the converter.  How about an option to .yas-setup.el, to provide this automated beginner grouping snippet addition for tmbundles?

only tweak the textmate-import.rb tool and the
.yas-setup.el files to provide a smoother importation.

A smooth import is great.  An augmented import is nice too, no? 


This behaviour exists in the "t." snippets of the textmate rails
bundle, I guess the author only thought it useful there.

Or drnic was concerned with his own use of the snippets he created.  Generously, he made them available to the public.  But he left the boring work of making them more friendly for beginners and intermediates as an exercise for the user.  So I've been adding my hand tweaks to the generated code.  I do not know the tm macro syntax, or I would have forked his tmbundle. 

Tangent: Thinking out loud: It would be hard to become very familiar with emacs without the describe-function, apropos-command and describe-variable functions.  I wonder if the snippet system could be tied into those as well?

A small change to the importer can greatly increase usability.  I guess automatically adding groupings could be done with a post import processing tool.  But, you probably have everything already at your finger tips.

You can also
use the menu to check out which validations are available.

See long list in menu, in the comment above.

Thanks,
João Távora

On Mon, Dec 19, 2011 at 3:24 PM, Charles M Magid <cmmagid <at> gmail.com> wrote:
Yasnippet  is cool.

I thought of a feature which might make the resulting rails snippets
more useful.

I started converting the snippets by hand but realized this might be
useful to a greater audience.

Please see video demo for explanation of my request:
http://www.youtube.com/watch?v=blB4AkFTVs8

Best,

::Charles

--
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to smart-snippet+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.




--
João Távora

--
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to smart-snippet+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.


--
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to smart-snippet+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.
João Távora | 21 Dec 2011 15:44
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

On Tue, Dec 20, 2011 at 5:30 PM, Charles Magid <cmmagid@...> wrote:
> Hey João,
>
> Thanks you for taking the time to read my comments.   I inlined a few new
> ones below.
>
> On Dec 19, 2011, at 8:58 PM, João Távora wrote:
>
> Nice video, but what exactly is the feature you are requesting?
>
>
> Common prefixes have a common short key (like t.) to allow user to choose
> from related snippets.  An option to .yas-setup.el.   Currently I'm using
> emacs macros to post process the tmbundle for rails snippets from drnic.

This is already a feature request I think, and one that I am *not*
thinking of implementing any time soon. This would add much complexity
to already complex code. Let me restate that, snippets with more than
one # key: directive are *not* supported and adding this is
low-priority. If you fork yasnippet and attempt to implement this I
can give you some pointers and/or verify your contributions. If it is
completely backward compatible I'll merge it in.

> Nice idea.  But if I can convince you to make bundle conversion friendlier
> then all imported bundles will benefit, not just the rails one from drnic.

Your argument is that a particular snippet collection A is friendlier
than another collection B if some of its snippets can be expanded with
more than one key. It could be that B is friendlier than A if the
snippets are all named after some rule, or if B's menu has 234 levels.
I don't argue with any of that. But yasnippet is snippet-collection
agnostic and these are characteristicsof the snippet collections,
*not* of the importation tool.  The fact that there is a (not very
good) legacy snippet collection under /snippets is for promotiona/demo
purposes.

> Nor do I but I am currently doing what could much more easily be done by the
> converter.  How about an option to .yas-setup.el, to provide this automated
> beginner grouping snippet addition for tmbundles?

textmate-import.rb would not be just importing the original
functionality, it would be adding functionality, which is beyond its
scope. I believe a tool should be very good at just one small thing.
But nothing stops you from chaining together textmate-import.rb and
charles-magid-beginner-snippets-from-professional-snippets.rb.

Lacking the multi-key feature in yasnippet.el, your tool could, for
the time being, replicate selected snippets and change their # key
directive. When multi-key becomes available in yasnippet.el your tool
can be simplified.

> Or drnic was concerned with his own use of the snippets he created.
>  Generously, he made them available to the public.  But he left the boring
> work of making them more friendly for beginners and intermediates as an
> exercise for the user.  So I've been adding my hand tweaks to the generated
> code.  I do not know the tm macro syntax, or I would have forked his
> tmbundle.

The bundles of drnic and many others are widely popular, they are so
canonical that many screencasts refer to them. And textmate, just like
yasnippet, allows you to tweak them. I say you should start with an
importation of a textmate bundle using textmate-import.rb and whatever
other augmentation tool.

Also there is a *lot* of work to be done in that .yas-setup files for
translating textmate conditions into emacs-lisp conditions for
example. Many snippets in rails-mode, for instance, have invalid
applicability or plain just don't work. I *will* gladly accept
modifications for the .yas-setup.el files that improve the importation
process for specific bundles or modifications to the
textmate-import.rb tool that improve the importation process for every
bundle.

>
> Tangent: Thinking out loud: It would be hard to become very familiar with
> emacs without the describe-function, apropos-command and describe-variable
> functions.  I wonder if the snippet system could be tied into those as well?

Snippets with direct keybindings should work well with describe-key.
There is also a yas/describe-tables which I encourage you to try. You
can use yas/visit-snippet also. Try them out and tell me what you are
missing.

--

-- 
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet@...
To unsubscribe from this group, send email to smart-snippet+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.

Charles M Magid | 22 Dec 2011 14:31
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

yas/describe-tables is very nice.

How to I make it so that my rhtml-mode and ruby-mode files are seen as
rails-mode by yas?

Can you throw me a bone so I can start to help with .yas-setup.el?

Thank you.

::Charles

On Dec 21, 9:44 am, João Távora <joaotav...@...> wrote:
> On Tue, Dec 20, 2011 at 5:30 PM, Charles Magid <cmma...@...> wrote:
> > Hey João,
>
> > Thanks you for taking the time to read my comments.   I inlined a few new
> > ones below.
>
> > On Dec 19, 2011, at 8:58 PM, João Távora wrote:
>
> > Nice video, but what exactly is the feature you are requesting?
>
> > Common prefixes have a common short key (like t.) to allow user to choose
> > from related snippets.  An option to .yas-setup.el.   Currently I'm using
> > emacs macros to post process the tmbundle for rails snippets from drnic.
>
> This is already a feature request I think, and one that I am *not*
> thinking of implementing any time soon. This would add much complexity
> to already complex code. Let me restate that, snippets with more than
> one # key: directive are *not* supported and adding this is
> low-priority. If you fork yasnippet and attempt to implement this I
> can give you some pointers and/or verify your contributions. If it is
> completely backward compatible I'll merge it in.
>
> > Nice idea.  But if I can convince you to make bundle conversion friendlier
> > then all imported bundles will benefit, not just the rails one from drnic.
>
> Your argument is that a particular snippet collection A is friendlier
> than another collection B if some of its snippets can be expanded with
> more than one key. It could be that B is friendlier than A if the
> snippets are all named after some rule, or if B's menu has 234 levels.
> I don't argue with any of that. But yasnippet is snippet-collection
> agnostic and these are characteristicsof the snippet collections,
> *not* of the importation tool.  The fact that there is a (not very
> good) legacy snippet collection under /snippets is for promotiona/demo
> purposes.
>
> > Nor do I but I am currently doing what could much more easily be done by the
> > converter.  How about an option to .yas-setup.el, to provide this automated
> > beginner grouping snippet addition for tmbundles?
>
> textmate-import.rb would not be just importing the original
> functionality, it would be adding functionality, which is beyond its
> scope. I believe a tool should be very good at just one small thing.
> But nothing stops you from chaining together textmate-import.rb and
> charles-magid-beginner-snippets-from-professional-snippets.rb.
>
> Lacking the multi-key feature in yasnippet.el, your tool could, for
> the time being, replicate selected snippets and change their # key
> directive. When multi-key becomes available in yasnippet.el your tool
> can be simplified.
>
> > Or drnic was concerned with his own use of the snippets he created.
> >  Generously, he made them available to the public.  But he left the boring
> > work of making them more friendly for beginners and intermediates as an
> > exercise for the user.  So I've been adding my hand tweaks to the generated
> > code.  I do not know the tm macro syntax, or I would have forked his
> > tmbundle.
>
> The bundles of drnic and many others are widely popular, they are so
> canonical that many screencasts refer to them. And textmate, just like
> yasnippet, allows you to tweak them. I say you should start with an
> importation of a textmate bundle using textmate-import.rb and whatever
> other augmentation tool.
>
> Also there is a *lot* of work to be done in that .yas-setup files for
> translating textmate conditions into emacs-lisp conditions for
> example. Many snippets in rails-mode, for instance, have invalid
> applicability or plain just don't work. I *will* gladly accept
> modifications for the .yas-setup.el files that improve the importation
> process for specific bundles or modifications to the
> textmate-import.rb tool that improve the importation process for every
> bundle.
>
>
>
> > Tangent: Thinking out loud: It would be hard to become very familiar with
> > emacs without the describe-function, apropos-command and describe-variable
> > functions.  I wonder if the snippet system could be tied into those as well?
>
> Snippets with direct keybindings should work well with describe-key.
> There is also a yas/describe-tables which I encourage you to try. You
> can use yas/visit-snippet also. Try them out and tell me what you are
> missing.

--

-- 
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet@...
To unsubscribe from this group, send email to smart-snippet+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.

João Távora | 22 Dec 2011 16:06
Picon
Gravatar

Re: Feature request for extras/textmate_import.rb

On Thu, Dec 22, 2011 at 1:31 PM, Charles M Magid <cmmagid@...> wrote:
> yas/describe-tables is very nice.

Great. Did you find any bugs? Can you find ways to improve it?

>
> How to I make it so that my rhtml-mode and ruby-mode files are seen as
> rails-mode by yas?

I don't know if you loaded your custom symlinking scheme of doing things in that
case I can't help you, but if you followed the instructions in the README
then 'extras/imported/rails-mode/.yas-setup.el'

Try M-x describe-symbol RET yas/extra-modes RET

It should show the symbol 'rails-mode as part of its value, which means, as I
explained before, that snippets hailing from folders called "rails-mode" under
elements of `yas/snippet-dirs' will be considered for expansion. Maybe I should
add this to the documentation of `yas/extra-modes'

If it does not show you that value, then switch to some ruby-mode or
rhtml-mode file in your rails
project and try M-x eval-expression RET (yas/rails-root) RET

It should show you the root dir of your rails project.

If it does not show you that and you followed the instructions in the README,
submit a bug report and a reproduction recipe starting with emacs -Q

>
> Can you throw me a bone so I can start to help with .yas-setup.el?

OK here goes: The idea of .yas-setup.el is to perform different functions all in
the same file, its a kind of input-output file (and it should probably be split
into different files). Currently, as I recall it has four sections.

1. Emacs-lisp helper functions to use in snippet definitions and
`yas/define-condition-cache' and the like. This is code that I mantain and that
I need your help for.

2. A list of substitution directives in the form of emacs-lisp comments. These
are read in by textmate-import.rb and teach it to replace textmate directives
with specific helper functions written in section 1. This is also code that I
maintain and that I need help for.

3. An **automatically generated** (!!) lisp form for building the menu bar
menu. This is re-generated every time textmate-import.rb is run. It should not
be hand edited by anyone (and should be in a file that is not checked in, or git
should be taught to ignore it)

4. A list of substitution directives that textmate-import.rb could not
resolve. It is also auto-generated code and helps me a little cause I can copy
these directives into section 2 and fix them selectively, after I've written the
corresponding helpers in 1. Like section 3, it should NOT be hand edited and
should probably also be in a separate file.

You could help me by:

1. write better .yas-setup.el files by slurping some unknown directives in
section 4 into section 2.

2. writing more robust conditions

3. fixing 'yas/ruby-toggle-single-multi-line-block' in ruby-mode/.yas-setup.el.

4. etc etc

OR, if you're feeling more confident....

1. Fix textmate-import.rb and yasnippet.el so that it works with 4
different files
instead of a single .yas-setup.el file. You can tweak yasnippet.el so that it
loads an additional .yas-menu.el (which would be auto generated) if it finds it.

2. Also, the retarded language that I came up with for the
substitution directives
could be substituted for a lisp or ruby DSL. But I would work separately on the
splitting problem

Thank you! looking forward to have a look at your work!

--

-- 
You received this message because you are subscribed to the Google Groups "smart-snippet and YASnippet" group.
To post to this group, send email to smart-snippet@...
To unsubscribe from this group, send email to smart-snippet+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/smart-snippet?hl=en.


Gmane