all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#23829: 25.0.90; ruby-mode.el ruby-toggle-string-quotes bug fix
@ 2016-06-22 17:12 Sriram Thaiyar
  2016-06-27  4:38 ` Dmitry Gutov
  0 siblings, 1 reply; 2+ messages in thread
From: Sriram Thaiyar @ 2016-06-22 17:12 UTC (permalink / raw)
  To: 23829


[-- Attachment #1.1: Type: text/plain, Size: 5541 bytes --]

Attached is a patch to fix `ruby-toggle-string-quotes' in ruby-mode.el.
It was messing up when there were other quotes within the string.

I tried to send this via "M-x report-emacs-bug" and "C-c M-i", but that
404s with a Bad Request for Gmail.

=============================================
In GNU Emacs 25.0.90.1 (x86_64-apple-darwin13.4.0, NS appkit-1265.21
Version 10.9.5 (Build 13F1603))
 of 2016-01-30 built on builder10-9.local
Windowing system distributor 'Apple', version 10.3.1347
Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp''

Configured features:
NOTIFY ACL LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Magit

Minor modes in effect:
  yas-global-mode: t
  yas-minor-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  diff-auto-refine-mode: t
  helm-mode: t
  shell-dirtrack-mode: t
  async-bytecomp-package-mode: t
  autopair-global-mode: t
  global-hl-line-mode: t
  my-keys-mode: t
  recentf-mode: t
  global-linum-mode: t
  show-paren-mode: t
  winner-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Open /Users/Sri/Desktop/emacs/test/lisp/progmodes/ruby-mode-tests.el
Turning on magit-auto-revert-mode...done
For information about GNU Emacs and the GNU system, type C-h C-a.
C-x g
Ran 1 tests, 0 results were as expected, 1 unexpected
Mark set
ruby-toggle-string-quotes
Ran 1 tests, 1 results were as expected
user-error: Beginning of history; no preceding item
delete-backward-char: Text is read-only [4 times]

Load-path shadows:
/Users/Sri/.emacs.d/elpa/helm-20160616.217/helm-multi-match hides
/Users/Sri/.emacs.d/elpa/helm-core-20160617.307/helm-multi-match

Features:
(shadow sort mail-extr emacsbug sendmail ruby-end ruby-mode-tests
ruby-mode smie ert ewoc debug helm-command helm-elisp helm-eval edebug
map yasnippet web-mode disp-table smart-mode-line-dark-theme
smart-mode-line rich-minority ob-ruby ob-python ob-calc calc-store
calc-trail calc-ext calc calc-loaddefs calc-macs org org-macro
org-footnote org-pcomplete org-list org-faces org-entities noutline
outline org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-src ob-keys ob-comint ob-core ob-eval org-compat org-macs
org-loaddefs find-func cal-menu calendar cal-loaddefs magit-blame
magit-stash magit-bisect magit-remote magit-commit magit-sequence magit
magit-apply magit-wip magit-log magit-diff smerge-mode magit-core
magit-autorevert autorevert filenotify magit-process magit-popup
magit-mode magit-git crm magit-section magit-utils git-commit log-edit
message rfc822 mml mml-sec epg mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils
mailheader pcvs-util add-log with-editor tramp-sh helm-ls-git vc-git
diff-mode vc vc-dispatcher helm-mode helm-files image-dired tramp
tramp-compat tramp-loaddefs trampver shell pcomplete format-spec
dired-aux helm-buffers helm-elscreen helm-tags helm-bookmark
helm-adaptive helm-info bookmark pp helm-locate helm-grep helm-regexp
helm-plugin helm-external helm-net browse-url xml helm-utils helm-help
helm-types helm easy-mmode helm-source eieio-compat helm-multi-match
helm-lib helm-config helm-easymenu edmacro kmacro async-bytecomp async
go-mode url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util mailcap find-file compile elisp-slime-nav
etags xref project coffee-mode rx bm autopair advice dired-x dired view
hl-line solarized-dark-theme solarized color recentf tree-widget
wid-edit ediff-merg ediff-wind ediff-diff ediff-mult ediff-help
ediff-init ediff-util ediff hippie-exp comint ansi-color linum ido seq
server paren winner ring whitespace rect ffap thingatpt url-parse
auth-source eieio gnus-util mm-util help-fns mail-prsvr password-cache
url-vars eval-expr dash cl-seq finder-inf go-mode-autoloads eieio-core
cl-macs info package epg-config byte-opt bytecomp byte-compile cl-extra
help-mode easymenu cconv cl gv cl-loaddefs pcase cl-lib time-date
mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel ns-win ucs-normalize term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment elisp-mode
lisp-mode prog-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese charscript
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote kqueue cocoa ns
multi-tty make-network-process emacs)

