Change doom/retab to reformat w/ opposite style if ARG

This commit is contained in:
Henrik Lissner 2018-05-20 12:10:03 +02:00
parent b7b1445712
commit af7fb1c628
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -215,17 +215,21 @@ possible, or just one char if that's not possible."
(t (delete-char (- n) killflag)))) (t (delete-char (- n) killflag))))
;;;###autoload ;;;###autoload
(defun doom/retab (&optional beg end) (defun doom/retab (arg &optional beg end)
"Converts tabs-to-spaces or spaces-to-tabs within BEG and END (defaults to "Converts tabs-to-spaces or spaces-to-tabs within BEG and END (defaults to
buffer start and end, to make indentation consistent. Which it does depends on buffer start and end, to make indentation consistent. Which it does depends on
the value of `indent-tab-mode'." the value of `indent-tab-mode'.
(interactive "r")
If ARG (universal argument) is non-nil, retab the current buffer using the
opposite indentation style."
(interactive "Pr")
(unless (and beg end) (unless (and beg end)
(setq beg (point-min) (setq beg (point-min)
end (point-max))) end (point-max)))
(if indent-tabs-mode (let ((indent-tabs-mode (if arg (not indent-tabs-mode) indent-tabs-mode)))
(tabify beg end) (if indent-tabs-mode
(untabify beg end))) (tabify beg end)
(untabify beg end))))
(defvar-local doom--buffer-narrowed-origin nil) (defvar-local doom--buffer-narrowed-origin nil)
;;;###autoload ;;;###autoload