Ruby based editor

Hi all,

I’ve started to write my own editor (in c) which shall be extendible by
via
Ruby. I have a question about the design, as this is a ‘from scratch’
approach I’m taking do you think I should write the basics in C and then
wrap it up with ruby or should I impliment with reliance on the Ruby
types
from the start? For example, say I have a simple buffer object:

typedef struct _BUFFER {
char *filename;
char *name;
} Buffer;

Should I use Data_Wrap_Struct() to wrap this up or should I build a
class
from scratch in Ruby using Ruby types. Either way the editor remains
extendible in C and Ruby but once I go for the second option embedding
any
other enterpriter (Python, Perl…) goes out of the window.

Let me know your thoughts (which aren’t allowed to include “do we really
need another editor” :)).

Cheers,
Phil

On 4/30/06, Phil J. [email protected] wrote:

char *name;

Cheers,
Phil

My thoughts are implement the whole thing in Ruby and then only bother
to write the parts in C where there is a reason (performance) to do
so.

pth

On Sunday 30 April 2006 11:00 am, Phil J. wrote:

Let me know your thoughts (which aren’t allowed to include “do we really
need another editor” :)).

Ok, I won’t ask that in quite that way, but:

  • What is your goal for this editor–is it a learning project or
    intended
    to eventually be a “product” in some sense?

  • Is it to be as full-featured as Emacs or more like Notepad?

  • Have you estimated how much time it will take to accomplish what
    you wish
    to accomplish? Is it a realistic estimate, and do you have that much
    time?

If I was going to expend effort on an editor, I’d work on nedit. It is
written in C, is very featureful and fast, etc. It includes a
C-style/based
macro language, keystroke recording to start macros, syntax
highlighting,
autoindent, etc., etc., etc.

But, as I understand it, the code base is at least a little messy at
this
point in time. A “faction” of developers is pushing to do something
along
the lines of a feature freeze while the codebase is reorganized.

(I am not a nedit developer, primarily an enthusiastic user. I am
planning to
incorporate nedit in a project I’m working on, currently at a me-ware
stage.
(IIR/UC, Joel Spolsky (sp?) developed the me-ware term for a project
that is
only suitable for use by the original developer (due to lack of all
kinds of
things–features, safety, robustness, … .))

Assuming a feature freeze happens, once the codebase is reorganized,
features
will again be added and this could include a Ruby based macro language.

One thing I don’t like about Nedit is the look and feel of the
Motif/lesstif
based widgets. I’m guessing (hoping?) that if the codebase were
rewritten in
an appropriate way, it would not be unreasonable to switch widget sets
or to
allow a user to choose one from a selection of suitable widget sets.

Depending on how much time and thought you’ve put into your plan to
create a
new editor, it may be worth your while to do some investigation of nedit
and
consider contributing your efforts there.

Here are some URLs and mailing lists:

Randy K.

On Mon, May 01, 2006 at 07:38:40AM +0900, Randy K. wrote:

On Sunday 30 April 2006 11:00 am, Phil J. wrote:

Let me know your thoughts (which aren’t allowed to include “do we really
need another editor” :)).

Ok, I won’t ask that in quite that way, but:

I think you may have mis-understood my question (or I didn’t explain
properly), what I was asking was more a design question than a general
“I’m
building yet another editor what do you think” question. As you took the
time to write a response I’ll answer you though (check bottom where I
re-phase my query):

  • What is your goal for this editor–is it a learning project or intended
    to eventually be a “product” in some sense?

Both, I’m very interested in editors and find myself downloading new
ones as
they arrive and playing with them (though I’m an avid Vim user).

  • Is it to be as full-featured as Emacs or more like Notepad?

Well, the idea is to write the base of the editor in C and have the API
almost completely available to Ruby. So, theoretically, it could be as
full-featured as Emacs or as simple as Notepad. :wink:

If I was going to expend effort on an editor, I’d work on nedit. It is
written in C, is very featureful and fast, etc. It includes a C-style/based
macro language, keystroke recording to start macros, syntax highlighting,
autoindent, etc., etc., etc.

To be honest I’d like to start from scratch and see what I come up with,
secondly I hate GUI based editors personally.

What I was actually trying to ask was:

The base will be written in C not in pure Ruby. I would like to know
whether
people think I would be better using C types at the core or Ruby types
implimented in C. So, I can, A), write a basic editor in C and then
wrap it
up with Ruby using Data_Wrap_Struct() much like an extenstion would. Or
I
can, B), start from the beginning with rb_define_class() and friends
thus
relying on Ruby from the start. The advantages and dis-advantages that I
think may exsist:

a) advantages:
* The core of the application would be instantly reconisable to a C
hacker who has no Ruby experience.
* If I decide it should be extendable by another language it would
be a
simple job.
* Better performance?

disadvantages:
* I would have to impliment and then map things like linked lists
meaning wheel re-invention.
* more work :slight_smile:
* Can’t rely on libruby for memory handling.

So which one?

Phil

On Mon, 1 May 2006, Phil J. wrote:

a) advantages:

  • Can’t rely on libruby for memory handling.

So which one?

