emacs 中的 Objective-C 缩进
我正在使用 Emacs 编辑 Objective-C 代码。 默认的缩进看起来像这样:
NSTimer *timer =
[NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(callback:)
userInfo:nil
repeats:YES];
我希望 Emacs 像 XCode 一样缩进代码,即与冒号对齐:
NSTimer *timer =
[NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(callback:)
userInfo:nil
repeats:YES];
有没有希望实现这一点?
I'm using Emacs to edit my Objective-C code. The default indentation looks like this:
NSTimer *timer =
[NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(callback:)
userInfo:nil
repeats:YES];
I would like Emacs to indent the code like XCode, that is, to align with the colons:
NSTimer *timer =
[NSTimer timerWithTimeInterval:1.0
target:self
selector:@selector(callback:)
userInfo:nil
repeats:YES];
Is there any hope to achieve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
c-offsets-alist 中 objc-method-call-cont 的 c-lineup-ObjC-method-call-colons 是否有问题?
Is there something wrong with c-lineup-ObjC-method-call-colons for objc-method-call-cont in c-offsets-alist?
有一个 Objective C 模式可以在此处执行此操作
它看起来像这样
There is a Objective C mode that does this here
Here is what it looks like
我已经对此进行了一些尝试并且已经接近了,但它还没有完全发挥作用。 我的解决方案是向
align-rules-list
添加一个条目,这样一个简单的Mxalign
就可以解决问题。 问题是您必须运行align
两次才能使其正常工作。我实际上不知道 Objective-C 模式的名称是什么,因此您必须将 obj-c-mode 替换为实际调用的模式。 您可以将其添加到
align-rules-list
中:现在,您必须执行
align
两次; 第一次只会按如下方式排列:请注意,冒号是离左侧太远的两个字符。 第二个
align
将纠正这个问题。 别问我为什么。align
命令有很多作用,所以弄清楚它很困难。 希望有人能想出一种方法来改进这一点。 不管怎样,请查看相关 EmacsWiki 页面,了解有关对齐的更多信息。I've been hacking on this for a bit and have gotten closer, but it's not fully functional yet. The solution I have is to add an entry to
align-rules-list
, so that a simpleM-x align
will do the trick. The problem is that you have to runalign
twice in order to get it to work.I don't actually know what the name of the objective-c mode is, so you will have to replace
obj-c-mode
with whatever the mode is actually called. You can add this toalign-rules-list
with:For now, you have to execute
align
twice; the first time will only line it up as follows:Notice that the colons are two characters too far to the left. The second
align
will correct this. Don't ask me why.There is a lot that goes on with the
align
command, so figuring it out is hard. Hopefully someone comes up with a way to improve upon this. Anyway, take a look at the relevant EmacsWiki page for more info on aligning.