[Top][All Lists]

[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 <> 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)
    :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.


reply via email to

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