Skip to content

feat: add editor config option to editor_command() - #6897

Open
Mo200227 wants to merge 6 commits into
beetbox:masterfrom
Mo200227:fix-issue-6641
Open

feat: add editor config option to editor_command()#6897
Mo200227 wants to merge 6 commits into
beetbox:masterfrom
Mo200227:fix-issue-6641

Conversation

@Mo200227

Copy link
Copy Markdown

Fixes #6641

Adds an editor config option so users can permanently set their preferred editor in config.yaml, overriding $VISUAL and $EDITOR environment variables which may not be available in virtualenv environments (e.g. pipx with uv backend).

Usage:

editor: nano

Changes:

  • Modified beets/util/__init__.pyeditor_command() now checks config["editor"] first before falling back to $VISUAL/$EDITOR
  • Added changelog entry to docs/changelog.rst
  • Added documentation to docs/reference/config.rst
  • Added 3 tests to test/test_util.py

@semohr — reopening here as a clean PR per your feedback. All previous review points addressed.

@Mo200227
Mo200227 requested a review from a team as a code owner July 31, 2026 16:45
@Mo200227

Copy link
Copy Markdown
Author

Fixes #6641

Comment thread docs/reference/config.rst
~~~~~~

The text editor to use when editing configuration files (e.g., via beet config
-e). Overrides the $VISUAL and $EDITOR environment variables. If none of these

@semohr semohr Aug 1, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put code markers around the inline variables and command.

I.e.

Overrides the ``$VISUAL`` and ``$EDITOR`` environment variables. If none of these
``beet config -e``

Comment thread test/test_util.py
monkeypatch.setattr("beets.util.os.altsep", "\\")
def test_editor_command_falls_back_to_visual(self):
"""Falls back to $VISUAL when no editor config is set."""
with patch.dict(os.environ, {"VISUAL": "vim"}, clear=True):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with patch.dict(os.environ, {"VISUAL": "vim"}, clear=True):
with patch.dict(os.environ, {"VISUAL": "vim", "EDITOR": "emacs"}, clear=True):

@semohr

semohr commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Last round of reviews. Again please rebase onto the current master. We need all CI/CD workflows to pass before we can consider merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$EDITOR is not respected, likely due to uv virtualenv

2 participants