1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 18:40:39 -08:00

Strip trailing whitespaces at the end of converted do block

* lisp/progmodes/ruby-mode.el (ruby-brace-to-do-end):
Strip trailing whitespaces at the end of converted do block
(bug#36756).

https://bugs.ruby-lang.org/issues/16014
https://github.com/syl20bnr/spacemacs/issues/12548
This commit is contained in:
Nobuyoshi Nakada 2019-07-22 10:14:01 +09:00 committed by Dmitry Gutov
parent a112547f91
commit 0cbdbac2bb
2 changed files with 7 additions and 2 deletions

View file

@ -1690,7 +1690,8 @@ See `add-log-current-defun-function'."
(when (eq (char-before) ?\}) (when (eq (char-before) ?\})
(delete-char -1) (delete-char -1)
(when (save-excursion (when (save-excursion
(skip-chars-backward " \t") (let ((n (skip-chars-backward " \t")))
(if (< n 0) (delete-char (- n))))
(not (bolp))) (not (bolp)))
(insert "\n")) (insert "\n"))
(insert "end") (insert "end")

View file

@ -369,7 +369,11 @@ VALUES-PLIST is a list with alternating index and value elements."
(ruby-with-temp-buffer "foo {|b|\n}" (ruby-with-temp-buffer "foo {|b|\n}"
(beginning-of-line) (beginning-of-line)
(ruby-toggle-block) (ruby-toggle-block)
(should (string= "foo do |b|\nend" (buffer-string))))) (should (string= "foo do |b|\nend" (buffer-string))))
(ruby-with-temp-buffer "foo {|b| b }"
(beginning-of-line)
(ruby-toggle-block)
(should (string= "foo do |b|\n b\nend" (buffer-string)))))
(ert-deftest ruby-toggle-block-to-brace () (ert-deftest ruby-toggle-block-to-brace ()
(let ((pairs '((17 . "foo { |b| b + 2 }") (let ((pairs '((17 . "foo { |b| b + 2 }")