Skip to content

Instantly share code, notes, and snippets.

@doitian
Created August 14, 2009 04:16
Show Gist options
  • Select an option

  • Save doitian/167640 to your computer and use it in GitHub Desktop.

Select an option

Save doitian/167640 to your computer and use it in GitHub Desktop.
;;; The command is extracted from interactively query-replace-regexp:
;;; 1) M-C-% or "M-x query-replace-regexp"
;;; 2) Search: \<[[:upper:]]\{2,\}\>
;;; 3) Replace: \,(capitalize \&)
;;; 4) After finish the query replace, use C-x M-: to extract the command
(defun iy/query-capitalize-upper-word ()
"Capitalize the word with all letters in upcase"
(interactive)
(query-replace-regexp
"\\<[[:upper:]]\\{2,\\}\\>"
(quote (replace-eval-replacement
replace-quote (capitalize (match-string 0))))
nil
(if (and transient-mark-mode mark-active)
(region-beginning))
(if (and transient-mark-mode mark-active)
(region-end))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment