emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/evil c3ae7ef6a4: Re-indent last line join if onto blank


From: ELPA Syncer
Subject: [nongnu] elpa/evil c3ae7ef6a4: Re-indent last line join if onto blank
Date: Mon, 22 May 2023 18:01:42 -0400 (EDT)

branch: elpa/evil
commit c3ae7ef6a4d43dd950dcaf846239dd8705c7364b
Author: Tom Dalziel <tom_dl@hotmail.com>
Commit: Tom Dalziel <33435574+tomdl89@users.noreply.github.com>

    Re-indent last line join if onto blank
---
 evil-commands.el | 11 ++++++++---
 evil-tests.el    |  7 ++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/evil-commands.el b/evil-commands.el
index 0a340a1115..f8cf142625 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -1844,12 +1844,17 @@ Add (add-hook 'evil-local-mode-hook 
'turn-on-undo-tree-mode) to your init file f
 (evil-define-operator evil-join (beg end)
   "Join the selected lines."
   :motion evil-line
-  (let ((count (count-lines beg end)))
+  (let ((count (count-lines beg end))
+        last-line-blank)
     (when (> count 1)
       (setq count (1- count)))
     (goto-char beg)
-    (dotimes (_ count)
-      (join-line 1))))
+    (dotimes (i count)
+      (when (= (1+ i) count) ; i.e. we're just before the last join
+        (evil-move-beginning-of-line)
+        (setq last-line-blank (looking-at "[ \t]*$")))
+      (join-line 1))
+    (and last-line-blank (indent-according-to-mode))))
 
 (evil-define-operator evil-join-whitespace (beg end)
   "Join the selected lines without changing whitespace.
diff --git a/evil-tests.el b/evil-tests.el
index e9ca224dc5..601bacc955 100644
--- a/evil-tests.el
+++ b/evil-tests.el
@@ -2415,7 +2415,12 @@ ABCthen enter the text in that file's own buffer.")))
       "[l]ine 1\nline 2\nline 3\nline 4"
       (":1,3join")
       "line 1 line 2 line 3\nline 4"))
-  )
+  (ert-info ("Join blank line")
+    (evil-test-buffer
+      "(when foo\n[]\n  bar)"
+      (emacs-lisp-mode)
+      ("J")
+      "(when foo\n  [b]ar)")))
 
 (ert-deftest evil-test-substitute ()
   "Test `evil-substitute'"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]