1

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 25.0.94.1 (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
  • 75,699
  • 9
  • 109
  • 225

1 Answers1

0

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*

phils
  • 48,657
  • 3
  • 76
  • 115