diff --git a/elfeed-export.el b/elfeed-export.el index 52832c1..77ea61f 100644 --- a/elfeed-export.el +++ b/elfeed-export.el @@ -161,23 +161,22 @@ the entry should be exported." entries "\n")))) -;;;###autoload -(defun elfeed-export-to-json-file (path) - "Write the JSON string to a file at PATH." - (interactive "F") - (write-region (elfeed-export-to-json) nil path nil nil nil t)) +(defmacro elfeed-export--to (format) + "Define an interactive command to export the elfeed database to FORMAT." + (let* ((function-name (intern (format "elfeed-export-to-%s-file" format))) + (payload-function (intern (format "elfeed-export-to-%s" format))) + (upcased-format (upcase (format "%s" format))) + (docstring (format "Export the elfeed database as %s to PATH." upcased-format))) + `(progn + (defun ,function-name (path) + ,docstring + (interactive "F") + (write-region (,payload-function) nil path nil nil nil t)) + (autoload ',function-name "elfeed-export" ,docstring t)))) -;;;###autoload -(defun elfeed-export-to-lisp-file (path) - "Write the JSON string to a file at PATH." - (interactive "F") - (write-region (elfeed-export-to-lisp) nil path nil nil nil t)) - -;;;###autoload -(defun elfeed-export-to-csv-file (path) - "Write the CSV string to a file at PATH." - (interactive "F") - (write-region (elfeed-export-to-csv) nil path nil nil nil t)) +(elfeed-export--to csv) +(elfeed-export--to lisp) +(elfeed-export--to json) (provide 'elfeed-export)