Memory information:
((conses 16 540184 37755)
 (symbols 48 49498 0)
 (miscs 40 780 649)
 (strings 32 114429 10253)
 (string-bytes 1 3438490)
 (vectors 16 68800)
 (vector-slots 8 1051173 30787)
 (floats 8 805 427)
 (intervals 56 1055 494)
 (buffers 976 21))

[-- Attachment #1.2: Type: text/html, Size: 7321 bytes --]

[-- Attachment #2: ruby-mode-bug-fix.patch --]
[-- Type: application/octet-stream, Size: 2239 bytes --]

From 48b5266274cf7904c5f288c3c6a658d3db074564 Mon Sep 17 00:00:00 2001
From: Sriram Thaiyar <sriram.thaiyar@gmail.com>
Date: Wed, 22 Jun 2016 09:21:26 -0700
Subject: [PATCH] Fix ruby-toggle-string-quotes bug

* lisp/progmodes/ruby-mode.el (ruby-toggle-string-quotes):
Change logic to quote based on the current quote of the string.

* test/lisp/progmodes/ruby-mode-tests.el (ruby-toggle-string-quotes-quotes-correctly):
Add test.
---
 lisp/progmodes/ruby-mode.el            |  2 +-
 test/lisp/progmodes/ruby-mode-tests.el | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index d75edbc..aa7c08c 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -1799,7 +1799,7 @@ If the result is do-end block, it will always be multiline."
            (content
             (buffer-substring-no-properties (1+ min) (1- max))))
       (setq content
-            (if (equal string-quote "\"")
+            (if (equal string-quote "'")
                 (replace-regexp-in-string "\\\\\"" "\"" (replace-regexp-in-string "\\([^\\\\]\\)'" "\\1\\\\'" content))
               (replace-regexp-in-string "\\\\'" "'" (replace-regexp-in-string "\\([^\\\\]\\)\"" "\\1\\\\\"" content))))
       (let ((orig-point (point)))
diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el
index 52126a3..5dd34f8 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -716,6 +716,17 @@ VALUES-PLIST is a list with alternating index and value elements."
     (ruby-backward-sexp)
     (should (= 2 (line-number-at-pos)))))
 
+(ert-deftest ruby-toggle-string-quotes-quotes-correctly ()
+  (let ((pairs
+         '(("puts 'foo\"\\''" . "puts \"foo\\\"'\"")
+           ("puts \"foo'\\\"\"" . "puts 'foo\\'\"'"))))
+    (dolist (pair pairs)
+      (ruby-with-temp-buffer (car pair)
+        (beginning-of-line)
+        (search-forward "foo")
+        (ruby-toggle-string-quotes)
+        (should (string= (buffer-string) (cdr pair)))))))
+
 (ert-deftest ruby--insert-coding-comment-ruby-style ()
   (with-temp-buffer
     (let ((ruby-encoding-magic-comment-style 'ruby))
-- 
2.2.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#23829: 25.0.90; ruby-mode.el ruby-toggle-string-quotes bug fix
  2016-06-22 17:12 bug#23829: 25.0.90; ruby-mode.el ruby-toggle-string-quotes bug fix Sriram Thaiyar
@ 2016-06-27  4:38 ` Dmitry Gutov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2016-06-27  4:38 UTC (permalink / raw)
  To: Sriram Thaiyar, 23829-done; +Cc: Bozhidar Batsov

Version: 25.2

Hi Sriram,

On 06/22/2016 08:12 PM, Sriram Thaiyar wrote:
> Attached is a patch to fix `ruby-toggle-string-quotes' in ruby-mode.el.
> It was messing up when there were other quotes within the string.

Thanks for the patch, pushed to master. I had to reformat the commit 
message a bit, though. Also see the follow-up commit, fixing a related case.

> I tried to send this via "M-x report-emacs-bug" and "C-c M-i", but that
> 404s with a Bad Request for Gmail.

Not sure where that 404 would be coming from, or why (I don't use 
Gmail), but you might want to send a separate bug report for that. With 
some details.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-06-27  4:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-22 17:12 bug#23829: 25.0.90; ruby-mode.el ruby-toggle-string-quotes bug fix Sriram Thaiyar
2016-06-27  4:38 ` 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.