unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to save custom variable programmatically?
Date: Tue, 17 Nov 2020 18:44:07 +0300	[thread overview]
Message-ID: <X7Pvx1ZrlGf15KrN@protected.rcdrun.com> (raw)
In-Reply-To: <87h7pwgbg1.fsf@web.de>

* 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



  parent reply	other threads:[~2020-11-17 15:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  7:51 How to save custom variable programmatically? Jean Louis
2020-11-10 10:43 ` Robert Pluim
2020-11-10 13:42   ` Jean Louis
2020-11-10 11:23 ` Michael Heerdegen
2020-11-10 13:55   ` Jean Louis
2020-11-10 14:36     ` Michael Heerdegen
2020-11-10 19:19       ` Jean Louis
2020-11-10 20:42         ` Marcin Borkowski
2020-11-10 21:46           ` Jean Louis
2020-11-11 21:20             ` Marcin Borkowski
2020-11-10 20:43         ` Michael Heerdegen
2020-11-10 21:52           ` Jean Louis
2020-11-11 18:00             ` Michael Heerdegen
2020-11-11 18:05               ` Jean Louis
2020-11-17 12:24             ` Michael Heerdegen
2020-11-17 15:07               ` Jean Louis
2020-11-10 21:15         ` Michael Heerdegen
2020-11-10 21:55           ` Jean Louis
2020-11-11 10:55             ` Michael Heerdegen
2020-11-17 15:44           ` Jean Louis [this message]
2020-11-17 16:38             ` Michael Heerdegen
2020-11-17 21:30               ` Stefan Monnier
2020-11-10 16:24 ` Drew Adams
2020-11-10 19:23   ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=X7Pvx1ZrlGf15KrN@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).