Skip to content

Instantly share code, notes, and snippets.

@jmdeldin
Created October 9, 2014 19:50
Show Gist options
  • Save jmdeldin/9a27f0a9a186abb7e2f8 to your computer and use it in GitHub Desktop.
Save jmdeldin/9a27f0a9a186abb7e2f8 to your computer and use it in GitHub Desktop.
Uppercase MySQL keywords in Emacs
(defun jm/fix-sql-case (start end)
"Uppercase SQL keywords"
(interactive "r")
(save-restriction
(narrow-to-region start end)
(goto-char 1)
(let ((case-fold-search nil))
(while (search-forward-regexp
(mapconcat 'downcase (mapcar 'symbol-name '(select from inner outer left join where and in group by into on)) "\\|")
nil t)
(replace-match (upcase (match-string 0)) t nil)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment