GNU bug report logs - #17057
24.3.50; [ruby-mode] Font-locking of special global variables like $$ is broken(missing)

Previous Next

Package: emacs;

Reported by: Bozhidar Batsov <bozhidar <at> batsov.com>

Date: Fri, 21 Mar 2014 12:54:02 UTC

Severity: minor

Found in version 24.3.50

Fixed in version 24.4

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17057 in the body.
You can then email your comments to 17057 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Fri, 21 Mar 2014 12:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Bozhidar Batsov <bozhidar <at> batsov.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 21 Mar 2014 12:54:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50;
 [ruby-mode] Font-locking of special global variables like $$ is
 broken(missing)
Date: Fri, 21 Mar 2014 14:53:14 +0200
Here's a few examples:

"this is #$$"

var = $!

Things are different for:

"this is #$1"

var = $1

I think those should be highlighted at least like $1 and friends.

There's another thing to consider - do built-in global vars should be
font-locked like built-ins or like the other (user-defined) global
variables? Personally I'd font-lock them as built-in to underline their
significance.



In GNU Emacs 24.3.50.1 (x86_64-apple-darwin13.0.0, NS apple-appkit-1265.00)
 of 2014-03-01 on Bozhidars-MacBook-Pro.local
Windowing system distributor `Apple', version 10.3.1265
Configured using:
 `configure --prefix=/usr/local/Cellar/emacs/HEAD --without-dbus
 --enable-locallisppath=/usr/local/share/emacs/site-lisp
 --infodir=/usr/local/Cellar/emacs/HEAD/share/info/emacs
 --without-gnutls --with-ns --disable-ns-self-contained'

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Ruby

Minor modes in effect:
  subword-mode: t
  ruby-tools-mode: t
  inf-ruby-minor-mode: t
  magit-auto-revert-mode: t
  diff-auto-refine-mode: t
  guru-mode: t
  erc-truncate-mode: t
  erc-spelling-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  global-flycheck-mode: t
  flycheck-mode: t
  which-function-mode: t
  flx-ido-mode: t
  ido-ubiquitous-mode: t
  winner-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  whitespace-mode: t
  global-anzu-mode: t
  anzu-mode: t
  projectile-global-mode: t
  projectile-mode: t
  flyspell-mode: t
  shell-dirtrack-mode: t
  volatile-highlights-mode: t
  global-hl-line-mode: t
  recentf-mode: t
  savehist-mode: t
  show-smartparens-global-mode: t
  show-smartparens-mode: t
  smartparens-mode: t
  global-auto-revert-mode: t
  delete-selection-mode: t
  prelude-global-mode: t
  prelude-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
t SPC i s SPC @ <backspace> # g o o t C-b C-b C-b C-b 
C-b C-d @ C-f C-f C-f C-f C-d C-x C-s C-e C-x b <return> 
C-p C-p C-e <return> p SPC n o d e . c h i l d r e 
n C-x C-s C-x b <return> C-a C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f C-f C-b C-b C-b { C-d C-f C-f 
C-f C-f C-f } C-x C-s C-b C-b C-b C-b C-b C-b C-b C-d 
C-f C-f C-f C-f C-f C-d C-x C-s C-x b <return> C-a 
C-a C-k C-k C-x b <return> C-b C-b C-b C-b C-b C-d 
$ C-x C-s C-d C-d C-d C-d $ C-x C-s <backspace> ! C-x 
C-s <backspace> 1 C-x C-s C-x b <return> C-n C-e . 
l o c . e x p r e s s i o n . s o u r c e C-x C-s C-n 
C-a C-f C-f C-f C-f C-f C-f C-k C-p C-a C-f C-f C-k 
C-n C-e C-y C-p C-p C-n C-a C-a C-k C-k C-n C-n C-n 
C-p C-p C-p C-n C-n C-n C-p C-k C-k C-n C-k C-k C-p 
<tab> C-x C-s <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <down-mouse-1> 
<mouse-1> <down-mouse-1> <mouse-1> C-x b t e s t <return> 
<backspace> ! <backspace> $ <backspace> 1 <backspace> 
$ <help-echo> <down-mouse-1> <mouse-1> C-v a <backspace> 
<return> v a r r <backspace> SPC = = SPC $ 1 <backspace> 
$ <backspace> ! <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <return> <return> 
t o p SPC = SPC $ t e s t <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> M-x 
r e b o <backspace> <backspace> p o r t <return>

