HenriAugusto / completion-plugin

Completion for Pure Data
BSD 3-Clause "New" or "Revised" License
19 stars 1 forks source link

Save preference dialog does not work #30

Closed 60-hz closed 4 years ago

60-hz commented 4 years ago

I tried to go change the hotkey in prefs (because on OSX control+space lead to spotlight search) and font size to 12, but nothing is saved even when I click "save to file" and restart. Editing completion.cfg file is ok.

Also clicking "Default" changed back the font size but not the hotkey.

OSX 10.9.5, pd 0.50, completion-plugin version 0.47.0-test1

HenriAugusto commented 4 years ago

When you click save do you get any error messages?

If not, can you search your file system for completion.cfg to see if it is being written somewhere not expected?

60-hz commented 4 years ago

No error message.

My completion plugin is in a classic path: user/Document/Pd/externals/completion-plugin

I see that a completion.cfg is written in user/Document/Pd/externals/completion.cfg But it is shorter than the one in user/Document/Pd/externals/completion-plugin:

This file was generated by PD AutoComplete in the absence of the original file that comes with the plugin.

hotkey Control-space max_lines 20 font DejaVu Sans Mono font_size 12 max_scan_depth 1 auto_complete_libs 1 bg #ff0000 fg white skipbg #0ad871 monobg #9832ff offset 0

HenriAugusto commented 4 years ago

Oh, i think i get it!

My theory:

The problem is with the current_plugin_loadpath variable. You are probably loading another plugin (or even a duplicate version of the completion-plugin as in #25 ) and this is messing with this variable because it is set in the pd-gui.tcl code even if the plugin is not loaded

proc load_startup_plugins {} {
    [...]
    # load other installed plugins
    foreach pathdir [concat $::sys_searchpath $::sys_temppath $::sys_staticpath] {
        set dir [file normalize $pathdir]
        if { ! [file isdirectory $dir]} {continue}
        foreach filename [glob -directory $dir -nocomplain -types {f} -- \
                              *-plugin/*-plugin.tcl *-plugin.tcl] {
            set ::current_plugin_loadpath [file dirname $filename]
            load_plugin_script $filename
        }
    }
}
proc load_plugin_script {filename} {
    global errorInfo

    set basename [file tail $filename]
    if {[lsearch $::loaded_plugins $basename] > -1} {
        ::pdwindow::post [_ "'$basename' already loaded, ignoring: '$filename'\n"]
        return
    }
   [...]
}

I've just realized the plugin is reading this global variable when it actually should have saved it's value in the plugin's initialization.

To test my theory:

  1. Go to Pd "Preferences->Path" and post here your searchpaths.
  2. do you have any other gui plugins?
  3. Do a system search for completion-plugin.tcl and see if you find duplicates of the plugin itself.
60-hz commented 4 years ago
  1. My path is the only classic Documents/Pd/externals path to keep things simple.
  2. I have many other gui plugin, so I moved them somewhere to test
  3. I have other completion plugin but they are in completely different path and do not interfere with my vanilla pd.

    Ok, I think you guessed right. Some other plugins are in conflict with completion-plugins settings, so I removed all and everything looks ok.

For exemple dnd-plugin, Trigerize and Patcherize plugins are saving completion-plugin.cfg in their own folders, so it breaks the settings restoration.

HenriAugusto commented 4 years ago

I've put a fix in 0.47.1. It should be on Deken soon or you can get it on the releases page.

HenriAugusto commented 4 years ago

Also, you might be interested in issue #32