0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gptel-magitのコミットメッセージを日本語にする

Last updated at Posted at 2025-11-07

gptel-magitのコミットメッセージを日本語にしたい

以下のコードをコンフィグに入れよう。

(setq gptel-magit-commit-prompt
      (concat gptel-magit-prompt-conventional-commits "\n\nコメントは日本語で出力すること"))

説明

gptel-magitmagitでコミットするときにgptelを介してLLMにコミットメッセージを生成させるパッケージだ。

特に設定もなくインストールするだけで良い感じでコミットメッセージを生成してくれるが、英語だ。これを日本語で生成させようと言うのが本エントリーの目的だ。

gptelにコミットメッセージを作るよう指示するプロンプトは gptel-magit-commit-prompt に設定するが、デフォルトではgptel-magit-prompt-conventional-commitsの内容がセットされている。引用すると以下の通り。

You are an expert at writing Git commits. Your job is to write a short clear commit message that summarizes the changes.

The commit message should be structured as follows:

    <type>(<optional scope>): <description>

    [optional body]

- Commits MUST be prefixed with a type, which consists of one of the followings words: build, chore, ci, docs, feat, fix, perf, refactor, style, test
- The type feat MUST be used when a commit adds a new feature
- The type fix MUST be used when a commit represents a bug fix
- An optional scope MAY be provided after a type. A scope is a phrase describing a section of the codebase enclosed in parenthesis, e.g., fix(parser):
- A description MUST immediately follow the type/scope prefix. The description is a short description of the code changes, e.g., fix: array parsing issue when multiple spaces were contained in string.
- Try to limit the whole subject line to 60 characters
- Capitalize the subject line
- Do not end the subject line with any punctuation
- A longer commit body MAY be provided after the short description, providing additional contextual information about the code changes. The body MUST begin one blank line after the description.
- Use the imperative mood in the subject line
- Keep the body short and concise (omit it entirely if not useful)"
  "A prompt adapted from Conventional Commits (https://www.conventionalcommits.org/en/v1.0.0/).

これの最後に「コメントは日本語で出力すること」と入れれば日本語でコメントを出力するようになる。それをやっているのが冒頭のsetq文というわけである。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?