3

Converting a subversion repo to git, and setting up an authors file. I'm running query-replace-regexp on this text:

E001234

using this regexp:

^\(.*\)$ -> \1 = Some Lowercase Text Here <[email protected]>

When I execute the replacement, the replacement text is being capitalized like this, due to the case sensitive nature of replacements:

E001234 = SOME LOWERCASE TEXT HERE <[email protected]>

I understand what's happening, but is there a way to turn this off w/o writing a custom function (trivial, but still...)?

1
  • Tried this:Query replace regexp (default ^\(.*\)$ -> \1 = \,(substring "OneAmerica Former Employee <[email protected]>" 0)): but no dice. Seems the replacing operates on the text after it's created. Feb 24, 2015 at 11:05

1 Answer 1

3

You can set the variable case-replace to nil before executing the command. Then you will get the following replacement

E001234 = Some Lowercase Text Here <[email protected]>

as expected. When case-replace is non-nil it preserves case in replacements, i.e. the case of the replacement matches that of the matched text.

Note, there is also the variable case-fold-search which also affects case in the match and as well as the replacement.

4
  • So sounds like I'd have to set that variable, run all my query-replace-regexp commands, then unset it? No way to toggle it as part of running query-replace-regexp? Feb 24, 2015 at 14:39
  • Indeed. There is no why standard way to invoke query-replace-regexp with a particular choice of case matching option. Instead it is controlled via these variables. Feb 24, 2015 at 17:13
  • @scottplumlee You can write a wrapper function that sets that variable in a let and then calls the query-replace-regexp. Let me know if you want me to elaborate that. Feb 25, 2015 at 5:43
  • @kaushalmodi That's the method I am going to try, thanks. Feb 25, 2015 at 17:59

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.