在Java模式如何我配置Emacs,这样就不会自动对齐方法参数 [英] How to I configure emacs in java mode so that it doesn't automatically align method parameters

查看:173
本文介绍了在Java模式如何我配置Emacs,这样就不会自动对齐方法参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Emacs的,当我输入:

 公共无效美孚(字符串之一,
    字符串二){
 

据tabifies是这样的:

 公共无效美孚(字符串之一,
                字符串二){
 

我宁愿它没有,只是对准像其他行延续参数。我该如何配置它不这样做?

解决方案

这来自于信息手册Emacs的CC模式,使用GNU Emacs的23.1在Windows上:

  1. 在开始建立,这不是正确地缩进Java类。在你的情况,正是你上面键入的内容。
  2. 将光标移动到这不是正确缩进该行的开始。在你的情况,串二){。
  3. 命中抄送铯( C-显示句法信息)要问的Emacs认为什么语法元素你看。在你的情况下,它会说,像((arglist中 - 对照非空纳米))。
  4. 使用抄送有限公司( C-设置偏移),告诉它你想改变缩进级别为这个语法元素。
  5. 默认为它认为语法元素,如参数列表的-CONT非空。只要按下RET如果默认是正确的。
  6. 现在,它想知道有什么用EX pression计算偏移。在你的情况下,默认的是一个elisp的EX pression。删除,并且只使用一个单一的加号+来代替。
  7. 在对其进行测试,以确保它的正常工作:命中TAB一大堆不同的线路,或MX缩进区域或类似
  8. 要使其永久,添加到您的.emacs文件:
  

(setq C-偏移-ALIST((arglist中 - 对照非空。+)))

In emacs, when I type:

public void foo(String one,
    String two) {

It tabifies like this:

public void foo(String one,
                String two) {

I'd rather it didn't, and just aligned parameters like other line continuations. How can I configure it not to do this?

解决方案

This comes from the Info manual for Emacs CC Mode, using GNU Emacs 23.1 on Windows:

  1. Start building your Java class that's not indenting properly. In your case, exactly what you've typed above.
  2. Move your cursor to the start of the line that's not indenting properly. In your case, "String two) {".
  3. Hit C-c C-s (c-show-syntactic-information) to ask Emacs what syntax element it thinks you're looking at. In your case, it'll say something like ((arglist-cont-nonempty n m)).
  4. Use C-c C-o (c-set-offset) to tell it you want to change the indentation level for this syntactic element.
  5. It defaults to what it thinks that syntactic element is, e.g., arglist-cont-nonempty. Just hit RET if that default is correct.
  6. Now it wants to know what expression to use to calculate the offset. In your case, the default is an elisp expression. Delete that, and just use a single plus sign + instead.
  7. Test it out to make sure it's working correctly: Hit TAB a bunch on different lines, or M-x indent-region or similar.
  8. To make it permanent, add this to your .emacs file:

(setq c-offsets-alist '((arglist-cont-nonempty . +)))

这篇关于在Java模式如何我配置Emacs,这样就不会自动对齐方法参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