IDE vs. editor

Thanks to you and Alan for the tip. A sensible approach. But I
wonder if any output buffer can be forced to be parsed into line
anchors to another buffer. Elisp wizards, hints?

Massimiliano

···

On Sun, Aug 18, 2002 at 03:57:22AM +0900, Alan Chen wrote:

How do you run tests and then jump to offending lines? I use to run
I’ve been running my unit tests from a makefile,

bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu writes:

You need a ruby version of etags. Then it’s just a simple
matter of using tags-query-replace. The hard bit is a ruby
version of etags. I said it was possible, not that I knew
exactly how to do it %-)!

rtags comes with irb (the separate package, not the one that comes in
the Ruby download). Never used it, but it doesn’t crash when I run
it… :slight_smile:

Dave

    • I can do all this in Emacs and have a powerful editor. Is it
      Same questions to you: how do you have a method’s renaming propagate,
    • You need a ruby version of etags. Then it’s just a simple
      matter of using tags-query-replace. The hard bit is a ruby
      version of etags.

I heard about etags supporting ruby, but never managed to get it work,
probably because I never used etags with any other language and I
don’t know how it is supposed to work when it does. Sounds like it’s
time for another try.

I wonder, though, what tags-query-replace does. If I modify class MyClass; def meth; end; end' into class MyClass; def new_meth; end;
end’, will the various my_instance.meth throughout the code be changed
into my_instance.new_meth? It doesn’t seem very likely – for one
thing, how would Emacs know that my_instance is an instance of MyClass
and not anything else?

I said it was possible, not that I knew exactly how to do it %-)!

Hey, you said you could do it, I just yearn to know how! :slight_smile:

Massimiliano

···

On Mon, Aug 19, 2002 at 02:44:06AM +0900, bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu wrote:

Massimiliano Mirra list@NOSPAMchromatic-harp.com writes:

How do you run tests and then jump to offending lines? I use to run
I’ve been running my unit tests from a makefile,

Thanks to you and Alan for the tip. A sensible approach. But I
wonder if any output buffer can be forced to be parsed into line
anchors to another buffer. Elisp wizards, hints?

