help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to reliably edit a file from within Emacs Lisp and return a stri


From: Jean Louis
Subject: Re: How to reliably edit a file from within Emacs Lisp and return a string?
Date: Sat, 24 Aug 2019 19:15:38 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

* Eli Zaretskii <eliz@gnu.org> [2019-08-24 18:56]:
> > Date: Sat, 24 Aug 2019 18:44:39 +0200
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > * Eli Zaretskii <eliz@gnu.org> [2019-08-24 18:12]:
> > > Is the program iterating over the fields in some predefined order?
> > 
> > I can choose which field to edit, like using helm and then choosing a
> > field to edit. But more often I keep it without helm. There is
> > completing-read. And I have choices like to choose what to edit, then
> > it comes back.
> > 
> > > Also, are you feeding back each field individually, or do you need to
> > > have them all edited before feeding them back as a single record?
> > 
> > Each field individually.
> 
> Then I don't understand the difficulty.  You already have a loop that
> goes over the fields one by one, right?  So, for each field let the
> user edit it, then feed the result back to the database, and continue
> to the next field.  The "feed back to the database" part can be done
> from a function called by kill-buffer-hook, and it will be triggered
> by the user killing the edit buffer once he/she is done editing.
> 
> What is missing from this idea to make it work for your program?

If I use the option with (recursive-edit) such will be cancelled for
example if I open email in other window from mutt using
emacsclient. As I do need to copy information from emails, such as
contact information, phone numbers, and similar.

This could be a bug, I do not know. If I could ensure that
(recursive-edit) remains stable for one buffer, without being
interrupted by calls of emacsclient, I could use that. I am already
now using it, but it is not perfect.

It is not good for information that comes from mind, as if I rely on
the buffer and recursive edit, and move to other buffers or invoke
emacsclient, I may lose information.

It is thus better keeping information in the file.

If I keep information in the file and edit it as buffer and file,
without recursive-edit, then I do not know how to return to the
initial programming loop.

> Yes, but this won't get you anywhere past the waiting stage, because
> there's no Emacs server that can serve the emacsclient's request.  I
> thought I explained that earlier.  You cannot do that via emacsclient,
> when the server is in the same Emacs which invoked emacsclient.  It
> doesn't matter how you invoke emacsclient from Emacs, you cannot have
> its request served within that same Emacs session.

If I have this file here as "~/bin/edit-file.sh"

#!/home/data1/protected/bin/lisp
(setf (getenv "EDITOR") "emacsclient")
(ed "~/new")

Then I see that I can invoke emacsclient from outside

(inferior-lisp "~/bin/edit-file.sh")

so I know it is not pure Emacs Lisp, it invokes basically shell file
that invokes lisp inside, but somehow it works.

I am trying to find solution to have it "waiting" so that outside
function finishes editing, then I can read the file.

> Moreover: you don't need it.  You have all of Emacs already at your
> server; why would you want to ask it to edit something via an outside
> client??

Because I do not know how to come back to main program loop after
using kill-buffer-hook to read the straing back. So far I made it, I
can read the string back, but cannot go back to main loop.

Actually  I need the waiting stage in any manner, so that emacsclient
is invoked, even from outside lisp (or any other language) and that I
can then continue execution.

I hope you understand that.

Jean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]