Recent messages:
Wrote /Users/bozhidar/projects/test.rb
Saving file /Users/bozhidar/projects/rubocop/lib/rubocop/cop/style/variable_interpolation.rb...
Wrote /Users/bozhidar/projects/rubocop/lib/rubocop/cop/style/variable_interpolation.rb
Mark set
Indenting region...done
Inconsistent indentation detected.
Saving file /Users/bozhidar/projects/rubocop/lib/rubocop/cop/style/variable_interpolation.rb...
Wrote /Users/bozhidar/projects/rubocop/lib/rubocop/cop/style/variable_interpolation.rb
Saving file /Users/bozhidar/projects/test.rb...
Wrote /Users/bozhidar/projects/test.rb
scroll-up-command: End of buffer

Load-path shadows:
/Users/bozhidar/.emacs.d/elpa/tabulated-list-20120406.2251/tabulated-list hides /usr/local/Cellar/emacs/HEAD/share/emacs/24.3.50/lisp/emacs-lisp/tabulated-list

Features:
(rect shadow sort emacsbug make-mode ielm lisp-mnt clojure-test-mode
cider-scratch network-stream starttls tls slime-fancy
slime-fontifying-fu slime-package-fu slime-references slime-scratch
slime-presentations slime-fuzzy slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-parse slime-repl elp slime
hyperspec ace-jump-mode hippie-exp browse-url cus-edit cus-start
cus-load slim-mode mail-extr eieio-opt speedbar sb-image ezimage dframe
rst yaml-mode superword subword ruby-tools inf-ruby ruby-mode-expansions
smartparens-ruby ruby-mode smie cider coffee-mode js-mode-expansions js
json cc-mode-expansions cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs web-mode-expansions
web-mode disp-table nxml-uchnm rng-xsd xsd-regexp rng-cmpct cider-mode
cider-repl cider-eldoc cider-interaction arc-mode archive-mode
cider-client nrepl-client cider-util ewoc clojure-mode-expansions
clojure-mode inf-lisp find-dired vc-annotate vc vc-dispatcher misearch
multi-isearch gitignore-mode conf-mode ibuf-ext ibuffer ffap url-parse
url-vars mule-util executable magit-key-mode magit view epa derived epg
epg-config diff-mode git-rebase-mode git-commit-mode server log-edit
message sendmail rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log vc-git markdown-mode noutline
outline rainbow-mode color rainbow-delimiters elisp-slime-nav guru-mode
prelude-key-chord key-chord prelude-xml nxml-mode-expansions
html-mode-expansions sgml-mode smartparens-html rng-nxml rng-valid
rng-loc rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn
nxml-ns nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc
xmltok prelude-web prelude-scss prelude-scheme prelude-ruby prelude-perl
prelude-org prelude-js prelude-erc erc-truncate erc-autoaway
erc-spelling erc-notify erc-log erc-list erc-menu erc-join erc-ring
erc-networks erc-pcomplete erc-track erc-match erc-button erc-fill
erc-stamp erc-netsplit erc-goodies erc erc-backend erc-compat
prelude-emacs-lisp prelude-css prelude-common-lisp slime-autoloads
prelude-clojure prelude-lisp prelude-c prelude-programming flycheck
help-mode rx f which-func imenu prelude-ido smex flx-ido flx
ido-ubiquitous warnings ido prelude-osx exec-path-from-shell
prelude-global-keybindings prelude-editor winner undo-tree diff esh-var
esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc esh-groups eshell
esh-module esh-mode esh-util re-builder whitespace browse-kill-ring
midnight ediff-merg ediff-wind ediff-diff ediff-mult ediff-help
ediff-init ediff-util ediff dired-x dired anzu projectile pkg-info
find-func grep compile s bookmark pp expand-region text-mode-expansions
er-basic-expansions expand-region-core expand-region-custom flyspell
ispell tramp tramp-compat auth-source gnus-util mm-util mail-prsvr
password-cache tramp-loaddefs trampver shell pcomplete comint ansi-color
format-spec etags ring volatile-highlights hl-line windmove recentf
tree-widget wid-edit savehist saveplace diminish smartparens-config
smartparens autorevert filenotify delsel prelude-mode easy-mmode edmacro
kmacro prelude-core epl advice help-fns dash thingatpt prelude-ui
zenburn-theme prelude-packages finder-inf ack-and-a-half-autoloads
diminish-autoloads erlang-autoloads flx-ido-autoloads eieio byte-opt
bytecomp byte-compile cconv eieio-core grizzl-autoloads
key-chord-autoloads logito-autoloads info easymenu cl-macs gv
pkg-info-autoloads rainbow-delimiters-autoloads rubocop-autoloads
volatile-highlights-autoloads yaml-mode-autoloads package cl cl-loaddefs
cl-lib time-date tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process cocoa ns
multi-tty emacs)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Fri, 21 Mar 2014 14:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 17057 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Bozhidar Batsov <bozhidar <at> batsov.com>
Cc: 17057 <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50;
 [ruby-mode] Font-locking of special global variables like $$ is
 broken(missing)
