From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to reliably edit a file from within Emacs Lisp and return a string? Date: Sat, 24 Aug 2019 14:24:05 +0200 Message-ID: <20190824122405.GS5516@protected.rcdrun.com> References: <20190822213103.GA26548@protected.rcdrun.com> <20190822224604.GA10900@protected.rcdrun.com> <83o90gb9u7.fsf@gnu.org> <20190823140145.GA28153@protected.rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="19111"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: help-gnu-emacs@gnu.org To: Robert Pluim Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 24 14:24:25 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1i1V5k-0004rg-Hy for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2019 14:24:24 +0200 Original-Received: from localhost ([::1]:37574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1V5i-000566-RD for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2019 08:24:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37635) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1V5V-00055z-W5 for help-gnu-emacs@gnu.org; Sat, 24 Aug 2019 08:24:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1V5V-0007sQ-4P for help-gnu-emacs@gnu.org; Sat, 24 Aug 2019 08:24:09 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:58563) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1V5U-0007sC-UH for help-gnu-emacs@gnu.org; Sat, 24 Aug 2019 08:24:09 -0400 Original-Received: from protected.rcdrun.com ([::ffff:31.223.149.228]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000320EB.000000005D612C67.00004033; Sat, 24 Aug 2019 05:24:07 -0700 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local id 00000000000C9452.000000005D612C65.000024C9; Sat, 24 Aug 2019 14:24:05 +0200 Content-Disposition: inline In-Reply-To: X-Mime-Autoconverted: from 8bit to quoted-printable by courier 1.0.6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.170.207.13 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:121359 Archived-At: * Robert Pluim [2019-08-23 16:15]: > >>>>> On Fri, 23 Aug 2019 16:01:45 +0200, Jean Louis = said: > Jean> I would be happy if I can do something like: >=20 > Jean> (defun emacsclient-edit (file) > Jean> (shell-command (format "emacsclient %s " file)) > Jean> (file-to-string file)) >=20 > Jean> But that does not work within Emacs itself. Would that work, = I would be fine. >=20 > Jean> It is somehow strange that I can run emacsclient from outside > Jean> Emacs and edit file and know that emacsclient finished its jo= b, > Jean> and read the string from file, and that I cannot do the same = from > Jean> Emacs. >=20 > I=CA=BCd investigate the 'with-editor' package, which lets you use > emacsclient to talk back to the emacs it=CA=BCs run from. I tried it, as I understand that package is preparing the environment $EDITOR for shell commands, so that it is ensured that editor will communicate to current Emacs instance. For example launching external mail reader that uses $EDITOR variable would use existing Emacs instance with emacsclient Jean