all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
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	[thread overview]
Message-ID: <20190824155103.GB11684@protected.rcdrun.com> (raw)
In-Reply-To: <83h866iopc.fsf@gnu.org>

* 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	other threads:[~2019-08-24 15:51 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 21:31 How to reliably edit a file from within Emacs Lisp and return a string? Jean Louis
2019-08-22 22:01 ` Noam Postavsky
2019-08-22 22:46   ` Jean Louis
2019-08-22 23:10     ` Óscar Fuentes
2019-08-22 23:22     ` Noam Postavsky
2019-08-23  1:19       ` Jean Louis
2019-08-23  1:27         ` Noam Postavsky
2019-08-23  7:49       ` Eli Zaretskii
2019-08-23 14:01         ` Jean Louis
2019-08-23 14:14           ` Robert Pluim
2019-08-24 12:20             ` Jean Louis
2019-08-24 12:24             ` Jean Louis
2019-08-23 14:25           ` Eli Zaretskii
2019-08-24 12:19             ` Jean Louis
2019-08-24 12:30               ` Eli Zaretskii
2019-08-24 12:41                 ` Jean Louis
2019-08-24 13:17                   ` Eli Zaretskii
2019-08-24 14:14                     ` Jean Louis
2019-08-24 14:55                       ` Jean Louis
2019-08-24 15:10                         ` Eli Zaretskii
2019-08-24 15:51                           ` Jean Louis [this message]
2019-08-24 16:11                             ` Eli Zaretskii
2019-08-24 16:44                               ` Jean Louis
2019-08-24 16:55                                 ` Eli Zaretskii
2019-08-24 17:02                                   ` Eli Zaretskii
2019-08-24 17:17                                     ` Jean Louis
2019-08-24 17:23                                       ` Eli Zaretskii
2019-08-24 17:37                                         ` Jean Louis
2019-08-24 18:25                                           ` Eli Zaretskii
2019-08-24 18:50                                             ` Jean Louis
2019-08-24 19:03                                               ` Eli Zaretskii
2019-08-24 21:30                                                 ` Jean Louis
2019-08-24 17:15                                   ` Jean Louis
2019-08-24 17:22                                     ` Eli Zaretskii
2019-08-24 16:18                             ` Yuri Khan
2019-08-24 17:07                               ` Jean Louis
2019-08-24 13:08                 ` Jean Louis
2019-08-23 21:44           ` Marcin Borkowski
2019-08-24 12:15         ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190824155103.GB11684@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.