* bug#7735: A questing mark at the end of a string in ruby-mode
@ 2010-12-25 23:28 Lennart Borgman
2011-01-23 1:07 ` Chong Yidong
2011-01-24 19:49 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: Lennart Borgman @ 2010-12-25 23:28 UTC (permalink / raw)
To: 7735
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#7735: A questing mark at the end of a string in ruby-mode
2010-12-25 23:28 bug#7735: A questing mark at the end of a string in ruby-mode Lennart Borgman
@ 2011-01-23 1:07 ` Chong Yidong
2011-01-24 19:49 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Chong Yidong @ 2011-01-23 1:07 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 7735
Lennart Borgman <lennart.borgman@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@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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#7735: A questing mark at the end of a string in ruby-mode
2010-12-25 23:28 bug#7735: A questing mark at the end of a string in ruby-mode Lennart Borgman
2011-01-23 1:07 ` Chong Yidong
@ 2011-01-24 19:49 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2011-01-24 19:49 UTC (permalink / raw)
To: Lennart Borgman; +Cc: 7735
> 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 "\"/")
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-24 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-25 23:28 bug#7735: A questing mark at the end of a string in ruby-mode Lennart Borgman
2011-01-23 1:07 ` Chong Yidong
2011-01-24 19:49 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).