well, if you choose A you’ll be following in the footsteps of vim, which
is
already extensible in ruby. why not start do B then to avoid breaking
programmer’s rule #42 ?

-a

On 5/1/06, John G. [email protected] wrote:
[snip]

You may want to have a look at “ne” (the Nice Editor).
http://ne.dsi.unimi.it/
[snip]
jumping-off point). It’s written in C, and is GPL’d. I’d love to see
it get syntax highlighting and be scriptable with Ruby. Man that would
rock. :slight_smile:

syntax coloring is not easy to add.

I did some editor work, but currently lacks time to complete it.
http://aeditor.rubyforge.org/

On 4/30/06, Phil J. [email protected] wrote:

time to write a response I’ll answer you though (check bottom where I
Well, the idea is to write the base of the editor in C and have the API
almost completely available to Ruby. So, theoretically, it could be as
full-featured as Emacs or as simple as Notepad. :wink:

If I was going to expend effort on an editor, I’d work on nedit. It is
written in C, is very featureful and fast, etc. It includes a C-style/based
macro language, keystroke recording to start macros, syntax highlighting,
autoindent, etc., etc., etc.

To be honest I’d like to start from scratch and see what I come up with,
secondly I hate GUI based editors personally.

(I don’t have an answer to your original question, however…)

You may want to have a look at “ne” (the Nice Editor).
http://ne.dsi.unimi.it/

The code looks neat and well-documented, and the editor has very good
end-user docs as well. The original author is quite a nice fellow. I
believe he no longer has the time to maintain or add features to ne.
ne may be a source of inspiration for you (or even possibly serve as a
jumping-off point). It’s written in C, and is GPL’d. I’d love to see
it get syntax highlighting and be scriptable with Ruby. Man that would
rock. :slight_smile:

—John

On Sunday 30 April 2006 07:25 pm, Phil J. wrote:

I think you may have mis-understood my question (or I didn’t explain
properly), what I was asking was more a design question than a general “I’m
building yet another editor what do you think” question. As you took the
time to write a response I’ll answer you though (check bottom where I
re-phase my query):

I think I understood your question :wink:

To be honest I’d like to start from scratch and see what I come up with,
secondly I hate GUI based editors personally.

But seeing the above clarification, I understand where you want to go
(non-GUI) and that you want to start from scratch.

Nevertheless, I’m sure your revised questions (below) will be helpful to
others who respond.

Randy K.

On 5/1/06, John G. [email protected] wrote:

syntax coloring is not easy to add.
Say, not to harp on FreeRIDE, but the project’s sound very similar.
Just curious, why did you start your own editor project in Ruby
instead of working on FreeRIDE?

I cannot recall. Something about that I wanted a lightweight editor,
that would work both in console and gui mode, highly portable, using
unicode, and scriptable in our favorite language.

I am using TextMate, until again I find time/money to do editor.

Also, I saw on your site that you switched to dvorak. I switched a
couple years ago and my hands are much happier. :slight_smile:

Having used dvorak for ~6 months I have switched back to qwerty,
because most keybindings favors qwerty :frowning:
Using vim in dvorak mode was interesting.

On Tue, May 02, 2006 at 02:16:06AM +0900, Simon S. wrote:
[…]
} I cannot recall. Something about that I wanted a lightweight editor,
} that would work both in console and gui mode, highly portable, using
} unicode, and scriptable in our favorite language.
}
} I am using TextMate, until again I find time/money to do editor.
}
} >Also, I saw on your site that you switched to dvorak. I switched a
} >couple years ago and my hands are much happier. :slight_smile:
}
} Having used dvorak for ~6 months I have switched back to qwerty,
} because most keybindings favors qwerty :frowning:
} Using vim in dvorak mode was interesting.

So you clearly know about vim. And you presumably know that it can be
used
in both console and GUI modes. And that it is portable enough that it
runs
on Windows, MacOS X, and *nix (under several X11 toolkits, even). Do you
know that it is scriptable in Ruby? Was there something else you were
looking for?

} Simon S.
–Greg

On 5/1/06, Gregory S. [email protected] wrote:

On Tue, May 02, 2006 at 02:16:06AM +0900, Simon S. wrote:
[…]
} I cannot recall. Something about that I wanted a lightweight editor,
} that would work both in console and gui mode, highly portable, using
} unicode, and scriptable in our favorite language.
}
} I am using TextMate, until again I find time/money to do editor.
}
[snip]

So you clearly know about vim. And you presumably know that it can be used
in both console and GUI modes. And that it is portable enough that it runs
on Windows, MacOS X, and *nix (under several X11 toolkits, even). Do you
know that it is scriptable in Ruby? Was there something else you were
looking for?

I know. Nevermind.

On 5/1/06, Simon S. [email protected] wrote:

On 5/1/06, John G. [email protected] wrote:
[snip]

You may want to have a look at “ne” (the Nice Editor).
http://ne.dsi.unimi.it/
[snip]
jumping-off point). It’s written in C, and is GPL’d. I’d love to see
it get syntax highlighting and be scriptable with Ruby. Man that would
rock. :slight_smile:

