[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ruby-end 91f3c3fc6e 40/91: Add option to expand on retu
From: |
ELPA Syncer |
Subject: |
[elpa] externals/ruby-end 91f3c3fc6e 40/91: Add option to expand on return. |
Date: |
Wed, 25 Jan 2023 19:58:26 -0500 (EST) |
branch: externals/ruby-end
commit 91f3c3fc6e367ebeaba5cd42b95e2c8f3bec5fa4
Author: Johan Andersson <johan.rejeep@gmail.com>
Commit: Johan Andersson <johan.rejeep@gmail.com>
Add option to expand on return.
---
features/ruby-end.feature | 19 +++++++++++++++
features/step-definitions/ruby-end-steps.el | 4 ++++
features/support/env.el | 3 ++-
ruby-end.el | 36 +++++++++++++++++++++++------
4 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/features/ruby-end.feature b/features/ruby-end.feature
index a93933e03e..5360111434 100644
--- a/features/ruby-end.feature
+++ b/features/ruby-end.feature
@@ -162,3 +162,22 @@ Feature: Insert end
end
"""
+ Scenario: Expand on return
+ When I type "Proc.new do"
+ And I press "RET"
+ Then I should see:
+ """
+ Proc.new do
+
+ end
+ """
+
+ Scenario: Do not expand on return when disabled
+ Given I disable expand on return
+ When I type "Proc.new do"
+ And I press "RET"
+ Then I should see:
+ """
+ Proc.new do
+
+ """
diff --git a/features/step-definitions/ruby-end-steps.el
b/features/step-definitions/ruby-end-steps.el
index 74ae3a1918..ae9ab7fdc8 100644
--- a/features/step-definitions/ruby-end-steps.el
+++ b/features/step-definitions/ruby-end-steps.el
@@ -41,3 +41,7 @@
(Given "^insert newline is turned off$"
(lambda ()
(setq ruby-end-insert-newline nil)))
+
+(Given "I disable expand on return"
+ (lambda ()
+ (setq ruby-end-expand-on-ret nil)))
diff --git a/features/support/env.el b/features/support/env.el
index 017d6f8f19..636e6eff37 100644
--- a/features/support/env.el
+++ b/features/support/env.el
@@ -9,7 +9,8 @@
(add-to-list 'load-path (expand-file-name "emacs-lisp" (expand-file-name
"lisp" (expand-file-name "ert" ruby-end-util-path))))
(Before
- (setq ruby-end-insert-newline t))
+ (setq ruby-end-insert-newline t)
+ (setq ruby-end-expand-on-ret t))
(require 'ruby-end)
(require 'espuds)
diff --git a/ruby-end.el b/ruby-end.el
index 7c6a4543f6..dd66f83780 100644
--- a/ruby-end.el
+++ b/ruby-end.el
@@ -48,13 +48,21 @@
(require 'ruby-mode)
-(defvar ruby-end-expand-key "SPC"
+(defvar ruby-end-expand-spc-key "SPC"
"Space key name.")
+(defvar ruby-end-expand-ret-key "RET"
+ "Return key name.")
+
+(defvar ruby-end-expand-on-ret t
+ "Should return expand or not.")
+
(defvar ruby-end-mode-map
(let ((map (make-sparse-keymap))
- (key (read-kbd-macro ruby-end-expand-key)))
- (define-key map key 'ruby-end-space)
+ (spc (read-kbd-macro ruby-end-expand-spc-key))
+ (ret (read-kbd-macro ruby-end-expand-ret-key)))
+ (define-key map spc 'ruby-end-space)
+ (define-key map ret 'ruby-end-return)
map)
"Keymap for `ruby-end-mode'.")
@@ -97,10 +105,24 @@
(ruby-end-insert-end)
(insert " "))
(t
- (let ((ruby-end-mode nil))
- (call-interactively
- (key-binding
- (read-kbd-macro ruby-end-expand-key)))))))
+ (ruby-end-fallback ruby-end-expand-spc-key))))
+
+(defun ruby-end-return ()
+ "Called when RET-key is pressed."
+ (interactive)
+ (cond
+ ((and ruby-end-expand-on-ret (ruby-end-expand-p))
+ (ruby-end-insert-end)
+ (forward-line 1)
+ (indent-according-to-mode))
+ (t
+ (ruby-end-fallback ruby-end-expand-ret-key))))
+
+(defun ruby-end-fallback (key)
+ "Execute function that KEY was bound to before `ruby-end-mode'."
+ (let ((ruby-end-mode nil))
+ (execute-kbd-macro
+ (edmacro-parse-keys key))))
(defun ruby-end-insert-end ()
"Closes block by inserting end."
- [elpa] externals/ruby-end 538c52fae3 10/91: Doc change., (continued)
- [elpa] externals/ruby-end 538c52fae3 10/91: Doc change., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 421206670d 14/91: Update to v0.0.2., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 9ac13296f0 18/91: tests for statement modifiers, ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 23c574c454 24/91: Add scenario for optional newline., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end bc018f6856 27/91: End should be inserted actually, ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 5e84c0c2fd 30/91: Update README., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 06c6378903 29/91: Update ecukes., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 47e5b92b8b 33/91: Autoformat using "cucumber --autoformat"., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 49354ca1a3 36/91: Add punctuation in doc., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end a7723ccdd2 38/91: These two are mixed up., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 91f3c3fc6e 40/91: Add option to expand on return.,
ELPA Syncer <=
- [elpa] externals/ruby-end 3b2794392a 03/91: Added necessary stuff for running Ecukes., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 5f9a9721a5 02/91: Added skeleton., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end d00bb287d6 05/91: Adding some docs., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end d957d3313b 12/91: Split on more than one line., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end afd0459b11 11/91: When not expanding, fall back instead of assuming that space inserts a blank., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 4498561af6 19/91: Split all keywords to modifiers and non-modifiers, ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 53605d0e85 20/91: Make `ruby-end-check-statement-modifiers` t by default., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end b04994ba90 21/91: Bumping version., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end 73d6c51ef8 46/91: Ignore elpa dir., ELPA Syncer, 2023/01/25
- [elpa] externals/ruby-end ba01dd2550 56/91: Update to version v0.2.2., ELPA Syncer, 2023/01/25