<commit_before>" expose new maps that explicitly allow hlsearch during incsearch
nnoremap g/ :let g:inchlsearch = 1<CR>/
nnoremap g? :let g:inchlsearch = 1<CR>?

" set nohlsearch during incsearch, except if explicitly allowed
" via the g/ and g? maps
function! s:EnterHlsearch() abort
  let g:save_hlsearch = &hlsearch

  if exists('g:inchlsearch') && g:inchlsearch
    set hlsearch
  else
    set nohlsearch
  endif
endfunction

" restore hlsearch setting after incsearch
function! s:LeaveHlsearch() abort
  if exists('g:inchlsearch')
    unlet g:inchlsearch
  endif

  if exists('g:save_hlsearch') && g:save_hlsearch
    set hlsearch
  else
    set nohlsearch
  endif
endfunction

" attach EnterHlsearch and LeaveHlsearch to autocmds
augroup IncSearch
  autocmd!

  autocmd CmdLineEnter [/\?] call s:EnterHlsearch()
  autocmd CmdLineLeave [/\?] call s:LeaveHlsearch()
augroup END

<commit_msg>Shorten conditions in inchlsearch.vim<commit_after>" expose new maps that explicitly allow hlsearch during incsearch
nnoremap g/ :let g:inchlsearch = 1<CR>/
nnoremap g? :let g:inchlsearch = 1<CR>?

" set nohlsearch during incsearch, except if explicitly allowed
" via the g/ and g? maps
function! s:EnterHlsearch() abort
  let g:save_hlsearch = &hlsearch

  let &hlsearch = exists('g:inchlsearch') && g:inchlsearch
endfunction

" restore hlsearch setting after incsearch
function! s:LeaveHlsearch() abort
  if exists('g:inchlsearch')
    unlet g:inchlsearch
  endif

  let &hlsearch = exists('g:save_hlsearch') && g:save_hlsearch
endfunction

" attach EnterHlsearch and LeaveHlsearch to autocmds
augroup IncSearch
  autocmd!

  autocmd CmdLineEnter [/\?] call s:EnterHlsearch()
  autocmd CmdLineLeave [/\?] call s:LeaveHlsearch()
augroup END


{'fraction_non_alphanumeric': 0.08918296892980437, 'fraction_numerical': 0.0023014959723820483, 'mean_word_length': 4.894915254237288, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4522418', 'n_tokens_mistral': 606, 'n_tokens_neox': 589, 'n_words': 177}