syntax coloring is not easy to add.

Understood. Also, I can guess that it might be easier or harder to add
depending on the design of the editor you’re trying to add it to.

I did some editor work, but currently lacks time to complete it.
http://aeditor.rubyforge.org/

Neat.

Say, not to harp on FreeRIDE, but the project’s sound very similar.
Just curious, why did you start your own editor project in Ruby
instead of working on FreeRIDE?

Also, I saw on your site that you switched to dvorak. I switched a
couple years ago and my hands are much happier. :slight_smile:

“Simon S.” [email protected] writes:

I cannot recall. Something about that I wanted a lightweight editor,
that would work both in console and gui mode, highly portable, using
unicode, and scriptable in our favorite language.

A few things I’ve noticed:

http://raa.ruby-lang.org/project/diakonos/

You’re not the first person to want these things, that’s for sure.

Also, I saw on your site that you switched to dvorak. I switched a
couple years ago and my hands are much happier. :slight_smile:

Having used dvorak for ~6 months I have switched back to qwerty,
because most keybindings favors qwerty :frowning:
Using vim in dvorak mode was interesting.

Heh. Dvorak was the main reason I chose Emacs over Vim several years
ago. I’m happy with the way things turned out, even if I didn’t have a
great reason to start out with.

-Phil H.

On 5/1/06, Phil H. [email protected] wrote:

ago. I’m happy with the way things turned out, even if I didn’t have a
great reason to start out with.

I use vim often these days, and have tried emacs for a time, but
didn’t see any difference regarding one being harder than the other
wrt dvorak vs. qwerty. Regardless of keyboard layout, emacs keys
seemed a bit more consistent, but I ended up using vim instead for
other reasons.

Also, emacs always gave me that eerie feeling that it was thinking
about things behind my back. Like it was just allowing me to edit text
as one of it’s low-priority background tasks (to humor me perhaps)
while silently carrying on with its own affairs. :wink:

Phil H. wrote:

IIRC the vi navigational keys are arranged such that they all fall on
the qwerty home row.

I also use Dvorak and Vim, and the key bindings never bothered me. The j
and k are also side by side and the h and l keys I don’t use that often
anyway. I use w (or e) and b instead, which are on the same row and
nearly side by side, so it’s not a problem.

Cheers,
Robin

“John G.” [email protected] writes:

I use vim often these days, and have tried emacs for a time, but
didn’t see any difference regarding one being harder than the other
wrt dvorak vs. qwerty. Regardless of keyboard layout, emacs keys
seemed a bit more consistent, but I ended up using vim instead for
other reasons.

IIRC the vi navigational keys are arranged such that they all fall on
the qwerty home row.

Also, emacs always gave me that eerie feeling that it was thinking
about things behind my back. Like it was just allowing me to edit text
as one of it’s low-priority background tasks (to humor me perhaps)
while silently carrying on with its own affairs. :wink:

Well, you can always (setq self-awareness nil) but where’s the fun in
that? It’s no coincidence… Lisp was originally used as an AI
language. =) You pretty much have to come to grips with the fact that
Emacs is smarter than you are… Once you do that everything falls
into place comfortably.

-Phil

On 5/4/06, Pistos C. [email protected] wrote:

Simon S. wrote:

I cannot recall. Something about that I wanted a lightweight editor,
that would work both in console and gui mode, highly portable, using
unicode, and scriptable in our favorite language.

I am using TextMate, until again I find time/money to do editor.

I’m surprised a bit at your responses in this thread. :slight_smile: I thought you
totally abandoned AEditor because you were so enamoured by TextMate. :slight_smile:

Even though TextMate has many interesting things, it still feels like I
am
missing certain stuff. I have’nt yet started analyzing what that stuff
is.
Some pointers about TextMate (Sorry Allan):

  • non-free.
  • mac only.
  • gui only.
  • sideways scrolling could be better.
  • no block caret ala Turbo Pascal.
  • sometimes too intelligent.
  • bad vertical scrolling for bottom/top parts of a file.
  • I want to advertise for its cmd+T that quick-opens files, its amazing.

I sometimes want a editor that can go fullscreen, where you cannot be
disturbed
by anything, so one can code.

These items is what I immediately can think of.
I am relatively satisfied with TM.

On May 4, 2006, at 12:41 AM, Simon S. wrote:

  • gui only.

I’ve always been impressed by how well it interacts with cli apps
though (via the mate command).

James Edward G. II

This doesn’t answer the question. But I’d just like to point out that
Emacs is extendible with ruby thanks to el4r[1]. I’ve been playing
around with it to build a Emacs GTD app using ical as the backend.

alex

[1] http://www.rubyist.net/~rubikitch/computer/el4r/index.en.html

Simon S. wrote:

I cannot recall. Something about that I wanted a lightweight editor,
that would work both in console and gui mode, highly portable, using
unicode, and scriptable in our favorite language.

I am using TextMate, until again I find time/money to do editor.

I’m surprised a bit at your responses in this thread. :slight_smile: I thought you
totally abandoned AEditor because you were so enamoured by TextMate. :slight_smile:

Pistos