Created
January 15, 2016 16:21
-
-
Save BrianZbr/63a7e02f5b1f5f98e884 to your computer and use it in GitHub Desktop.
elisp function for pasting quotes from pdfs into org-mode documents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 | |
(with-temp-buffer | |
(yank) | |
(buffer-string) | |
)) | |
;;;; 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") | |
(newline) | |
(setq quote-begin (point)) | |
(insert quote) | |
(setq quote-end (point)) | |
(insert " ()") | |
(left-char 1) | |
(setq page-number-spot (point)) | |
(insert pages) | |
(end-of-line) | |
(newline) | |
(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