Handle multiple backends

Handle use case below. A single file extension associated with
multiple backends.
`(org-pandoc-import-backend foo '("txt"))`
`(org-pandoc-import-backend bar '("txt"))`
This commit is contained in:
Declan Qian 2022-09-21 14:22:39 +08:00
parent d3cd2b0519
commit 2af29d63fd
1 changed files with 13 additions and 8 deletions

View File

@ -353,14 +353,19 @@ When SYNCRONOUS-P is set, the pandoc process is run in a blocking manner."
The backend is found from searching `org-pandoc-import-backends', and is nil
if no such match could be found."
(when file
(let ((ext (file-name-extension file))
the-backend)
(dolist (backend org-pandoc-import-backends)
(when (member ext (symbol-value
(intern
(format "org-pandoc-import-%s-extensions"
(symbol-name backend)))))
(setq the-backend backend)))
(let* ((ext (file-name-extension file))
(available-backends
(seq-filter (lambda (backend)
(member ext (symbol-value
(intern
(format "org-pandoc-import-%s-extensions"
(symbol-name backend))))))
org-pandoc-import-backends))
(the-backend
((lambda () (if (length> available-backends 1)
(intern (completing-read
"Import from: " available-backends nil t))
(car available-backends))))))
the-backend)))
(dont-compile