taskWeeChat - Tasks: task #12332, Setting default options for script...

 
 

task #12332: Setting default options for script options

Submitter:  None
Submitted:  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:  In Progress Privacy:  Public
Percent Complete:  0% Assigned to:  flashcode
Originator Name:  * Peter Boström Originator Email:  * -email is unavailable-
Open/Closed:  Open Planned Release:  0.4.2
IRC nick:  pbos
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Fri 03 May 2013 09:48:00 AM UTC, comment #2: 

Please use a hashtable as second argument (after name of option), so that any future default can be added without changing API and plugins calling this function.
Thanks!

Sebastien Helleu <flashcode>
Project Administrator
Tue 19 Feb 2013 10:07:10 PM UTC, comment #1: 

Patch attached. Coarsely tested for all script languages. :)

Peter Boström <pbos>
Project Member
Tue 27 Nov 2012 12:47:35 PM UTC, original submission:  

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.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #27482:  0001-core-API-function-config_set_defaults_plugin-for-set.patch added by pbos (34KiB - text/x-patch - Introduces 'config_set_defaults_plugin', deprecates 'config_set_desc_plugin')

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pbos (Updated the item)
  • -email is unavailable- added by flashcode (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-04 flashcode Assigned topbos flashcode
    2013-05-03 flashcode StatusNone In Progress
        Planned ReleaseNone 0.4.2
    2013-02-19 pbos Attached File- Added 0001-core-API-function-config_set_defaults_plugin-for-set.patch, #27482
    2013-02-19 flashcode Assigned toNone pbos

    Back to the top


    Powered by Savane 3.9