Function: ruby-toggle-block
ruby-toggle-block is an interactive and byte-compiled function defined
in ruby-mode.el.gz.
Signature
(ruby-toggle-block)
Documentation
Toggle block type from do-end to braces or back.
The block must begin on the current line or above it and end after the point. If the result is do-end block, it will always be multiline.
Probably introduced at or before Emacs version 24.3.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ruby-mode.el.gz
(defun ruby-toggle-block ()
"Toggle block type from do-end to braces or back.
The block must begin on the current line or above it and end after the point.
If the result is do-end block, it will always be multiline."
(interactive)
(let ((start (point)) beg end)
(end-of-line)
(unless
(if (and (re-search-backward "\\(?:[^#]\\)\\({\\)\\|\\(\\_<do\\_>\\)")
(let ((ruby-use-smie (and ruby-use-smie (consp smie-grammar))))
(goto-char (or (match-beginning 1) (match-beginning 2)))
(setq beg (point))
(with-suppressed-warnings ((obsolete ruby-forward-sexp))
(save-match-data (ruby-forward-sexp)))
(setq end (point))
(> end start)))
(if (match-beginning 1)
(ruby-brace-to-do-end beg end)
(ruby-do-end-to-brace beg end)))
(goto-char start))))