[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 16:14:21 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
* Eli Zaretskii <eliz@gnu.org> [2019-08-24 15:18]:
> What do you mean by "disturbing"? If the problem is that you are
> using recursive-edit, and you exit recursive-edit with C-M-c, then I
> specifically did NOT suggest to use recursive-edit. You shouldn't
> need it, AFAIU. You need a simple editing of a buffer, that's all.
I am listening to your advice.
> You could, but I don't see how this is going to solve your problem any
> better than installing a kill-buffer-hook. After all, if you are
> afraid that the user might kill the buffer when they shouldn't, then
> your reliability issue is not solved by using the kill-buffer as a
> trigger for feeding the stuff back to the database?
Yes, I tried before with kill-buffer-hook and I was doing something
wrong.
With those advises, I made the below function, which does mostly what
I want.
Thank you, it is solved!
Jean
(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)))
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, (continued)
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/23
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/23
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Robert Pluim, 2019/08/23
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/23
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?,
Jean Louis <=
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Eli Zaretskii, 2019/08/24
- Re: How to reliably edit a file from within Emacs Lisp and return a string?, Jean Louis, 2019/08/24