Use own persistency file instead of savehist mode.

#2 Declined
  1. juergenhoetzel
No description

Comments (2)

  1. Paul Sexton repo owner

    I appreciate the effort you've put in here, but I'm not keen on recapitulating savehist-mode inside org-gamify. A bespoke persistence mechanism is really outside its scope.

    Emacs needs a better solution for persistent variables. Savehist-mode provides most of the necessary functionality but it doesn't handle some corner cases such as your need to finely control which variables get saved where. Can I suggest that you consider submitting a patch to savehist that allows the user to specify that certain variables 'live' in particular files. This would both solve your problem and make savehist a more useful general persistence facility for Emacs.

  2. juergenhoetzel author

    IMHO savehist shouln't be used as generic persistence library.

    But there is no generic persistence functionality in emacs also. So every emacs mode comes with its own persitence functionality: org-clock, tetris, tramp-cache...

    But I found a nice workaround for my problem. I use the savehist-save-hook, to save the inventory to an additional file which i also load on startup:

    (defvar org-gamify-persistency-file-name "~/shared/org/org-gamify-persist.el")
    (require 'savehist)
    (add-hook 'savehist-save-hook
          (lambda ()
            (let ((file-precious-flag t)
              (coding-system-for-write 'no-conversion))
              (with-temp-file org-gamify-persistency-file-name
            (insert ";; -*- mode: emacs-lisp -*-\n")
            (insert ";; org-gameify inventory file \n\n")
            (let ((print-length nil)
                  (print-string-length nil)
                  (print-level nil)
                  (print-readably t)
                  (print-quoted t))
              (dolist (symbol '(org-gamify-currencies org-gamify-inventory org-gamify-last-update-day))
                (when (boundp symbol)
                  (let ((value (symbol-value symbol)))
                (prin1 `(setq ,symbol ',value) (current-buffer))))))))))
    (load org-gamify-persistency-file-name t  nil t)

    So you can close this Pull request. There is no need to reinvent the wheel again ;-)