Use M-x compile to run the tests, and set
compilation-error-regexp-alist to parse out the line number and file
name of the failing test. Then next-error (normally bound to ^X-` will
load the file and take you to the line in error. (This is all theory:
I’ve never tried parsing Test::Unit output, but I can’t see a problem
doing it.)

Cheers

Dave

···

On Sun, Aug 18, 2002 at 03:57:22AM +0900, Alan Chen wrote:

Again, I did not ask how you jump to a line, I asked
how do you jump to the line of a failed test, which
you said can be done.

Several ways. The easiest is to run the tests from the M-x compile
command and use the find next error command.

If you run them from within a shell in emacs (rather than M-x
compile), then you can use the following two functions and keybinding
to search for errors in the immediately preceeding command output in
the shell.

Note that find-errors searches backwards for a shell prompt. If you
have an unusual shell prompt, this may require tweeking.

···

(defun find-errors ()
“Find the Errors in the current shell buffer.”
(interactive)
(save-excursion
(re-search-backward “[1]+\$”)
(set-mark (point))
(re-search-backward “[2]+\$”)
(find-errors-in-region)
(next-error '(4)))
)

(defun find-errors-in-region ()
“Use highlighted errors as compile errors.”
(interactive)
(copy-region-as-kill (region-beginning) (region-end))
(goto-char (point-max))
(let ((oldbuf (get-buffer “shell errors”)))
(if oldbuf (kill-buffer oldbuf)))
(let ((outbuf (get-buffer-create “shell errors”)) )
(switch-to-buffer outbuf)
(insert-string “\n\n\n\n”)
(yank)
(setq compilation-last-buffer outbuf)
(compilation-mode) ))

(global-set-key “\C-ce” 'find-errors)

Emacs uses regular expressions to find and parse the “compile” output.
If it cannot find the test case errors, jsut add the appropriate REs
to the error list.


– Jim Weirich jweirich@one.net http://w3.one.net/~jweirich

“Beware of bugs in the above code; I have only proved it correct,
not tried it.” – Donald Knuth (in a memo to Peter van Emde Boas)


  1. a-zA-Z0-9 ↩︎

  2. a-zA-Z0-9 ↩︎

Sorry, I misunderstood. I believed the subject being discussed was
users’ benefit, not salesmen’s.

Massimiliano

···

On Sun, Aug 18, 2002 at 08:22:37AM +0900, Lothar Scholz wrote:

On Sun, Aug 18, 2002 at 01:38:43AM +0900, Lothar Scholz wrote:

And the community of hard core vi or emacs persons is to small.

What planet do you live on? :slight_smile:

Earth.

But to be more precise: The community of persons who are buying and
evaluating IDE’s. Even in companies with as low as 5 programmers that
are normally not the geeks that what to use the editor.

I analysed this with the economic aspect in mind. And this will be
hard to deny.

There is also exuberant ctags (http://ctags.sf.net) which supports
ruby tag scans for both vi and emacs.

···

On Mon, Aug 19, 2002 at 03:16:18AM +0900, Dave Thomas wrote:

bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu writes:

You need a ruby version of etags. Then it’s just a simple
matter of using tags-query-replace. The hard bit is a ruby
version of etags. I said it was possible, not that I knew
exactly how to do it %-)!

rtags comes with irb (the separate package, not the one that comes in
the Ruby download). Never used it, but it doesn’t crash when I run
it… :slight_smile:

Dave


Alan Chen
Digikata LLC
http://digikata.com

This is obviously the problem of editors vs IDEs. IntelliJ IDE for Java
manages such things as “method” rename with incredible ease. I wonder if it’s
even possible for Ruby - dynamically typed and all.

Thoughts? I’d like to see it one day. How does the Smalltalk refactoring
browser work?

Gavin

···

----- Original Message -----
From: “Massimiliano Mirra” list@NOSPAMchromatic-harp.com

[snip too much context]

I wonder, though, what tags-query-replace does. If I modify class MyClass; def meth; end; end' into class MyClass; def new_meth; end;
end’, will the various my_instance.meth throughout the code be changed
into my_instance.new_meth? It doesn’t seem very likely – for one
thing, how would Emacs know that my_instance is an instance of MyClass
and not anything else?

Massimiliano

In article 20020818183052.GA4757@prism.localnet,

    • I can do all this in Emacs and have a powerful editor. Is it
      Same questions to you: how do you have a method’s renaming propagate,
    • You need a ruby version of etags. Then it’s just a simple
      matter of using tags-query-replace. The hard bit is a ruby
      version of etags.

I heard about etags supporting ruby, but never managed to get it work,
probably because I never used etags with any other language and I
don’t know how it is supposed to work when it does. Sounds like it’s
time for another try.

I wonder, though, what tags-query-replace does. If I modify class MyClass; def meth; end; end' into class MyClass; def new_meth; end;
end’, will the various my_instance.meth throughout the code be changed
into my_instance.new_meth? It doesn’t seem very likely – for one
thing, how would Emacs know that my_instance is an instance of MyClass
and not anything else?

    • You’ve got me there. I was extrapolating my C refactoring
      experience, there tags-query-replace rules. However, I can
      see the problems with doing that in ruby. It would depend
      on how smart the tag program was, I suspect you’d have to
      have a full blown ruby parser to fully support this kind
      of refactoring. But since we have one handy, I don’t think
      it would be impossible.
    • Booker C. Bense
···

Massimiliano Mirra list@NOSPAMchromatic-harp.com wrote:

On Mon, Aug 19, 2002 at 02:44:06AM +0900, bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu wrote:

Massimiliano Mirra list@NOSPAMchromatic-harp.com writes:

    • I can do all this in Emacs and have a powerful editor. Is it
      Same questions to you: how do you have a method’s renaming
      propagate,
    • You need a ruby version of etags. Then it’s just a simple
      matter of using tags-query-replace. The hard bit is a ruby
      version of etags.

I heard about etags supporting ruby, but never managed to get it work,

probably because I never used etags with any other language and I
don’t know how it is supposed to work when it does. Sounds like it’s
time for another try.

You roll your own ruby support if your etags doesn’t have it (I am
using emacs 21.2.1 and the version of etags supplied doesn’t have it).

Here’s how to roll your own:
etags -l none --regex=‘your regex’ --regex=‘your other regex’ files

You get the point, you can supply your own regexes that matches what
you want stored in the tags file as ruby definitions.

An example that I use because the etags python support didn’t store
method definition (only class names and functions).

etags %s --regex=“/[ \t]+def+(.+?)(/\1/”

The point of this regexp is to match a line looking like this
def theIdentifierThatEtagsWillPutInTheTagsFile(self, *args):

theIdentifierThatEtagsWillPutInTheTagsFile is matched by the first
group in the regex (in fact the only group) and then you tell etags
which group contains the identifier by writing \1 (for the first
group, you might need more if you need to group for or’ing parts of
regexps)

If you use *nix I think you should substitute the enclosing " with ’

I wonder, though, what tags-query-replace does. If I modify class MyClass; def meth; end; end' into class MyClass; def new_meth; end;
end’, will the various my_instance.meth throughout the code be changed

into my_instance.new_meth? It doesn’t seem very likely – for one
thing, how would Emacs know that my_instance is an instance of MyClass

and not anything else?

That’s why it’s called query, it asks you for each time it finds meth
so you can say yes (or no).

It would be fine if any replies to this posting would be cc’ed to me,
I am more of a python guy currently, but had to check out the group as
Ron Jeffries and Dave Thomas seems to appreciate Ruby a lot.

···

On Mon, Aug 19, 2002 at 02:44:06AM +0900, > bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu wrote:

Vennlig hilsen

Syver Enstad

Thanks to you and Alan for the tip. A sensible approach. But I
wonder if any output buffer can be forced to be parsed into line
anchors to another buffer. Elisp wizards, hints?
Use M-x compile to run the tests,

It’s M-x compile’ing that turns me a bit down, because it requires the
extra step of saving. Right now, I just press C-c-c, current buffer
is evaluated (whether saved or not), and since it contains:

if FILE == $0
require ‘test/unit’

end

…tests are run, and output shown in a lower window. I was wondering
whether that appearing window could be made a parsed-for-line-numbers
one like M-x compile’s. Maybe I’m just being too lazy…

and set compilation-error-regexp-alist to parse out the line number
and file name of the failing test. Then next-error (normally bound
to ^X-` will load the file and take you to the line in error. (This
is all theory: I’ve never tried parsing Test::Unit output, but I
can’t see a problem doing it.)

(Some minutes later…)

…or maybe I’d better just RTFM. :slight_smile:

C-x runs the command next-error which is an interactive compiled Lisp function incompile’.
(next-error &optional ARGP)

[…]

C-x normally uses the most recently started compilation or grep buffer. However, it can operate on any buffer with output from the M-x compile and M-x grep commands, or, more generally, on any buffer in Compilation mode or with Compilation Minor mode enabled. To specify use of a particular buffer for error messages, type C-x in that buffer.

Ok, time to learn some elisp. :slight_smile:

Massimiliano

···

On Sun, Aug 18, 2002 at 12:05:02PM +0900, Dave Thomas wrote:

Does anyone know of a good source on best practices to make ruby coding
easier with VIM? I’m looking for tips like these, how to intergrate
Test::Unit in VIM if there are better Syntax files. How to access CVS
from VIM. I"m pretty certain all this is possible I just don’t know
where or how. If this source isn’t already available I’d be more than
willing to create it. The only problem is I don’t know it already.;

Carl P.

···

On Sat, 2002-08-17 at 20:05, Dave Thomas wrote:

Massimiliano Mirra list@NOSPAMchromatic-harp.com writes:

On Sun, Aug 18, 2002 at 03:57:22AM +0900, Alan Chen wrote:

How do you run tests and then jump to offending lines? I use to run
I’ve been running my unit tests from a makefile,

Thanks to you and Alan for the tip. A sensible approach. But I
wonder if any output buffer can be forced to be parsed into line
anchors to another buffer. Elisp wizards, hints?

Use M-x compile to run the tests, and set
compilation-error-regexp-alist to parse out the line number and file
name of the failing test. Then next-error (normally bound to ^X-` will
load the file and take you to the line in error. (This is all theory:
I’ve never tried parsing Test::Unit output, but I can’t see a problem
doing it.)

Cheers

Dave

I believe a parser wouldn’t be enough:

a = create_some_object()
a.instance  # 2 b renamed? depends on a.type

Sure, a really clever tool would analyze create_some_object() and infer
the type, but this is guaranteed not to work always (eval, etc…) and
will fail a lot if the program isn’t so intelligent.

The only way I can think of that could possibly work is interpreting
and keeping track of the method calls (plus their position in the
source code). But we’d have to test all code branches, which might be
impossible…

···

On Mon, Aug 19, 2002 at 11:28:28PM +0900, bbense+comp.lang.ruby.Aug.19.02@telemark.stanford.edu wrote:

    • You’ve got me there. I was extrapolating my C refactoring
      experience, there tags-query-replace rules. However, I can
      see the problems with doing that in ruby. It would depend
      on how smart the tag program was, I suspect you’d have to
      have a full blown ruby parser to fully support this kind
      of refactoring. But since we have one handy, I don’t think
      it would be impossible.


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

Windows without the X is like making love without a partner.
– MaDsen Wikholm, mwikholm@at8.abo.fi

Or you download Exuberant Ctags and save yourself some work. Supports
both vim and Emacs, as well as ruby.

http://ctags.sourceforge.net/languages.html

Dan

···

At Fri, 13 Sep 2002 06:41:14 +0900, Syver Enstad wrote:

You roll your own ruby support if your etags doesn’t have it (I am
using emacs 21.2.1 and the version of etags supplied doesn’t have it).


/^Dan Debertin$/
airboss@nodewarrior.org | Did I sleep a little too late,
www.nodewarrior.org | or am I awake? --Byrne

…< roll your own stuff deleted>

No need to roll your own, you can use exuberant ctags which has
support for ruby in etags format. I believe it supports Python too.

I’ve been happily using it for many languages for years now.

···

On Fri, Sep 13, 2002 at 06:41:14AM +0900, Syver Enstad wrote:

Massimiliano Mirra list@NOSPAMchromatic-harp.com writes:

On Mon, Aug 19, 2002 at 02:44:06AM +0900, > > bbense+comp.lang.ruby.Aug.18.02@telemark.stanford.edu wrote:

    • I can do all this in Emacs and have a powerful editor. Is it
      Same questions to you: how do you have a method’s renaming
      propagate,
    • You need a ruby version of etags. Then it’s just a simple
      matter of using tags-query-replace. The hard bit is a ruby
      version of etags.

I heard about etags supporting ruby, but never managed to get it work,

probably because I never used etags with any other language and I
don’t know how it is supposed to work when it does. Sounds like it’s
time for another try.

You roll your own ruby support if your etags doesn’t have it (I am
using emacs 21.2.1 and the version of etags supplied doesn’t have it).


Alan Chen
Digikata LLC
http://digikata.com

“Syver Enstad” syver-en+usenet@online.no schrieb im Newsbeitrag news:uvg5ax5bu.fsf@online.no…

Massimiliano Mirra list@NOSPAMchromatic-harp.com writes:

Here’s how to roll your own:
etags -l none --regex=‘your regex’ --regex=‘your other regex’ files

I also use etags with the following regexp:

‘/[ \t](def|class|module)[ \t<]([^ \t])[ \t]/\2/’

Its not perfect but works for me.

Cheers
Horst

http://www.rubygarden.org/ruby?VimExtensions is a good place to start.

Regards,
Doug

···

On Sun, Aug 18, 2002 at 10:59:13PM +0900, Carl Parrish wrote:

Does anyone know of a good source on best practices to make ruby coding
easier with VIM?

See VimExtensions on the Ruby Garden wiki (if you don’t know where that is, me
neither; I use rubycentral.com as a link repository).

You’ll find a few tricks there. Also search for “ruby” at www.vim.org.

Finally, put this in your {.vim/vimfiles}/ftplugin/ruby:

imap end-cc

Then type
def fun(x) ( is shift-carriage_return)

and you’ll see

def fun(x)
[cursor]
end

That of course can be used with for, if, class, begin, …

If you don’t understand any of this or the above trick doesn’t seem to work,
drop me an email.

Cheers,
Gavin

···

----- Original Message -----
From: “Carl Parrish” cparrish@cox.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Sunday, August 18, 2002 11:59 PM
Subject: Re: IDE vs. editor

Does anyone know of a good source on best practices to make ruby coding
easier with VIM? I’m looking for tips like these, how to intergrate
Test::Unit in VIM if there are better Syntax files. How to access CVS
from VIM. I"m pretty certain all this is possible I just don’t know
where or how. If this source isn’t already available I’d be more than
willing to create it. The only problem is I don’t know it already.;

Carl P.

Carl,

I haven’t come across any integration for Test::Unit in ViM. Sure there are
ways to easily run your main Test::Unit test suite from within ViM, but I
haven’t seen anything mapping the errors back to the offending line in the
source file.

CVS can be loosely integrated through a front end script called CVSMenu (get
it http://vim.sf.net). I would prefer something that is easier to use/view
myself. I can’t get used to the diffs and I also like it when I don’t have to
do anything to see what needs to be updated, my view is always “live” showing
me what has changed and what hasn’t.


Signed,
Holden Glova

···

On Mon, 19 Aug 2002 01:59, Carl Parrish wrote:

Does anyone know of a good source on best practices to make ruby coding
easier with VIM? I’m looking for tips like these, how to intergrate
Test::Unit in VIM if there are better Syntax files. How to access CVS
from VIM. I"m pretty certain all this is possible I just don’t know
where or how. If this source isn’t already available I’d be more than
willing to create it. The only problem is I don’t know it already.;

Carl P.

Agreed: a simple parser wouldn’t be enough. “eval” is one of
many examples where it’s non-trivial to discover the correct type
of a Ruby object from source.

The original Smalltalkers dealt with this problem in a simple
way: Just substitute textually, prompting the user with the list
of effected lines.

To my knowledge, no one has ever written a more effective
RenameMethod for a dynamically typed language. Probably the
80/20 rule in effect.

  • Ryan King
···

On 2002.08.20, Mauricio Fern?ndez batsman.geo@yahoo.com wrote:

[regarding a mechanical “RenameMethod” refactoring for ruby]:
I believe a parser wouldn’t be enough: