GithubHelp home page GithubHelp logo

Add interface to -g option about ag.el HOT 6 CLOSED

wilfred avatar wilfred commented on May 21, 2024
Add interface to -g option

from ag.el.

Comments (6)

Wilfred avatar Wilfred commented on May 21, 2024

Yep, I'd definitely see exposing ag -g as a worthwhile feature.

Perhaps we could add commands ag-find and ag-find-regexp? You might want ag-project-find too, to save prompting for the base directory.

find-dired is very cool, I've not seen it before, and the UI looks suitable for ag -g too.

Anyway, I'd welcome patches.

from ag.el.

Fuco1 avatar Fuco1 commented on May 21, 2024

I've checked and ag doesn't support non-regexp argument for -g option yet, and I would not dare to escape the string manually in elisp to "not be regexp" myself since that's very easily breakable. So for now we'll only get ag-find-regexp. The project thing is also a good idea, I'll add that too.

I have it basically done, only adding docstrings and formatting it a bit better.

from ag.el.

Fuco1 avatar Fuco1 commented on May 21, 2024

Hm, what about calling it ag-dired in analogy with find-dired (which can be interpreted as "run X and dump the output in dired")

from ag.el.

Wilfred avatar Wilfred commented on May 21, 2024

It's actually pretty easy to escape PCRE regexes. I've found the implementation in the Python standard library:

_alphanum = frozenset(
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

def escape(pattern):
    "Escape all non-alphanumeric characters in pattern."
    s = list(pattern)
    alphanum = _alphanum
    for i, c in enumerate(pattern):
        if c not in alphanum:
            if c == "\000":
                s[i] = "\\000"
            else:
                s[i] = "\\" + c
    return pattern[:0].join(s)

from ag.el.

Fuco1 avatar Fuco1 commented on May 21, 2024

Oh well that's pretty simple. I don't have time to continue hacking today, I can add this tomorrow to the same branch, then you can pull it all together.

from ag.el.

Wilfred avatar Wilfred commented on May 21, 2024

Merged, so we're done here :).

from ag.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.