jEdit Community - Resources for users of the jEdit Text Editor
Snippet Functionality
Submitted by kemitchell on Friday, 6 October, 2006 - 06:54
After being much inspired by Sune Simonsen's wonderful SuperAbbrevs, i decided i would try my hand at coding my take on the "Snippets" concept which seems to have become so popular (and expensive... trendy... dangerous? ;-P ) recently in light of the public's adoration for textmate and all things supernaturally shiny.

https://webspace.utexas.edu/kem642/www/Snippets_SRC.zip

i'm posting the code here in hopes that if i completely run out of time it will at least be available for posterity, BUT MORE OPTIMISTICALLY on the chance that one of you might take a brief look at it and point out where i might be going wrong api-wise, or where i've taken the decidedly more difficult path. For one things, my use of BufferChangeListeners seems to have become deprecated. Updates... the devil take them!

i'll likely hack away as time (and school) permit. I'll keep you all posted here, assuming this is the proper place to do so... (?)


A few noets:
I am working for compatibility with the current development version (4.3pre6), and have funcitoning (read: not well tested, but it "works for me and my limited imagination" (TM) ) solution for recursive snippets (use them inside of each other!) with end tags via a stack of insertions per buffer. the framework is in place to at least parse templates with named variables (i.e. with the same value), default values, and enumerated field values, but those remain broken for the moment in terms of actual functionality. The method of selection is currently a triggered inline popup which does a running filter and auto-insertion of the last match. Defining new snippets based on input not recognized there is planned, but not currently implemented (the method is called, but it doesn't do anything yet).

currently, the snippets are stored like /%userdir%/.jedit/snippets/%mode%/%name of snippet%.snip

there is no snippet editor or viewer in place (options panel) in place quite yet, but that ought to be trivial to pull off (or at least more straightforward).

the archive includes a buildfile i use to build the jar file when i compile. if you've got ANT and a JDK you shouldn't have any problems if you want to give it a whirl.

it ain't clean, but with a little time, it will ready to go soon enough.


thanks in advance for any help, direction, etc.
dont worry... you'll get thanked again, too!

~K
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
Snippets
by sune_simonsen on Mon, 13/11/2006 - 23:50
Hej kemitchell

I always wellcomes new plugins to jEdit, but I just want to hear the reason not to improve SuperAbbrevs instead of starting a new plugin with more or less the same funtionality?

I know SuperAbbrevs needs alot of love to become really good, but the latest beta can do some pretty need tricks. I'm unfortunally so busy, that I don't even have the time to make a release untill febuary (Master Thesis). But I plan to take up the work on SuperAbbrevs when I get the time.

Good luck on the plugin.

-- Sune Simonsen (SuperAbbrevs)
 
n reference to your question
by kemitchell on Thu, 16/11/2006 - 04:37
n reference to your question ("why not modify superabbrevs?"), i'd give two reasons:

The first is that my plugin started out as an exploration of plugin-writing for jEdit in general, and also a bit of a toy to let me play with beanshell. At this point i think i've certainly got something worth brining to a releasable state, but i'm still reaping the benefits of knowing my own code while i get things squared away. I didn't want to start with an established jar of source, i wanted to learn the API from the ground up.

Secondly, i think (judging from some of your posts on the boards and some recent Betas of SAs) that our priorities in the implementation of snippets are quite a bit different. My current development version, for instance, is using beanshell to script the snippets, with an aim to support value updating when the value of a field changes.

This doesn't necessarily mean that i am hell-bent on releasing a separate plugin. You will be the first to know when i think i've got something together that represents a coherent solution. At that point i'd like very much to talk about mergin some of those feature into SuperAbbrevs if that suits our dispositions, and we can go from there.
 
Re
by sune_simonsen on Sat, 02/12/2006 - 00:42
Hej kemitchell
I checked out your code - and I now understand that the implementation is pretty different.
Your templates is parsed, while mine is compiled to a datastructure. I do have scripting functionality in two forms. You can generate the templates with beenshell code, and the template can include tranformer field that change depending on another field on the fly. But by parsing the templates in each step you gain some flexibillity. I couse to compile the templates, to boost the performance.

I just want to wish you good luck on the development.

-- Sune Simonsen (SuperAbbrevs)
 
Sune your email is bouncing
by wolfmanjm on Sat, 02/12/2006 - 03:21
Hi Sune,

Did you know you Email at sourceforge is bouncing?

Just an FYI
 
SF email bouncing
by sune_simonsen on Sat, 02/12/2006 - 11:24
No I didn't know that. Thats not good, I will look into fixing it.

Edit: This should be fixed. Thank you very much for mentioning it.

-- Sune Simonsen (SuperAbbrevs)
https://webspace.utexas.edu/k
by kemitchell on Sun, 12/11/2006 - 08:08
https://webspace.utexas.edu/kem642/www/jSnippetsAlpha2.zip

updated sources, including support for snippets-in-snippets, some syntactic additions to the snippet description format itself, the ability to relate all snippets from modes to other modes, and other goodies. It lacks general polish and any option-pane interface for snippet editing, but the real problem solving is done.

I'll try to get it releasable on my own before the year is out. Once exams are done i ought to have some time...
 
Thanks
by wolfmanjm on Sat, 02/12/2006 - 03:25
Hi,

I have invested quite some time in porting over the Ruby and Rails textmate snippets to SuperAbbrevs, however the features that are missing in SuperAbbrevs that I really need are the snippets-in-snippets, and $0 handling.

I'll take a look at what you have done and see how hard it will be to modify my scripts to export to your format, either way a textmate compatible snippet facility in JEdit is greatly appreciated.

check out http://blog.wolfman.com for what I have done so far.

Thanks
User login
Browse archives
« November 2024  
MoTuWeThFrSaSu
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   101634
Context Free Art (*.cfdg)   0.31   46062
BBEdit scheme   1.0   18601
JBuilder scheme   .001   18502
ColdFusion scheme   1.0   18031
R Edit Mode - extensive version   0.1   17481
Advanced HTML edit mode   1.0   16213
Matlab Edit Mode   1.0   16075
jEdit XP icons   1.0   15236
XP icons for jEdit   1.1   14300