* bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation
@ 2012-07-12 14:53 Rolando Pereira
2012-07-14 20:22 ` Dmitry Gutov
0 siblings, 1 reply; 4+ messages in thread
From: Rolando Pereira @ 2012-07-12 14:53 UTC (permalink / raw)
To: 11923
When writing ruby code, if you type something like
:"foo#{variable_name}" emacs can no longer indent lines following it
because it gives the following error:
ruby-forward-string: Search failed: "[^\\]\\(\\\\\\\\\\)*[\"]"
However, ruby-mode has no problem indenting lines that only contain
:"foo" (ie. without the string interpolation).
Here's an ERT that shows the problem. In it, I don't activate ruby-mode
because `ruby-indent-line' can be called after the call to (require
'ruby-mode) and I believe it makes the test simpler (eg. no need to
worry about stuff in ruby-mode-hook):
(ert-deftest indent-line-after-symbol-made-from-string-interpolation ()
"Ensure that `ruby-mode' can indent lines after seeing a symbol made using string interpolation
The syntax for creating a symbol using string interpolation is the following:
:\"bar#{variable_name}\"
For example, if `variable_name' is the number 10, then this
creates the symbol :bar10 and if `variable_name' is the string
\"bar\", then this creates the symbol :barbar."
(let ((initial-content "def foo(suffix)
:\"bar#{suffix}\"
")
(expected-content "def foo(suffix)
:\"bar#{suffix}\"
"))
(require 'ruby-mode)
(with-temp-buffer
;; No need to call `ruby-mode', since `ruby-indent-line' can be
;; used after the (require 'ruby-mode)
;(ruby-mode)
(insert initial-content)
(ruby-indent-line)
(let ((buffer-content (buffer-substring-no-properties (point-min) (point-max))))
(ert-should (string= buffer-content expected-content))))))
To experience the problem from emacs -Q you can do the following steps
(which are similar to the steps that the ERT test performs):
1. Open emacs -Q
2. Require 'ruby-mode with M-: (require 'ruby-mode)
2. Create a "ruby-temp" buffer with C-x b ruby-temp RET
3. Write the following:
"def foo(suffix)
:"bar#{suffix}"
" <-- cursor is here
4. Call M-x ruby-indent-line
The final result should be:
"def foo(suffix)
:"bar#{suffix}
" <-- cursor is here
But ruby-indent-line crashes instead with the following error:
ruby-forward-string: Search failed: "[^\\]\\(\\\\\\\\\\)*[\"]"
In GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
of 2012-06-17 on rolando-desktop
Bzr revision: 108644 rudalics@gmx.at-20120617104350-tpcax4jzuiamvw9r
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
Important settings:
value of $LANG: pt_PT.utf8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
<down> <down> <down> M-x r u b y - i n d e n t - l
i n e <return> C-x b * n m e <backspace> <backspace>
<backspace> m e s <tab> <backspace> <backspace> <backspace>
M e s s <tab> <return> <help-echo> <help-echo> <down-mouse-1>
<mouse-1> <double-down-mouse-1> <double-mouse-1> <triple-down-mouse-1>
<triple-mouse-1> C-x b * s c r <tab> <return> C-y <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> <right> <right> <right> <right>
<right> <right> <right> - i n t e r p o l a t i o n
<down> <end> <C-backspace> <C-backspace> <C-backspace>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<end> u s i n g SPC s t r i n g SPC i n r t e <backspace>
<backspace> <backspace> t e r p o l a t i o n <down>
<down> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <left> <left> <left> <left> <left> <left> <left>
<left> <right> u s i n g SPC s t r i n g SPC i n t
e r p o l a t i o n SPC i s M-d M-d M-d M-d <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <right> <right> <right> <right> M-x r e p o
r t - e m <tab> <return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
byte-code: End of buffer
ruby-forward-string: Search failed: #("[^\\]\\(\\\\\\\\\\)*[\"]" 14 15 (face font-lock-string-face fontified t))
Mark set
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils ruby-mode time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation
2012-07-12 14:53 bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation Rolando Pereira
@ 2012-07-14 20:22 ` Dmitry Gutov
2012-07-19 12:09 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Gutov @ 2012-07-14 20:22 UTC (permalink / raw)
To: rolando_pereira; +Cc: 11923
[-- Attachment #1: Type: text/plain, Size: 389 bytes --]
--=-=-=
Content-Type: text/plain
Rolando Pereira <rolando_pereira@sapo.pt> writes:
> When writing ruby code, if you type something like
> :"foo#{variable_name}" emacs can no longer indent lines following it
> because it gives the following error:
>
> ruby-forward-string: Search failed: "[^\\]\\(\\\\\\\\\\)*[\"]"
> ...
Here's a patch, including the slightly rewritten test case.
[-- Attachment #2: ruby-mode-11923.diff --]
[-- Type: text/plain, Size: 3130 bytes --]
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 2cbdbdb..3ac7b2e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2012-07-14 Dmitry Gutov <dgutov@yandex.ru>
+
+ * progmodes/ruby-mode.el (ruby-parse-partial): No error when end
+ up inside string symbol literal.
+
2012-07-12 Eli Zaretskii <eliz@gnu.org>
* emacs-lisp/bytecomp.el (byte-recompile-directory): Use cl-incf,
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index 15c8246..a947442 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -594,7 +594,7 @@ and `\\' when preceded by `?'."
(goto-char pnt))
((looking-at ":\\(['\"]\\)")
(goto-char (match-beginning 1))
- (ruby-forward-string (buffer-substring (match-beginning 1) (match-end 1)) end))
+ (ruby-forward-string (buffer-substring (match-beginning 1) (match-end 1)) end t))
((looking-at ":\\([-,.+*/%&|^~<>]=?\\|===?\\|<=>\\|![~=]?\\)")
(goto-char (match-end 0)))
((looking-at ":\\([a-zA-Z_][a-zA-Z_0-9]*[!?=]?\\)?")
diff --git a/test/ChangeLog b/test/ChangeLog
index 489298d..f876c08 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-14 Dmitry Gutov <dgutov@yandex.ru>
+
+ * automated/ruby-mode-tests.el: New file with one test.
+
2012-07-11 Stefan Monnier <monnier@iro.umontreal.ca>
* eshell.el: Use cl-lib.
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
new file mode 100644
index 0000000..2535f36
--- /dev/null
+++ b/test/automated/ruby-mode-tests.el
@@ -0,0 +1,37 @@
+;;; ruby-mode-tests.el --- Test suite for ruby-mode
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ruby-mode)
+
+(ert-deftest indent-line-after-symbol-made-from-string-interpolation ()
+ "It can indent the line after symbol made using string interpolation."
+ (let ((initial-content "def foo(suffix)\n :\"bar#{suffix}\"\n")
+ (expected-content "def foo(suffix)\n :\"bar#{suffix}\"\n "))
+ (with-temp-buffer
+ (insert initial-content)
+ (ruby-indent-line) ; Doesn't rely on text properties or the syntax table.
+ (let ((buffer-content (buffer-substring-no-properties (point-min)
+ (point-max))))
+ (should (string= buffer-content expected-content))))))
+
+(provide 'ruby-mode-tests)
+
+;;; ruby-mode-tests.el ends here
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation
2012-07-14 20:22 ` Dmitry Gutov
@ 2012-07-19 12:09 ` Stefan Monnier
[not found] ` <500894B1.8010608@yandex.ru>
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2012-07-19 12:09 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: rolando_pereira, 11923
> Here's a patch, including the slightly rewritten test case.
Feel free to install it and close the bug.
Thank you,
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation
[not found] ` <500894B1.8010608@yandex.ru>
@ 2012-07-20 11:53 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-07-20 11:53 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 11923-done
>>> Here's a patch, including the slightly rewritten test case.
>> Feel free to install it and close the bug.
> I don't think I have commit access.
> For one, I've only registered at Savannah today.
Duh, I confused you with "Dmitry Antipov <dmantipov@yandex.ru>".
This is embarrassing. I'm very sorry for this.
Installed, and thank you,
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-20 11:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-12 14:53 bug#11923: 24.1.50; (Contains ERT test) ruby-indent-line doesn't indent line after symbol creation using string interpolation Rolando Pereira
2012-07-14 20:22 ` Dmitry Gutov
2012-07-19 12:09 ` Stefan Monnier
[not found] ` <500894B1.8010608@yandex.ru>
2012-07-20 11:53 ` Stefan Monnier
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.