-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insert GFM code block and edit-indirect #251
Comments
I instrumented Another thing to note, once we do get this working, is that this ends up with the indirect buffer with the newline, so the point starts at line 2, since the codeblock as inserted by insert-gfm-code-block leaves an empty line, which is indeed what I would normally want, but it gets in the way when trying to edit-indirect in one go. |
I'm not too familiar with this, but it seems like it finds the codeblock by the text properties, perhaps the edit-indirect function is running too quickly, before there's been a chance to propertize the text that was inserted by insert-gfm-codeblock. I guess I'll try to find a way to force the text to propertize before continuing on to the edit-indirect call. If that's inadvisable, another way would be to supply the edit call explicit bounds which can probably be deduced in a straightforward manner given that the insert-gfm-codeblock call is the one constructing it. |
That was indeed the issue. Calling This works well so far: (defun my-markdown-insert-gfm-code-block-and-edit ()
(interactive)
(call-interactively #'markdown-insert-gfm-code-block)
(kill-line)
(font-lock-ensure)
(markdown-edit-code-block)) I suppose if this package would like to add this kind of function (I think it would be great, it's a very fluid/fast way to edit with all of the modes and configuration for the codeblock's mode), some things to consider would be:
|
Also the guess-mode-function can be made more resilient. Currently if the language's mode can't be detected in (let* ((lang (markdown-code-block-lang))
(mode (and lang (markdown-get-lang-mode lang)))
(edit-indirect-guess-mode-function
(lambda (_parent-buffer _beg _end)
(funcall mode))))
(edit-indirect-region begin end 'display-buffer)) I think instead we should check if the |
The commit above and the two previous ones I think should address all of the things you mentioned above. You can now insert-and-edit with C-u C-c C-s C (prefix the GFM insertion command). Let me know what you think, or if it doesn't work. |
It appears to be working just fine! Thanks a ton as usual. |
Ran into #284 which I think may be due to the changes made here, but I'm not sure. |
I thought it would be nice to have a bind that does both of these in one go, so I created a function:
The problem is that I get "Not inside a GFM or tilde code block," even though it clearly seems like the point is inside of the code block. Any ideas?
The text was updated successfully, but these errors were encountered: