ruby-toggle-block-space-before-parameters: New user option
* lisp/progmodes/ruby-mode.el (ruby-toggle-block-space-before-parameters): New user option (bug#53321). (ruby-do-end-to-brace): Handle it. * test/lisp/progmodes/ruby-mode-tests.el (ruby-toggle-block-to-brace-no-space): New test.
This commit is contained in:
parent
7269106578
commit
9a0842dffe
3 changed files with 26 additions and 7 deletions
4
etc/NEWS
4
etc/NEWS
|
|
@ -842,6 +842,10 @@ the Netscape web browser was released in February, 2008.
|
|||
This support has been obsolete since Emacs 25.1. The final version of
|
||||
the Galeon web browser was released in September, 2008.
|
||||
|
||||
** Ruby Mode
|
||||
|
||||
*** New user option 'ruby-toggle-block-space-before-parameters'.
|
||||
|
||||
** Miscellaneous
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -325,6 +325,13 @@ It is used when `ruby-encoding-magic-comment-style' is set to `custom'."
|
|||
"Use `ruby-encoding-map' to set encoding magic comment if this is non-nil."
|
||||
:type 'boolean :group 'ruby)
|
||||
|
||||
(defcustom ruby-toggle-block-space-before-parameters t
|
||||
"When non-nil, ensure space between the \"toggled\" curly and parameters.
|
||||
This only affects the output of the command `ruby-toggle-block'."
|
||||
:type 'boolean
|
||||
:safe 'booleanp
|
||||
:version "29.1")
|
||||
|
||||
;;; SMIE support
|
||||
|
||||
(require 'smie)
|
||||
|
|
@ -1722,13 +1729,14 @@ See `add-log-current-defun-function'."
|
|||
(insert "}")
|
||||
(goto-char orig)
|
||||
(delete-char 2)
|
||||
;; Maybe this should be customizable, let's see if anyone asks.
|
||||
(insert "{ ")
|
||||
(setq beg-marker (point-marker))
|
||||
(when (looking-at "\\s +|")
|
||||
(delete-char (- (match-end 0) (match-beginning 0) 1))
|
||||
(forward-char)
|
||||
(re-search-forward "|" (line-end-position) t))
|
||||
(insert "{")
|
||||
(if (looking-at "\\s +|")
|
||||
(progn
|
||||
(just-one-space (if ruby-toggle-block-space-before-parameters 1 0))
|
||||
(setq beg-marker (point-marker))
|
||||
(forward-char)
|
||||
(re-search-forward "|" (line-end-position) t))
|
||||
(setq beg-marker (point-marker)))
|
||||
(save-excursion
|
||||
(skip-chars-forward " \t\n\r")
|
||||
(setq beg-pos (point))
|
||||
|
|
|
|||
|
|
@ -407,6 +407,13 @@ VALUES-PLIST is a list with alternating index and value elements."
|
|||
(ruby-toggle-block)
|
||||
(should (string= "foo { \"#{bar}\" }" (buffer-string)))))
|
||||
|
||||
(ert-deftest ruby-toggle-block-to-brace-no-space ()
|
||||
(ruby-with-temp-buffer "foo do |b|\n b + 2\nend"
|
||||
(beginning-of-line)
|
||||
(let (ruby-toggle-block-space-before-parameters)
|
||||
(ruby-toggle-block))
|
||||
(should (string= "foo {|b| b + 2 }" (buffer-string)))))
|
||||
|
||||
(ert-deftest ruby-recognize-symbols-starting-with-at-character ()
|
||||
(ruby-assert-face ":@abc" 3 font-lock-constant-face))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue