Also handle escaping when string begins with a quote

* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
Handle quoting of the first character in the string.

* test/lisp/progmodes/ruby-mode-tests.el
(ruby-toggle-string-quotes-quotes-correctly): Update.
This commit is contained in:
Dmitry Gutov 2016-06-27 07:26:46 +03:00
parent 7f02dedfca
commit 15c307417f
2 changed files with 4 additions and 4 deletions

View file

@ -1800,8 +1800,8 @@ If the result is do-end block, it will always be multiline."
(buffer-substring-no-properties (1+ min) (1- max))))
(setq content
(if (equal string-quote "'")
(replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\([^\\\\]\\)'" "\\1\\\\'" content))
(replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\([^\\\\]\\)\"" "\\1\\\\\"" content))))
(replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)'" "\\1\\\\'" content))
(replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\(\\`\\|[^\\\\]\\)\"" "\\1\\\\\"" content))))
(let ((orig-point (point)))
(delete-region min max)
(insert