Date: Fri, 21 Mar 2014 16:47:59 +0200
Bozhidar Batsov <bozhidar <at> batsov.com> writes:

> Here's a few examples:
>
> "this is #$$"
>
> var = $!
>
> Things are different for:
>
> "this is #$1"
>
> var = $1

Have you tried it in the latest Emacs? For me, only one example

"this is #$$"

is not highlighted (I'll fix that).

> There's another thing to consider - do built-in global vars should be
> font-locked like built-ins or like the other (user-defined) global
> variables? Personally I'd font-lock them as built-in to underline their
> significance.

Hmmm, maybe. But we also highlight nil, self, true, false, __LINE__,
__ENCODING__ and __FILE__ with font-lock-variable-name-face. Should we
change these, too?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Fri, 21 Mar 2014 14:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 17057 <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 17057 <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special
 global variables like $$ is broken(missing)
Date: Fri, 21 Mar 2014 16:53:08 +0200
[Message part 1 (text/plain, inline)]
On Friday, March 21, 2014 at 4:47 PM, Dmitry Gutov wrote:
> Bozhidar Batsov <bozhidar <at> batsov.com (mailto:bozhidar <at> batsov.com)> writes:
>  
> > Here's a few examples:
> >  
> > "this is #$$"
> >  
> > var = $!
> >  
> > Things are different for:
> >  
> > "this is #$1"
> >  
> > var = $1
>  
> Have you tried it in the latest Emacs? For me, only one example
>  
> "this is #$$"
>  
> is not highlighted (I'll fix that).
>  
> > There's another thing to consider - do built-in global vars should be
> > font-locked like built-ins or like the other (user-defined) global
> > variables? Personally I'd font-lock them as built-in to underline their
> > significance.
> >  
>  
>  
> Hmmm, maybe. But we also highlight nil, self, true, false, __LINE__,
> __ENCODING__ and __FILE__ with font-lock-variable-name-face. Should we
> change these, too?
>  
>  

Technically speaking all of those are keywords, not variables. Somewhat odd __LINE__ and friends are  
treated at string literals by the Ruby parser. As all of those evaluate to some value unlike most other keywords I guess it makes some sense to font-lock them as variables, but I’d prefer if we used font-locking that makes their special status more apparent.  
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Sat, 22 Mar 2014 10:03:01 GMT) Full text and rfc822 format available.

Message #14 received at 17057 <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 17057 <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special
 global variables like $$ is broken(missing)
Date: Sat, 22 Mar 2014 12:02:10 +0200
[Message part 1 (text/plain, inline)]
On Friday, March 21, 2014 at 4:53 PM, Bozhidar Batsov wrote:
> On Friday, March 21, 2014 at 4:47 PM, Dmitry Gutov wrote:
> > Bozhidar Batsov <bozhidar <at> batsov.com (mailto:bozhidar <at> batsov.com)> writes:
> >  
> > > Here's a few examples:
> > >  
> > > "this is #$$"
> > >  
> > > var = $!
> > >  
> > > Things are different for:
> > >  
> > > "this is #$1"
> > >  
> > > var = $1
> >  
> > Have you tried it in the latest Emacs? For me, only one example
> >  
> > "this is #$$"
> >  
> > is not highlighted (I'll fix that).
> >  
> > > There's another thing to consider - do built-in global vars should be
> > > font-locked like built-ins or like the other (user-defined) global
> > > variables? Personally I'd font-lock them as built-in to underline their
> > > significance.
> > >  
> >  
> >  
> > Hmmm, maybe. But we also highlight nil, self, true, false, __LINE__,
> > __ENCODING__ and __FILE__ with font-lock-variable-name-face. Should we
> > change these, too?
> >  
> >  
> >  
>  
> Technically speaking all of those are keywords, not variables. Somewhat odd __LINE__ and friends are  
> treated at string literals by the Ruby parser. As all of those evaluate to some value unlike most other keywords I guess it makes some sense to font-lock them as variables, but I’d prefer if we used font-locking that makes their special status more apparent.  
>  
>  

There’s one more thing to consider - the special variables aliases defined in `English`. Those are considered de facto built-in (and are actually built-in in some implementations like JRuby; will probably be available out-of-the-box in MRI 3 as well), so I’d suggest treating them the same way as vars like $$, etc.  
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Sat, 22 Mar 2014 10:06:01 GMT) Full text and rfc822 format available.

Message #17 received at 17057 <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 17057 <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special
 global variables like $$ is broken(missing)
Date: Sat, 22 Mar 2014 12:05:42 +0200
[Message part 1 (text/plain, inline)]
On Saturday, March 22, 2014 at 12:02 PM, Bozhidar Batsov wrote:
> On Friday, March 21, 2014 at 4:53 PM, Bozhidar Batsov wrote:
> > On Friday, March 21, 2014 at 4:47 PM, Dmitry Gutov wrote:
> > > Bozhidar Batsov <bozhidar <at> batsov.com (mailto:bozhidar <at> batsov.com)> writes:
> > >  
> > > > Here's a few examples:
> > > >  
> > > > "this is #$$"
> > > >  
> > > > var = $!
> > > >  
> > > > Things are different for:
> > > >  
> > > > "this is #$1"
> > > >  
> > > > var = $1
> > >  
> > > Have you tried it in the latest Emacs? For me, only one example
> > >  
> > > "this is #$$"
> > >  
> > > is not highlighted (I'll fix that).
> > >  
$1 gets font-locked immediately, but $$ currently gets font-locked only after some “word-boundary” character gets inserted (like space, newline, etc).  
> > >  
> > > > There's another thing to consider - do built-in global vars should be
> > > > font-locked like built-ins or like the other (user-defined) global
> > > > variables? Personally I'd font-lock them as built-in to underline their
> > > > significance.
> > > >  
> > >  
> > >  
> > > Hmmm, maybe. But we also highlight nil, self, true, false, __LINE__,
> > > __ENCODING__ and __FILE__ with font-lock-variable-name-face. Should we
> > > change these, too?
> > >  
> > >  
> > >  
> >  
> > Technically speaking all of those are keywords, not variables. Somewhat odd __LINE__ and friends are  
> > treated at string literals by the Ruby parser. As all of those evaluate to some value unlike most other keywords I guess it makes some sense to font-lock them as variables, but I’d prefer if we used font-locking that makes their special status more apparent.  
> >  
> >  
> >  
>  
> There’s one more thing to consider - the special variables aliases defined in `English`. Those are considered de facto built-in (and are actually built-in in some implementations like JRuby; will probably be available out-of-the-box in MRI 3 as well), so I’d suggest treating them the same way as vars like $$, etc.  
>  
>  


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Mon, 24 Mar 2014 07:34:02 GMT) Full text and rfc822 format available.

Message #20 received at 17057 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Bozhidar Batsov <bozhidar <at> batsov.com>
Cc: 17057 <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special global
 variables like $$ is broken(missing)
Date: Mon, 24 Mar 2014 09:33:26 +0200
On 22.03.2014 12:05, Bozhidar Batsov wrote:

> $1 gets font-locked immediately, but $$ currently gets font-locked only
> after some “word-boundary” character gets inserted (like space, newline,
> etc).

Here's the relevant matcher, it's pretty old:

"\\(\\$\\([^a-zA-Z0-9 \n]\\|[0-9]\\)\\)\\W"

Apparently, it was meant as a light-weight syntax hint: no highlighting 
means syntax error.

Very ad-hoc, so I'm up for removing it.

($1 also hits another matcher because 1 has the word syntax).




Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Mon, 24 Mar 2014 09:13:02 GMT) Full text and rfc822 format available.

