Search code examples
variablesemacscase-sensitivecase-insensitivedot-emacs

setq of case-sensitivity in .emacs has no effect


I have a lot of custom stuff in my .emacs file: fonts, colors, window sizing, key bindings, etc. All of it works.

Then at the end, I just added a: (setq case-fold-search nil). It's a variable that when set to nil is supposed to make search case-sensitive in all emacs modes. It doesn't for me.

Setting case-fold-search to nil in an individual buffer works, but when I set it in .emacs, it doesn't work. Is there a reason why a setq declaration in a .emacs may not work sometimes? How should I try to debug the issue?


Solution

  • That's normal behavior for buffer-local variables. setq-default can be used to establish a default value for them.

    You can determine that a variable is buffer local by checking out its documentation, using C-h v case-fold-search (or M-x describe-variable), which in this case reports (note 4th line):

    case-fold-search is a variable defined in `buffer.c'.
    Its value is t
    
      Automatically becomes buffer-local when set in any fashion.
    
    Documentation:
    *Non-nil if searches and matches should ignore case.
    
    You can customize this variable.