[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/ws-butler 404e70e75a 43/64: Tabify indentation for non-nil
From: |
Stefan Kangas |
Subject: |
[nongnu] elpa/ws-butler 404e70e75a 43/64: Tabify indentation for non-nil indent-tabs-mode |
Date: |
Fri, 31 Dec 2021 11:09:32 -0500 (EST) |
branch: elpa/ws-butler
commit 404e70e75a82d7035e701b0f803cb232f1d862d3
Author: Ingo Lohmar <i.lohmar@gmail.com>
Commit: Ingo Lohmar <i.lohmar@gmail.com>
Tabify indentation for non-nil indent-tabs-mode
When indent-tabs-mode is t, replace spaces in the indentation by tabs,
just as we do the opposite when the mode is nil.
---
ws-butler.el | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/ws-butler.el b/ws-butler.el
index 93f52524f3..900af1e1b8 100644
--- a/ws-butler.el
+++ b/ws-butler.el
@@ -133,20 +133,25 @@ Also see `require-final-newline'."
(defun ws-butler-clean-region (beg end)
"Delete trailing blanks in region BEG END.
-If `indent-tabs-mode' is nil, then tabs in indentation is
-replaced by spaces."
+If `indent-tabs-mode' is nil, then tabs in indentation are
+replaced by spaces, and vice versa if t."
(interactive "*r")
(ws-butler-with-save
(narrow-to-region beg end)
;; _much slower would be: (replace-regexp "[ \t]+$" "")
(goto-char (point-min))
(while (not (eobp))
- ;; convert leading tabs to spaces
- (unless indent-tabs-mode
- (let ((eol (point-at-eol)))
- (skip-chars-forward " " (point-at-eol))
+ ;; convert leading tabs to spaces or v.v.
+ (let ((eol (point-at-eol)))
+ (if indent-tabs-mode
+ (progn
+ (skip-chars-forward "\t" eol)
+ (when (eq (char-after) ?\ )
+ (tabify (point) (progn (skip-chars-forward " \t" eol)
+ (point)))))
+ (skip-chars-forward " " eol)
(when (eq (char-after) ?\t )
- (untabify (point) (progn (skip-chars-forward " \t" (point-at-eol))
+ (untabify (point) (progn (skip-chars-forward " \t" eol)
(point))))))
(end-of-line)
(delete-horizontal-space)
- [nongnu] elpa/ws-butler a7f62dcb00 17/64: fix bug when point is after a tab at save time, (continued)
- [nongnu] elpa/ws-butler a7f62dcb00 17/64: fix bug when point is after a tab at save time, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler bb70ff8fe3 14/64: fix saving what point is at EOB, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 8c4cb5485a 28/64: Use (1- end) to hack around highlight-changes bug., Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler c5b920b6b6 32/64: Merge pull request #10 from DarwinAwardWinner/patch-1, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 631db62b31 40/64: README.md typo., Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 0fbba548ff 38/64: Bump to 0.3, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 88b4570b31 15/64: add autoload cookies and global minor-mode, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler c906d77aee 10/64: provide feature #1, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler ec4172bb7a 22/64: Add debug declaration to macro., Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler e80d0df3e3 20/64: ignore PGP sig error in travis setting, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 404e70e75a 43/64: Tabify indentation for non-nil indent-tabs-mode,
Stefan Kangas <=
- [nongnu] elpa/ws-butler 0c48a1d102 47/64: Merge pull request #17 from ilohmar/indent-tabs-symmetry, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 123a517a14 49/64: bump version to 0.4, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler e3a38d93e0 64/64: Merge pull request #37 from lewang/revert-31-patch-1, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler ea94b9895a 57/64: Add subsection on basic config in README.md, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 2d546097bb 62/64: Use cl-lib, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 80dabd5d15 56/64: README tweak, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 84b3666af3 04/64: fix revert-hook typo, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 24cd7721f8 21/64: widen before doing work, Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler 246e5655ab 23/64: Fix never removing blank lines from EOF., Stefan Kangas, 2021/12/31
- [nongnu] elpa/ws-butler de5d1569bf 26/64: Clear buffer-modified-p only when necessary., Stefan Kangas, 2021/12/31