与不同 IDE 配合使用的 Clojure 缩进问题
我正在使用 emacs + slime 进行 clojure 开发。最近我们有一个新的团队成员,他不喜欢 emacs,所以他安装了带有 la clojure 插件的 intellij。
emacs 和 intellij 都允许自动重新缩进大块代码、整个函数甚至模块。
这会导致一个非常烦人的问题。如果他做了一个小更改(几行),然后重新缩进整个文件,那么显然将其记录到 dvcs(我们使用 darcs)中将产生包含数百行更改的大补丁。这使得代码审查变得不可能。我如何知道数百行中的哪 3 行确实发生了变化?
所以现在我们有合作问题。我想知道是否还有其他 Clojure 团队使用不同的 IDE。您如何解决这些问题?
我看到的选项是:
强制使用一个 IDE (emacs)。这将解决问题,但我不喜欢这种权威的方法。
以某种方式将两个环境设置为相同缩进(不确定是否可能)
同意始终在一个 IDE 中缩进。这很麻烦并且容易出错。
I am using emacs + slime for clojure development. Recently we got a new team member and he does not like emacs, so he installed intellij with la clojure plugin.
Both emacs and intellij allow to automatically re-indent big blocks of code, entire functions and even modules.
This leads to a very annoying problem. If he makes a small change (few lines) and then reindents entire file, then obviously recording it into dvcs (we use darcs) will produce big patch with hundreds rows changed. That makes code review impossible. How do i know which 3 out of hundreds committed lines really changed ?
So now we have collaboration problem. I wonder if there are other clojure teams who use different IDEs. How do you reconcile these problems ?
The options i see are:
Enforce the use of one IDE (emacs). This will solve the problem, but i do not like such an authoritative approach.
Somehow setup both environments to indent identically (not sure if its possible)
Agree to always indent in one IDE. This is cumbersome and prone to errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试要求他尊重团队的其他成员,而不是自动重新格式化每个人的代码。
您还可以编写一个外部程序来执行缩进,然后将其作为预提交步骤挂接到源代码系统中。这样,使用什么编辑器就无关紧要了,它会变得一致。我想这是选项#2 的变体。
祝你好运。
You could try asking him to respect the rest of the team and not automatically reformat everybody's code.
You might also write an external program to do the indenting, and then hook that into your source code system as a pre-commit step. That way it wouldn't matter what editor was used, it would become consistent. I suppose this is a variation on option #2.
Good luck.
如果有人选择使用不同的 IDE,他们就有责任将其配置为团队的优秀成员。如果他们不知道如何做到这一点,他们可能没有太多理由使用它而不是任何其他 IDE。
但是,缩进的配置选项位于:Preferences >代码风格
If someone chooses to use a different IDE, it's their responsibility to configure it to be a good member of the team. If they don't know how to do so, they probably don't have much of a reason to use it over any other IDE.
However, the configuration options for indentation are located in: Preferences > Code Style
第 2 条):一个团队,一种编码标准。
Number 2): One team, one coding standard.
如果您可以从忽略空白更改的补丁中生成差异,那么您的特定问题就会消失。 +1 是为了团队内一致的编码风格。
If you can generate a diff from the patch that ignores whitespace changes then your specific problem would go away. +1 for a consistent coding style within the team though.