开发者

Emacs code to automatically set indent-tabs-mode according to existing code

开发者 https://www.devze.com 2023-01-16 04:40 出处:网络
Is there ready Emacs code/package to automatically set indent-tabs-mode according to the file being visited? That is, if the currently visited file uses tabs for indentation, indent-tabs-mode should b

Is there ready Emacs code/package to automatically set indent-tabs-mode according to the file being visited? That is, if the currently visited file uses tabs for indentation, indent-tabs-mode should be set buffer-locally to true. Correspondingly if spaces are used, indent-tabs-mode should be set to false. The purpose of this is to automatically detect and use the tab mode of an existing project (without needing Emacs-specific file variable annotations), to stay consistent with the tab style of existing 开发者_StackOverflow中文版code.

An even more advanced version of this detection might accomodate for the fact that a single file might have mixed tabs and spaces. In this case a sensible heuristic could be to use the tab mode on the previous line when indenting, instead of deciding upon a tab mode global to the entire file.


You might also be interested in dtrt-indent, which detects the offset when spaces are used for indentation in addition to determining if tabs are used.

http://savannah.nongnu.org/projects/dtrt-indent/

0

精彩评论

暂无评论...
验证码 换一张
取 消