Add package prefix to accessors
This commit is contained in:
parent
da1f2ed329
commit
78048824e5
|
@ -5,6 +5,7 @@
|
|||
;; makes all aliases not take effect - probably specific to Org
|
||||
;; literate programs
|
||||
((nil . ((nameless-aliases . (("c" . "chronometrist")
|
||||
("cb" . "chronometrist-backend")
|
||||
("cc" . "chronometrist-common")
|
||||
("cd" . "chronometrist-details")
|
||||
("ce" . "chronometrist-events")
|
||||
|
|
|
@ -332,25 +332,25 @@ The list must be on a single line, as emitted by `prin1'."
|
|||
(defclass chronometrist-backend ()
|
||||
((path ;; :initform (error "Path is required")
|
||||
:initarg :path
|
||||
:accessor path
|
||||
:accessor chronometrist-backend-path
|
||||
:custom 'string
|
||||
:documentation
|
||||
"Path to backend file, without extension.")
|
||||
(extension ;; :initform (error "Extension is required")
|
||||
:initarg :ext
|
||||
:accessor ext
|
||||
:accessor chronometrist-backend-ext
|
||||
:custom 'string
|
||||
:documentation
|
||||
"Extension of backend file.")
|
||||
(file :initarg :file
|
||||
:accessor file
|
||||
:accessor chronometrist-backend-file
|
||||
:custom 'string
|
||||
:documentation "Full path to backend file, with extension.")))
|
||||
|
||||
(cl-defmethod initialize-instance :after ((backend chronometrist-backend) &rest initargs)
|
||||
(when (and (path backend) (ext backend) (not (file backend)))
|
||||
(setf (file backend)
|
||||
(concat (path backend) "." (ext backend)))))
|
||||
(when (and (chronometrist-backend-path backend) (chronometrist-backend-ext backend) (not (chronometrist-backend-file backend)))
|
||||
(setf (chronometrist-backend-file backend)
|
||||
(concat (chronometrist-backend-path backend) "." (chronometrist-backend-ext backend)))))
|
||||
|
||||
(defvar chronometrist-backends-alist nil
|
||||
"Alist of Chronometrist backends.
|
||||
|
@ -465,11 +465,11 @@ EXPR is bound to each s-expression."
|
|||
,@loop-clauses)))
|
||||
|
||||
(cl-defmethod chronometrist-edit-file ((backend chronometrist-plist-backend))
|
||||
(find-file-other-window (file backend))
|
||||
(find-file-other-window (chronometrist-backend-file backend))
|
||||
(goto-char (point-max)))
|
||||
|
||||
(cl-defmethod chronometrist-count-records ((backend chronometrist-plist-backend))
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-min))
|
||||
(cl-loop with count = 0
|
||||
while (ignore-errors (read (current-buffer)))
|
||||
|
@ -477,7 +477,7 @@ EXPR is bound to each s-expression."
|
|||
finally return count)))
|
||||
|
||||
(cl-defmethod chronometrist-latest-record ((backend chronometrist-plist-backend))
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
(backward-list)
|
||||
(ignore-errors (read (current-buffer)))))
|
||||
|
@ -495,7 +495,7 @@ The data is acquired from `chronometrist-file'.
|
|||
|
||||
Return final number of events read from file, or nil if there
|
||||
were none."
|
||||
(chronometrist-sexp-in-file (file (chronometrist-active-backend))
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file (chronometrist-active-backend))
|
||||
(goto-char (point-min))
|
||||
(let ((index 0) expr pending-expr)
|
||||
(while (or pending-expr
|
||||
|
@ -522,7 +522,7 @@ were none."
|
|||
(unless (zerop index) index))))
|
||||
|
||||
(cl-defmethod chronometrist-create-file ((backend chronometrist-plist-backend))
|
||||
(let ((file (file backend)))
|
||||
(let ((file (chronometrist-backend-file backend)))
|
||||
(unless (file-exists-p file)
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(goto-char (point-min))
|
||||
|
@ -531,7 +531,7 @@ were none."
|
|||
|
||||
(cl-defmethod chronometrist-insert ((backend chronometrist-plist-backend) plist)
|
||||
"Add new PLIST at the end of `chronometrist-file'."
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
;; If we're adding the first s-exp in the file, don't add a
|
||||
;; newline before it
|
||||
|
@ -542,7 +542,7 @@ were none."
|
|||
|
||||
(cl-defmethod chronometrist-replace-last ((backend chronometrist-plist-backend) plist)
|
||||
"Replace the last s-expression in `chronometrist-file' with PLIST."
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
(unless (and (bobp) (bolp)) (insert "\n"))
|
||||
(backward-list 1)
|
||||
|
@ -566,13 +566,13 @@ This is meant to be run in `chronometrist-file' when using the s-expression back
|
|||
(unless (eobp) (insert "\n")))))
|
||||
|
||||
(cl-defmethod chronometrist-list-tasks ((backend chronometrist-plist-backend) &key start end)
|
||||
(--> (chronometrist-loop-file for plist in (file backend)
|
||||
(--> (chronometrist-loop-file for plist in (chronometrist-backend-file backend)
|
||||
collect (plist-get plist :name))
|
||||
(cl-remove-duplicates it :test #'equal)
|
||||
(sort it #'string-lessp)))
|
||||
|
||||
(cl-defmethod chronometrist-list-records ((backend chronometrist-plist-backend))
|
||||
(chronometrist-loop-file for plist in (file backend) collect plist))
|
||||
(chronometrist-loop-file for plist in (chronometrist-backend-file backend) collect plist))
|
||||
|
||||
(defvar chronometrist--file-state nil
|
||||
"List containing the state of `chronometrist-file'.
|
||||
|
|
|
@ -886,18 +886,18 @@ The list must be on a single line, as emitted by `prin1'."
|
|||
(defclass chronometrist-backend ()
|
||||
((path ;; :initform (error "Path is required")
|
||||
:initarg :path
|
||||
:accessor path
|
||||
:accessor chronometrist-backend-path
|
||||
:custom 'string
|
||||
:documentation
|
||||
"Path to backend file, without extension.")
|
||||
(extension ;; :initform (error "Extension is required")
|
||||
:initarg :ext
|
||||
:accessor ext
|
||||
:accessor chronometrist-backend-ext
|
||||
:custom 'string
|
||||
:documentation
|
||||
"Extension of backend file.")
|
||||
(file :initarg :file
|
||||
:accessor file
|
||||
:accessor chronometrist-backend-file
|
||||
:custom 'string
|
||||
:documentation "Full path to backend file, with extension.")))
|
||||
#+END_SRC
|
||||
|
@ -906,9 +906,9 @@ The list must be on a single line, as emitted by `prin1'."
|
|||
Initialize FILE based on PATH and EXTENSION.
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod initialize-instance :after ((backend chronometrist-backend) &rest initargs)
|
||||
(when (and (path backend) (ext backend) (not (file backend)))
|
||||
(setf (file backend)
|
||||
(concat (path backend) "." (ext backend)))))
|
||||
(when (and (chronometrist-backend-path backend) (chronometrist-backend-ext backend) (not (chronometrist-backend-file backend)))
|
||||
(setf (chronometrist-backend-file backend)
|
||||
(concat (chronometrist-backend-path backend) "." (chronometrist-backend-ext backend)))))
|
||||
#+END_SRC
|
||||
|
||||
**** backends-alist :variable:
|
||||
|
@ -1190,13 +1190,13 @@ EXPR is bound to each s-expression."
|
|||
**** edit-file :method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-edit-file ((backend chronometrist-plist-backend))
|
||||
(find-file-other-window (file backend))
|
||||
(find-file-other-window (chronometrist-backend-file backend))
|
||||
(goto-char (point-max)))
|
||||
#+END_SRC
|
||||
**** count-records :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-count-records ((backend chronometrist-plist-backend))
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-min))
|
||||
(cl-loop with count = 0
|
||||
while (ignore-errors (read (current-buffer)))
|
||||
|
@ -1207,7 +1207,7 @@ EXPR is bound to each s-expression."
|
|||
**** latest-record :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-latest-record ((backend chronometrist-plist-backend))
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
(backward-list)
|
||||
(ignore-errors (read (current-buffer)))))
|
||||
|
@ -1229,7 +1229,7 @@ The data is acquired from `chronometrist-file'.
|
|||
|
||||
Return final number of events read from file, or nil if there
|
||||
were none."
|
||||
(chronometrist-sexp-in-file (file (chronometrist-active-backend))
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file (chronometrist-active-backend))
|
||||
(goto-char (point-min))
|
||||
(let ((index 0) expr pending-expr)
|
||||
(while (or pending-expr
|
||||
|
@ -1258,7 +1258,7 @@ were none."
|
|||
**** create-file :writer:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-create-file ((backend chronometrist-plist-backend))
|
||||
(let ((file (file backend)))
|
||||
(let ((file (chronometrist-backend-file backend)))
|
||||
(unless (file-exists-p file)
|
||||
(with-current-buffer (find-file-noselect file)
|
||||
(goto-char (point-min))
|
||||
|
@ -1269,7 +1269,7 @@ were none."
|
|||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-insert ((backend chronometrist-plist-backend) plist)
|
||||
"Add new PLIST at the end of `chronometrist-file'."
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
;; If we're adding the first s-exp in the file, don't add a
|
||||
;; newline before it
|
||||
|
@ -1282,7 +1282,7 @@ were none."
|
|||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-replace-last ((backend chronometrist-plist-backend) plist)
|
||||
"Replace the last s-expression in `chronometrist-file' with PLIST."
|
||||
(chronometrist-sexp-in-file (file backend)
|
||||
(chronometrist-sexp-in-file (chronometrist-backend-file backend)
|
||||
(goto-char (point-max))
|
||||
(unless (and (bobp) (bolp)) (insert "\n"))
|
||||
(backward-list 1)
|
||||
|
@ -1311,7 +1311,7 @@ This is meant to be run in `chronometrist-file' when using the s-expression back
|
|||
**** list-tasks :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-list-tasks ((backend chronometrist-plist-backend) &key start end)
|
||||
(--> (chronometrist-loop-file for plist in (file backend)
|
||||
(--> (chronometrist-loop-file for plist in (chronometrist-backend-file backend)
|
||||
collect (plist-get plist :name))
|
||||
(cl-remove-duplicates it :test #'equal)
|
||||
(sort it #'string-lessp)))
|
||||
|
@ -1326,7 +1326,7 @@ This is meant to be run in `chronometrist-file' when using the s-expression back
|
|||
**** list-records :reader:method:
|
||||
#+BEGIN_SRC emacs-lisp
|
||||
(cl-defmethod chronometrist-list-records ((backend chronometrist-plist-backend))
|
||||
(chronometrist-loop-file for plist in (file backend) collect plist))
|
||||
(chronometrist-loop-file for plist in (chronometrist-backend-file backend) collect plist))
|
||||
#+END_SRC
|
||||
**** file-state :internal:variable:
|
||||
:PROPERTIES:
|
||||
|
@ -1468,7 +1468,7 @@ Return
|
|||
#+BEGIN_SRC emacs-lisp :tangle chronometrist-tests.el :load test
|
||||
(ert-deftest chronometrist-file-change-type ()
|
||||
(let* ((test-contents (with-current-buffer (find-file-noselect
|
||||
(file chronometrist-plist-test-backend))
|
||||
(chronometrist-backend-file chronometrist-plist-test-backend))
|
||||
(buffer-substring (point-min) (point-max))))
|
||||
(chronometrist--file-state-old chronometrist--file-state)
|
||||
(chronometrist--file-state (list :last (chronometrist-file-hash :before-last nil)
|
||||
|
@ -1517,7 +1517,7 @@ Return
|
|||
(save-buffer))
|
||||
(chronometrist-tests--change-type-and-update chronometrist--file-state)))))
|
||||
(with-current-buffer
|
||||
(find-file-noselect (file chronometrist-plist-test-backend))
|
||||
(find-file-noselect (chronometrist-backend-file chronometrist-plist-test-backend))
|
||||
(delete-region (point-min) (point-max))
|
||||
(insert test-contents)
|
||||
(save-buffer))
|
||||
|
@ -3700,5 +3700,5 @@ be a hash table similar to `chronometrist-events'."
|
|||
|
||||
** Local variables :NOEXPORT:
|
||||
# Local Variables:
|
||||
# nameless-current-name: "chronometrist"
|
||||
# nameless-aliases: (("cb" . "chronometrist-backend") ("c" . "chronometrist"))
|
||||
# End:
|
||||
|
|
Reference in New Issue