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:41:20 +0200 Message-ID: <20190824124120.GT5516@protected.rcdrun.com> References: <20190822213103.GA26548@protected.rcdrun.com> <20190822224604.GA10900@protected.rcdrun.com> <83o90gb9u7.fsf@gnu.org> <20190823140145.GA28153@protected.rcdrun.com> <83lfvkj6wd.fsf@gnu.org> <20190824121924.GQ5516@protected.rcdrun.com> <83r25aiw4f.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="87316"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: GNU Emacs Help To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 24 14:41:39 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 1i1VMR-000Mc1-88 for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2019 14:41:39 +0200 Original-Received: from localhost ([::1]:37626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1VMP-0008J5-I6 for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Aug 2019 08:41:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39432) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i1VMF-0008Ix-G3 for help-gnu-emacs@gnu.org; Sat, 24 Aug 2019 08:41:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i1VME-00070H-8y for help-gnu-emacs@gnu.org; Sat, 24 Aug 2019 08:41:27 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:47971) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i1VMC-0006zH-NM; Sat, 24 Aug 2019 08:41:24 -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.000000005D613071.000041A7; Sat, 24 Aug 2019 05:41:21 -0700 Original-Received: from localhost (localhost [127.0.0.1]) (uid 1001) by protected.rcdrun.com with local id 00000000000C9452.000000005D613070.000025CC; Sat, 24 Aug 2019 14:41:20 +0200 Content-Disposition: inline In-Reply-To: <83r25aiw4f.fsf@gnu.org> 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:121361 Archived-At: * Eli Zaretskii [2019-08-24 14:31]: > That can be done easily, but I cannot resist asking: why do you need > the intermediate temporary file? Why not insert the string into a > buffer, let the user edit that string in a buffer, and then have a > command in that buffer that tells you the user is done editing? That is exactly what I am doing now. And I am losing editing. What I am doing now is using M-C-c to finish recursive-edit. But problem is that I use other functions of Emacs which are disturbing it. If I am ONLY editing words from mind, that would be fine, but I use Emacs to switch to other buffers, maybe open mutt, maybe launch new emacsclient from outside, to open other file, to copy staff from other file to such buffer. Observation and reality is that my recursive-edit will simply break. It does not last. It does not last when I invoke additional emacsclient from outside. Bufer is *edit-string* so if I am opening this email with emacsclient, the recursive-edit in the buffer *edit-string* is not any more... The message is "No recursive edit is in progress". Any more complex buffer editing without file is not reliable any more. I can even kill the buffer by thinking that the string will be read, but it will not be read. I can click M-C-c by expected that string will be read from buffer, but it is not as recursive-edit was disturbed for background reasons not known to me. > As for feeding the string into the database: can you tell in more > detail how you are doing that? Are you invoking some external > program passing it the edited string, for example? I am just invoking from Emacs Lisp to read the database, to read the field from database, and then I am editing that field as a string and feeding it back. Simple numbers can be edited with (read-number "Prompt: ") and some short strings I edit from minibuffer, as those are not complex edits. When I am editing Org file or Markdown from database, it is complex, requires using other windows, other buffers, and also using emacsclient to open other files for references. By opening emacsclient during recursive-edit, such is then interrupted. > > Question is basically how to know, from Emacs Lisp, reliably, that > > process of editing of a buffer finished, so that string can be > > read from file, thereafter. > > The best way is for the user to tell you so. Only the user knows > for sure, right? I am the user and my staff members. Eli, do you think I could do that somehow by installing some kind of timer or async function or something that works in background, which is checking if the buffer created with find-file is still there? Then I could read the string from well known file back into the database. That is my idea how to solve that. Jean