Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Settings listener classes

オープン
#164 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

Start by locating SettingsDict.subscribe and the existing Sublime listener classes referenced in the issue. Review how clear_on_change, add_on_change, and listener lifetime currently work. Done should provide the proposed GlobalSettingsListener and ViewSettingsListener conveniences, including value-change handling and automatic subscription cleanup, with behavior matching the examples.

索引モデルが issue の本文から書いたものです。

説明

As seen on Discord. Motivating examples:

from sublime_lib import GlobalSettingsListener, ViewSettingsListener, on_setting_changed

class TabSizeListener(ViewSettingsListener):
    @classmethod
    def is_applicable(cls, settings: sublime.Settings) -> bool:
        return settings.get('translate_tabs_to_spaces', False)

    @classmethod
    def applies_to_primary_view_only(cls) -> bool:
        return True

    @on_setting_changed('tab_size')
    def tab_size_changed(self, new_value: object, old_value: object) -> None:
        self.view.run_command('resize_existing_tabs', {
            'new_size': new_value,
            'old_size': old_value,
        })

class JsCustomConfigurationsListener(GlobalSettingsListener)
    SETTINGS_NAME = 'JS Custom.sublime-settings'

    @on_setting_changed(get_configurations)
    def configurations_changed(self, new_configurations, old_configurations):
        if not self.settings.get('auto_build', False):
            return

        changed = [
            name for name in set(old_configurations) | set(new_configurations)
            if old_configurations.get(name, None) != new_configurations.get(name, None)
        ]

        if changed:
            print('JS Custom: Configuration changed. Rebuilding some syntaxes.')
            sublime.active_window().run_command('build_js_custom_syntaxes', {'versions': changed})

This would provide the same convenience features as SettingsDict.subscribe: selecting the desired value from the settings, detecting whether that value has changed, and keeping track of the previous value. What is also provides beyond that is automatic management of the subscription lifetime. Manually calling clear_on_change is annoying, easy to forget, prone to mistakes, and when done right kind of boilerplate-y. A SettingsListener class can handle this automatically by simply inheriting from the existing listener classes (that Sublime already manages), calling clear_on_change in __del__, and using a weakref in add_on_change.

主要言語
Python
スター
56
フォーク
5
平均マージ
25分
マージ済み PR(30日)
3

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SublimeText/sublime_lib のほかの issue

SublimeText/sublime_lib の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。