[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master b515edb: Fix bug in delete-indentation when region
From: |
Stephen Leake |
Subject: |
[Emacs-diffs] master b515edb: Fix bug in delete-indentation when region is inactive |
Date: |
Fri, 22 Mar 2019 19:15:19 -0400 (EDT) |
branch: master
commit b515edb98521cf489c81457fa22e6efe78bb042d
Author: Stephen Leake <address@hidden>
Commit: Stephen Leake <address@hidden>
Fix bug in delete-indentation when region is inactive
* test/lisp/simple-tests.el: Add tests for delete-indentation.
(simple-delete-indentation-no-region): Works with no region.
(simple-delete-indentation-inactive-region): Was broken with inactive
region; now fixed.
* lisp/simple.el (delete-indentation): Check (use-region-p) before using
BEG.
---
lisp/simple.el | 3 ++-
test/lisp/simple-tests.el | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index f52bd95..f76f31a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -617,7 +617,8 @@ region is ignored if prefix argument is given.)"
(+ (point) (length fill-prefix)))))
(delete-region (point) (+ (point) (length fill-prefix))))
(fixup-whitespace)
- (if (and beg
+ (if (and (use-region-p)
+ beg
(not arg)
(< beg (point-at-bol)))
(beginning-of-line)))))
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 08e81a7..d9f059c 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -214,6 +214,40 @@
(remove-hook 'post-self-insert-hook inc))))
+;;; `delete-indentation'
+(ert-deftest simple-delete-indentation-no-region ()
+ "delete-indentation works when no mark is set."
+ ;; interactive \r returns nil for BEG END args
+ (unwind-protect
+ (with-temp-buffer
+ (insert (concat "zero line \n"
+ "first line \n"
+ "second line"))
+ (delete-indentation)
+ (should (string-equal
+ (buffer-string)
+ (concat "zero line \n"
+ "first line second line")))
+ )))
+
+(ert-deftest simple-delete-indentation-inactive-region ()
+ "delete-indentation ignores inactive region."
+ ;; interactive \r returns non-nil for BEG END args
+ (unwind-protect
+ (with-temp-buffer
+ (insert (concat "zero line \n"
+ "first line \n"
+ "second line"))
+ (push-mark (point-min) t t)
+ (deactivate-mark)
+ (delete-indentation)
+ (should (string-equal
+ (buffer-string)
+ (concat "zero line \n"
+ "first line second line")))
+ )))
+
+
;;; `delete-trailing-whitespace'
(ert-deftest simple-delete-trailing-whitespace--bug-21766 ()
"Test bug#21766: delete-whitespace sometimes deletes non-whitespace."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master b515edb: Fix bug in delete-indentation when region is inactive,
Stephen Leake <=