Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
elisp function for pasting quotes from pdfs into org-mode documents
(defun my/paste-quote (pages)
"inserts and formats text from the clipboard, formatted for org-mode"
(interactive "sEnter page number\(s\): ")
;;;; convert clipboard to string
(setq quote
;;;; remove newlines from string
(setq newline "
(setq one-space " ")
(setq multiple-space " +")
(setq quote (replace-regexp-in-string newline one-space quote))
(setq quote (replace-regexp-in-string multiple-space one-space quote))
(setq quote (replace-regexp-in-string "\\.- " "" quote))
;;;; insert reformatted quote, saving relevant positions
(insert "#+BEGIN_QUOTE")
(setq quote-begin (point))
(insert quote)
(setq quote-end (point))
(insert " ()")
(left-char 1)
(setq page-number-spot (point))
(insert pages)
(insert "#+END_QUOTE")
;;;; correct spelling in case of bad OCR
(flyspell-region quote-begin quote-end)
(ispell-region quote-begin quote-end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment