From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CKQgKTBjRmO1XAAAbAwnHQ (envelope-from ) for ; Wed, 12 Oct 2022 08:48:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MPVIKDBjRmOx9wAAG6o9tA (envelope-from ) for ; Wed, 12 Oct 2022 08:48:16 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 544D93F3AB for ; Wed, 12 Oct 2022 08:48:16 +0200 (CEST) Received: from localhost ([::1]:38644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiVXL-0003U6-EM for larch@yhetil.org; Wed, 12 Oct 2022 02:48:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiVSM-0002ku-Fb for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 02:43:08 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:46056) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oiVSK-0004HA-Jx for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 02:43:06 -0400 Received: by mail-pj1-x102e.google.com with SMTP id o9-20020a17090a0a0900b0020ad4e758b3so1140825pjo.4 for ; Tue, 11 Oct 2022 23:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=VvTbr4GVqJpSJfej8zER97FQEcAB6eeppBmo5lL8FWQ=; b=FEpLDEMWXr4Z2S+VBN7mW5mZleJiwB3vYhZRY/ZYecplHPZPBn9rwf5gTWFTgCfaWg hZ8Z9UtL5dSmJfg0hJN/9WragDD5qSjbQb/nPXFZUtY4J6Dcuf/iTjW+VCBIh3C6G5wr a7fCJFcV89NGLQXYGk23T3anlf5Z0mYJr/6oG6CyusCgjV9y2nlWU4a48K6XVCYw6mXp 5/ay8eCyWMDIM44ydRabj5FONQGcvSgBTAwbHqflp+jhlA/FwiGs0WEhfUMj2SLFELSM vFSLXI3QQMJXIhVl0IQB2ktg7lv+PxpYP4irKhI/l48NlfxjxoW6PUoExHSeSDaIrfak 1P6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VvTbr4GVqJpSJfej8zER97FQEcAB6eeppBmo5lL8FWQ=; b=xxlYtMOQ59E+WtPK5gom6E2UXwtqYN0858ixxVzmVvYVRBwTOs9SYajIqe6Rx+/zF+ Eb+SWm0xUiRADyiCEBIQn+R/gnFRd32hrj7MNtaMQecoPZbVGMNLw4z2yiLbj9/KhzYq LHEAqBRGSV8/6FdjFx2opUvGAJLlejMWEzszzFL8W9a/jTsaHnQUyfuSNOSNw5I75cr3 PPn9TtbDYBaOsOYe57/PPcNp0o753bZAomLe3LF6t4HKySQnOpJntRxE0OfFhqPJGjF/ o5H34nvc6HaYUP9je9PjPRhPG2quAw5KjLXCukuzOVMjsBAaR0J8cHfzJJAT68+sTLJd 7ZmQ== X-Gm-Message-State: ACrzQf1eC9i/rO0bqoMygtfju4Sdfxn+JQ661gnn4aCMePfePoJ8azyU KVFj406C6tRkWDlXRxSNAQ4= X-Google-Smtp-Source: AMsMyM55REOHDTgsVsjmt3lPdutsqSLOQzg+oP2ArTc/HQ8UhDpopVsMtPLZ+BaEd94duwLrhDCzLA== X-Received: by 2002:a17:902:f708:b0:178:9b70:310b with SMTP id h8-20020a170902f70800b001789b70310bmr27413585plo.65.1665556982575; Tue, 11 Oct 2022 23:43:02 -0700 (PDT) Received: from localhost ([2409:8970:af2:32f:6c23:3ad5:f37d:541b]) by smtp.gmail.com with ESMTPSA id w8-20020a17090abc0800b0020d43c5c9a0sm674013pjr.18.2022.10.11.23.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 23:43:01 -0700 (PDT) From: Ihor Radchenko To: Karthik Chikmagalur Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] LSP support in org-src buffers In-Reply-To: <877d157wax.fsf@gmail.com> References: <87bkqmdhqz.fsf@gmail.com> <87mta5ease.fsf@localhost> <877d157wax.fsf@gmail.com> Date: Wed, 12 Oct 2022 14:43:50 +0800 Message-ID: <87fsftsfrt.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=yantar92@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665557296; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=VvTbr4GVqJpSJfej8zER97FQEcAB6eeppBmo5lL8FWQ=; b=UFzg/G+Vp1u8kxJSPaUta8vjNIQxVGm8nu9kJ+UJdSG68SoAu3CHwVWIgR0T8Z5mNwmszg +nz4LrmYlJ6jaNx+BA7dc4+apOiLkYGORFHHoyuwUWFrMrtwgNUalzpMog0WfMaj67zCJu te7IIrDaxFwNQcQDgikhNel2NxeM9N+MOphgomBcyhYLW8c2pFO+VveRY3XwrlbA86lmGK DVqRPlFY/iCLbSQL9V4SZTaL93LoB6NedNNMXnitF+DaaTg92uhAnRLfInZU1eK+ouHvzN NJAs/xgfQxPXNYMTCAbOlu7V3XZM4a6vPlkD0JTg1YvZfXYhonXBEtgtvRAFAA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665557296; a=rsa-sha256; cv=none; b=WbnPmnHQL2eeSclisfBL60Vk4ZXSMKpsLcgHQIKRiuXqUGCUFWKT/AktKBg7RS3pr13AyT QTCiROSZNBnFUYf9tfSlpyMT5n5RcJvLdrEmKEdj+g65PS7TDQFLNP3NDDAXZoCuJzareW 9NEXjicl8uno3rTM/k6e8sQzmQH7XPHR2qGnjul00MiCdmwMi0HHxIYCf5VijAptxQUaGI CAPW5+a5OHeDJgfGLRxPJqIrfWoROpmyAEPZME7wp//DXji9LFOZ162DRT8fGB26s+HTur MM7EEzyl2bJliK4A9JkZLoVsPRYA028QUmCc5Vg/tYAXHHvx8czsLlIrmPGS3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FEpLDEMW; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.40 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=FEpLDEMW; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 544D93F3AB X-Spam-Score: -3.40 X-Migadu-Scanner: scn1.migadu.com X-TUID: jFNueJp2Si13 Karthik Chikmagalur 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, <> 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 <> 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 . Support Org development at , or support my work at