Add Version header, docs, generics
This commit is contained in:
parent
0d9b833858
commit
6a9af94b7a
1 changed files with 12 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
;; Author: Tom Willemse <tom@ryuslash.org>
|
;; Author: Tom Willemse <tom@ryuslash.org>
|
||||||
;; Keywords: convenience, outlines
|
;; Keywords: convenience, outlines
|
||||||
|
;; Version: 0.1.0
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or modify
|
;; This program is free software; you can redistribute it and/or modify
|
||||||
;; it under the terms of the GNU General Public License as published by
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -47,8 +48,11 @@
|
||||||
:group 'persistent-outline
|
:group 'persistent-outline
|
||||||
:type 'directory)
|
:type 'directory)
|
||||||
|
|
||||||
(defclass perso-file-local-storage () ())
|
(defclass perso-file-local-storage () ()
|
||||||
(defclass perso-filesystem-storage () ())
|
:documentation
|
||||||
|
"A storage back-end that saves the state in a file-local variable.")
|
||||||
|
(defclass perso-filesystem-storage () ()
|
||||||
|
"A storage back-end that saves the state in a dedicated file.")
|
||||||
|
|
||||||
(defvar perso-outline)
|
(defvar perso-outline)
|
||||||
|
|
||||||
|
@ -134,6 +138,9 @@ functions for creating backup and autosave filenames."
|
||||||
(unless (file-exists-p directory)
|
(unless (file-exists-p directory)
|
||||||
(make-directory directory :parents))))
|
(make-directory directory :parents))))
|
||||||
|
|
||||||
|
(defgeneric perso-save-to-storage (storage outline)
|
||||||
|
"Tell the storage back-end to save the current outline state.")
|
||||||
|
|
||||||
(defmethod perso-save-to-storage ((storage perso-file-local-storage)
|
(defmethod perso-save-to-storage ((storage perso-file-local-storage)
|
||||||
outline)
|
outline)
|
||||||
"Save the current states to a file-local variable."
|
"Save the current states to a file-local variable."
|
||||||
|
@ -150,6 +157,9 @@ functions for creating backup and autosave filenames."
|
||||||
(print outline (current-buffer))
|
(print outline (current-buffer))
|
||||||
(write-file filename))))
|
(write-file filename))))
|
||||||
|
|
||||||
|
(defgeneric perso-load-from-storage (storage)
|
||||||
|
"Tell the storage back-end to load the saved outline state.")
|
||||||
|
|
||||||
(defmethod perso-load-from-storage ((storage perso-file-local-storage))
|
(defmethod perso-load-from-storage ((storage perso-file-local-storage))
|
||||||
"Load saved states from a file-local variable."
|
"Load saved states from a file-local variable."
|
||||||
(when (boundp (make-local-variable 'perso-outline))
|
(when (boundp (make-local-variable 'perso-outline))
|
||||||
|
|
Loading…
Reference in a new issue