diff options
| author | Stephen Leake | 2019-03-22 16:14:50 -0700 |
|---|---|---|
| committer | Stephen Leake | 2019-03-22 16:14:50 -0700 |
| commit | b515edb98521cf489c81457fa22e6efe78bb042d (patch) | |
| tree | 091144df9a7ad8facda14cd03a1f8f1815856ae6 | |
| parent | c1b63af4458e92bad33da0def2b15c206656e2fa (diff) | |
| download | emacs-b515edb98521cf489c81457fa22e6efe78bb042d.tar.gz emacs-b515edb98521cf489c81457fa22e6efe78bb042d.zip | |
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.
| -rw-r--r-- | lisp/simple.el | 3 | ||||
| -rw-r--r-- | test/lisp/simple-tests.el | 34 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index f52bd95bf84..f76f31ad146 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -617,7 +617,8 @@ region is ignored if prefix argument is given.)" | |||
| 617 | (+ (point) (length fill-prefix))))) | 617 | (+ (point) (length fill-prefix))))) |
| 618 | (delete-region (point) (+ (point) (length fill-prefix)))) | 618 | (delete-region (point) (+ (point) (length fill-prefix)))) |
| 619 | (fixup-whitespace) | 619 | (fixup-whitespace) |
| 620 | (if (and beg | 620 | (if (and (use-region-p) |
| 621 | beg | ||
| 621 | (not arg) | 622 | (not arg) |
| 622 | (< beg (point-at-bol))) | 623 | (< beg (point-at-bol))) |
| 623 | (beginning-of-line))))) | 624 | (beginning-of-line))))) |
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 08e81a7fefb..d9f059c8fc2 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el | |||
| @@ -214,6 +214,40 @@ | |||
| 214 | (remove-hook 'post-self-insert-hook inc)))) | 214 | (remove-hook 'post-self-insert-hook inc)))) |
| 215 | 215 | ||
| 216 | 216 | ||
| 217 | ;;; `delete-indentation' | ||
| 218 | (ert-deftest simple-delete-indentation-no-region () | ||
| 219 | "delete-indentation works when no mark is set." | ||
| 220 | ;; interactive \r returns nil for BEG END args | ||
| 221 | (unwind-protect | ||
| 222 | (with-temp-buffer | ||
| 223 | (insert (concat "zero line \n" | ||
| 224 | "first line \n" | ||
| 225 | "second line")) | ||
| 226 | (delete-indentation) | ||
| 227 | (should (string-equal | ||
| 228 | (buffer-string) | ||
| 229 | (concat "zero line \n" | ||
| 230 | "first line second line"))) | ||
| 231 | ))) | ||
| 232 | |||
| 233 | (ert-deftest simple-delete-indentation-inactive-region () | ||
| 234 | "delete-indentation ignores inactive region." | ||
| 235 | ;; interactive \r returns non-nil for BEG END args | ||
| 236 | (unwind-protect | ||
| 237 | (with-temp-buffer | ||
| 238 | (insert (concat "zero line \n" | ||
| 239 | "first line \n" | ||
| 240 | "second line")) | ||
| 241 | (push-mark (point-min) t t) | ||
| 242 | (deactivate-mark) | ||
| 243 | (delete-indentation) | ||
| 244 | (should (string-equal | ||
| 245 | (buffer-string) | ||
| 246 | (concat "zero line \n" | ||
| 247 | "first line second line"))) | ||
| 248 | ))) | ||
| 249 | |||
| 250 | |||
| 217 | ;;; `delete-trailing-whitespace' | 251 | ;;; `delete-trailing-whitespace' |
| 218 | (ert-deftest simple-delete-trailing-whitespace--bug-21766 () | 252 | (ert-deftest simple-delete-trailing-whitespace--bug-21766 () |
| 219 | "Test bug#21766: delete-whitespace sometimes deletes non-whitespace." | 253 | "Test bug#21766: delete-whitespace sometimes deletes non-whitespace." |