>> + (setq-local font-lock-keywords-case-fold-search hi-lock-case-fold-search) > > This affects all the font-lock-keywords, so it's likely to mess things > up for the non-hi-lock keywords. > > I think we should change the patterns added to `font-lock-keywords` > instead, such that they do > > (let ((case-fold-search hi-lock-case-fold-search)) <...>) > > around the corresponding regexp search. I tried this, and it works well. Then instead of adding defcustom I copied all related details from occur to highlight-regexp/highlight-symbol-at-point and from isearch-occur to isearch-highlight-regexp to make occur/hi-lock identical in regard how they handle case-folding (docstrings were copied too). There is one remaining case that is unclear - whether to use case-fold-search in hi-lock-process-phrase. Its comment says: ;; FIXME fragile; better to just bind case-fold-search? (Bug#7161) But according to docstring of highlight-phrase: When called interactively, replace whitespace in user-provided regexp with arbitrary whitespace, and make initial lower-case letters case-insensitive, before highlighting with `hi-lock-set-pattern'. I'm not sure if "make initial lower-case letters case-insensitive" the same as this code (if (and case-fold-search search-upper-case) (isearch-no-upper-case-p regexp t) case-fold-search) shared between occur and hi-lock in this patch: