I just ran into a problem with the snippets plugin of gedit 3.4.1 running on Ubuntu 12.04. The problem is that the snippets plugin stops working (i. e., doesn't react to keyboard shortcuts and tab-completion) when a file has an encoding other than UTF-8, e. g. ISO-8859-1. In that case, the snippets plugin doesn't work any more and the error output on the console states:
Traceback (most recent call last):
File "/usr/lib/gedit/plugins/snippets/library.py", line 678, in accelerator_activated
ret = cb(group, obj, keyval, mod)
File "/usr/lib/gedit/plugins/snippets/windowactivatable.py", line 216, in accelerator_activated
return controller.accelerator_activate(keyval, mod)
File "/usr/lib/gedit/plugins/snippets/document.py", line 148, in accelerator_activate
self.apply_snippet(snippets[0])
File "/usr/lib/gedit/plugins/snippets/document.py", line 519, in apply_snippet
env = self.get_environment()
File "/usr/lib/gedit/plugins/snippets/document.py", line 483, in get_environment
v = variables[var](buf)
File "/usr/lib/gedit/plugins/snippets/document.py", line 348, in env_get_current_line
return {'utf8': u8, 'noenc': self.string_in_native_doc_encoding(buf, u8)}
File "/usr/lib/gedit/plugins/snippets/document.py", line 320, in string_in_native_doc_encoding
except GLib.GError:
NameError: global name 'GLib' is not defined
Apparently, there is a problem in file /usr/lib/gedit/plugins/snippets/document.py where a function GLib.convert is called whenever the document encoding is not UTF-8. Consequently, if I save the same file as UTF-8, it all works well.
I'm not much into Python, so any pointer how to fix this would be much appreciated.