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

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

Re: How to save custom variable programmatically?


From: Jean Louis
Subject: Re: How to save custom variable programmatically?
Date: Tue, 17 Nov 2020 18:44:07 +0300
User-agent: Mutt/2.0 (3d08634) (2020-11-07)

* Michael Heerdegen <michael_heerdegen@web.de> [2020-11-11 00:17]:
> Jean Louis <bugs@gnu.support> writes:
> 
> > Thank you. If you have ready simplest example it may be useful for
> > review.
> 
> Simplest?  Ok, that might be possible.  Let's make a wrapper holding a
> single value that is savable:
> 
> #+begin_src emacs-lisp
>   (defclass my-persistent (eieio-persistent)
>     ((data :initarg :data)))
> 
>   (defun my-save-in-location (thing file)
>     (let ((obj (my-persistent :data thing)))
>       (setf (oref obj file) file)
>       (eieio-persistent-save obj)))

> This is not only a nice abstraction.  eieio-persistent has some
> (programmable) knowledge about how to print and "restore" objects where
> a normal print+read cycle would not work.
> 
> Michael.

I remember from Common Lisp about `defstruc' and more than that I did
not use. But I remember `defstruct' preparing various methods
(probably methods) automatically. From there I understand this and
keep it as note until I come to implement it.

As it is built-in, it offers straight solution, good to know!

Jean



reply via email to

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