I have HELLOWORLD string inside my file.

My setup:

(defun my-find-orgfiles ()
  (setq toggle-case-fold-search 0)  ; Turn Off Smart Case Sensitivity
  (find-name-dired "~/folder" "*py"))

(global-set-key (kbd "M-m") 'my-find-orgfiles)

(add-hook 'python-mode-hook
          (lambda ()
            (setq flycheck-python-pylint-executable "~/venv/bin/pylint")
            (setq flycheck-pylintrc "~/.pylintrc")))
(setq case-fold-search nil)

Than, t to toggle marked/unmarked files (thus marking them all, since none were marked). Then I use Q to use query-replace on the marked files. And enter helloword to replace with hello.

On the minibuffer I face with following:

Query replacing helloworld with HELLO: (? for help)

Than replaces HELLOWORLD into HELLO.

  • Here if replacement occurs I want it to replace into hello rather than HELLO, since I enter lower case hello

  • Since lower case helloword does not exist in the file, it shouldn't attempt to replace anything.

Note: Adding (setq case-fold-search nil) did not help.

1 Answer 1


Do M-x toggle-case-fold-search (message is Case-Insensitive Search disabled globally) before Q.

toggle-case-fold-search isn't a standard variable but rather a function. Perhaps you wanted to set buffer-local variable case-fold-search in my-find-orgfiles? Or maybe to call toggle-case-fold-search?

  • Can I set it in .emacs file?
    – alper
    Jun 27, 2020 at 22:18
  • Yes, you can (setq case-fold-search nil) in your .emacs/.init.el
    – Mark
    Jun 28, 2020 at 14:05
  • I did but still I am having the same problem, it did not have any affect @Mark
    – alper
    Jun 28, 2020 at 14:30
  • 1
    Because it's a buffer-local variable, you'll may want (setq-default case-fold-search nil)
    – Mark
    Jun 28, 2020 at 14:51

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.