hammerspoon: Problems after coroutine & modernise hs.application/window/uielement merge

@cmsj & @asmagill - I have now merged the latest Hammerspoon master into CommandPost-App. The first issue I’ve come across is:

2020-04-08 17:21:54: *** ERROR: ...ost.app/Contents/Resources/extensions/hs/window/init.lua:947: attempt to index a nil value (global 'uielement')
stack traceback:
	...ost.app/Contents/Resources/extensions/hs/window/init.lua:947: in metamethod '__index'
	...rishocking/Github/CommandPost/src/extensions/cp/init.lua:40: in main chunk
	[C]: in function 'xpcall'
	...Github/CommandPost/src/extensions/hs/_coresetup/init.lua:794: in function 'hs._coresetup.setup'
	(...tail calls...)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 44 (44 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, I’m done tweaking the Leveraging documentation… for some reason it completely slipped my mind when considering callback functions – they can allow passing new data into the coroutine as well, so I rewrote the section about passing data in and out. I’m done for tonight (on this at least), I promise!

Ok, I think I’ve worked out most of the bugs in my examples… let me know if I’ve missed anything!

@cmsj I agree that we should wait a bit before embarking on the great renaming… if you’re still serious about locking down v1.0 in the near(ish) future (on even days I think its a good idea, on odd ones I’m not as sure since we’re all just contributing “as and when we can”), then maybe make it part of v2?

And @latenitefilms you’ll probably also be interested in this: I’ve added some documentation to the Hammerspoon wiki; first I moved my hs.canvas examples to the main wiki (and added a section in the menu for modules because I think there are some others than deserve examples as well) because I recently discovered that the hs.canvas doc strings still reference the one hosted on my github site… I’ll correct this in a future pull, but it’s a minor detail so not worthy of its own pull request.

I also added a section in the side menu for Developers and added a main page for my discussions about coroutines. While the old info is still relevant, and probably even important to module developers going forward, the more interesting document is the one about Leveraging Coroutines in Hammerspoon that you can get to from the main Coroutine page. It takes a barebones generic lua function and shows how to rewrite it to leverage coroutine.applicationYield as well as discuss some variants and limitations. I consider it very draftish at the moment, as I haven’t tested all of the examples (especially the ones using hs.watchable to pass data in and out) fully yet, so let me know if you find any issues before I do… I’ll be thoroughly testing it myself over the next couple of days, but figured even in its early state it would be of interest to the two of you.

@asmagill yeah I’ve considered doing The Great Renaming several times in the past couple of years. I think we should, but I think we should be very deliberate about it. We’ve had more pain than we might have done by landing the coroutines and application/window/uielement changes closely to each other, because they’re kinda intertwined a bit.

If we do The Great Renaming, I think we should decide on what the outcome looks like, clear out anything else first that will interfere, and then get it all done.

See if 0.7.5.1 for axuielement fixes it… it looks like the axuielement created for HSapplication objects is retained in it’s initializers; the initializer for HSwindow assumes it’s retained outside (because it usually is with a create or copy method prior to invoking the initializer, rather than hs.axuielement’s way of slipping one in it already has the CFobject).

Yeah, just got one myself, but haven’t had a chance to review the crash log yet… Ok, well, it’s getting there, just in fits and spurts…

@latenitefilms try the latest at https://github.com/asmagill/hs._asm.axuielement

@cmsj I’m not quite ready to integrate axuielement, but with a little luck will be this weekend.

@asmagill since we seem to have gone into a little nexus of significant refactoring, how do you feel about us doing a push to integrate axuielement? 😄

Will test out 9c9ad75 now.

Here’s the code I’m using, however it might not mean much to you, so probably best to refer to @asmagill’s original code here. Keep in mind though that it’s using hs._asm.axuielement - so it’s probably a bug in there, rather than in your changes.