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

**URL:** <https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142>\
**Category:** Ruby\
**Created:** [January 23, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142 "2007-01-23T21:55:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Weber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@Weber](https://www.ruby-forum.com/u/Weber)\
**Post date:** [January 23, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142/1 "2007-01-23T21:55:22Z")

</div>

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/](http://www.dilbert.com/)”).read  
soup = BeautifulSoup.new(src)  
url = soup.find(‘img’, { :attrs =\> { ‘alt’ =\> /Today’s Comic/ } })  
open(“[http://www.dilbert.com](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

---

<div class="post-metadata">

**Author:** ![Weber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@Weber](https://www.ruby-forum.com/u/Weber)\
**Post date:** [January 23, 2007, 10:41pm UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142/2 "2007-01-23T22:41:34Z")

</div>

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/](http://www.dilbert.com/)”).read  
soup = BeautifulSoup.new(src)  
url = soup.find(‘img’, { :attrs =\> { ‘alt’ =\> %r{Today’s Comic} } })  
open(“[http://www.dilbert.com](http://www.dilbert.com)” + url[‘src’], “rb”).read  
end

Jason

---

<div class="post-metadata">

**Author:** ![Weber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@Weber](https://www.ruby-forum.com/u/Weber)\
**Post date:** [January 24, 2007, 9:45am UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142/3 "2007-01-24T09:45:51Z")

</div>

On 2007-01-23, Weber [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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/](http://www.dilbert.com/)”).read  
> soup = BeautifulSoup.new(src)  
> url = soup.find(‘img’, { :attrs =\> { ‘alt’ =\> /Today’s Comic/ } })  
> open(“[http://www.dilbert.com](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.

---

<div class="post-metadata">

**Author:** ![Weber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@Weber](https://www.ruby-forum.com/u/Weber)\
**Post date:** [September 25, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142/4 "2007-09-25T22:53:10Z")

</div>

Yukihiro M. wrote:

> Hi,
> 
> In message “Re: BUG: ruby-mode.el /Today’s Comic/”  
> on Wed, 24 Jan 2007 05:55:06 +0900, “Weber” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![Weber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/da6949/32.png) [@Weber](https://www.ruby-forum.com/u/Weber)\
**Post date:** [January 24, 2007, 10:37am UTC](https://www.ruby-forum.com/t/bug-ruby-mode-el-todays-comic/83142/5 "2007-01-24T10:37:05Z")

</div>

Hi,

In message “Re: BUG: ruby-mode.el /Today’s Comic/”  
on Wed, 24 Jan 2007 05:55:06 +0900, “Weber” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
+

- 
  - 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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

- 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))
