在emacs中控制代码美化
如何让 Emacs 在左括号周围添加填充空格并在缩进 () 上添加运算符?
How can I get Emacs to put padding spaces around opening brackets and operators on indentation ()?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如其他答案中所述,有解决方案可以解决您的问题。但是,代码美化并不总是可以作为一种选择,因为您可能正在使用另一个编码标准处理另一个项目。在为项目做出贡献时,您最不想做的事情就是在提交补丁之前弄乱代码的风格,原因如下:
幸运的是,有一个中途之家可以让您和维护人员保持理智,
glasses-mode
:它不仅会使标识符更具可读性,还会在函数括号之前放置一个空格。
glasses-mode
只是“假装”代码美丽,仅供您的眼睛使用。至少值得注意。As stated in other answers there are solutions to solve your problem. But, code beautifying is not always available as an option as you may be working on another project with another coding standard. The last thing you want to be doing when contributing to a project is messing with the style of the code before you submit your patch for these reasons:
Luckily, there is a half-way-house which will keep you and maintainers sane,
glasses-mode
:Not only will it make identifiers more readable, it will also place a space before your function brackets.
glasses-mode
just 'pretends' that the code is beautiful, for your eyes only. Note-worthy at the very least.您可以建议
indent-region
函数在缩进区域后应用填充,如下所示:You could advise the
indent-region
function to apply the padding after indenting the region, like so: