dajva / rg.el

Emacs search tool based on ripgrep
https://rgel.readthedocs.io
GNU General Public License v3.0
465 stars 38 forks source link

Separate option --multiline-dotall and --multiline #123

Closed feng-qi closed 2 years ago

feng-qi commented 2 years ago

Using option --multiline doesn't necessarily mean the user also wants --multiline-dotall. The user may be certain about the number of new lines involved. For example, with this code snippet:

    if (level == 2U) {
        parent_irq = irq_parent_level_2(irq);
        table_idx = parent_offset + irq_from_level_2(irq);
    }
#ifdef CONFIG_3RD_LEVEL_INTERRUPTS
    else if (level == 3U) {
        parent_irq = irq_parent_level_3(irq);
        table_idx = parent_offset + irq_from_level_3(irq);
    }

If I want to search all the #ifdef followed by a else statement, I can use regex #ifdef.*\n.*else. If --multiline-dotall is used, this regex will match more lines than I expected.

feng-qi commented 2 years ago

Besides, one can use the dot all modifier, which looks like (?s), to change the dot's behavior if --multiline-dotall is not available. https://til.hashrocket.com/posts/9zneks2cbv-multiline-matches-with-ripgrep-rg

coveralls commented 2 years ago

Coverage Status

Coverage remained the same at 80.775% when pulling e3af9b3f41967a203d1a1288e548e17220ee9ac8 on feng-qi:master into 0fa6d33d2f3123aecd0b0dbc5fa3d884edf10a92 on dajva:master.