簡単な説明:
元の質問は次のように要約されました。
ほとんどではないにしても、多くの emacs c インデント スタイルは、行にコメントを付けます。
// ...
周囲のコードに合わせてインデントします。
//+ や //- のようなコメントを、周囲のコードよりもインデント設定を 1 つ以上インデントしたい。
私は通常、同じインデント レベルのコメントがコードの次の行に適用され、余分なインデント レベルのコメントがコードの前の行に適用されるという観点からこれを考えます。しかし、それはただのスタイルです。
簡単に:
コメントが次の行に関連付けられているかどうか (この場合、構文に合わせて適切にインデントする必要があります)、またはコメントが前の行 (この場合、追加のレベルをインデントしたい)?
例えば
int
foo()
{
// this comment is for the variable bazz below
int bazz;
//- this comment is for the variable bazz,on the line above.
//- I want it indented an extra level, which I will do by hand here.
// this comment is for the next variable, biff
int biff;
int example; /* comment
* on multiple lines
* but this can be too much indented
*/
int example_of_a_really_long_name_that_can_produce_excessive_indentation; /* comment
* on multiple lines
* but this can be too much indented
*/
}
// と //- で始まるコメントは、私が望んでいるものです。// 周囲のコードと一緒にインデントされます。これはemacsが私に与えるものです。
//- 追加のインデント レベルでインデントされます。または//+、または慣習がある場合は何でも。正規表現の仕事のように聞こえます。
// と / に対して私が知っている方法の例を提供します。/コメントは複数の行にまたがりますが、過度にインデントすることができます。
詳細:
私はちょうど今emacs 24.1をインストールしています - または少なくとも私はそれをインストールしているといいのですが、作業中のシステムには非常に古くて厄介なディストリビューションがあります。しかし、21.4.1 などの古い emacs で何かが動作する場合、私はさらに幸せです。多くの異なるシステムに emacs をインストールする手間が省けます。
================================
ちなみに、c-indent-comment-syntaxally については既に知っていますし、cc-mode.el の多くについても知っています。
特に、c-indent-comment-syntaxically は次のように表示します。
int
foo()
{
// this comment is for the variable bazz below
int bazz;
//- this comment is for the variable bazz,on the line above.
//- I want it indented an extra level, which I will do by hand here.
// this comment is for the next variable, biff
int biff;
int example; /* comment
* on multiple lines
* but this can be too much indented
*/
int example_of_a_really_long_name_that_can_produce_excessive_indentation; /* comment
* on multiple lines
* but this can be too much indented
*/
if( foo )
// comment
bar();
if( foo ) {
// comment
bar();
}
}
これは私が望むものではありません。//- コメント行を追加のインデント レベルでインデントする必要があります。
一体、なぜelispのようなものではないのですか:
/// <-- 列 0 から開始
// 構文的にインデントされます (コードの次の行に関係します)
またはおそらく //^ (^ は「上」を示します。
//- または //^ - 追加のインデント レベル (コードの前の行に関連するもの) をインデントします。