* bug#16079: `ruby-forward-string' chokes on caret delimiters (PATCH)
@ 2013-12-06 17:33 Cameron Desautels
2013-12-09 3:46 ` Dmitry Gutov
0 siblings, 1 reply; 2+ messages in thread
From: Cameron Desautels @ 2013-12-06 17:33 UTC (permalink / raw)
To: 16079
[-- Attachment #1: Type: text/plain, Size: 972 bytes --]
`ruby-forward-string' is a function used to skip past strings in Ruby
mode. Ruby supports using any non-alpha character following a "%" to
delimit a string. All of the following are valid Ruby syntax:
- %[foo bar]
- %/foo bar/
- %%foo bar%
- %^foo bar^
Currently ruby-mode can handle all of these except the last one, which
yields the following:
# Debugger entered--Lisp error: (invalid-regexp "Unmatched [ or [^")
The root of the problem is the construction of the following invalid
regexp: "[^]" (which is an incomplete negated character class).
This bug manifests itself by breaking `ruby-parse-region' in any
buffer containing a caret-delimited string. This breaks indentation,
movement commands, and even keeps Emacs from building an Imenu.
I've attached a patch which resolves the issue. Note that this patch
builds on the test suite for `ruby-forward-string' that I included in
issue #16078.
--
Cameron Desautels <camdez@gmail.com>
[-- Attachment #2: fix-ruby-forward-string.diff --]
[-- Type: text/plain, Size: 2216 bytes --]
*** lisp/progmodes/ruby-mode.el.orig 2013-12-06 11:17:04.000000000 -0600
--- lisp/progmodes/ruby-mode.el 2013-12-06 11:16:21.000000000 -0600
***************
*** 807,815 ****
This command assumes the character after point is an opening
delimiter."
(let ((n 1) (c (string-to-char term))
! (re (if expand
! (concat "[^\\]\\(\\\\\\\\\\)*\\([" term "]\\|\\(#{\\)\\)")
! (concat "[^\\]\\(\\\\\\\\\\)*[" term "]"))))
(while (and (re-search-forward re end no-error)
(if (match-beginning 3)
(ruby-forward-string "}{" end no-error nil)
--- 807,818 ----
This command assumes the character after point is an opening
delimiter."
(let ((n 1) (c (string-to-char term))
! (re (concat "[^\\]\\(\\\\\\\\\\)*\\("
! (if (string= term "^") ;[^] is not a valid regexp
! "\\^"
! (concat "[" term "]"))
! (when expand "\\|\\(#{\\)")
! "\\)")))
(while (and (re-search-forward re end no-error)
(if (match-beginning 3)
(ruby-forward-string "}{" end no-error nil)
*** test/automated/ruby-mode-tests.el.orig 2013-12-06 11:17:04.000000000 -0600
--- test/automated/ruby-mode-tests.el 2013-12-06 11:16:21.000000000 -0600
***************
*** 658,667 ****
(ert-deftest ruby-forward-string-accepts-single-delimiters ()
(ruby-forward-string-should-move-to "/foo/bar" "/" 6)
(ruby-forward-string-should-move-to "|foo|bar" "|" 6)
! (ruby-forward-string-should-move-to "-foo-bar" "-" 6))
!
! (ert-deftest ruby-forward-string-accepts-carets ()
! :expected-result :failed
(ruby-forward-string-should-move-to "^foo^bar" "^" 6))
(ert-deftest ruby-forward-string-scans-the-shortest-match ()
--- 658,664 ----
(ert-deftest ruby-forward-string-accepts-single-delimiters ()
(ruby-forward-string-should-move-to "/foo/bar" "/" 6)
(ruby-forward-string-should-move-to "|foo|bar" "|" 6)
! (ruby-forward-string-should-move-to "-foo-bar" "-" 6)
(ruby-forward-string-should-move-to "^foo^bar" "^" 6))
(ert-deftest ruby-forward-string-scans-the-shortest-match ()
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#16079: `ruby-forward-string' chokes on caret delimiters (PATCH)
2013-12-06 17:33 bug#16079: `ruby-forward-string' chokes on caret delimiters (PATCH) Cameron Desautels
@ 2013-12-09 3:46 ` Dmitry Gutov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2013-12-09 3:46 UTC (permalink / raw)
To: Cameron Desautels; +Cc: 16079-done
Cameron Desautels <camdez@gmail.com> writes:
> This bug manifests itself by breaking `ruby-parse-region' in any
> buffer containing a caret-delimited string. This breaks indentation,
> movement commands, and even keeps Emacs from building an Imenu.
Thanks, I've applied the fix.
> I've attached a patch which resolves the issue. Note that this patch
> builds on the test suite for `ruby-forward-string' that I included in
> issue #16078.
The tests are not included so far, let's continue discussing them in
#16078. Closing this one.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-09 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-06 17:33 bug#16079: `ruby-forward-string' chokes on caret delimiters (PATCH) Cameron Desautels
2013-12-09 3:46 ` Dmitry Gutov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.