weechat-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Weechat-dev] [task #12332] Setting default options for script options


From: anonymous
Subject: [Weechat-dev] [task #12332] Setting default options for script options
Date: Tue, 27 Nov 2012 12:47:37 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0

URL:
  <http://savannah.nongnu.org/task/?12332>

                 Summary: Setting default options for script options
                 Project: WeeChat
            Submitted by: None
            Submitted on: Tue 27 Nov 2012 12:47:35 PM UTC
                Category: scripts
         Should Start On: Tue 27 Nov 2012 12:00:00 AM UTC
   Should be Finished on: Tue 27 Nov 2012 12:00:00 AM UTC
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
         Originator Name: Peter Boström
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
                IRC nick: pbos

    _______________________________________________________

Details:

Plugin variables have no default, so /set plugin.* looks weird because all
scripts options have (default: "")

An api function: weechat.config_set_plugin_defaults(option, default_value,
description)

Would allow changing the following snippet (from urlserver.py):


        for option, value in urlserver_settings_default.items():
            if weechat.config_is_set_plugin(option):
                urlserver_settings[option] =
weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                urlserver_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(option, '%s (default: "%s")' %
(value[1], value[0]))


to:


        for option, value in urlserver_settings_default.items():
            weechat.config_set_plugin_defaults(option, value[0], value[1])
            urlserver_settings[option] = weechat.config_get_plugin(option)


Ignoring the int(version) issue, this moves responsibility of displaying
plugin defaults in descriptions from scripts to the /set system which already
supports it. Scripts don't have to reinvent the wheel to display defaults,
it's already in place. Less code duplication, and a more uniform look. Along
with shorter code per script.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?12332>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]