[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 15c3074 2/2: Also handle escaping when string begin
From: |
Dmitry Gutov |
Subject: |
[Emacs-diffs] master 15c3074 2/2: Also handle escaping when string begins with a quote |
Date: |
Mon, 27 Jun 2016 04:34:40 +0000 (UTC) |
branch: master
commit 15c307417f7bc13b27f06994dd931cb04873a26f
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
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.
---
lisp/progmodes/ruby-mode.el | 4 ++--
test/lisp/progmodes/ruby-mode-tests.el | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index aa7c08c..e7b37ac 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -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
diff --git a/test/lisp/progmodes/ruby-mode-tests.el
b/test/lisp/progmodes/ruby-mode-tests.el
index 5dd34f8..97f277b 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -718,8 +718,8 @@ VALUES-PLIST is a list with alternating index and value
elements."
(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
(let ((pairs
- '(("puts 'foo\"\\''" . "puts \"foo\\\"'\"")
- ("puts \"foo'\\\"\"" . "puts 'foo\\'\"'"))))
+ '(("puts '\"foo\"\\''" . "puts \"\\\"foo\\\"'\"")
+ ("puts \"'foo'\\\"\"" . "puts '\\'foo\\'\"'"))))
(dolist (pair pairs)
(ruby-with-temp-buffer (car pair)
(beginning-of-line)