From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: with-editor seems like a bug fix Date: Sat, 29 Jun 2024 13:06:54 +0200 Message-ID: <87msn4nh2p.fsf@gmx.de> References: <86frsz6i6v.fsf@gnu.org> <87o77miusp.fsf@ledu-giraud.fr> <8634oy65mo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21053"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Manuel Giraud , rms@gnu.org, emacs-devel@gnu.org, Jonas Bernoulli To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 29 13:08:00 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sNVw0-0005D0-8M for ged-emacs-devel@m.gmane-mx.org; Sat, 29 Jun 2024 13:08:00 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNVvD-0003jR-Po; Sat, 29 Jun 2024 07:07:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNVv6-0003i3-5G for emacs-devel@gnu.org; Sat, 29 Jun 2024 07:07:07 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNVv3-0002gQ-1y; Sat, 29 Jun 2024 07:07:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1719659215; x=1720264015; i=michael.albinus@gmx.de; bh=EYWdPXaVLciqku9ccNpom+WKAUICex2bIk6oVARyAEg=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=Bw66ULIhg8yJke6WLwlPNyRP2wscwcD01yYHZPX28I4JUCA3r+tU3rpmEKkXdkYR JVuKEsssYjWNcNyhCSOh8/MjfzGA8foKNfMa3swZgqc/rNiaRH/G2z0dH2dF8WM1L l3nbUqFwhe9abRHML9yNGm1HwlC0jmXM7xwX/AXcdHxIZY90+dZOEcgwYCzYsEXo8 Eynm9Yr5hE1BeOWTeAoVFpZnkDlnu69oUVtxSt6RaKKlD1olSv9obxpeWqJSmnvtH +lwaxJhLj/FHO64U0gQ6PDaCUmuD7/O1fbW9YjbPSIaMTsP70W+nG64u/t319SIHu 7Ne0kNNystQV9QSCSQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mlw3X-1smuia1HtL-00hDLH; Sat, 29 Jun 2024 13:06:55 +0200 In-Reply-To: <8634oy65mo.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 27 Jun 2024 13:29:19 +0300") X-Provags-ID: V03:K1:Tkwt5V+wpLTBBFZfLVhpRdz5dL/RXBXGyHR1UZwQWiWT4SHMpA/ ifShYGcxLFx5sdhXCViyHPRYGBHXFVnZ3GmFRs4c59RPlMHyQRKxNdK3UquAAs/5VQIxLb3 WrMCWtGk8bV+kdrxm0mVnpizjucsp9GFhYcPz1qMKszLyOXDZCXXD9D9ET2VSGViItxsc9y Th7BMCGAKg2va7JVHYTCA== UI-OutboundReport: notjunk:1;M01:P0:PzKujV9jgnQ=;AzrCCnCO7N9z8+1AA0n04ueXxgt 4Vw+hlQwrbJGrnXKOl0EsG5T0islp7AZjMBbdUFo1N6j6EzUKIYqlhubHVzghhzo+/aUwuRJs wXP0sOIcjLadQSXwt3jNZVGq411R/7vGY+4UCWFaQ6aUV9SFxqkz/aRIRpKAVlKvZrhhrx2gu 7EI1i8NE5i32Vaq6fLiONJ8RTAYVC4BIDRD0r6XAQjZyYqSqmGL3yUG/Z0k/BDtxL5geZGnsr 2Z+vLadXN/Cn94m/lDzcpuCEW5CINWk/OBTeOP/JNj53As5zWdFcIss+C+bhSynlUV5HnaoKH dh7XP0ud3scN1diAaJ9M7RKxZ/K4cD7w17kl+DnfpZFtGnUwY7dIblsmPS7OV4hnBETLnhRdD 6dSzJya1mNNYACa1Z3Mt/UEyHm70GsLiykoSmRJuR/uKv9YmfMQecmEFqKvchfHI/ogrBLunH S4oOE9JPqhrh2eg6OoK4JD2WWL0MsfnXMdFpMAhdaQUnIlLDe9MuoLYxdnINlrrnObf2/ruIU xTq5EVEK26kE66kJ4OAuYkSMbX+t//y1t2+TMsM0BWzDxjWduwhyOaEEY7h9hbPmyp9UV6rDO 0ngDUp7tcUJ0ookbNhCi+IUOFm19rsKbYK/RWRmkS2WUFKzzNHPQZTwSCu4msWF/SxX7VcoWW yy2l05qxn/Sec/atgXvBbxMeHVInWAX51FgoaDacbEjJv7eFEZg/XOTGydwLXp/GTfdWDF5iU 2qP3w6kwK8ptx27zJa1EjRMkGIeYkJGJShWnACd0JD6rS/65+5d+Eliyo0G/tabJ+8UDjAEr Received-SPF: pass client-ip=212.227.17.21; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:320842 Archived-At: Eli Zaretskii writes: Hi Eli, >> >> What with-editor does seems like a bug fix to me, not like a feature= . >> >> It really ought to be standardly enabled in Emacs whenever the Emacs >> >> client is. >> > >> > If someone can explain what is/are the bug(s) and show a recipe for >> > reproducing it/them, we will fix it, yes. >> >> I said it in september 2023 and I don't know if it's a bug that needs a >> fix but here is recipe of what 'with-editor' does well and could be >> useful: >> >> - C-x C-f /ssh:remote-server|su:: >> - M-x eshell >> - vipw --> and here it works, opening an Emacs buffer through >> emacsclient so I could edit and C-c C-c when done >> >> Note that: >> - EDITOR is set to "emacsclient" on the localhost >> - Emacs/emacsclient is not installed on remote-server >> >> It seems that 'with-editor' does that with the following shell hackery >> into $EDITOR on the remote server: >> >> sh -c 'printf "\nWITH-EDITOR: $$ OPEN $0\037$1\037 IN $(pwd)\n"; sleep >> 604800 & sleep=3D$!; trap "kill $sleep; exit 0" USR1; trap "kill $sleep= ; >> exit 1" USR2; wait $sleep' > > Ouch! > >> So maybe that is what we need in Emacs if we want this feature. > > I hope not. > > Michael, can you please look into this and see what can we do in such > cases? As Manual says, we've discussed this last autumn. In the local case, with-editor tries to set a proper environment for calling emacsclient from child processes started in Emacs. This could be 'git commit', 'vipw', 'crontab -e', whatever. Mainly it solves two tasks: searching for a proper emacsclient program (which isn't trivial, as Jonas did explain), and setting the $EDITOR environment variable when calling the child process. In the remote case, when a program is called on another host, with-editor doesn't use emacsclient at all. Finding a proper emacsclient remotely is more complicate, and setting the $EDITOR environment variable needs more logic, because it must use emacsclient's -T argument. Jonas has said that he doesn't use Tramp himself, so using a remote emacsclient wasn't an option for him. The emacsclient -T argument exists since Emacs 26; the with-editor package requires Emacs 25.1, it wasn't available when the package started to exist. And there are even more problems using a remote emacsclient program. It simply coouldn't exist remotely. It simply couldn't be possible to use a socket from the remote host back to the local host, for example if the local host is indide a firewall, and the remote host isn't. It simply couldn't be possible to establish a socket at all from the remote host to the local host, when the remote host is reachable via a (Tramp) multi-hop path only, like "/ssh:user1@proxyhost|ssh:user2@targethost:". TL;DR: I don't believe with-editor is just a bug fix. There are reasons for the implementation as-it-is. It might profit from using emacsclient also for the remote case (when possible), but nobody has taken the stab. Best regards, Michael.