(defun my/format-region-or-buffer(&optional column)
"Perform a bunch of operations on the whitespace content of a buffer.
Indent region/buffer with COLUMN space(s).
Including indent-buffer, which should not be called automatically on save."
(interactive "p")
(save-excursion
(let ((column (prefix-numeric-value column)))
(if (region-active-p)
(progn
(untabify (region-beginning) (region-end))
(delete-trailing-whitespace (region-beginning) (region-end))
(indent-region (region-beginning) (region-end) column)
(message "Selected region formatted."))
(progn
(untabify (point-min) (point-max))
(delete-trailing-whitespace)
(indent-region (point-min) (point-max) column)
(message "Buffer formatted."))))))
我想让这个函数在有C-u
传入参数的时候按照传递的参数进行缩进,没有参数的时候就遵循默认缩进
但是在不输入参数的情况下prefix-numeric-value
会返回1
,也就导致了不输入参数时默认缩进到一个空格处,有什么办法可以解决这个问题🐎️?