BUG: ruby-mode.el /Today's Comic/

Hi all
This regexp seems to break ruby-mode parser or something like that (I’m
not an advanced emacs user)
This is the code:

def image_data
src = open(“http://www.dilbert.com/”).read
soup = BeautifulSoup.new(src)
url = soup.find(‘img’, { :attrs => { ‘alt’ => /Today’s Comic/ } })
open(“http://www.dilbert.com” + url[‘src’], “rb”).read
end

I’d appreciate if someone else tried this too. I’m using last version
of ruby-mode.el and Gnu Emacs 22.0.92.1

Cheers
-Weber

It buggers up Vim’s syntax highlighting as well, not sure how best to
fix
it, but there is a work-around, the %r{} construct:

def image_data
src = open(“http://www.dilbert.com/”).read
soup = BeautifulSoup.new(src)
url = soup.find(‘img’, { :attrs => { ‘alt’ => %r{Today’s Comic} } })
open(“http://www.dilbert.com” + url[‘src’], “rb”).read
end

Jason

On 2007-01-23, Weber [email protected] wrote:

This regexp seems to break ruby-mode parser or something like that
(I’m not an advanced emacs user)
This is the code:

def image_data
src = open(“http://www.dilbert.com/”).read
soup = BeautifulSoup.new(src)
url = soup.find(‘img’, { :attrs => { ‘alt’ => /Today’s Comic/ } })
open(“http://www.dilbert.com” + url[‘src’], “rb”).read
end

What’s the actual problem? I don’t see anything wrong - at least
still sets the indentation correctly.

An obvious guess is that the “'” character is the problem. Try
escaping it: " /Today's Comic/ ". Of course I can’t test this fix as
I don’t see the problem!

I’d appreciate if someone else tried this too. I’m using last
version of ruby-mode.el and Gnu Emacs 22.0.92.1

$ ruby --version
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux]
$ emacs !$
emacs --version
GNU Emacs 21.4.1
Copyright (C) 2002 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named 

COPYING.

ruby-mode.el patched as follows (to fix a different regexp problem):

diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 38d5b71…33c5901 100755
— a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el
@@ -383,6 +383,8 @@ The variable ruby-indent-level controls the amount
of indentation.
(t
(setq in-string (point))
(goto-char end))))

  •   ((looking-at "/=")
    
  • (goto-char pnt))
    ((looking-at “/”)
    (cond
    ((and (not (eobp)) (ruby-expr-beg 'expr-re))

Regards,

Jeremy H.

Yukihiro M. wrote:

Hi,

In message “Re: BUG: ruby-mode.el /Today’s Comic/”
on Wed, 24 Jan 2007 05:55:06 +0900, “Weber” [email protected] writes:

|Hi all
|This regexp seems to break ruby-mode parser or something like that (I’m
|not an advanced emacs user)

Could you try the following patch for ruby-mode.el?

It does work for me (Emacs 21.4.1, debian).

Cheers,

Vince

Hi,

In message “Re: BUG: ruby-mode.el /Today’s Comic/”
on Wed, 24 Jan 2007 05:55:06 +0900, “Weber” [email protected]
writes:

|Hi all
|This regexp seems to break ruby-mode parser or something like that (I’m
|not an advanced emacs user)

Could you try the following patch for ruby-mode.el?

          matz.

diff --git a/ChangeLog b/ChangeLog
index 1a51f52…516582e 100644
— a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan 24 18:05:39 2007 Yukihiro M. [email protected]
+

    • misc/ruby-mode.el (ruby-font-lock-syntactic-keywords): fix
  • regexp font-lock bug. [ruby-talk:235758]

Tue Jan 23 11:02:33 2007 Yukihiro M. [email protected]

  • lib/webrick/httprequest.rb (WEBrick::HTTPRequest::read_line):
    diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
    index 825839f…4816488 100644
    — a/misc/ruby-mode.el
    +++ b/misc/ruby-mode.el
    @@ -1013,7 +1013,7 @@ balanced expression is found."
    ;; ?’ ?" ? are ascii codes ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"']\)" 3 (1 . nil))
    ;; regexps
  • (“\(^\|[=(,~?:;]\|\(^\|\s
    \)\(if\|elsif\|unless\|while\|until\|when\|and\|or\|&&\|||\)\|g?sub!?\|scan\|split!?\)\s
    \(/\)[^/\n\\]\(\\.[^/\n\\]\)\(/\)”
  • (“\(^\|[=(,~?:;<>]\|\(^\|\s
    \)\(if\|elsif\|unless\|while\|until\|when\|and\|or\|&&\|||\)\|g?sub!?\|scan\|split!?\)\s
    \(/\)[^/\n\\]\(\\.[^/\n\\]\)\(/\)”
    (4 (7 . ?/))
    (6 (7 . ?/)))
    (“^\(=\)begin\(\s \|$\)” 1 (7 . nil))