Add a command to upgrade anki-connect

This commit is contained in:
louie 2018-01-15 13:03:58 +08:00
parent 07c34fd5d2
commit 019baa35f8
2 changed files with 26 additions and 8 deletions

View file

@ -18,14 +18,15 @@ anki-editor -- an Emacs package that helps you create Anki cards in Org-mode
org-mode's html backend, with the latex syntax translated to org-mode's html backend, with the latex syntax translated to
the Anki style the Anki style
4. Command Cheat Sheet 4. Command Cheat Sheet
| Command | Default Keybinding | Description | | Command | Keybinding | Description |
|-----------------------------------------------+--------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| =anki-editor-setup-default-keybindings= | N/A | Set up default keybindings. | | =anki-editor-setup-default-keybindings= | N/A | Set up default keybindings. |
| =anki-editor-submit= | C-c a s | Send notes in current buffer to Anki. | | =anki-editor-submit= | C-c a s | Send notes in current buffer to Anki. |
| =anki-editor-insert-deck= | C-c a i d | Insert a deck heading with the same level as current heading. With prefix, only insert the deck name. | | =anki-editor-insert-deck= | C-c a i d | Insert a deck heading with the same level as current heading. With prefix, only insert the deck name. |
| =anki-editor-insert-note= | C-c a i n | Insert a note heading that's one level lower to current heading. The inserted heading will be structured with the property drawer and subheadings that correspond to the fields of the selected note type. | | =anki-editor-insert-note= | C-c a i n | Insert a note heading that's one level lower to current heading. The inserted heading will be structured with the property drawer and subheadings that correspond to the fields of the selected note type. |
| =anki-editor-export-heading-contents-to-html= | C-c a e | Export the contents of the heading at point to HTML. | | =anki-editor-export-heading-contents-to-html= | C-c a e | Export the contents of the heading at point to HTML. |
| =anki-editor-convert-region-to-html= | N/A | Convert and replace region to HTML. | | =anki-editor-convert-region-to-html= | N/A | Convert and replace region to HTML. |
| =anki-editor-anki-connect-upgrade= | N/A | Upgrade anki-connect to the latest version. This will display a confirmation dialog box in Anki asking if you want to continue. The upgrading is done by downloading the latest code in the master branch of its Github repo. This is useful when new version of this package depends on the bugfixes or new features of anki-connect. |
*Not a native speaker, hope this README is clear enough. Happy hacking :)* *Not a native speaker, hope this README is clear enough. Happy hacking :)*

View file

@ -160,6 +160,23 @@ note type."
(local-set-key (car map) (cdr map))) (local-set-key (car map) (cdr map)))
(message "anki-editor default keybindings have been set")) (message "anki-editor default keybindings have been set"))
;;;###autoload
(defun anki-editor-anki-connect-upgrade ()
"Upgrade anki-connect to the latest version.
This will display a confirmation dialog box in Anki asking if you
want to continue. The upgrading is done by downloading the latest
code in the master branch of its Github repo.
This is useful when new version of this package depends on the
bugfixes or new features of anki-connect."
(interactive)
(let* ((response (anki-editor--anki-connect-invoke "upgrade" 5))
(result (alist-get 'result response))
(err (alist-get 'error response)))
(when err (error err))
(when (and (booleanp result) result)
(message "anki-connect has upgraded, you may have to restart Anki to make it in effect."))))
;; Core Functions ;; Core Functions