" ingo/regexp/magic.vim: Functions around handling magicness in regular expressions. " " DEPENDENCIES: " - ingo/collections.vim autoload script for ingo#regexp#magic#Normalize() " - ingo/collections/fromsplit.vim autoload script " - ingo/regexp/collection.vim autoload script " " Copyright: (C) 2011-2018 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat let s:save_cpo = &cpo set cpo&vim function! ingo#regexp#magic#GetNormalizeMagicnessAtom( pattern ) "****************************************************************************** "* PURPOSE: " Return normalizing \m (or \M) if a:pattern contains atom(s) that change the " default magicness. This makes it possible to append another pattern without " having a:pattern affect it. " "* ASSUMPTIONS / PRECONDITIONS: " None. "* EFFECTS / POSTCONDITIONS: " None. "* INPUTS: " a:pattern Regular expression to observe. "* RETURN VALUES: " Normalizing atom or empty string. "****************************************************************************** let l:normalizingAtom = (&magic ? 'm' : 'M') let l:magicChangeAtoms = substitute('vmMV', '\C'.l:normalizingAtom, '', '') return (a:pattern =~# '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@