该文档tabify提到了仅适用于行前导空格的合适值.我用它来编写这个我觉得很方便的函数,但你可以在init文件中设置它并放弃一个单独的函数:
(defun tabify-leading (start end)
"Call `tabify' with `tabify-regexp' set so that only leading
spaces are treated."
(interactive "r")
(setq tabify-regexp-old tabify-regexp)
(unwind-protect
(progn
(setq tabify-regexp "^\t* [ \t]+")
(tabify start end))
(setq tabify-regexp tabify-regexp-old)))
Run Code Online (Sandbox Code Playgroud)