Subject: Ruby Mode Missing Syntax
From: Nick Ewing <[email-masked]>
To: [email-masked]
Date: Thu, 27 May 2010 14:48:33 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Ruby mode does not fully support general delimited strings or regular
expressions in many cases.

General delimited strings using parentheses, brackets, or curly braces
are not supported at all by Ruby mode, therefore the following valid
code is not correctly highlighted:

%Q{This is a string}
%w(foo bar)
etc...

This problem is most apparent when there is a single quote or a double
quote within the general delimited string.  In such a case, the quote
starts highlighting everything following it as a string.  Example:

%Q{foo 'bar}

Ruby mode does support general delimited strings while using a single
character delimiter as such:

%Q|This is a string|

However, if there is a quote contained within this syntax, as follows,
the highlighting breaks:

%Q|foo 'bar|

Also, general delimited strings are restricted to one line by Ruby mode,
however Ruby allows them to be multiline.  Therefore the following valid
Ruby code is not highlighted by Ruby mode:

%w|
  element1
  element2
  element3
|

Finally, regular expressions do not work in all cases where they should.
For example, the following Cucumber step definition (using valid Ruby
syntax) will cause the regular expression contained in it to not be
highlighted.

Given /A user is logged in/

It seems that Ruby mode highlights Given as a constant, which is
understandable, but fails to recognize the regular expression as valid
when after a constant.

I attempted to fix some of these problems myself, but was unable.
Hopefully a more experienced emacs user can provide some help.

Thank you!

In GNU Emacs 23.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.29)
 of 2010-05-08 on black.local
Windowing system distributor `Apple', version 10.3.949
configured using `configure  '--host=x86_64-apple-darwin'
'--build=i686-apple-darwin' '--with-ns'
'build_alias=i686-apple-darwin' 'host_alias=x86_64-apple-darwin'
'CC=gcc -mmacosx-version-min=10.5''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Debugger

Minor modes in effect:
  global-whitespace-mode: t
  autopair-mode: t
  autopair-global-mode: t
  show-paren-mode: t
  ido-everywhere: t
  textmate-mode: t
  global-hl-line-mode: t
  yas/global-mode: t
  nxhtml-menu-mode: t
  tooltip-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-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<escape> x <help-echo> <down-mouse-1> <mouse-1> <escape>
x <escape> x <up> <up> <down> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> r e p o r t <tab> <return>

Recent messages:
[yas] warning: won't overwrite keybinding "k e y b i n d i n g" for
snippet "module" in `ruby-mode-map'
[yas] warning: won't overwrite keybinding "k e y b i n d i n g" for
snippet "if" in `ruby-mode-map'
[yas] warning: won't overwrite keybinding "k e y b i n d i n g" for
snippet "for" in `ruby-mode-map'
[yas] warning: won't overwrite keybinding "k e y b i n d i n g" for
snippet "do" in `ruby-mode-map'
[yas] warning: won't overwrite keybinding "k e y b i n d i n g" for
snippet "class" in `ruby-mode-map'
Ido mode enabled [2 times]
For information about GNU Emacs and the GNU system, type C-h C-a.
Entering debugger...
goto-history-element: Beginning of history; no preceding item [2 times]
call-interactively: Text is read-only [2 times]

Load-path shadows:
/Users/nick/.emacs.d/vendor/nxhtml/related/php-mode hides
~/.emacs.d/vendor/php-mode
~/.emacs.d/vendor/whitespace hides
/Applications/Emacs.app/Contents/Resources/lisp/whitespace
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/speedbar/speedbar hides
/Applications/Emacs.app/Contents/Resources/lisp/speedbar
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/speedbar/sb-image hides
/Applications/Emacs.app/Contents/Resources/lisp/sb-image
~/.emacs.d/vendor/linum hides
/Applications/Emacs.app/Contents/Resources/lisp/linum
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/ezimage hides
/Applications/Emacs.app/Contents/Resources/lisp/ezimage
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/speedbar/dframe hides
/Applications/Emacs.app/Contents/Resources/lisp/dframe
/Users/nick/.emacs.d/elpa/ruby-mode-1.1/ruby-mode hides
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/ruby-mode
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-speedbar hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-speedbar
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-opt hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-opt
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-datadebug hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-datadebug
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-custom hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-custom
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-comp hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-comp
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/eieio-base hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eieio-base
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/eieio/chart hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/chart
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/srecode/srecode hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/srecode
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/semantic/semantic hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/semantic
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/pulse hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/pulse
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/mode-local hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/mode-local
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/inversion hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/inversion
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/ede/ede hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/ede
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/data-debug hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/data-debug
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/cedet hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/cedet
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/cedet-idutils hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/cedet-idutils
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/cedet-global hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/cedet-global
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/cedet-files hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/cedet-files
/Users/nick/.emacs.d/vendor/cedet-1.0pre7/common/cedet-cscope hides
/Applications/Emacs.app/Contents/Resources/lisp/cedet/cedet-cscope

Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils mailheader canlock sha1 hex-util
hashcash mail-utils emacsbug cedet-edebug debug semantic-el
semantic-bovine bovine-debug semantic-debug highlight-parentheses
warnings erlang-start whitespace autopair paren cus-edit cus-start
cus-load linum ido textmate hl-line yasnippet dropdown-list mumamo-fun
mumamo nxhtml-autostart nxhtml-autoload majmodpri rinari easy-mmode jump
inflections findr ruby-compilation which-func imenu pcomplete ansi-color
inf-ruby ruby-mode nxhtml-menu web-autoload nxhtml-base ecb-layout-defs
ecb ecb-symboldef ecb-analyse ecb-compatibility ecb-winman-support
ecb-autogen autoload ecb-tod ecb-cycle ecb-eshell ecb-help ecb-jde
ecb-method-browser hideshow ecb-file-browser ecb-layout compile comint
ecb-create-layout ecb-compilation ecb-speedbar ecb-common-browser
ecb-cedet-wrapper semanticdb-mode semanticdb-find semanticdb-ref
ecb-navigate ecb-mode-line ecb-face tree-buffer ecb-upgrade ecb-util
ring thingatpt cedet cedet-contrib-load cogre-load cogre-srecode
semantic-edit srecode-template-mode srecode-template srecode-template-wy
semantic-wisent wisent srecode-map srecode-dictionary speedbar-load
sb-info ede-load ede-speedbar ede-files ede ede-base ede-auto
eieio-speedbar semantic-ia-sb semantic-analyze semantic-scope
semantic-analyze-fcn semantic-sort semanticdb-el semanticdb
semantic-ctxt semantic-format semantic-util-modes semantic-util semantic
semantic-lex semantic-tag working fame speedbar sb-image ezimage dframe
assoc eieio-custom ede-source eieio-base srecode-load srecode
semantic-load semantic-fw mode-local find-func derived eieio-load
cedet-load cedet-compat eieio byte-opt bytecomp byte-compile inversion
blank-mode-autoloads gist-autoloads rspec-mode-autoloads
ruby-test-mode-autoloads sass-mode-autoloads advice help-fns
advice-preload info wrap-region-autoloads yaml-mode-autoloads package
color-theme edmacro kmacro wid-edit cl cl-19 sendmail regexp-opt
reporter tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win
easymenu tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag 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 loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process ns multi-tty emacs)