Notification sent to Bozhidar Batsov <bozhidar <at> batsov.com>:
bug acknowledged by developer. (Mon, 24 Mar 2014 09:13:03 GMT) Full text and rfc822 format available.

Message #25 received at 17057-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Bozhidar Batsov <bozhidar <at> batsov.com>
Cc: 17057-done <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special global
 variables like $$ is broken(missing)
Date: Mon, 24 Mar 2014 11:12:34 +0200
Version: 24.4

On 21.03.2014 16:53, Bozhidar Batsov wrote:

> Technically speaking all of those are keywords, not variables. Somewhat
> odd __LINE__ and friends are
> treated at string literals by the Ruby parser. As all of those evaluate
> to some value unlike most other keywords I guess it makes some sense to
> font-lock them as variables, but I’d prefer if we used font-locking that
> makes their special status more apparent.

Sounds good to me. Does this list look exhaustive to you?

http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables

Aside from changing faces, the problems mentioned in this bug should be 
fixed now, emacs-24 r116850.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Mon, 24 Mar 2014 09:46:02 GMT) Full text and rfc822 format available.

Message #28 received at 17057-done <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 17057-done <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special
 global variables like $$ is broken(missing)
Date: Mon, 24 Mar 2014 11:45:01 +0200
[Message part 1 (text/plain, inline)]
On Monday, March 24, 2014 at 11:12 AM, Dmitry Gutov wrote:
> Version: 24.4
>  
> On 21.03.2014 16:53, Bozhidar Batsov wrote:
>  
> > Technically speaking all of those are keywords, not variables. Somewhat
> > odd __LINE__ and friends are
> > treated at string literals by the Ruby parser. As all of those evaluate
> > to some value unlike most other keywords I guess it makes some sense to
> > font-lock them as variables, but I’d prefer if we used font-locking that
> > makes their special status more apparent.
> >  
>  
>  
> Sounds good to me. Does this list look exhaustive to you?
>  
> http://www.zenspider.com/Languages/Ruby/QuickRef.html#pre-defined-variables
>  
Yeah, seems that everything important is listed there. Here’s one a bit more extensive list, though:

https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/style/global_vars.rb

It features the JRuby-specific global vars in addition to the standard ones.   
>  
> Aside from changing faces, the problems mentioned in this bug should be  
> fixed now, emacs-24 r116850.
>  
>  


Thanks!   

[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Wed, 26 Mar 2014 12:37:02 GMT) Full text and rfc822 format available.

Message #31 received at 17057-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Bozhidar Batsov <bozhidar <at> batsov.com>
Cc: 17057-done <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special global
 variables like $$ is broken(missing)
Date: Wed, 26 Mar 2014 14:35:13 +0200
On 24.03.2014 11:45, Bozhidar Batsov wrote:

> Yeah, seems that everything important is listed there. Here’s one a bit
> more extensive list, though:
>
> https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/style/global_vars.rb
>
> It features the JRuby-specific global vars in addition to the standard
> ones.

I see that you don't include the $(digit) globals, which reference the 
last regexp-matched groups. The patch below does.

Not sure if it's okay to install in 24.4, though: on the one hand it's 
low-risk, on the other hand it's not a bugfix.


=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el	2014-03-24 08:53:56 +0000
+++ lisp/progmodes/ruby-mode.el	2014-03-26 11:33:42 +0000
@@ -2108,13 +2108,28 @@
      1 font-lock-variable-name-face)
     ;; Keywords that evaluate to certain values.
     ("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>"
-     (0 font-lock-variable-name-face))
+     (0 font-lock-builtin-face))
     ;; Symbols.

