I wrote the following command to do a regexp replacement in a region.
(defun camel-case-to-underscore (a b &optional use-dash) (interactive "r") (save-excursion (let ((sep (if use-dash "-" "_")) (case-fold-search t)) (goto-char a) (while (re-search-forward "\\([[a-z]\\)\\([A-Z]\\)" b t) (replace-match (concat (match-string 1) sep (downcase (match-string 2)))) (incf b (length sep))))))
case-fold-search appears to not be affecting
re-search-forward, causing undesired results:
thisIsAnExampleInCamelCase => t_hi_sI_SA_NE_Xa_mp_le_in_ca_me_lC_As_e
What is wrong with my use of
GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.10) of 2017-10-09