Created
April 21, 2014 23:03
-
-
Save markrwilliams/11159500 to your computer and use it in GitHub Desktop.
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 python-swap-quotes () | |
(interactive) | |
(save-excursion | |
(let ((state (syntax-ppss))) | |
(when (eq 'string (syntax-ppss-context state)) | |
(let* ((left (nth 8 state)) | |
(right (1- (scan-sexps left 1))) | |
(newquote (if (= ?' (char-after left)) | |
?\" ?'))) | |
(dolist (loc (list left right)) | |
(goto-char loc) | |
(delete-char 1) | |
(insert-char newquote 1))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment