GNU bug report logs - #7735
A questing mark at the end of a string in ruby-mode

Previous Next

Package: emacs;

Reported by: Lennart Borgman <lennart.borgman <at> gmail.com>

Date: Sat, 25 Dec 2010 23:22:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

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 7735 in the body.
You can then email your comments to 7735 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 owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7735; Package emacs. (Sat, 25 Dec 2010 23:22:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lennart Borgman <lennart.borgman <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 25 Dec 2010 23:22:02 GMT) Full text and rfc822 format available.

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

From: Lennart Borgman <lennart.borgman <at> gmail.com>
To: Emacs Bugs <bug-gnu-emacs <at> gnu.org>
Subject: A questing mark at the end of a string in ruby-mode
Date: Sun, 26 Dec 2010 00:28:04 +0100
A question mark at the end of a string makes ruby-mode believe the
string does not end there.

To show this place the following in a ruby-mode buffer:

  re_str = wild.join(".*?")
  re = Regexp.new(re_str, 1)


GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600) of 2010-12-15




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7735; Package emacs. (Sun, 23 Jan 2011 01:00:03 GMT) Full text and rfc822 format available.

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

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Stefan Monnier  <monnier <at> iro.umontreal.ca>
Cc: 7735 <at> debbugs.gnu.org, Lennart Borgman <lennart.borgman <at> gmail.com>
Subject: Re: bug#7735: A questing mark at the end of a string in ruby-mode
Date: Sat, 22 Jan 2011 20:07:13 -0500
Lennart Borgman <lennart.borgman <at> gmail.com> writes:

> A question mark at the end of a string makes ruby-mode believe the
> string does not end there.
>
> To show this place the following in a ruby-mode buffer:
>
>   re_str = wild.join(".*?")
>   re = Regexp.new(re_str, 1)

This bug was appeared during the introduction of syntax-propertize.
Stefan, could you take a look?

2010-09-10  Stefan Monnier  <monnier <at> iro.umontreal.ca>

  * progmodes/ruby-mode.el (ruby-here-doc-beg-re):
  Define while compiling.
  (ruby-here-doc-end-re, ruby-here-doc-beg-match)
  (ruby-font-lock-syntactic-keywords, ruby-comment-beg-syntax)
  (syntax-ppss, ruby-in-ppss-context-p, ruby-in-here-doc-p)
  (ruby-here-doc-find-end, ruby-here-doc-beg-syntax)
  (ruby-here-doc-end-syntax): Only define when
  syntax-propertize is not available.
  (ruby-syntax-propertize-function, ruby-syntax-propertize-heredoc):
  New functions.
  (ruby-in-ppss-context-p): Update to new syntax of heredocs.
  (electric-indent-chars): Silence bytecompiler.
  (ruby-mode): Use prog-mode, syntax-propertize-function, and
  electric-indent-chars.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7735; Package emacs. (Mon, 24 Jan 2011 19:42:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Lennart Borgman <lennart.borgman <at> gmail.com>
Cc: 7735 <at> debbugs.gnu.org
Subject: Re: bug#7735: A questing mark at the end of a string in ruby-mode
Date: Mon, 24 Jan 2011 14:49:35 -0500
> A question mark at the end of a string makes ruby-mode believe the
> string does not end there.

Indeed, when I switched to syntax-propertize-rules code, I didn't notice
that one of the regexps use backrefs, which aren't supported by
syntax-propertize-rules.
I've just installed the patch below which should fix it,


        Stefan


=== modified file 'lisp/progmodes/ruby-mode.el'
--- lisp/progmodes/ruby-mode.el	2011-01-16 02:21:30 +0000
+++ lisp/progmodes/ruby-mode.el	2011-01-24 19:47:16 +0000
@@ -1121,14 +1121,13 @@
          (syntax-propertize-rules
           ;; #{ }, #$hoge, #@foo are not comments
           ("\\(#\\)[{$@]" (1 "."))
-          ;; the last $', $", $` in the respective string is not variable
-          ;; the last ?', ?", ?` in the respective string is not ascii code
-          ("\\(^\\|[\[ \t\n<+\(,=]\\)\\(['\"`]\\)\\(\\\\.\\|\\2\\|[^'\"`\n\\\\]\\)*?\\\\?[?$]\\(\\2\\)"
-           (2 "\"")
-           (4 "\""))
           ;; $' $" $` .... are variables
           ;; ?' ?" ?` are ascii codes
-          ("\\(^\\|[^\\\\]\\)\\(\\\\\\\\\\)*[?$]\\([#\"'`]\\)" (3 "."))
+          ("\\([?$]\\)[#\"'`]"
+           (1 (unless (save-excursion
+                        ;; Not within a string.
+                        (nth 3 (syntax-ppss (match-beginning 0))))
+                (string-to-syntax "\\"))))
           ;; regexps
           ("\\(^\\|[=(,~?:;<>]\\|\\(^\\|\\s \\)\\(if\\|elsif\\|unless\\|while\\|until\\|when\\|and\\|or\\|&&\\|||\\)\\|g?sub!?\\|scan\\|split!?\\)\\s *\\(/\\)[^/\n\\\\]*\\(\\\\.[^/\n\\\\]*\\)*\\(/\\)"
            (4 "\"/")





bug closed, send any further explanations to Lennart Borgman <lennart.borgman <at> gmail.com> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Mon, 24 Jan 2011 20:04:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Feb 2011 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 117 days ago.

Previous Next


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