From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bozhidar Batsov Newsgroups: gmane.emacs.devel Subject: Re: Small improvements to ruby-mode Date: Sat, 22 Jun 2013 10:05:27 +0300 Message-ID: <6EF2AEF8D67840A2AF1C908AA3D0725F@gmail.com> References: <2A6700DEDCA640EF92B326002717596D@gmail.com> <87txkrm46t.fsf@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="51c54cb7_275ac794_238" X-Trace: ger.gmane.org 1371884747 19670 80.91.229.3 (22 Jun 2013 07:05:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Jun 2013 07:05:47 +0000 (UTC) Cc: Stefan Monnier , emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 22 09:05:48 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UqHtK-0004uL-6W for ged-emacs-devel@m.gmane.org; Sat, 22 Jun 2013 09:05:46 +0200 Original-Received: from localhost ([::1]:58481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqHtJ-0002nY-Jy for ged-emacs-devel@m.gmane.org; Sat, 22 Jun 2013 03:05:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqHtB-0002nP-Mi for emacs-devel@gnu.org; Sat, 22 Jun 2013 03:05:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqHt6-0004Qr-93 for emacs-devel@gnu.org; Sat, 22 Jun 2013 03:05:37 -0400 Original-Received: from mail-bk0-x232.google.com ([2a00:1450:4008:c01::232]:52124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqHt5-0004Qn-V3 for emacs-devel@gnu.org; Sat, 22 Jun 2013 03:05:32 -0400 Original-Received: by mail-bk0-f50.google.com with SMTP id ik8so3676030bkc.37 for ; Sat, 22 Jun 2013 00:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:message-id:in-reply-to:references:subject :x-mailer:mime-version:content-type; bh=ABmGeZhgiMW2MBVtfVGJg8lF49s492PCKnC3Y4cqXig=; b=dC5hOnbm/P45yh6UyBm5m8ApO0zyk8FeayLEJ/c+AgiRcE7djZ6vBFeuhv5tC8a8w7 leZ1grp4WTZaSrfG1a7yfYaNVabJkP35DTC0Bhbi5Z5kvHXoNYKV6u6T6/uKtZSrhuj/ 6YVcJW0JW7/yBtDHeFRpYlnncBgQ34fF7wr4mSBa+YdH/hlKXZVfrC5tYr+ytpbIlQ3M x323IjMCAl9pWDn572CKEuYORmUyX9oKqyDe9jTIEngegoroiPQGUtFpLb5GUYq6nqLm DRoQrgaegWoy5+JEMEyong022jQBWvSPOw1pINN0PqatLo6qeAuUknZAn1lvuIYIMHeF Gmrg== X-Received: by 10.204.241.75 with SMTP id ld11mr2421618bkb.78.1371884730993; Sat, 22 Jun 2013 00:05:30 -0700 (PDT) Original-Received: from [10.0.1.3] (93-152-182-45.ddns.onlinedirect.bg. [93.152.182.45]) by mx.google.com with ESMTPSA id rj6sm2225261bkb.12.2013.06.22.00.05.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 22 Jun 2013 00:05:30 -0700 (PDT) In-Reply-To: <87txkrm46t.fsf@yandex.ru> X-Mailer: sparrow 1.6.4 (build 1178) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4008:c01::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:160872 Archived-At: --51c54cb7_275ac794_238 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 > > > commands https://github.com/rejeep/ruby-tools > > > > > > > > > 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. > > --51c54cb7_275ac794_238 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
On S= aturday, June 22, 2013 at 2:31 AM, Dmitry Gutov wrote:
* =46ont-lock changes
Some of = the Ruby =22keywords=22 that are currently highlighted as keywords are
not actually Ruby keywords, but plain methods - alias=5Fmethod,
module=5Ffunction, throw, raise, private, protected, public. I f= eel that they
should not be highlighted like this to keep the h= ighlighting syntactically
correct. Technically speaking true, f= alse and self are also keywords, but
given their semantics I gu= ess the current highlighting is ok.
On a related note I think = that it would make sense to use
font-lock-builtin-face for meth= ods like alias=5Fmethod, module=5Ffunction,
throw, raise, priv= ate, protected, public and other keyword like methods for
Kerne= l 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, req= uire=5Frelative
and autoload to the second list.

Great=21 Thanks a lot of the = quick response=21
 
Should we add more, e.g. include,
attr=5Faccessor, using, refine=3F
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, e= tc. 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 =22command-like=22 methods for Kernel that ar= e usually used without an explicit receiver everywhere. There's not that = many such commands:

abort
at=5Fexit
catch
eval
exec
exit
exit= =21
fail
fork
format
p
= print
printf
putc
puts
rand
=
sleep
spawn
sprintf
srand
sy= scall
system
trap
warn 

* Treat= more filenames/file extensions as Ruby code

<= /div>
Most Rubyists these days have to = add the following in their Emacs config:

(add-to-list 'auto-mode-alist '(= =22=5C=5C.rake=5C=5C'=22 . ruby-mode))
(add-to-list 'auto-mode-= alist '(=22=5C=5C.ru=5C=5C'=22 . ruby-mode))
(add-to-list 'auto= -mode-alist '(=22Gemfile=5C=5C'=22 . ruby-mode))
(add-to-list '= auto-mode-alist '(=22Guardfile=5C=5C'=22 . ruby-mode))
(add-to-= list 'auto-mode-alist '(=22Capfile=5C=5C'=22 . ruby-mode))
(add= -to-list 'auto-mode-alist '(=22=5C=5C.thor=5C=5C'=22 . ruby-mode))
<= div>(add-to-list 'auto-mode-alist '(=22Thorfile=5C=5C'=22 . ruby-mode))
(add-to-list 'auto-mode-alist '(=22Vagrantfile=5C=5C'=22 . ruby-= mode))
(add-to-list 'auto-mode-alist '(=22=5C=5C.jbuilder=5C=5C= '=22 . ruby-mode))

These shou= ld be consolidated into a single regexp and should probably be
= made a bit tighter (e.g. don't put BadCapfile in ruby-mode).
<= /blockquote>

Also done, revno 113129 and 113130.
=
=46antastic=21 

I'm not too happy about having so many= different patterns, tho (even if
consolidated into a single re= gexp). Why are so many different namings
used=3F

These are for different tools, using diffe= rent DSLs inside. Anyway, I
blame Make, they started it.
<= div>
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 <=46oo>file =3F
Most of (=3F) these work just as well if you add the extensio= n, but nobody
actually does that.

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

We coul= d 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=3F
<= /span>
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. T= he 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 particu= larly complex commands. 

Patches and suggestions on w= hat polish we could provide exactly are
always welcome.
=20 =20 =20 =20
=20

--51c54cb7_275ac794_238--