From 2486661ba86dd02d3abe4dc7f92ab68b84602c86 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 11 Apr 2024 09:47:58 +0300 Subject: gnosis-display-next-review: Adjust for overrides --- gnosis.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'gnosis.el') diff --git a/gnosis.el b/gnosis.el index a29ca1f..3890ac5 100644 --- a/gnosis.el +++ b/gnosis.el @@ -418,12 +418,19 @@ Also see `gnosis-string-edit'." (defun gnosis-display-next-review (id success) "Display next interval of note ID for SUCCESS." - (let ((interval (car (gnosis-review-algorithm id success)))) - (goto-char (point-max)) - (insert "\n\n" - (propertize "Next review:" 'face 'gnosis-face-directions) - " " - (propertize (format "%s" interval) 'face 'gnosis-face-next-review)))) + (let* ((interval (car (gnosis-review-algorithm id success))) + (next-review-msg (format "\n\n%s %s" + (propertize "Next review:" 'face 'gnosis-face-directions) + (propertize (format "%s" interval) 'face 'gnosis-face-next-review)))) + (if (search-backward "Next review" nil t) + ;; Delete previous result, and override with new this should + ;; occur only when used with `gnosis-review-override' + (progn (delete-region (point) (progn (end-of-line) (point))) + (insert (propertize (replace-regexp-in-string "\n" "" next-review-msg) + 'face (if success 'gnosis-face-correct 'gnosis-face-false)))) + ;; Default behaviour + (goto-char (point-max)) + (insert next-review-msg)))) (cl-defun gnosis--prompt (prompt &optional (downcase nil) (split nil)) "PROMPT user for input until `q' is given. -- cgit v1.2.3