("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
      2 font-lock-constant-face)
-    ;; Variables.
-    ("\\$[^a-zA-Z \n]"
-     0 font-lock-variable-name-face)
+    ;; Special variables.
+    (,(concat "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
+              (regexp-opt '("LOAD_PATH" "LOADED_FEATURES" "PROGRAM_NAME"
+                            "ERROR_INFO" "ERROR_POSITION"
+                            "FS" "FIELD_SEPARATOR"
+                            "OFS" "OUTPUT_FIELD_SEPARATOR"
+                            "RS" "INPUT_RECORD_SEPARATOR"
+                            "ORS" "OUTPUT_RECORD_SEPARATOR"
+                            "NR" "INPUT_LINE_NUMBER"
+                            "LAST_READ_LINE" "DEFAULT_OUTPUT" 
"DEFAULT_INPUT"
+                            "PID" "PROCESS_ID" "CHILD_STATUS"
+                            "LAST_MATCH_INFO" "IGNORECASE"
+                            "ARGV" "MATCH" "PREMATCH" "POSTMATCH"
+                            "LAST_PAREN_MATCH" "stdin" "stdout" "stderr"
+                            "DEBUG" "FILENAME" "VERBOSE" "SAFE" "CLASSPATH"
+                            "JRUBY_VERSION" "JRUBY_REVISION" "ENV_JAVA"))
+              "\\_>\\)")
+     0 font-lock-builtin-face)
     ("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
      0 font-lock-variable-name-face)
     ;; Constants.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Wed, 26 Mar 2014 12:43:02 GMT) Full text and rfc822 format available.

Message #34 received at 17057-done <at> debbugs.gnu.org (full text, mbox):

From: Bozhidar Batsov <bozhidar <at> batsov.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 17057-done <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special
 global variables like $$ is broken(missing)
Date: Wed, 26 Mar 2014 14:42:51 +0200
[Message part 1 (text/plain, inline)]
I didn’t include them in RuboCop’s code since they actually constitute a different syntactic category according to the parser - a “nth-reference”. I don’t think we should care about this in ruby-mode, though. The patch looks great. Given the fact that Emacs releases are pretty far apart (usually more than 1 year) I think we should include this given that’s if virtually impossible to introduce a regression.

--  
Cheers,
Bozhidar


On Wednesday, March 26, 2014 at 2:35 PM, Dmitry Gutov wrote:

