(EDIT: have hacked a solution, but it is a hack. details at the end)
Hi Jon. The Text command is being executed, but the insert just isn’t happening. Here’s the code for my yank command:
#
# Yank the most recent kill
#
class EmacsYank(sublimeplugin.TextCommand):
def run(self, view, args):
global killRing
valueToYank = killRing.peek()
for s in view.sel():
print "YANKING '%s' to (%s, %s) in file '%s'" % (valueToYank, s.begin(), s.end(), view.fileName())
view.erase(s)
view.insert(s.begin(), valueToYank)
# once we've yanked, we definitely don't want to
# reuse the old kill buffer
killRing.LastKillPosition = -1
Now, if I do a direct call to EmacsYank, using a keybinding, I get this;
YANKING '# reuse the old kill buffer' to (4351, 4351) in file 'C:\Users\Steve\AppData\Roaming\Sublime Text\Packages\EmacsKillRing\EmacsKillRing.py'
So the yank is happening with the right text, at the right point in the right file. But when I invoke that via the quickpanel, I get this;
YANKING '# reuse the old kill buffer' to (0, 0) in file 'None'
Which looks to me like it’s running in the wrong view – I suspect it’s the still-visible quickpanel. The quickpanel doesn’t disappear until after the command has finished running. This is more obvious with a long-running command like a compile.
Anyway, to check that I’m invoking it right, I looked at my invoking command. Here that is;
#
# Yank any clip from the kill ring
#
class EmacsYankChoice(sublimeplugin.TextCommand):
def run(self, view, args):
# choose from the yank-buffer using the quick panel
global killRing
choices = killRing.choices()
names = [name for (idx, name) in choices]
idx = "%s" % idx for (idx, name) in choices]
print "YANK CHOICE IN " + view.fileName()
view.window().showQuickPanel("", "emacsYank", idx, names)
Note the lastt two lines; I print the file name for the view, then call the quickpanel for the view’s window. That print statement says
YANK CHOICE IN C:\Users\Steve\AppData\Roaming\Sublime Text\Packages\EmacsKillRing\EmacsKillRing.py
Which again looks fine.
(EDIT: I’ve hacked a solution, which is that just before showing the quick panel, I store the current view into a global variable. When an item is selected, I use the global variable to paste, and not the view parameter of the run method of EmacsYankChoice