Subject: ruby-mode: problems with font-lock

From: "Pietro Giorgianni" <[email-masked]>
Date: Tue, 16 Dec 2008 12:06:43 +0100

The syntax  %{#{'?'}} , while legal (it is equivalent to '?'), makes
all the following text appear in font-lock-string-face.

The same happens with %{#{"?"}} , and seems to rise from the ?" or ?'
part: if I put a space (or whatever) after the ? , things work.

Real life example (from the sources of rubyonrails):

self.class_eval %{
  def self.#{method_id}(*args)
    guard_protected_attributes = false

    if args[0].is_a?(Hash)
      guard_protected_attributes = true
      attributes = args[0].with_indifferent_access
      find_attributes = attributes.slice(*[:#{attribute_names.join(',:')}])
    else
      find_attributes = attributes =
construct_attributes_from_arguments([:#{attribute_names.join(',:')}],
args)
    end

    options = { :conditions => find_attributes }
    set_readonly_option!(options)

    record = find_initial(options)

     if record.nil?
      record = self.new { |r| r.send(:attributes=, attributes,
guard_protected_attributes) }
      #{'yield(record) if block_given?'}
      #{'record.save' if instantiator == :create}
      record
    else
      record
    end
  end
}, __FILE__, __LINE__

---

In GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600)
 of 2008-09-06 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4)'

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: ITA
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t

Major mode: Ruby

Minor modes in effect:
  erc-log-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-highlight-nicknames-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-readonly-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  display-time-mode: t
  encoded-kbd-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t

Recent input:
c e n s o r e d

Recent messages:
censored...
Loading emacsbug...done