Add a command to cloze region
This commit is contained in:
parent
971181df30
commit
8523ddb9c1
2 changed files with 15 additions and 0 deletions
|
@ -55,6 +55,7 @@ anki-editor -- Make Anki Cards in Org-mode
|
|||
| =anki-editor-insert-deck= | Insert a deck heading. |
|
||||
| =anki-editor-insert-note= | Insert the skeleton of a note. |
|
||||
| =anki-editor-insert-tags= | Insert a tag at point with autocompletion. |
|
||||
| =anki-editor-cloze-region= | Cloze region. |
|
||||
| =anki-editor-export-heading-contents-to-html= | Export the contents of the heading at point to HTML. |
|
||||
| =anki-editor-convert-region-to-html= | Convert and replace region to HTML. |
|
||||
|
||||
|
|
|
@ -279,6 +279,20 @@ Otherwise, it's inserted at point."
|
|||
(let ((tags (sort (anki-editor--anki-connect-invoke-result "getTags" 5) #'string-lessp)))
|
||||
(while t (insert (format " %s" (completing-read "Choose a tag: " tags))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun anki-editor-cloze-region (&optional arg)
|
||||
"Cloze region with number ARG."
|
||||
(interactive "p")
|
||||
(unless (region-active-p) (error "No active region"))
|
||||
(let ((region (buffer-substring (region-beginning) (region-end)))
|
||||
(hint (read-from-minibuffer "Hint (optional): ")))
|
||||
(save-excursion
|
||||
(delete-region (region-beginning) (region-end))
|
||||
(insert (with-output-to-string
|
||||
(princ (format "{{c%d::%s" (or arg 1) region))
|
||||
(unless (string-empty-p (string-trim hint)) (princ (format "::%s" hint)))
|
||||
(princ "}}"))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun anki-editor-export-heading-contents-to-html ()
|
||||
"Export the contents of the heading at point to HTML."
|
||||
|
|
Loading…
Reference in a new issue