From ff3230f32f5b2a704cf6200bf6d8f9539be91ff4 Mon Sep 17 00:00:00 2001 From: louie Date: Mon, 9 Mar 2020 21:36:27 +0800 Subject: [PATCH] Incorporate changes in PR#62 --- Changelog.org | 2 ++ README.org | 1 + anki-editor.el | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Changelog.org b/Changelog.org index 56b969e..604402f 100644 --- a/Changelog.org +++ b/Changelog.org @@ -26,6 +26,8 @@ 4. Command ~anki-editor-remove-styles~ 11. Updated anki-connect to version 6 1. ~anki-editor-api-upgrade~ removed + 12. Added variable ~anki-editor-note-match~ to make matching note + entries customizable ** v0.3.3 diff --git a/README.org b/README.org index 74e0366..079f6c8 100644 --- a/README.org +++ b/README.org @@ -90,6 +90,7 @@ there are any ambiguity or grammatical mistakes ;-)/ | anki-editor-latex-style | builtin | The style of latex to translate into. | | anki-editor-include-default-style | t | Wheter or not to include `org-html-style-default' when using `anki-editor-copy-styles'. | | anki-editor-html-head | nil | Additional html tags to append to card stylings when using `anki-editor-copy-styles'. | + | anki-editor-note-match | nil | Additional matching string for mapping through anki note headings. | ** Functions and Macros diff --git a/anki-editor.el b/anki-editor.el index 4fec8be..7f303b8 100644 --- a/anki-editor.el +++ b/anki-editor.el @@ -118,6 +118,11 @@ provide your custom styles in `anki-editor-html-head'." For example, you can put custom styles or scripts in this variable." :type 'string) +(defcustom anki-editor-note-match nil + "Additional matching string for mapping through anki note headings. +A leading logical operator like `+' or `&' is required." + :type 'string) + ;;; AnkiConnect @@ -451,12 +456,18 @@ as note types won't change in BODY." (setq anki-editor--collection-data-updated nil))))) (defun anki-editor-map-note-entries (func &optional match scope &rest skip) - "Simple wrapper that calls `org-map-entries' with - `&ANKI_NOTE_TYPE<>\"\"' appended to MATCH." + "Simple wrapper that calls `org-map-entries' with entries that match +`ANKI_NOTE_TYPE<>\"\"', `anki-editor-note-match' and MATCH. +A leading logical operator like `+' or `&' is required in MATCH." ;; disable property inheritance temporarily, or all subheadings of a ;; note heading will be counted as note headings as well (let ((org-use-property-inheritance nil)) - (org-map-entries func (concat match "&" anki-editor-prop-note-type "<>\"\"") scope skip))) + (org-map-entries func + (concat "+" anki-editor-prop-note-type "<>\"\"" + match + anki-editor-note-match) + scope + skip))) (defun anki-editor--insert-note-skeleton (prefix deck heading type fields) "Insert a note subtree (skeleton) with HEADING, TYPE and FIELDS.