dajva / rg.el

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

Pad line numbers or align results #44

Closed net closed 6 years ago

net commented 6 years ago

An option to pad line numbers or otherwise align results would be useful. Likewise, an option to change or hide the line number separator (currently a :) would help reduce visual clutter.

Unaligned:
5:fifth line
15:fifteenth line

Aligned:
 5:fifth line
15:fifteenth line

Custom separator:
 5┊fifth line
15┊fifteenth line
dajva commented 6 years ago

The output format is decided by ripgrep currently. I have done very little to improve that but have been thinking about making the looks of the output a bit more clear. So your suggestion is very welcome.

Since the output is just "piped" into the result-buffer I am not sure what would be possible to do here but I will definitely look into this.

Thanks for the report.

dajva commented 6 years ago

I have just played around with this a bit but this is currently my plan.

Add a custom variable rg-match-pos-separator (naming to be decided) that can control the character used as separator. Using space here would "hide" it. Also adding custom variable rg-align-match-pos that turns on/off alignment.

Default algnment to be decided but probably 5 digits for line and 3 for column. That would allow for about 100000 lines and 1000 columns to look good. That should be enough for most cases but I will also add custom varables for these values so that the alignment could be tweaked.

net commented 6 years ago

I'm excited to hear that!

Do you think a default of 4 or even 3 for line alignment would be sufficient? I suspect searching a file with 100,000 lines is a fairly rare case for most users that can be configured for if desired.

dajva commented 6 years ago

Unfortunately this breaks wgrep support so currently on hold although the implementation is essentially finished.

There are also more problems with wgrep-ag with a stalled solution upstream: https://github.com/mhayashi1120/Emacs-wgrep/issues/41

Possible solution would be to fork wgrep-ag into this package and do local fixes here.

dajva commented 6 years ago

I've pushed a test branch, align_separator, with this feature. Needs a bit of fixing but you can try it out if you want. Will take a bit of time before this is merged to master.

dajva commented 6 years ago

Merged to master.