emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Small improvements to ruby-mode


From: Bozhidar Batsov
Subject: Re: Small improvements to ruby-mode
Date: Sat, 22 Jun 2013 10:05:27 +0300

On Saturday, June 22, 2013 at 2:31 AM, Dmitry Gutov wrote:
* Font-lock changes
Some of the Ruby "keywords" that are currently highlighted as keywords are
not actually Ruby keywords, but plain methods - alias_method,
module_function, throw, raise, private, protected, public. I feel that they
should not be highlighted like this to keep the highlighting syntactically
correct. Technically speaking true, false and self are also keywords, but
given their semantics I guess the current highlighting is ok.
On a related note I think that it would make sense to use
font-lock-builtin-face for methods like alias_method, module_function,
throw, raise, private, protected, public and other keyword like methods for
Kernel and Module. I feel that such a move would increase the readability of
the Ruby source code.

Good idea, done in revno 113128. I also added require, require_relative
and autoload to the second list.

Great! Thanks a lot of the quick response!
 
Should we add more, e.g. include,
attr_accessor, using, refine?
Yes, I think we should definitely add more. The ones you listed - for sure. We should also add fail (it's a synonym for raise), extend, etc. Btw catch is also a method, not a keyword. loop should also be on the second list, as should be proc and lambda IMO.

I'd also suggest adding the "command-like" methods for Kernel that are usually used without an explicit receiver everywhere. There's not that many such commands:

abort
at_exit
catch
eval
exec
exit
exit!
fail
fork
format
p
print
printf
putc
puts
rand
sleep
spawn
sprintf
srand
syscall
system
trap
warn 

* Treat more filenames/file extensions as Ruby code

Most Rubyists these days have to add the following in their Emacs config:

(add-to-list 'auto-mode-alist '("\\.rake\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.ru\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Gemfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Guardfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.thor\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Thorfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile\\'" . ruby-mode))
(add-to-list 'auto-mode-alist '("\\.jbuilder\\'" . ruby-mode))

These should be consolidated into a single regexp and should probably be
made a bit tighter (e.g. don't put BadCapfile in ruby-mode).

Also done, revno 113129 and 113130.
Fantastic! 

I'm not too happy about having so many different patterns, tho (even if
consolidated into a single regexp). Why are so many different namings
used?

These are for different tools, using different DSLs inside. Anyway, I
blame Make, they started it.

It sounds like the Ruby people consider that all the world is
Ruby and other tools just have to deal with it. Would it have been so
hard to add a .rb to all those <Foo>file ?

Most of (?) these work just as well if you add the extension, but nobody
actually does that.

* Implement some ruby-tools like commands in ruby-mode
ruby-tools is a small package, that adds some extra code manipulation

We could integrate it into ruby-mode, of course.

I'm not so sure about re-implementing it, though. It's easy enough to
install in its current form, no?
Sure - my point is that not all Emacs users would know about the package. I'd venture a guess saying most of them won't. The functionality in it seems a perfect fit for ruby-mode. Even if it has to be reimplemented - we're talking about a only a handful of not particularly complex commands. 

Patches and suggestions on what polish we could provide exactly are
always welcome.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]