Skip to content

Commit

Permalink
fix eyeinsky#55 by changing to the org buffer at first.
Browse files Browse the repository at this point in the history
  • Loading branch information
whatacold committed Sep 10, 2023
1 parent ddc9af1 commit 8cb7e69
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions org-anki.el
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,6 @@ with result."
:type type
:marker (point-marker))))

;; TODO how to delete markers properly?
(defun org-anki--delete-markers (notes)
"Delete the markers held by NOTES."
(-map (lambda (note)
(when (org-anki--note-marker note)
(set-marker (org-anki--note-marker note) nil)))
notes))

(defun org-anki--get-fields (type)
"Get note field values from entry at point."

Expand Down Expand Up @@ -477,9 +469,11 @@ be removed from the Anki app, return actions that do that."
(cond
;; added note
((equal "addNote" action-value)
(save-excursion
(goto-char (org-anki--note-marker note))
(org-set-property org-anki-prop-note-id (number-to-string result))))
(with-current-buffer (or (marker-buffer (org-anki--note-marker note))
(current-buffer))
(save-excursion
(goto-char (org-anki--note-marker note))
(org-set-property org-anki-prop-note-id (number-to-string result)))))
;; update note: do nothing but message success
((equal "updateNoteFields" action-value)
(org-anki--report
Expand Down Expand Up @@ -596,9 +590,11 @@ be removed from the Anki app, return actions that do that."
(lambda (_)
(-map
(lambda (note)
(save-excursion
(goto-char (org-anki--note-marker note))
(org-delete-property org-anki-prop-note-id)))
(with-current-buffer (or (marker-buffer (org-anki--note-marker note))
(current-buffer))
(save-excursion
(goto-char (org-anki--note-marker note))
(org-delete-property org-anki-prop-note-id))))
(reverse notes))
)
(lambda (the-error)
Expand Down

0 comments on commit 8cb7e69

Please sign in to comment.