]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Ruby indentation with double splat as first block param
authorDmitry Gutov <dgutov@yandex.ru>
Tue, 26 Apr 2022 02:36:35 +0000 (05:36 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Tue, 26 Apr 2022 02:36:35 +0000 (05:36 +0300)
* lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
(ruby-smie--backward-token): Tokenize "**" separately from "|".
Problem reported at https://github.com/dgutov/robe/issues/136.

lisp/progmodes/ruby-mode.el
test/lisp/progmodes/ruby-mode-resources/ruby.rb

index fdc8164dc0bacc5d27be5c31c0ff9c1632a77467..a1977246341238e9d6a50ca65cc75ffd70952ae9 100644 (file)
@@ -508,7 +508,7 @@ This only affects the output of the command `ruby-toggle-block'."
            ((member tok '("unless" "if" "while" "until"))
             (if (save-excursion (forward-word-strictly -1) (ruby-smie--bosp))
                 tok "iuwu-mod"))
-           ((string-match-p "\\`|[*&]?\\'" tok)
+           ((string-match-p "\\`|[*&]*\\'" tok)
             (forward-char (- 1 (length tok)))
             (setq tok "|")
             (cond
@@ -561,7 +561,7 @@ This only affects the output of the command `ruby-toggle-block'."
            ((ruby-smie--closing-pipe-p) "closing-|")
            (t tok)))
          ((string-match-p "\\`[^|]+|\\'" tok) "closing-|")
-         ((string-match-p "\\`|[*&]\\'" tok)
+         ((string-match-p "\\`|[*&]*\\'" tok)
           (forward-char 1)
           (substring tok 1))
          ((and (equal tok "") (eq ?\\ (char-before)) (looking-at "\n"))
index f31cea86a547410e661620f50495216bd57aa8df..0c206b1e0c29fd2e40e9673725de2a54305d2827 100644 (file)
@@ -491,3 +491,12 @@ in ['th', orig_text, 'en', trans_text]
 in {'th' => orig_text, 'ja' => trans_text}
   puts "Japanese translation: #{orig_text} => #{trans_text}"
 end
+
+# Tokenizing "**" and "|" separately.
+def resolve(**args)
+  members = proc do |**args|
+    p(**args)
+  end
+
+  member.call(**args)
+end