From 43cf618f6fdb26fa478b7241d110959b7c72f1c6 Mon Sep 17 00:00:00 2001 From: h-east Date: Sat, 10 May 2025 05:34:33 +0900 Subject: [PATCH 1/3] Update develop.{txt,jax} --- doc/develop.jax | 97 +++++++++++++++--------------------------------- en/develop.txt | 98 +++++++++++++++---------------------------------- 2 files changed, 59 insertions(+), 136 deletions(-) diff --git a/doc/develop.jax b/doc/develop.jax index bb045ec53..4c9f33062 100644 --- a/doc/develop.jax +++ b/doc/develop.jax @@ -1,4 +1,4 @@ -*develop.txt* For Vim バージョン 9.1. Last change: 2025 Apr 18 +*develop.txt* For Vim バージョン 9.1. Last change: 2025 May 05 VIMリファレンスマニュアル by Bram Moolenaar @@ -217,7 +217,7 @@ sound.c と sign.c は、配布された .clang-format ファイルに従って Marriott) -☆コメント *style-comments* +☆コメント *style-comments* 関数本体内に複数行のコメントを入れないようにすること。関数が非常に複雑で、一部 を個別にコメントする必要がある場合は、関数の構造を再検討する必要がある。 @@ -232,7 +232,7 @@ sound.c と sign.c は、配布された .clang-format ファイルに従って < -☆インデント *style-indentation* +☆インデント *style-indentation* コードのインデントには 4 つのスペースを使用する。Vim を使用してソースを編集し ている場合は、|modeline| があるため何もする必要はない。 @@ -240,7 +240,7 @@ sound.c と sign.c は、配布された .clang-format ファイルに従って 他のエディタの場合は、リポジトリのルートに `.editorconfig` が提供される。 -☆宣言 *style-declarations* +☆宣言 *style-declarations* 可能であれば、ガード内で `for` ループ変数を宣言する: OK: > @@ -261,113 +261,77 @@ OK: > < -☆括弧 *style-braces* +☆括弧 *style-braces* すべての波括弧は改行しなければならない: OK: > if (cond) { - cmd; - cmd; + cmd; + cmd; } else { - cmd; - cmd; + cmd; + cmd; } < 間違い: > if (cond) { - cmd; - cmd; + cmd; + cmd; } else { - cmd; - cmd; + cmd; + cmd; } < OK: > while (cond) { cmd; + cmd; } < 間違い: > while (cond) { cmd; + cmd; } < -ブロックがコメントを含めて 1 行の場合は、波括弧は省略できる。 OK: > - if (cond) - cmd; - else - cmd; -< -間違い: > - if (cond) - /* - * comment - */ + do + { cmd; - else cmd; + } while (cond); < -`if`/`else` の一方のブロックに波括弧がある場合は、もう一方のブロックにも波括弧 -が必要である。 -OK: > - if (cond) - { - cmd; - } - else +または > + do { cmd; cmd; } + while (cond); < 間違い: > - if (cond) + do { cmd; - else - { - cmd; - cmd; - } - - if (cond) - { - cmd; - cmd; - } - else - cmd; -< -OK: > - while (cond) cmd; -< -間違い: -> - while (cond) - if (cond) - cmd; + } while (cond); < ☆型 *style-types* -記述的な型を使用すること。それらのリストは src/structs.h ファイル内、またはお -そらく作業中のファイルの typedef 内にある。 - +説明的な型を使用すること。これらは src/vim.h、src/structs.h などで定義されてい +る。 Note すべてのカスタム型には「_T」という接尾辞が付けられることに注意 -OK: > - int is_valid_line_number(linenr_T lnum); +例: > + linenr_T + buf_T + pos_T < -間違い: > - int is_valid_line_number(unsigned long lnum); -< - ☆空白と句読法 *style-spaces* @@ -388,8 +352,8 @@ OK: func(arg1, arg2); for (i = 0; i < 2; ++i) '=', '+', '/' 等の前後に空白を入れる。 -間違い: var=a*5; OK: var = a * 5; +間違い: var=a*5; 似たような動作をグループ化するには、空行を使う。 @@ -414,7 +378,6 @@ OK: > while (buf != NULL && !got_int) < - ☆関数 *style-functions* 関数宣言は、戻り値の型を別のインデントされた行に記述して使用する: diff --git a/en/develop.txt b/en/develop.txt index 18e2caec7..621e7f668 100644 --- a/en/develop.txt +++ b/en/develop.txt @@ -1,4 +1,4 @@ -*develop.txt* For Vim version 9.1. Last change: 2025 Apr 18 +*develop.txt* For Vim version 9.1. Last change: 2025 May 05 VIM REFERENCE MANUAL by Bram Moolenaar @@ -215,7 +215,7 @@ them: - flexible array members: Not supported by HP-UX C compiler (John Marriott) -COMMENTS *style-comments* +COMMENTS *style-comments* Try to avoid putting multiline comments inside a function body: if the function is so complex that you need to separately comment parts of it, you @@ -230,8 +230,7 @@ For everything else use: > // comment < - -INDENTATION *style-indentation* +INDENTATION *style-indentation* We use 4 space to indent the code. If you are using Vim to edit the source, you don't need to do anything due to the |modeline|. @@ -239,7 +238,7 @@ you don't need to do anything due to the |modeline|. For other editors an `.editorconfig` is provided at the root of the repo. -DECLARATIONS *style-declarations* +DECLARATIONS *style-declarations* Declare, when possible, `for` loop variables in the guard: OK: > @@ -259,114 +258,76 @@ Wrong: > int *ptr; < - -BRACES *style-braces* +BRACES *style-braces* All curly braces must be returned onto a new line: OK: > if (cond) { - cmd; - cmd; + cmd; + cmd; } else { - cmd; - cmd; + cmd; + cmd; } < Wrong: > if (cond) { - cmd; - cmd; + cmd; + cmd; } else { - cmd; - cmd; + cmd; + cmd; } < OK: > while (cond) { cmd; + cmd; } < Wrong: > while (cond) { cmd; + cmd; } < -When a block has one line, including comments, the braces can be left out. OK: > - if (cond) - cmd; - else - cmd; -< -Wrong: > - if (cond) - /* - * comment - */ + do + { cmd; - else cmd; + } while (cond); < -When an `if`/`else` has braces on one block, the other should have it too. -OK: > - if (cond) - { - cmd; - } - else +or > + do { cmd; cmd; } + while (cond); < Wrong: > - if (cond) - cmd; - else - { - cmd; - cmd; - } - - if (cond) - { - cmd; - cmd; - } - else + do { cmd; -< -OK: > - while (cond) cmd; + } while (cond); < -Wrong: -> - while (cond) - if (cond) - cmd; -< - TYPES *style-types* -Use descriptive types. You can find a list of them in the src/structs.h file -and probably in a typedef in the file you are working on. - +Use descriptive types. These are defined in src/vim.h, src/structs.h etc. Note that all custom types are postfixed with "_T" -OK: > - int is_valid_line_number(linenr_T lnum); -< -Wrong: > - int is_valid_line_number(unsigned long lnum); +Example: > + linenr_T + buf_T + pos_T < - SPACES AND PUNCTUATION *style-spaces* No space between a function name and the bracket: @@ -386,8 +347,8 @@ Wrong: func(arg1,arg2); for (i = 0;i < 2;++i) Use a space before and after '=', '+', '/', etc. -Wrong: var=a*5; OK: var = a * 5; +Wrong: var=a*5; Use empty lines to group similar actions together. @@ -412,7 +373,6 @@ Wrong: > while (buf != NULL && !got_int) < - FUNCTIONS *style-functions* Use function declarations with the return type on a separate indented line. From 6965ff2c8f5589dc53538959e0198f510ee29894 Mon Sep 17 00:00:00 2001 From: h-east Date: Tue, 13 May 2025 22:43:01 +0900 Subject: [PATCH 2/3] Tweak blank lines by review --- doc/develop.jax | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/develop.jax b/doc/develop.jax index 4c9f33062..a3f39bcd4 100644 --- a/doc/develop.jax +++ b/doc/develop.jax @@ -260,7 +260,6 @@ OK: > int *ptr; < - ☆括弧 *style-braces* すべての波括弧は改行しなければならない: @@ -320,7 +319,6 @@ OK: > } while (cond); < - ☆型 *style-types* 説明的な型を使用すること。これらは src/vim.h、src/structs.h などで定義されてい @@ -531,20 +529,19 @@ OK: do ンドウ、xtermのウィンドウ、Vimのバッファを表示するウィンドウなど。 混乱を避けるため、時にウィンドウと呼ばれる他の物には別の名前が付けられている。 -ここに関連する物の概観を示す。 +ここに関連する物の概観を示す: スクリーン(screen) ディスプレイ全体。GUIでは例えば1024x768ピクセルの画 面。Vimシェルはスクリーン全体を使うことも一部を使う こともできる。 - シェル(shell) Vimアプリケーション。スクリーン全体(例えばコンソール で実行した時)、あるいはその一部(xtermやGUI)。 - ウィンドウ(window) バッファの表示画面。Vimは複数のウィンドウを持つこと ができる。ウィンドウはコマンドラインやメニューバー、 ツールバーなどといっしょに表示される。これらはシェル に納まる。 + スペルチェック *develop-spell* Vim にスペルチェックを追加することになったとき、利用可能なスペルチェックのライ From 5bf0f1956b3b72aeb6ffe6e44c2c4f0b70fedeb2 Mon Sep 17 00:00:00 2001 From: h-east Date: Tue, 13 May 2025 22:46:43 +0900 Subject: [PATCH 3/3] More tweaking --- doc/develop.jax | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/develop.jax b/doc/develop.jax index a3f39bcd4..62f1549d1 100644 --- a/doc/develop.jax +++ b/doc/develop.jax @@ -321,9 +321,9 @@ OK: > ☆型 *style-types* -説明的な型を使用すること。これらは src/vim.h、src/structs.h などで定義されてい -る。 -Note すべてのカスタム型には「_T」という接尾辞が付けられることに注意 +説明的な型を使用すること。これらは src/vim.h や src/structs.h などで定義されて +いる。 +Note すべてのカスタム型には "_T" という接尾辞が付けられることに注意 例: > linenr_T