> On 24.03.2014 11:45, Bozhidar Batsov wrote:
>  
> > Yeah, seems that everything important is listed there. Here’s one a bit
> > more extensive list, though:
> >  
> > https://github.com/bbatsov/rubocop/blob/master/lib/rubocop/cop/style/global_vars.rb
> >  
> > It features the JRuby-specific global vars in addition to the standard
> > ones.
> >  
>  
>  
> I see that you don't include the $(digit) globals, which reference the  
> last regexp-matched groups. The patch below does.
>  
> Not sure if it's okay to install in 24.4, though: on the one hand it's  
> low-risk, on the other hand it's not a bugfix.
>  
>  
> === modified file 'lisp/progmodes/ruby-mode.el'
> --- lisp/progmodes/ruby-mode.el 2014-03-24 08:53:56 +0000
> +++ lisp/progmodes/ruby-mode.el 2014-03-26 11:33:42 +0000
> @@ -2108,13 +2108,28 @@
> 1 font-lock-variable-name-face)
> ;; Keywords that evaluate to certain values.
> ("\\_<__\\(?:LINE\\|ENCODING\\|FILE\\)__\\_>"
> - (0 font-lock-variable-name-face))
> + (0 font-lock-builtin-face))
> ;; Symbols.
>  
> ("\\(^\\|[^:]\\)\\(:\\([-+~]@?\\|[/%&|^`]\\|\\*\\*?\\|<\\(<\\|=>?\\)?\\|>[>=]?\\|===?\\|=~\\|![~=]?\\|\\[\\]=?\\|@?\\(\\w\\|_\\)+\\([!?=]\\|\\b_*\\)\\|#{[^}\n\\\\]*\\(\\\\.[^}\n\\\\]*\\)*}\\)\\)"
> 2 font-lock-constant-face)
> - ;; Variables.
> - ("\\$[^a-zA-Z \n]"
> - 0 font-lock-variable-name-face)
> + ;; Special variables.
> + (,(concat "\\$\\(?:[:\"!@;,/\\._><\\$?~=*&`'+0-9]\\|-[0adFiIlpvw]\\|"
> + (regexp-opt '("LOAD_PATH" "LOADED_FEATURES" "PROGRAM_NAME"
> + "ERROR_INFO" "ERROR_POSITION"
> + "FS" "FIELD_SEPARATOR"
> + "OFS" "OUTPUT_FIELD_SEPARATOR"
> + "RS" "INPUT_RECORD_SEPARATOR"
> + "ORS" "OUTPUT_RECORD_SEPARATOR"
> + "NR" "INPUT_LINE_NUMBER"
> + "LAST_READ_LINE" "DEFAULT_OUTPUT"  
> "DEFAULT_INPUT"
> + "PID" "PROCESS_ID" "CHILD_STATUS"
> + "LAST_MATCH_INFO" "IGNORECASE"
> + "ARGV" "MATCH" "PREMATCH" "POSTMATCH"
> + "LAST_PAREN_MATCH" "stdin" "stdout" "stderr"
> + "DEBUG" "FILENAME" "VERBOSE" "SAFE" "CLASSPATH"
> + "JRUBY_VERSION" "JRUBY_REVISION" "ENV_JAVA"))
> + "\\_>\\)")
> + 0 font-lock-builtin-face)
> ("\\(\\$\\|@\\|@@\\)\\(\\w\\|_\\)+"
> 0 font-lock-variable-name-face)
> ;; Constants.
>  
>  


[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#17057; Package emacs. (Thu, 27 Mar 2014 08:27:01 GMT) Full text and rfc822 format available.

Message #37 received at 17057-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Bozhidar Batsov <bozhidar <at> batsov.com>
Cc: 17057-done <at> debbugs.gnu.org
Subject: Re: bug#17057: 24.3.50; [ruby-mode] Font-locking of special global
 variables like $$ is broken(missing)
Date: Thu, 27 Mar 2014 10:26:23 +0200
On 26.03.2014 14:42, Bozhidar Batsov wrote:
> Given the fact that Emacs releases are
> pretty far apart (usually more than 1 year) I think we should include
> this given that’s if virtually impossible to introduce a regression.

Okay, this was probably enough time for someone else to weigh in.

Guess I'll keep installing small tweaks in ruby-mode until an explicit 
slap on the wrist. :)

emacs-24, r116870.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 24 Apr 2014 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 5 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.