Adobe
Adobe

Reputation: 13477

Set case-fold-search in elisp

Emacs doesn't appear to respect case-fold-search when set in elisp:

(defun test-case (start end)
  "Replace D to Delta in a region."
  (interactive "r")
  (let
      (
       (case-fold-search nil)
       )
    (narrow-to-region start end)

    (goto-char start)
    (while (search-forward-regexp "D" nil t) (replace-match "Delta" nil t))
    )
  )

Calling that on Dublin return DELTAublin while I wanted it to return Deltaublin. What do I do wrong?

Upvotes: 1

Views: 196

Answers (1)

Sean Perry
Sean Perry

Reputation: 3886

You actually want to pass 't' instead of 'nil' as the first optional parameter to (replace-match). This should do what you want.

Upvotes: 1

Related Questions