Navigation Menu

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: #region, #endregion のインデントに対応する #192

Closed
x022235 opened this issue Apr 1, 2012 · 0 comments
Closed

c#-mode: #region, #endregion のインデントに対応する #192

x022235 opened this issue Apr 1, 2012 · 0 comments
Assignees
Milestone

Comments

@x022235
Copy link
Member

x022235 commented Apr 1, 2012

背景

869 名無しさん@お腹いっぱい。sage 2007/08/20(月) 22:02:59 ID:EWuzXhbq0
C#のソースを書いてるとき、 
#regionと#endregionが自動インデントで行頭に行ってしまうのを防ぐにはどこをいじればいいんでしょうか? 
xyzzyで書くと行頭でVisualStudioだとインデントされた位置でずれてしまうのです。

872 名無しさん@お腹いっぱい。sage 2007/08/21(火) 20:08:44 ID:Z27zuLFW0
>>869 
プリプロセス命令用のインデントをやめるのはこんなのでできます。 
(require "c#-mode") 
(add-hook '*csharp-mode-hook* 
          #'(lambda ()
              (set-syntax-option ed::*csharp-mode-syntax-table* ed::*syntax-option-indent-csharp*)))

873 名無しさん@お腹いっぱい。 sage 2007/08/22(水) 14:53:30 ID:HVpYbJYV0
>872 
#ifとかと#regionの区別はできないんですね… 
これだと#regionを書く度にインデントが深くなるっぽい。

874 名無しさん@お腹いっぱい。 sage 2007/08/22(水) 18:17:53 ID:du/OCSxi0
>>873 
c-calc-indent-line を元に、#region とかだったら 
calc-c-indent でインデントの深さを計算せずに、 
自分の好きな値を返すように修正すれば良いんじゃないの?

xyzzyの使い方が分からぬやし 励ましあえ その10
http://www.bookshelf.jp/2ch/software/1163847543.html#869

参考

  • VisualStudio の場合
    • 「#」を入力した時点で自動的にインデントがなくなる (行頭に移動)
    • #region または #endregion まで入力すると通常のインデント位置に移動
    • #region または #endregion の次の行も通常のインデント (深くなったりはしない)
@ghost ghost assigned x022235 Apr 1, 2012
x022235 added a commit that referenced this issue Apr 1, 2012
* 「#」を入力した時点で行頭に移動する
* 「#region」を入力して Tab を押すとインデントする
* VisualStudio とは違い「#region」を入力した時点で勝手にインデントするわけではない
@x022235 x022235 closed this as completed Apr 4, 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` などもインデントできるようにしたことで問題が再発。
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