From 4b4746dce42361be8d817da35e00f3668dfe7ed6 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 02:58:33 +0200 Subject: Refactor gnosis-export-note - Rewrite suboptimal code - Add export of ef & ff --- gnosis.el | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/gnosis.el b/gnosis.el index fb13b5c..cf2e6a3 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1250,33 +1250,16 @@ quotes. The final exported note is indented using the `indent-region' function to improve readability." - (let ((type (gnosis-get 'type 'notes `(= id ,id))) - (main (gnosis-get 'main 'notes `(= id ,id))) - (options (gnosis-get 'options 'notes `(= id ,id))) - (answer (gnosis-get 'answer 'notes `(= id ,id))) - (tags (gnosis-get 'tags 'notes `(= id ,id))) - (extra-notes (gnosis-get 'extra-notes 'extras `(= id ,id))) - (image (gnosis-get 'images 'extras `(= id ,id))) - (second-image (gnosis-get 'extra-image 'extras `(= id ,id)))) - (cl-loop for (field . value) in `((type . ,type) - (main . ,main) - (options . ,options) - (answer . ,answer) - (tags . ,tags) - (extra-notes . ,extra-notes) - (image . ,image) - (second-image . ,second-image)) - do (cond ((member field '(extra-notes image second-image)) - (insert (format ":%s \"%s\"\n" field value))) - ((numberp value) - (insert (format ":%s %s\n" field value))) - ((listp value) - (insert (format ":%s %s\n" field (format "%s" (cl-loop for item in value - collect (format "\"%s\"" item)))))) - ((equal value nil) - (insert (format ":%s %s\n" field 'nil))) - (t (insert (format ":%s \"%s\"\n" field value)) - (indent-region (point-min) (point-max))))))) + (let ((values (append (gnosis-select '[id main options answer tags] 'notes `(= id ,id) t) + (gnosis-select '[extra-notes images extra-image] 'extras `(= id ,id) t) + (gnosis-select '[ef ff] 'review `(= id ,id) t))) + (fields '(:id :main :options :answer :tags :extra-notes :image :second-image :ef :ff))) + (cl-loop for value in values + for field in fields + do (insert + (if (listp value) + (format "\n%s '%s" (symbol-name field) (prin1-to-string value)) + (format "\n%s %s" (symbol-name field) (prin1-to-string value))))))) (defun gnosis-export-deck (filename) "Export notes for deck in FILENAME. -- cgit v1.2.3 From 4045f9554d874083d6771647f18ec46eaee92ac1 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 02:59:54 +0200 Subject: Rewrite gnosis-edit-note Just export note & adjust values in gnosis-edit buffer. --- gnosis.el | 70 ++++++++------------------------------------------------------- 1 file changed, 9 insertions(+), 61 deletions(-) diff --git a/gnosis.el b/gnosis.el index cf2e6a3..62f19c4 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1091,31 +1091,6 @@ NOTES: List of note ids" ;; Editing notes (defun gnosis-edit-note (id) - "Edit note with value of id ID." - (pcase (funcall gnosis-completing-read-function "Edit: " '("contents" "ef") nil t) - ("contents" (gnosis-edit-note-contents id)) - ("ef" (gnosis-edit-ef id)) - (_ (message "No such value.")))) - -(defun gnosis-edit-ef (id) - "Edit easiness factor values for note with id value ID." - (let ((ef-full (caar (gnosis-select 'ef 'review `(= id ,id)))) - (old-value-index (pcase (funcall gnosis-completing-read-function "Change Factor: " - '("Increase" "Decrease" "Total")) - ("Total" 2) - ("Decrease" 1) - ("Increase" 0))) - (new-value (float (string-to-number (read-string "New value: "))))) - ;; error checking. - (cond ((>= 0 new-value) (error "New value needs to be a number & higher than `0'")) - ;; Check if when total-ef is selected, new value is higher than 1.3 - ((and (>= 1.3 new-value) (= old-value-index 2) (error "New total ef needs to be higher than `1.3'")))) - ;; Use `gnosis-replace-item-at-index' to generate new list with - ;; new ef value. Change ef value at gnosis-db using - ;; `gnosis-update' - (gnosis-update 'review `(= ef ',(gnosis-replace-item-at-index old-value-index new-value ef-full)) `(= id ,id)))) - -(defun gnosis-edit-note-contents (id) "Edit the contents of a note with the given ID. This function creates an Emacs Lisp buffer named *gnosis-edit* and populates it @@ -1138,42 +1113,15 @@ The note fields that will be shown in the buffer are: The buffer automatically indents the expressions for readability. After finishing editing, evaluate the entire expression to apply the changes." - (let ((id (gnosis-get 'id 'notes `(= id ,id))) - (main (gnosis-get 'main 'notes `(= id ,id))) - (options (gnosis-get 'options 'notes `(= id ,id))) - (answer (gnosis-get 'answer 'notes `(= id ,id))) - (tags (gnosis-get 'tags 'notes `(= id ,id))) - (extra-notes (gnosis-get 'extra-notes 'extras `(= id ,id))) - (image (gnosis-get 'images 'extras `(= id ,id))) - (second-image (gnosis-get 'extra-image 'extras `(= id ,id)))) - (with-current-buffer (switch-to-buffer (get-buffer-create "*gnosis-edit*")) - (gnosis-edit-mode) - (erase-buffer) - (insert ";;\n;; You are editing a gnosis note. DO NOT change the value of id.\n\n") - (insert "(gnosis-edit-update-note ") - (cl-loop for (field value) in `((id ,id) - (main ,main) - (options ,options) - (answer ,answer) - (tags ,tags) - (extra-notes ,extra-notes) - (image ,image) - (second-image ,second-image)) - do (cond ((eq field 'id) - (insert (format ":id %s \n" (propertize (number-to-string value) 'read-only t)))) - ((numberp value) - (insert (format ":%s %s\n" field value))) - ((and (listp value) - (not (equal value nil))) - (insert (format ":%s '%s\n" field (format "%s" (cl-loop for item in value - collect (format "\"%s\"" item)))))) - ((null value) - (insert (format ":%s %s\n" field 'nil))) - (t (insert (format ":%s \"%s\"\n" field value))))) - (delete-char -1) ;; delete extra line - (insert ")") - (insert "\n;; After finishing editing, save changes with ` '\n;; Do NOT exit without saving.") - (indent-region (point-min) (point-max))))) + (with-current-buffer (switch-to-buffer (get-buffer-create "*gnosis-edit*")) + (gnosis-edit-mode) + (erase-buffer) + (insert ";;\n;; You are editing a gnosis note. DO NOT change the value of id.\n\n") + (insert "(gnosis-edit-update-note ") + (gnosis-export-note id) + (insert ")") + (insert "\n\n;; After finishing editing, save changes with ` '\n;; Do NOT exit without saving.") + (indent-region (point-min) (point-max)))) (defun gnosis-edit-save-exit () "Save edits and exit." -- cgit v1.2.3 From e2b4fa8546567b185c625bf213a8c64f135780de Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 03:00:57 +0200 Subject: gnosis-update-note: Add ef & ff --- gnosis.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gnosis.el b/gnosis.el index 62f19c4..d982e04 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1141,7 +1141,8 @@ changes." :keymap gnosis-edit-mode-map) -(cl-defun gnosis-edit-update-note (&key id main options answer tags (extra-notes nil) (image nil) (second-image nil)) +(cl-defun gnosis-edit-update-note (&key id main options answer tags (extra-notes nil) (image nil) (second-image nil) + ef ff) "Update note with id value of ID. ID: Note id @@ -1161,10 +1162,14 @@ SECOND-IMAGE: Image to display after user-input" (tags . ,tags) (extra-notes . ,extra-notes) (image . ,image) - (second-image . ,second-image)) + (second-image . ,second-image) + (ef . ',ef) + (ff . ,ff)) when value do (cond ((memq field '(extra-notes image second-image)) (gnosis-update 'extras `(= ,field ,value) `(= id ,id))) + ((memq field '(ef ff)) + (gnosis-update 'review `(= ,field ,value) `(= id ,id))) ((listp value) (gnosis-update 'notes `(= ,field ',value) `(= id ,id))) (t (gnosis-update 'notes `(= ,field ,value) `(= id ,id)))))) -- cgit v1.2.3 From b7d99a6a06b27d0e21bf1e8dd7b87e326031f0b9 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 03:01:38 +0200 Subject: version: start 0.1.8-dev --- gnosis.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnosis.el b/gnosis.el index d982e04..c1fea1b 100644 --- a/gnosis.el +++ b/gnosis.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions ;; URL: https://thanosapollo.org/projects/gnosis -;; Version: 0.1.7 +;; Version: 0.1.8-dev ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2") (emacsql "20240124")) -- cgit v1.2.3 From 50a05e728f034d3fba22d9d1c318897e95f2c3e3 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:26:29 +0200 Subject: [fix] gnosis-display-mcq-options: hardcoded id --- gnosis.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnosis.el b/gnosis.el index c1fea1b..aac6840 100644 --- a/gnosis.el +++ b/gnosis.el @@ -224,7 +224,7 @@ Example: (defun gnosis-display-mcq-options (id) "Display answer options for mcq note ID." - (let ((options (apply #'append (gnosis-select 'options 'notes `(= id 1) t))) + (let ((options (apply #'append (gnosis-select 'options 'notes `(= id ,id) t))) (option-num 1)) (insert "\n\n" (propertize "Options:" 'face 'gnosis-face-directions)) (cl-loop for option in options -- cgit v1.2.3 From f5fa43148cd2f6f10a3064933aa41f9d7c3df144 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:26:55 +0200 Subject: gnosis-edit-save-exit: Exit recursive edit IF we are in one --- gnosis.el | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gnosis.el b/gnosis.el index aac6840..569c466 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1128,7 +1128,10 @@ changes." (interactive) (eval-buffer) (kill-buffer) - (exit-recursive-edit)) + ;; exit recursive edit if we are in one + (if (>= (recursion-depth) 1) + (exit-recursive-edit) + (gnosis-dashboard))) (defvar-keymap gnosis-edit-mode-map :doc "gnosis-edit keymap" -- cgit v1.2.3 From 6f23150a8c7c4a67adbf1d67f6f4ec9ddd4c98f0 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:27:36 +0200 Subject: gnosis-edit-update-note: Add ef ff suspend values --- gnosis.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gnosis.el b/gnosis.el index 569c466..67f2e6b 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1143,9 +1143,8 @@ changes." :lighter " Gnosis Edit" :keymap gnosis-edit-mode-map) - (cl-defun gnosis-edit-update-note (&key id main options answer tags (extra-notes nil) (image nil) (second-image nil) - ef ff) + ef ff suspend) "Update note with id value of ID. ID: Note id @@ -1167,12 +1166,15 @@ SECOND-IMAGE: Image to display after user-input" (image . ,image) (second-image . ,second-image) (ef . ',ef) - (ff . ,ff)) + (ff . ,ff) + (suspend . ,suspend)) when value do (cond ((memq field '(extra-notes image second-image)) (gnosis-update 'extras `(= ,field ,value) `(= id ,id))) ((memq field '(ef ff)) (gnosis-update 'review `(= ,field ,value) `(= id ,id))) + ((eq field 'suspend) + (gnosis-update 'review-log `(= ,field ,value) `(= id ,id))) ((listp value) (gnosis-update 'notes `(= ,field ',value) `(= id ,id))) (t (gnosis-update 'notes `(= ,field ,value) `(= id ,id)))))) -- cgit v1.2.3 From f94b733e3381c499073708f711e743ceffbb9bd5 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:28:02 +0200 Subject: [fix] gnosis-get-notes-for-deck Deprecated use of gnosis-select --- gnosis.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnosis.el b/gnosis.el index 67f2e6b..6385e1a 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1181,9 +1181,9 @@ SECOND-IMAGE: Image to display after user-input" (cl-defun gnosis-get-notes-for-deck (&optional (deck (gnosis--get-deck-id))) "Return a list of ID vlaues for each note with value of deck-id DECK." - (gnosis-select 'id 'notes `(= deck-id ,deck) '1=1 t)) + (gnosis-select 'id 'notes `(= deck-id ,deck) t)) -(defun gnosis-export-note (id) +(cl-defun gnosis-export-note (id &optional (export-for-deck nil)) "Export fields for note with value of id ID. ID: Identifier of the note to export. -- cgit v1.2.3 From f7c73b592069072d70cebdeac22ad7e0a9608b2f Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:28:54 +0200 Subject: gnosis-export-note: Rewrite cleanly & with review-log --- gnosis.el | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/gnosis.el b/gnosis.el index 6385e1a..538b4e6 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1210,18 +1210,26 @@ The final exported note is indented using the `indent-region' function to improve readability." (let ((values (append (gnosis-select '[id main options answer tags] 'notes `(= id ,id) t) (gnosis-select '[extra-notes images extra-image] 'extras `(= id ,id) t) - (gnosis-select '[ef ff] 'review `(= id ,id) t))) - (fields '(:id :main :options :answer :tags :extra-notes :image :second-image :ef :ff))) + (gnosis-select '[ef ff] 'review `(= id ,id) t) + (gnosis-select 'suspend 'review-log `(= id ,id) t))) + (fields '(:id :main :options :answer :tags :extra-notes :image :second-image :ef :ff :suspend))) + (when export-for-deck + (setf values (append (gnosis-select 'type 'notes `(= id ,id) t) + (butlast (cdr values) 3))) + (setf fields (append '(:type) (butlast (cdr fields) 3)))) (cl-loop for value in values for field in fields do (insert - (if (listp value) - (format "\n%s '%s" (symbol-name field) (prin1-to-string value)) - (format "\n%s %s" (symbol-name field) (prin1-to-string value))))))) + (cond ((listp value) + (format "\n%s '%s" (symbol-name field) (prin1-to-string value))) + (t (format "\n%s %s" (symbol-name field) (prin1-to-string value)))))))) -(defun gnosis-export-deck (filename) +;; TODO: Fix export of deck! +(defun gnosis-export-deck (deck export-deck-name filename) "Export notes for deck in FILENAME. +WARNING: This function is not yet implemented. + FILENAME: The name of the file to save the exported deck. This function prompts the user to provide a deck name and allows the -- cgit v1.2.3 From 6f05efdcc861d8d3a0ef374ceafe91f735da10cf Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:29:53 +0200 Subject: Add gnosis-dashboard-output-note --- gnosis.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnosis.el b/gnosis.el index 538b4e6..1ef8b0b 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1357,6 +1357,16 @@ review." (:foreign-key [id] :references notes [id] :on-delete :cascade))) +;; Dashboard +(defun gnosis-dashboard-output-note (id) + "Output note contents formatted for gnosis dashboard." + (cl-loop for item in (append (gnosis-select '[main options answer tags] 'notes `(= id ,id) t) + (gnosis-select 'suspend 'review-log `(= id ,id) t)) + if (listp item) + collect (mapconcat #'identity item ", ") + else + collect (prin1-to-string item))) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From de2068a23f6f60e48311b15e6829080b87aaaf9b Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:30:05 +0200 Subject: Add gnosis-dashboard-output-notes --- gnosis.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnosis.el b/gnosis.el index 1ef8b0b..006b4c2 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1367,6 +1367,12 @@ review." else collect (prin1-to-string item))) +(defun gnosis-dashboard-output-notes () + "Return note contents for gnosis dashboard." + (let ((max-id (apply 'max (gnosis-select 'id 'notes '1=1 t)))) + (cl-loop for id from 1 to max-id collect + (list (number-to-string id) (vconcat (gnosis-dashboard-output-note id)))))) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From e0054062ef219634c7944c09db8cd138584e380c Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:30:55 +0200 Subject: Add gnosis-dashboard-edit-note --- gnosis.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gnosis.el b/gnosis.el index 006b4c2..b20c5e5 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1373,6 +1373,13 @@ review." (cl-loop for id from 1 to max-id collect (list (number-to-string id) (vconcat (gnosis-dashboard-output-note id)))))) +(defun gnosis-dashboard-edit-note () + "Get note id from tabulated list and edit it." + (interactive) + (let ((id (tabulated-list-get-id))) + (gnosis-edit-note (string-to-number id)) + (message "Editing note with id: %s" id))) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From 683338fa26add3f60ae3fac579292aeed68e7f80 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:31:04 +0200 Subject: Add gnosis-dashboard-mode-map --- gnosis.el | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gnosis.el b/gnosis.el index b20c5e5..0770976 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1380,6 +1380,11 @@ review." (gnosis-edit-note (string-to-number id)) (message "Editing note with id: %s" id))) +(defvar-keymap gnosis-dashboard-mode-map + :doc "gnosis-dashboard keymap" + "e" #'gnosis-dashboard-edit-note + "q" #'quit-window) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From 3b422a8573bd53cca74387ac79851a2022c2e748 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:31:16 +0200 Subject: Add gnosis-dashboard-mode --- gnosis.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gnosis.el b/gnosis.el index 0770976..9337848 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1385,6 +1385,20 @@ review." "e" #'gnosis-dashboard-edit-note "q" #'quit-window) +(define-derived-mode gnosis-dashboard-mode tabulated-list-mode "Gnosis Dashboard" + "Major mode for displaying Gnosis dashboard." + :keymap gnosis-dashboard-mode-map + (interactive) + (display-line-numbers-mode 0) + (setq tabulated-list-format [("Main" 30 t) + ("Options" 20 t) + ("Answer" 25 t) + ("Tags" 25 t) + ("Suspend" 5 t)]) + (setq tabulated-list-padding 2 + tabulated-list-sort-key nil) + (tabulated-list-init-header)) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From 730804a41aac213b6d438b56e47699e799b73161 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:31:27 +0200 Subject: Add gnosis-dashboard --- gnosis.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnosis.el b/gnosis.el index 9337848..b2a276f 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1399,6 +1399,16 @@ review." tabulated-list-sort-key nil) (tabulated-list-init-header)) +;;;###autoload +(defun gnosis-dashboard () + "Display gnosis dashboard." + (interactive) + (pop-to-buffer "*gnosis-dashboard*" nil) + (gnosis-dashboard-mode) + (setq tabulated-list-entries + (gnosis-dashboard-output-notes)) + (tabulated-list-print t)) + (defun gnosis-db-init () "Create gnosis essential directories & database." (unless (length= (emacsql gnosis-db [:select name :from sqlite-master :where (= type table)]) 6) -- cgit v1.2.3 From ed29a6c0e57496b34dbfd0264ae0f0b1926e5d9d Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:35:43 +0200 Subject: Add TODO.org Move task list to TODO.org from CONTRIBUTING --- CONTRIBUTING.org | 33 --------------------------------- TODO.org | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 33 deletions(-) create mode 100644 TODO.org diff --git a/CONTRIBUTING.org b/CONTRIBUTING.org index eda1a7e..6b617a1 100644 --- a/CONTRIBUTING.org +++ b/CONTRIBUTING.org @@ -22,36 +22,3 @@ $ git format-patch HEAD^1 #+end_src /You can find my email on the git log/ - - -* Tasks -** TODO Add Dashboard -+ Create a dashboard to view all notes created, user can edit & - suspend notes. Use tabulated-list-mode, preferably. - -** TODO Algorithm: changes for ef increase/decrease factors -+ After 3 successful in a row reviews increase ef increase factor by 5% & vice versa - -** DONE Refactor =completing-read= UI choices -CLOSED: [2024-02-17 Sat 21:59] -/DONE on version 0.1.7/ - -=completing-read= is not an ideal solution as a UI. If user has not -enabled a completion system, such as vertico, this would make gnosis -unusable. - -One possible solution is to create defcustom =gnosis-completing-read-function= -that has ido-completing-read by default if vertico/ivy/helm is not -enabled - -*** Fix - -Implemented =gnosis-completing-read-function= - -** DONE Use vc instead git shell commands -CLOSED: [2024-02-17 Sat 21:59] - -/DONE on version 0.1.7/ - -Implemented =gnosis-git-*= functions to handle git commands. - diff --git a/TODO.org b/TODO.org new file mode 100644 index 0000000..1cc3771 --- /dev/null +++ b/TODO.org @@ -0,0 +1,44 @@ +#+title: TODO's for Gnosis +#+author: Thanos Apollo + +* Gnosis TODO's + +** DONE Add Dashboard +CLOSED: [2024-02-20 Tue 13:33] ++ Create a dashboard to view all notes created, user can edit & + suspend notes. Use tabulated-list-mode, preferably. +*** Notes after completion ++ Dashboard added using tabulated-list-mode. Performance is not ideal + when 20K > notes, values should be cached + +** TODO Dashboard: Improve Performance +** TODO Dashboard: Add filtering/search + +** TODO Algorithm: changes for ef increase/decrease factors ++ After 3 successful in a row reviews increase ef increase factor by 5% & vice versa + + +** DONE Refactor =completing-read= UI choices +CLOSED: [2024-02-17 Sat 21:59] +/DONE on version 0.1.7/ + +=completing-read= is not an ideal solution as a UI. If user has not +enabled a completion system, such as vertico, this would make gnosis +unusable. + +One possible solution is to create defcustom =gnosis-completing-read-function= +that has ido-completing-read by default if vertico/ivy/helm is not +enabled + +*** Notes + +Implemented =gnosis-completing-read-function= + + +** DONE Use vc instead git shell commands +CLOSED: [2024-02-17 Sat 21:59] + +/DONE on version 0.1.7/ + +Implemented =gnosis-git-*= functions to handle git commands. + -- cgit v1.2.3 From a1a5ac2558a0edb9def2862bee4f6526c7fa173c Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Tue, 20 Feb 2024 13:54:25 +0200 Subject: version bump: 0.1.8 --- gnosis.el | 77 ++++++++++++++++++++++----------------------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/gnosis.el b/gnosis.el index b2a276f..a04bdec 100644 --- a/gnosis.el +++ b/gnosis.el @@ -5,7 +5,7 @@ ;; Author: Thanos Apollo ;; Keywords: extensions ;; URL: https://thanosapollo.org/projects/gnosis -;; Version: 0.1.8-dev +;; Version: 0.1.8 ;; Package-Requires: ((emacs "27.2") (compat "29.1.4.2") (emacsql "20240124")) @@ -1245,61 +1245,38 @@ resulting code is saved to a file with the provided FILENAME and a Each note is exported using the `gnosis-export-note` function. The generated code includes a call to `gnosis-define-deck` with the deck name and all notes formatted as nested lists" - (interactive (list (read-string "Filename: "))) - (let ((notes (gnosis-get-notes-for-deck)) - (deck-name (read-string "Export deck as (name): "))) - (with-temp-file (concat filename ".el") - (insert "(gnosis-define-deck " "'" deck-name " '(") - (cl-loop for note in notes - do (insert "(") (gnosis-export-note note) (insert ")" "\n") - finally (insert "))"))))) + ;; (interactive (list (gnosis-get-notes-for-deck) + ;; (read-string "Export deck as (name): ") + ;; (read-string "Filename: "))) + (with-temp-file (concat filename ".el") + (insert "(gnosis-define-deck " "'" export-deck-name " '(") + (cl-loop for note in deck + do (insert "(") (gnosis-export-note note t) (insert ")" "\n") + finally (insert "))")))) ;; TODO: Add defcustom to have suspended as 0 or 1 depending on ;; gnosis-add-decks-suspended t or nil (cl-defun gnosis-define-deck (deck notes &optional (suspended 0)) - "Define DECK consisting of NOTES, optionally add them as SUSPENDED. - -The `gnosis-define-deck` function adds a new deck with the specified -name to `gnosis-db'. It also adds each note from the given list -of `notes` to the deck. The function takes three optional arguments: -`deck`, `notes`, and `suspended`. - -- `deck`: The name of the deck to be added. It should be provided as a - symbol. - -- `notes`: A list containing the notes to be added to the deck. Each - note should be represented as a property list with the - following keys: `:type`, `:main`, `:options`, `:answer` - -- extras include :`:extra-notes`, `:tags`, `:image`, and `:second-image`. - -- `suspended`: An optional argument specifying whether the deck should - be created in a suspended state. A non-zero value - suspends the deck, while a value of 0 (default) creates - the deck in an active state. - -When calling `gnosis-define-deck`, the deck is added to the Gnosis -system by calling `gnosis-add-deck`. Each note is added to the deck -using `gnosis-add-note-fields`. The function iterates over the list of -`notes` and extracts the necessary fields from each note's property -list before adding them to the deck. - -The purpose of this function is to create a full deck with its -associated notes in `gnosis-db', ready for further processing or -review." + "Define DECK consisting of NOTES, optionally add them as SUSPENDED." (gnosis-add-deck (symbol-name deck)) - (sit-for 0.1) ;; + (sit-for 0.1) (cl-loop for note in notes - do (gnosis-add-note-fields (symbol-name deck) - (plist-get note :type) - (plist-get note :main) - (plist-get note :options) - (plist-get note :answer) - (plist-get note :extra-notes) - (plist-get note :tags) - suspended - (plist-get note :image) - (plist-get note :second-image)))) + do (let ((type (plist-get note :type)) + (main (plist-get note :main)) + (options (plist-get note :options)) + (answer (plist-get note :answer)) + (extra-notes (plist-get note :extra-notes)) + (tags (plist-get note :tags)) + (suspend (plist-get note :suspend)) + (image (plist-get note :image)) + (second-image (plist-get note :second-image))) + (gnosis-add-note-fields deck type main options answer extra-notes tags suspend image second-image)) + collect note)) + +;; Rewrite this similarly to gnosis +(cl-defun gnosis-define-deck--note (&keys deck type main options answer extra-notes tags image second-image) + "Define a note for DECK." + (gnosis-add-note-fields deck type main options answer extra-notes tags 0 image second-image)) ;;;###autoload -- cgit v1.2.3