From a045b2fc3c430389da6f0c363edb702a5aa29097 Mon Sep 17 00:00:00 2001 From: fpi Date: Thu, 2 Jun 2022 14:45:10 +0200 Subject: Add basic functions to insert list of annotations in org --- pdf-tools-annotation-list.el | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'pdf-tools-annotation-list.el') diff --git a/pdf-tools-annotation-list.el b/pdf-tools-annotation-list.el index b3ec4d8..08c8199 100644 --- a/pdf-tools-annotation-list.el +++ b/pdf-tools-annotation-list.el @@ -90,6 +90,25 @@ need region." ))) extracted-annots)) +(defun pdf-tools-annotation-list-entry-to-org (annotation) + "Converts ANNOTATION to org formatted text" + (format + "%s:\n%s%s\n" + (plist-get annotation :link) + (let ((text (plist-get annotation :text))) + (if text + (format "#+BEGIN_QUOTE\n%s\n#+END_QUOTE\n" text) + "")) + (plist-get annotation :contents))) + +(defun pdf-tools-annotation-list-insert-in-org (pdf) + (let* ((pdfbuffer (find-file-noselect pdf)) + (annotations (with-current-buffer pdfbuffer + (pdf-tools-annotation-list-create-list)))) + (mapc (lambda (annot) + (insert (pdf-tools-annotation-list-entry-to-org annot))) + annotations) + nil)) (provide 'pdf-tools-annotation-list) ;;; pdf-tools-annotation-list.el ends here -- cgit v1.2.3