Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No option in UI to check regex #11

Open
jpfleury opened this issue Jun 20, 2011 · 2 comments
Open

No option in UI to check regex #11

jpfleury opened this issue Jun 20, 2011 · 2 comments

Comments

@jpfleury
Copy link
Contributor

gedit-file-search seems to already have all code needed to search using regular expression. However, we must activate it by hand in gconf-editor (key /apps/gedit-2/plugins/file-search/is_reg_exp).

It would be convenient to have a checkbox "Regular expression" under the search field, beside "Case sensitive" and "Whole word".

@oliver
Copy link
Owner

oliver commented Jun 20, 2011

IMHO the RegExp feature needs much more work before it can be released. The main issue are the different RegExp dialects:

  • grep on Debian and Ubuntu supports PCRE (Perl-compatible syntax) with -P option, which is marked as experimental
  • grep on Red Hat (Fedora, RHEL) does not support PCRE (I think they use "POSIX" flavor); a separate pcregrep tool can be installed
  • Pythons re module uses an own flavor (this is important for highlighting of results)

http://www.regular-expressions.info/refflavors.html lists various RE flavors.

I think before the RegExp checkbox can be enabled, the following requirements should be met:

  • the same syntax should be used on all systems (I use gedit-file-search regularly on RHEL and Ubuntu and don't want to mentally "switch")
  • highlighting in result field should work correctly (as you noted in issue 12)

Some possible solutions:

  • disable RegExp support if grep does not support the flavor we need (this might mean that RHEL and Fedora and other platforms won't have this feature and basically only Debian and Ubuntu etc. are supported)
  • use an own grep implementation for RegExp support; ie. some grep tool written in Python (might be lots of work, and might be slower and have more bugs)
  • use a different grep implementation which is bundled with the plugin; for example ack-grep (http://betterthangrep.com/) is a Perl script (sadly not Python :-) which we might put into the .tgz
  • find a way to translate one RegExp flavor into the different RegExp flavors of Debian-grep, RedHat-grep and Python (not sure if this is possible at all)
  • lower the requirements and just use the system grep and let users figure out what dialect is supported on their platform (then the plugin won't behave the same on different platforms; and if we later fix this, people will have to switch to a different RegExp flavor)

Thoughts? Suggestions?

@jpfleury
Copy link
Contributor Author

  • grep on Debian and Ubuntu supports PCRE (Perl-compatible syntax) with -P option, which is marked as experimental
  • grep on Red Hat (Fedora, RHEL) does not support PCRE (I think they use "POSIX" flavor); a separate pcregrep tool can be installed

So grep -E (ERE, extended regular expression) should be used to have a common regex flavor between distributions?

  • Pythons re module uses an own flavor (this is important for highlighting of results)

If we use grep -E, then we must have a way to highlight results the same way they're searched. Some ideas:

  1. nwgrep seems to be a good starting point. It's all Python and it's described as "grep++, similar to ack-grep but with different features". It works with ERE by default, so it may be used to highlight results from grep -E.
  2. Otherwise, is it possible to capture matches in parallel as grep is searching, with something like grep -o? Then gedit-file-search could highlight fixed strings in results.

Some possible solutions:

  • use a different grep implementation which is bundled with the plugin; for example ack-grep (http://betterthangrep.com/) is a Perl script (sadly not Python :-) which we might put into the .tgz

Not a bad idea.

  • lower the requirements and just use the system grep and let users figure out what dialect is supported on their platform (then the plugin won't behave the same on different platforms; and if we later fix this, people will have to switch to a different RegExp flavor)

It depends on how gedit-file-search is perceived: as an advanced GUI for grep or as an advanced GUI for search.

In the first case, I don't see problems to only use grep capabilities of the current platform.

In the second case, it would be more appropriate to have a single regex syntax for all platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants