Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c-mode: マクロのインデントに対応する #194

Closed
x022235 opened this issue Apr 1, 2012 · 1 comment
Closed

c-mode: マクロのインデントに対応する #194

x022235 opened this issue Apr 1, 2012 · 1 comment
Assignees
Milestone

Comments

@x022235
Copy link
Member

x022235 commented Apr 1, 2012

背景

  • xyzzy では C の directive はインデントなしになる
int main() {
#if DEBUG
  hoge;
#endif
}
  • これを以下のように書きたい
int main() {
  #if DEBUG
  hoge;
  #endif
}
  • syntax-option から *syntax-option-c-preprocessor* を外すと正しくインデントされない

via http://twitter.com/nayuri_aohime/status/186394016986841088

仕様

  • c-preprocessor-offset を追加する
    • nil の場合はインデントなし (従来通りの動作)
    • 数値が指定されている場合は通常のインデント位置からのオフセット
      (0 だと同じ位置)
    • デフォルトは nil
    • Emacs の cpp-macro 相当の設定
  • Emacs の cpp-macro-cont 相当の設定は、従来の c-continued-statement-offset を利用
  • c++-mode, c#-mode も同様のものを用意する

参考

x022235 added a commit that referenced this issue Apr 2, 2012
* 0.2.2.235 ではマクロは常にインデントなしになる
* マクロのインデントを制御する変数を追加
  * c-preprocessor-offset
  * c++-preprocessor-offset
  * csharp-preprocessor-offset
* nil ならインデントなし、数値なら通常のインデント位置からのオフセット

Note:

* Java にプリプロセッサはないので java-preprocessor-offset は
  追加していない
* しかし、実装上の都合でシンボルは定義してある
@x022235
Copy link
Member Author

x022235 commented Apr 2, 2012

ちょっと自身がないので develop ブランチにはまだマージしていない。
少し寝かしてからマージする。

@ghost ghost assigned x022235 Apr 7, 2012
x022235 added a commit that referenced this issue Apr 7, 2012
以下のようなソースで `#endif` のあとでタブを押すと「'else'が妙な場所にあります」
というエラーになっていた。0.2.2.235 でも発生する。

  #if FOO
  #region hoge
  #endregion
  #else
  #endif

`#endif` を見つけた場合に対応する `#if` まで戻るような処理があるが、
この `#endif` を探す処理が最初の `#end` までしか見ていない。
そのため、`#endregion` を `#endif` と勘違いして処理してしまい、
`#if` - `#endif` のバランスが取れていないと判断していた。

`#end` の検索は行頭しか見ていなかったので、#192 の `#endregin` を
インデントするようになったことで一時的に問題はなくなっていた。

しかし、#194 で `#if` などもインデントできるようにしたことで問題が再発。
@x022235 x022235 closed this as completed Apr 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant