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 17:51:03 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

* Eli Zaretskii <eliz@gnu.org> [2019-08-24 17:11]:
> > Date: Sat, 24 Aug 2019 16:55:12 +0200
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> > 
> > > (defun edit-db-field-value (table field type id value file)
> > >   (string-to-file-force value file)
> > >   (let* ((buffer (create-file-buffer file)))
> > >     (switch-to-buffer buffer)
> > >     (set-visited-file-name file)
> > >     (insert value)
> > >     (add-hook 'kill-buffer-hook `(lambda ()
> > >                             (let ((new-value (file-to-string ,file)))
> > >                               (rcd-db-update-entry ,table ,field ,type 
> > > ,id new-value)))
> > >         0 t)))
> > > 
> > 
> > I was just thinking it is solved, but it does not solves anything but
> > that string can be read into the file.
> > 
> > However, that way program execution does not continue. There is no
> > waiting loop or something like that.
> > 
> > It just makes sure that one field is read back into string.
> 
> So now you need to take that string and feed it back into the
> database, right?  So why are you saying this is not the solution?
> What else is missing?

kill-buffer-hook is a hook, it does not help me to continue program
execution.

A database table can have many fields:

page-title

page-description

page-body

Program may iterate over fields. After each editing of title, the
program moves back to the initial iteration of fields or main program
loop. After editing of title, I move back to the above list. Then I
edit description, I should be able to move back.

If hook is installed, it just ensured to read back the string into
database, but it escapes the main loop, program execution basically
and there, as nothing is holding it.

It could be solved if I could hold on find-file, and to know that
find-file finished its job, so that Emacs Lisp can continue after
find-file

Jean



reply via email to

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