zkry / yaml-pro

Edit YAML in Emacs like a pro
GNU General Public License v3.0
137 stars 9 forks source link

yaml-pro-edit-ts-scalar, support changing mode in *yaml-pro-edit* buffer #58

Closed uqix closed 4 months ago

uqix commented 4 months ago

Given test.yaml:

a: |
  {
    "a": "b",
    "x": 1
  }

Steps to reproduce:

  1. yaml-pro-edit-ts-scalar on key a's value
  2. *yaml-pro-edit* buffer displayed in fundamental-mode
  3. json-ts-mode
  4. Error: C-c C-c is undefined
zkry commented 4 months ago

Thanks for pointing this out! Being able to change modes is definitely something that should be supported.

zkry commented 4 months ago

Ok, the latest commint should now contain a new command while in edit mode, C-c C-m (aka C-c RET). With this you can easily select a mode to change to and the buffer will retain its edit state. Let me know if you have any other issues.

uqix commented 3 months ago

Thanks, will try as soon as it's available in Melpa. BTW, is it feasible to select mode just by plain old foo-mode command instead of a new command?

zkry commented 3 months ago

I tried to get this to work but I was running into difficulty as changing the major mode messes with local variables. I tried to get around this with hooks but I couldn't figure it out.

uqix commented 3 months ago

Is it about permanent-local property?

zkry commented 3 months ago

oh, that's interesting. I wasn't aware of this permanent-local property. Let me see if I can get it to work with this. Also changing the major mode seemed to disable the minor mode, I'll have to look into that too.

zkry commented 3 months ago

Setting permanent-local did the trick. I'm making a release with the changes so far.