[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Modifying a shared file (was: Extending the ecomplete.el data store)
From: |
Stefan Monnier |
Subject: |
Modifying a shared file (was: Extending the ecomplete.el data store) |
Date: |
Tue, 06 Feb 2018 16:01:59 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>> I haven't used ecomplete very much so far, but I've noticed some issues
>> which I think are linked to having multiple Emacs sessions use it at the
>> same time. I haven't investigated enough to be sure, but in any case
>> it's a use case that should be kept in mind.
> Yes, ecomplete should check the modification date and reload the data if
> it has changed.
[ Plus some kind of locking to avoid modifying the file at the
same time. ]
I'd welcome some new function
(defun update-file (file modification)
"Apply MODIFICATION to FILE."
...)
tho we'd want to avoid re-reading the file if it hasn't been modified
since last time. So maybe we need to first define
(cl-defstruct file-contents
(file nil :type string)
(reader nil :type function)
(writer nil :type function)
timestamp
val)
and then
(defun file-contents-read (file &optional reader writer)
"Return a `file-contents` object representing the contents of FILE."
(with-temp-buffer
(insert-file-contents file)
(make-file-contents :file file :reader reader :writer writer
:timestamp ...
:val (funcall (or reader #'read))))
(defun file-contents-update (fc modification)
"Apply MODIFICATION both to FC and to its file."
...)
where `modification` is a function that takes the old value and returns
a new value (and it might be called several times).
-- Stefan
- Extending the ecomplete.el data store., Karl Fogel, 2018/02/04
- Re: Extending the ecomplete.el data store., Stefan Monnier, 2018/02/04
- Re: Extending the ecomplete.el data store., Karl Fogel, 2018/02/04
- Re: Extending the ecomplete.el data store., Stefan Monnier, 2018/02/04
- Re: Extending the ecomplete.el data store., Karl Fogel, 2018/02/05
- Re: Extending the ecomplete.el data store., Stefan Monnier, 2018/02/05
- Re: Extending the ecomplete.el data store., Karl Fogel, 2018/02/06
- Re: Extending the ecomplete.el data store., Stefan Monnier, 2018/02/06
Re: Extending the ecomplete.el data store., Lars Ingebrigtsen, 2018/02/05
- Modifying a shared file (was: Extending the ecomplete.el data store),
Stefan Monnier <=
- Re: Modifying a shared file, Clément Pit-Claudel, 2018/02/06
Re: Extending the ecomplete.el data store., Lars Ingebrigtsen, 2018/02/05