I'm trying to use replace-regexp-in-string (see function below) and I need to detect the boundary between a lower case and upper case character. Apparently let-binding case-fold-search to nil doesn't work? I'm trying this in the latest pretest

GNU Emacs (x86_64-apple-darwin13.4.0, NS appkit-1265.21 Version 10.9.5 (Build 13F1603)) of 2016-05-17

as well as

GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21) of 2015-04-10 on builder10-9.porkrind.org

(obviously on a Mac)

(defun spread-upcase-filename (filename)
  "fooBar.h => F O O  B A R . H"
  (let ((case-fold-search nil)
        (str (replace-regexp-in-string "\\([a-z0-9]\\)\\([A-Z]+\\)"
                                       "\\1\x01\\2" filename t)))
    (setq str (mapconcat 'identity (split-string str "" t) " "))
    ;;(setq str (replace-regexp-in-string "\x01" "" str t))
    (upcase str)))

From the documentation I've seen so far, case-fold-search is supposed to be dynamically-bound rather than lexically-bound, but it doesn't seem to have any effect.

  • @Drew: really? it looks like a completely different issue.
    – Stefan
    Aug 25, 2017 at 3:05
  • @Stefan: Right. Voted to close the wrong one. Thx.
    – Drew
    Aug 25, 2017 at 3:52

1 Answer 1


Your problem is that you haven't bound case-fold-search in the scope of the the call to replace-regexp-in-string.

See the difference between C-hf let and C-hf let*

  • D'oh, I had moved it up and totally lost track of this. Thx. Jun 8, 2016 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.