From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Adding with-editor to Emacs? Date: Fri, 01 Sep 2023 21:42:20 +0300 Message-ID: <837cp9bur7.fsf@gnu.org> References: <85msy98sni.fsf@elpa.gnu.org> <87r0nidkmt.fsf@bernoul.li> <83bkelc1p1.fsf@gnu.org> <87fs3xwzxm.fsf@bernoul.li> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40512"; mail-complaints-to="usenet@ciao.gmane.io" Cc: stefankangas@gmail.com, emacs-devel@gnu.org, rms@gnu.org To: Jonas Bernoulli Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 01 20:43:40 2023 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 1qc97L-000AJw-I3 for ged-emacs-devel@m.gmane-mx.org; Fri, 01 Sep 2023 20:43:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qc96T-0002Zd-Ev; Fri, 01 Sep 2023 14:42:45 -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 1qc96R-0002PO-1A for emacs-devel@gnu.org; Fri, 01 Sep 2023 14:42:43 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qc96P-0001YS-LO; Fri, 01 Sep 2023 14:42:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=ARSaIkVUcWENfT/6Dg+0OVS96mG4oLXVghSv6MxaspY=; b=JT7FK0WqWJxr pZ3PXl3l1z/GjnyW9LQ9wWAjQ8GNZyNVGMNnjKXvIDGLaqVPqIruqlXcqe/KdJ9qQjVcS+K7lT7nQ R7mmURchxOMOOFDQU5D9w2QdtFD8uIpVb0kRGWXKZ0Jp4Q9vDg6BnNgcZaUyuPYvbSk8YzPWZv4oK W7vClNhkUj01AdUw1kELVUwd05uJR5UUrsOTH4EWrZnzyvqht6P/EenKz8Q0vUGxuFNIEkGMJGLM3 Bc2VqChpu2pQZZV1ymQRDQfyg1leM5CtuCdaZCDGaU417KjNqWa8nht/KHr0qA/hDsDN+JC1UsKLk ZmWyY7JgMw4H1Sb+x2BfSQ==; In-Reply-To: <87fs3xwzxm.fsf@bernoul.li> (message from Jonas Bernoulli on Fri, 01 Sep 2023 19:44:53 +0200) 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:309831 Archived-At: > From: Jonas Bernoulli > Cc: emacs-devel@gnu.org, rms@gnu.org > Date: Fri, 01 Sep 2023 19:44:53 +0200 > > Eli Zaretskii writes: > > > I'm probably missing something because if all we want is to allow > > child processes to use the current Emacs session as their editor, we > > just need to inject some environment variables into > > process-environment when running those child processes, and start the > > server. > > That's the core of what with-editor does. Additionally > > - It tries hard to find the correct emacsclient to use. See below: I don't think I understand why this has to be "hard". > - It implements a "sleeping editor". This is a shell script, which > outputs a request on stdout and then waits to be told to return. > With-editor use a process filter too look for that output and when > it sees it, it responds in a similar fashion to server.el. This > is useful because makes it possible to do this over Tramp. (I > believe this could also be done using regular emacsclient+server.el, > but that is difficult to setup and a security risk if not done > correctly. If we want a better/safer client-server connections for remote hosts, it should be handled in Tramp, I think. > - It provides some convenience functionality to use this from various > shells running inside Emacs. Can you provide details? The above is too terse for me to understand the functionality. > > Emacs knows very well where to find its corresponding emacsclient. > > I wasn't aware of that. How can I make use of that knowledge? I.e., > is there a function that answers the question "what is the path of the > emacsclient that was installed with this version of emacs"? When Emacs runs installed, emacsclient is in the same directory where we install the Emacs binary, so emacsclient should be in invocation-directory. If Emacs runs uninstalled, emacsclient is in ../lib-src/ relative to invocation-directory. Whether Emacs runs installed or not is determined by the value of installation-directory: if it's nil, Emacs runs installed. There could be a complication if the programs were renamed when installed (see TRANSFORM in the top-level Makefile). When that happens, emacsclient's name is also TRANSFORMed in the same way. You can find out what was the actual name under which Emacs was invoked from the value of invocation-name, and then apply the same TRANSFORM to the name of emacsclient. > > Why is there a need for a separate library? > > I agree that there theoretically isn't a need for this library, but it > turned out that just setting EDITOR=emacsclient in the environment of > the sub process also doesn't cut it, because for many users (who never > use emacsclient directly), would have to add some configuration to make > it work. The core and original functionality provided by with-editor, > is making the configuration unnecessary by using heuristics. Can you elaborate on the configuration that is needed? I always thought that emacsclient worked for everybody OOTB. > > (I couldn't find the beginning of this discussion, so maybe I missed > > some of the relevant context, in which case I apologize.) > > The text I quoted, was the very beginning of this discussion. Yes, but did RMS write anything that you haven't quoted?