[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Persistence of variables
From: |
Eric Abrahamsen |
Subject: |
Re: Persistence of variables |
Date: |
Mon, 26 Mar 2018 09:48:43 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Drew Adams <drew.adams@oracle.com> writes:
>> > But no, way too heavy. I want _one variable_ to persist, and nothing
>> > more.
>>
>> If you already use savehist-mode, you can add your variable to
>> savehist-additional-variables.
>
> There are several possibilities, including these:
>
> 1. `savehist.el' (what Eric said)
> 2. Customize (option value)
> 3. Bookmark (e.g., Bookmark+ variable-list bookmark)
> 4. Desktop
>
> If you only want to save one variable, just use an option.
To muddy the waters further, there's also eieio-persistent:
(require 'eieio-base)
(defclass my-var-persister (eieio-persistent)
((directory
:initarg :directory
:initform ""
:type string)))
(setq persister (make-instance 'my-var-persister
:directory "~/dir"
:file "~/.emacs.d/persist"))
(eieio-persistent-save persister)
;; Restart Emacs
(setq persister (eieio-persistent-read "~/.emacs.d/persist"))
(slot-value persister 'directory) ; "~/.dir"
Probably too heavy-weight for what you're describing, but it's another
option. If you ever want to save more complex data than just a single
value, it's not a bad choice.
Eric
- Re: Persistence of variables, (continued)
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/27
- Re: Persistence of variables, Marcin Borkowski, 2018/03/28
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/28
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/21
- Message not available
- Re: Persistence of variables, Robert L., 2018/03/24
- Re: Persistence of variables, Marcin Borkowski, 2018/03/25
- Re: Persistence of variables,
Eric Abrahamsen <=
- Re: Persistence of variables, Marcin Borkowski, 2018/03/28
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/21
- Re: Persistence of variables, Eli Zaretskii, 2018/03/21
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/21
- Message not available
- Re: Persistence of variables, Rolf Ade, 2018/03/21
- Re: Persistence of variables, Eli Zaretskii, 2018/03/22
- Message not available
- Re: Persistence of variables, Emanuel Berg, 2018/03/23