LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-29-2005, 04:08 PM   #1
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Rep: Reputation: 0
Smart snippets in emacs


Is there a minor mode for emacs, that makes the same behavior available, as smart code snippets in TextMate? (macromates.com I'm new here so I can't make it clickable, eclipse also has this functionality. If not is it possible to program?.

Example of a snippet:
Code:
Iterator ${2:iter} = ${1:list}.iterator(); 
while (${2:iter}.hasNext()){
   ${3:type} ${element} = (${3:type})${2:iter}.next();
   $5
}
When you insert the snippet you presented with:
Code:
Iterator iter = list.iterator(); 
while (iter.hasNext()){
   type element = (type)iter.next();
   
}
You can then jump from field to field, and if you change one field, all the
fields with the same name will change at the same time.

I'm not looking for a mode what prompt me for every variable in the snippet, it has to be unobtrusive.
The TextMate editor is really nice, but its not cross platform, and i like using the same editor everywhere.

- Sune Simonsen

Last edited by Sune Simonsen; 05-29-2005 at 04:26 PM.
 
Old 05-29-2005, 04:22 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
I don't know TextMate, but ELSE may do what you're looking
for ... if you find it too interactive you can easily tame it by
editing its underlying lse files.

http://www.zipworld.com.au/~peterm/

Cheers,
Tink
 
Old 05-29-2005, 04:31 PM   #3
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
emacs can do macro commands if that's what you are talking about ?
recorded keystrokes you can easily play over and over ?

Cntrl-x (
type macro
Cntrl-x )

then Cntrl-x e to play the macro

then you can do stuff with it like Esc 6 Cntrl-x e
Cntrl-u Cntrl-x e

and like that

macros can start with any commands or keystrokes like searches or whatever

if you want to save the macro to make it permanent
Esc x name-last-kbd-macro RETURN
give it a name RETURN
from now on your commend is ESC x mancroname

open .emacs and move to it bottom and type ESC x insert-kbd-macro RETURN macroname RETURN
save

this can get very complicated your macros can have pauses and stuff take a look at an emacs manual for more
 
Old 05-29-2005, 04:35 PM   #4
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
If you have tried ELSE, I would really like you to comment on how it's working.
I seen the website before, but i was a little skeptical about it, because it looked
rather complicated, or say ambitious.

- Sune Simonsen
 
Old 05-29-2005, 04:36 PM   #5
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 927

Rep: Reputation: 30
Technically, you can tame emacs to do just about anything under the sun if you really want to spend the time to code it. For example, you probably could create a list of things you type a lot, override the 'tab' button to search through that list, looking for the first three or so characters which match the characters that you just typed in the current buffer, and then Insert whatever text is at that matching element of the list. However, that would be pretty static. I'm not entirely sure how hard it would be to make it learn...but it would probably be really tricky, probably messy and inefficient, and would involve reading/writing to some sort of save file each time you open/close a buffer with whatever type of code you're writing if you wanted the snippets to be at all persistent.

Folding, which I also saw touted on the TextMate webpage, is something that emacs ain't so good with. It'll p'bly do it, but it's not quite as nice as it is in say, Vim.

So the short answer is Yes, you could certainly program emacs to do that, if you wanted to spend a lot of time learning the Emacs brand of Lisp. Emacs is a great editor and does some really nifty stuff - you never ever need to touch the mouse once you've opened it, it's fantastic - but it isn't and probably won't ever be an IDE. That's just not what it's supposed to be :-/

(And to create a link, click the "http://" button when you create a post/reply, or use [url="http://www.stuff.com"][/url] tags).
 
Old 05-29-2005, 04:40 PM   #6
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Yep macros is nice, but not quite what I was looking for.
I know I didn't explained my self very well at first, but i updated the
question, so it should be clearer was I'm looking for now.

By the way thanks for the answers, the answers came faster than I expected.

- Sune Simonsen
 
Old 05-29-2005, 04:51 PM   #7
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
rose_bud4201 thank for the answer.
I don't want to make emacs a IDE, what I'm talking about is not that
code sensitive, it's just abbreviation on druks, and it's really useful.
If you go outside the the snippet, it losses it's information. So emacs "only"
has to keep track of the positions of the variables in the current snippet.
The snippets will be created in the .emacs file or in the hook for different
major modes.
I think you are right, of cause i can be done.

(I know about how you make a URL, but they restricted the system, so you can't
before you have made 5 posts, to prevent spamming)

- Sune Simonsen
 
Old 05-29-2005, 05:08 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,986
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally posted by Sune Simonsen
If you have tried ELSE, I would really like you to comment on how it's working.
I seen the website before, but i was a little skeptical about it, because it looked
rather complicated, or say ambitious.

- Sune Simonsen
I actually quite like it, even though the C++ definitions
are a bit lacking ... it makes C code a breeze, but it's
most suitable for writing a new program.

Haven't looked at the other lingos, and don't do much coding
these days. In terms of completeness the ADA stuff should
be the best since Peter actually codes in ADA.


Cheers,
Tink
 
Old 05-29-2005, 05:34 PM   #9
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
I've installed ELSE, but i think it's is a little weird,
but I will definitely give it a change. I think TextMate
and eclipse way is more intuitive, but i might be harder to
program.

- Sune Simonsen
 
Old 10-26-2005, 05:15 PM   #10
Sune Simonsen
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
I've have implemented this feature in jedit, if anybody is interrested in trying it. You can download it from det plugin manager under the name SuperAbbrevs.

-- Sune Simonsen
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
where is the .emacs file in the emacs source code tarball? aizkorri Programming 2 01-13-2007 02:05 PM
Smart Quotes apostate Linux - Software 1 09-09-2005 07:27 PM
emacs not responding to .emacs file in Mandriva 2005 LE. Please help LaptopLinux Mandriva 1 06-08-2005 08:36 AM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM
How To Ask Questions The Smart Way yixudong General 4 08-31-2002 11:07 AM


All times are GMT -5. The time now is 06:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration