From: Ihor Radchenko <yantar92@gmail.com>
To: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] LSP support in org-src buffers
Date: Wed, 12 Oct 2022 14:43:50 +0800 [thread overview]
Message-ID: <87fsftsfrt.fsf@localhost> (raw)
In-Reply-To: <877d157wax.fsf@gmail.com>
Karthik Chikmagalur <karthikchikmagalur@gmail.com> writes:
>> You already implemented a way to associate the org-edit-src buffer with
>> the fully tangled code. Then, why not make it simple and do the real
>> tangling first and then make org-edit-src work directly with a real
>> file buffer associated with the tangled file?
>
> This will drastically simplify the patch, true. I was working on the assumption that since tangling overwrites the file on disk, it should not be an implicit operation invoked as a side-effect of another action. It causes other changes that the user might not have intended, like updating timestamps on the tangled file, etc. What do you suggest?
>
> Moreover, for Eglot to function correctly it is sufficient to (i) associate the buffer with a file -- any file, and (ii) Set the default-directory variable to the correct value. "Tangling" to a file in /tmp (as I do in the patch) will not work with all the non-Eglot use-cases you describe above.
Then, I suggest to not actually write things on the disk. Instead, we
can augment `org-edit-src-save' to write on disk depending on some
customization (with values t, nil, and 'ask). That customization will,
by default, make `org-edit-src-save' query user if it is desired to
write files on disk.
Also, note that once you associate buffer with a file, various
auto-saving mechanisms may write the file to disk without user consent.
We may also need to look into write-contents-functions to prevent such
scenarios when undesired.
>> The only tricky problem I am seeing with your approach is dealing with
>> noweb references. Care should be taken about editing code blocks
>> containing noweb.
>
> If I reuse the actual tangling machinery in ob-tangle instead of writing my own version reusing only some of the primitives in this library, this should be handled automatically for me. Is this correct?
No.
`org-edit-special' will _not_ expand noweb.
`org-babel-expand-src-block' will.
In the first case, <<noweb>> syntax may drive native syntax checkers
crazy. In the second case, care should be taken to prevent editing the
noweb-replaced text. This distinction is something we would not want to
break.
Also, be aware that some <<noweb()>> references may involve code execution,
possibly on remote machines. Remote execution might be undesired during
normal editing. I am not 100% sure how to approach this problem in a
reliable way that will fit all the uses.
> Also: org-src-context-mode works by advising some org-edit-src-* functions. Is it preferable to edit these functions directly instead and add a check for whether org-src-context-mode is enabled?
I am not even sure if a separate org-src-context-mode is needed. It
could be simply a customization for org-edit-special rather than a minor
mode.
So, I am all for editing the functions directly and more complete
integration.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2022-10-12 6:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-08 5:08 [PATCH] LSP support in org-src buffers Karthik Chikmagalur
2022-10-08 12:50 ` Christopher M. Miles
2022-10-09 7:06 ` Ihor Radchenko
2022-10-11 23:52 ` Karthik Chikmagalur
2022-10-12 6:43 ` Ihor Radchenko [this message]
2022-11-21 3:19 ` Ihor Radchenko
2022-11-21 14:39 ` João Pedro
2022-11-22 2:23 ` Ihor Radchenko
2022-11-22 8:21 ` Cook, Malcolm
2022-11-22 8:44 ` Ihor Radchenko
2023-07-27 8:01 ` [TASK] Making org-src buffers sync with real files to allow LSP and other dev tools integration (was: [PATCH] LSP support in org-src buffers) Ihor Radchenko
2022-11-30 4:35 ` [PATCH] LSP support in org-src buffers João Pedro
2022-12-12 13:16 ` Ihor Radchenko
2022-12-15 19:24 ` João Pedro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fsftsfrt.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=karthikchikmagalur@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.