Created
May 23, 2015 20:15
-
-
Save jmn/9c1492ae1b483b84c203 to your computer and use it in GitHub Desktop.
Emacs org-capture: Handle wrong (non utf-8) character encoding using special template
This file contains 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
;; If the org property value of CODING is not nil, mark the (capture) buffer it and use recode-region to recode it to UTF-8. | |
(defun jmn/recode-buffer-from-cp1252-to-utf-8 () | |
"" | |
(message "recoding buffer!") | |
(interactive) | |
(mark-whole-buffer) | |
(recode-region (region-beginning) (region-end) 'cp1252 'utf-8) | |
) | |
(add-hook 'org-capture-prepare-finalize-hook | |
'(lambda () | |
(if (cdr(assoc "CODING" (org-entry-properties nil 'standard))) | |
(progn | |
(org-delete-property "CODING") | |
(jmn/recode-buffer-from-cp1252-to-utf-8) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment