Comments (6)
How did you come about in running in to this, do you run an elisp script to sync certain files without having the files themselves open?
Yes. I'm writing the code to generate and sync anki cards from part of my org files which have :ANKI:
tag automatically without user interaction. I, sometimes, forget to sync anki after editing bunch of my prompts following org-roam backlinks. I figure out batch ankifying is really useful if prompts are prepared already in the org files. You can see the test code is just simplyfing the error case. It's not real usecase.
I think I did manage to reproduce it by having test.org closed, then running the test code above from the M-: (eval-expression) minibuffer prompt.
Yes. Ensure the test file is closed and call the test code from scratch buffer or M-x <org-anki-sync-batch>(if you defined as an interactive function)
.
from org-anki.
I'm running into the same problem: even though calling org-anki-sync-entry
succeeds and the note is created in anki, no ANKI_NOTE_ID
property is created at the header.
I'm on emacs 29, org-mode 9.6-??-bed47b4
from org-anki.
After some digging, I found the cause of this issue is that org-anki
uses anki-connect
API request as asynchronous call. So, org-anki-sync-entry
can't org-set-property
in the buffer which is closed already.
@eyeinsky Is there any other way to solve this? emacs-request
provides :sync
keyword only. I feel buffer-local variable is a more reasonable option for this issue.
from org-anki.
I thought adding sync buffer-local variables fix this issue simply. But I found that org-anki
is using emacs-promise
as well as emacs-request
.
Actually buffer-name
is changed to *scratch*
from test.org
when then
clause of promise-chain is executed.
Lines 434 to 443 in dda524d
In addition, I found this chuntaro/emacs-promise#13
According to the above issue, The below with-current-buffer
clause has a same potential issue.
Lines 542 to 548 in dda524d
from org-anki.
How did you come about in running in to this, do you run an elisp script to sync certain files without having the files themselves open?
I think I did manage to reproduce it by having test.org closed, then running the test code above from the M-:
(eval-expression) minibuffer prompt.
from org-anki.
I managed to handle this. In order to solve this issue, it needs the synchronous emacs-promise
and the synchronous emacs-request
. sync request can be solved by #56. But emacs-promise side, it needs await
of the async-await
module.
async-await
doesn't block main thread. I think async-await
can be applied into org-anki
.
After applying #56, You can make an anki card using below code.
(require 'async-await)
(funcall (async-lambda ()
(with-current-buffer (find-file-noselect "~/test.org")
(org-mode)
(setq org-anki-sync-request t)
(save-excursion
(goto-char (point-max))
(await (org-anki-sync-entry)))
(save-buffer)
(kill-buffer))
(message "done")))
from org-anki.
Related Issues (20)
- how to add note with Cloze? HOT 8
- Can images be included in content? HOT 2
- Special symbols throw error using org-anki-sync-entry HOT 2
- Weird issue with org-anki-sync-entry HOT 2
- The template for Cloze should not be hardcoded in `org-anki--get-fields` HOT 1
- Feature: Convert links into cloze fields HOT 3
- Feature request : Using code blocks as fields HOT 2
- Cannot convert file-level headings HOT 5
- Multiline basic deck problem: Not enough arguments for format string HOT 2
- Use latex instead of mathjax for Anki cards HOT 2
- Create the "Customize" section of README automatically from `defcustom` and its comment
- Question: how to best update all anki-entries from all files in a subfolder HOT 3
- Importing a deck fails (wrong-type-argument stringp nil) HOT 3
- Feature: Seamless Card Movement Between Anki Decks Based On Heading's Location HOT 2
- Feature: add outline path as header to card HOT 1
- Controlling tag inheritance HOT 1
- Is it possible to do a heading without creating a card? HOT 10
- Syncing erases existing tags HOT 2
- Remove unresolved links and create flash card. HOT 2
- when add audio link, converting issue. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from org-anki.