Skip to content
New issue

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

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

Already on GitHub? # to your account

Windows support #10

Open
akermu opened this issue Aug 29, 2018 · 7 comments
Open

Windows support #10

akermu opened this issue Aug 29, 2018 · 7 comments

Comments

@akermu
Copy link

akermu commented Aug 29, 2018

Currently this package is somehow broken on Windows. There is no output in the helm-buffer. I tried to debug it, but I couldn't find the culprit, maybe you have more luck..

@dsisnero
Copy link

Same here. I have a working ripgrep but get the following on install

Compiling file c:/Dominic/.emacs.d/elpa/helm-rg-20180629.920/helm-rg.el at Thu Oct 18 14:16:46 2018
Entering directory ‘c:/Dominic/.emacs.d/elpa/helm-rg-20180629.920/’
helm-rg.el:262:1:Error: Symbol’s function definition is void: helm-rg-cl-typep--pcase-macroexpander

@Kuresov
Copy link

Kuresov commented Feb 19, 2019

Also seeing no output results here. rg is in my path and works elsewhere. Unfortunately, I'm fairly new to emacs and am not entirely sure how to debug this.

Will look into it over the next few days :)

@cpbotha
Copy link

cpbotha commented Apr 16, 2019

Exactly the same symptoms over here.

helm-do-grep-ag from helm-grep.el does work with ripgrep on the exact same setup, but I have not yet been able to determine exactly how.

@dbldippy
Copy link

Same here. Just executing (compile "rg sth") under Windows also does not terminate. However, (compile "rg sth .") does.

@xuchengpeng
Copy link

I also have the same problem, don't know how to fix it.

@jonmoore
Copy link

jonmoore commented May 31, 2020

It seems to work on Windows after

  1. using (or paths (list helm-rg--current-dir)) instead of paths in helm-rg, addressing the point mentioned by @wauisaui
  2. adding ("-p" :face helm-rg-inactive-arg-face) to helm-rg--ripgrep-argv-format-alist, to format ripgrep's output as expected by helm-rg. This is with ripgrep 0.9.0.

@Schievel1
Copy link

Schievel1 commented Jul 26, 2022

It seems to work on Windows after

1. using `(or paths (list helm-rg--current-dir))` instead of `paths` in `helm-rg`, addressing the point mentioned by @wauisaui

2. adding `("-p" :face helm-rg-inactive-arg-face)` to `helm-rg--ripgrep-argv-format-alist`, to format ripgrep's output as expected by helm-rg.  This is with ripgrep 0.9.0.

Could you elaborate a bit more how to get it to work? The first point is completely beyond me

//
Ok I figured it out.
Since I am using doom emacs where .emacs.d is under version control from doom, I didn't want to change helm-rg.el itself.
So I overwrite functions and variables via my config. Without Doom one can just change helm-rg.el in ~/.emacs.d/.local/straight/bulid/helm-rg/helm-rg.el.
I could try if this breaks helm-rg on Linux, if not, should I make a PR?

So, in helm-rg.el change the variable "helm-rg--ripgrep-argv-format-alist" (currently in line 847, to:

(defconst helm-rg--ripgrep-argv-format-alist
  `((helm-rg-ripgrep-executable :face helm-rg-base-rg-cmd-face)
    ((->> helm-rg--case-sensitive-argument-alist
          (helm-rg--alist-get-exhaustive helm-rg--case-sensitivity))
     :face helm-rg-active-arg-face)
    ("--color=ansi" :face helm-rg-inactive-arg-face)
    ((helm-rg--construct-match-color-format-arguments)
     :face helm-rg-inactive-arg-face)
    ((unless (helm-rg--empty-glob-p helm-rg--glob-string)
       (list "-g" helm-rg--glob-string))
     :face helm-rg-active-arg-face)
    **("-p" :face helm-rg-inactive-arg-face)**
    (helm-rg--extra-args :face helm-rg-extra-arg-face)
    (it
     :face font-lock-string-face)
    ((helm-rg--process-paths-to-search helm-rg--paths-to-search)
     :face helm-rg-directory-cmd-face))

Then change the "paths" on line 2451, so the whole functions looks like this:

(defun helm-rg (rg-pattern &optional pfx paths)
  "Search for the PCRE regexp RG-PATTERN extremely quickly with ripgrep.
When invoked interactively with a prefix argument, or when PFX is non-nil,
set the cwd for the ripgrep process to `default-directory'. Otherwise use the
cwd as described by `helm-rg-default-directory'.
If PATHS is non-nil, ripgrep will search only those paths, relative to the
process's cwd. Otherwise, the process's cwd will be searched.
Note that ripgrep respects glob patterns from .gitignore, .rgignore, and .ignore
files, excluding files matching those patterns. This composes with the glob
defined by `helm-rg-default-glob-string', which only finds files matching the
glob, and can be overridden with `helm-rg--set-glob', which is defined in
`helm-rg-map'.
There are many more `defcustom' forms, which are visible by searching for \"defcustom\" in the
`helm-rg' source (which can be located using `find-function'). These `defcustom' forms set defaults
for options which can be modified while invoking `helm-rg' using the keybindings listed below.
The ripgrep command's help output can be printed into its own buffer for
reference with the interactive command `helm-rg-display-help'.
\\{helm-rg-map}"
  (interactive (list (helm-rg--get-thing-at-pt) current-prefix-arg nil))
  (let* ((helm-rg--current-dir
          (or helm-rg--current-dir
              (and pfx default-directory)
              (helm-rg--interpret-starting-dir helm-rg-default-directory)))
         ;; TODO: make some declarative way to ensure these variables are all initialized and
         ;; destroyed (an alist `defconst' should do the trick)!
         (helm-rg--glob-string
          (or helm-rg--glob-string
              helm-rg-default-glob-string))
         (helm-rg--extra-args
          (or helm-rg--extra-args
              helm-rg-default-extra-args))
         (helm-rg--paths-to-search
          (or helm-rg--paths-to-search
             **(or paths (list helm-rg--current-dir))))**
         (helm-rg--case-sensitivity
          (or helm-rg--case-sensitivity
              helm-rg-default-case-sensitivity)))
    ;; FIXME: make all the `defvar's into buffer-local variables (or give them local counterparts)?
    ;; the idea is that `helm-resume' can be applied and work with the async action -- currently it
    ;; tries to find a buffer which we killed in the cleanup here when we do the async action
    ;; (i think)
    (setq helm-rg--last-dir helm-rg--current-dir)
    (unwind-protect (helm-rg--do-helm-rg rg-pattern)
      (helm-rg--unwind-cleanup))))

For doom emacs, just put this into your config.el:

(after! helm-rg
  (setq helm-rg--ripgrep-argv-format-alist '(
        (helm-rg-ripgrep-executable :face helm-rg-base-rg-cmd-face)
        ((->> helm-rg--case-sensitive-argument-alist
              (helm-rg--alist-get-exhaustive helm-rg--case-sensitivity))
                :face helm-rg-active-arg-face)
        ("--color=ansi" :face helm-rg-inactive-arg-face)
        ((helm-rg--construct-match-color-format-arguments)
                :face helm-rg-inactive-arg-face)
        ((unless
             (helm-rg--empty-glob-p helm-rg--glob-string)
                (list "-g" helm-rg--glob-string))
                :face helm-rg-active-arg-face)
        ("-p" :face helm-rg-inactive-arg-face)
        (helm-rg--extra-args :face helm-rg-extra-arg-face)
        (it :face font-lock-string-face)
        ((helm-rg--process-paths-to-search helm-rg--paths-to-search)
                :face helm-rg-directory-cmd-face)))

(defun helm-rg (rg-pattern &optional pfx paths)
  "Search for the PCRE regexp RG-PATTERN extremely quickly with ripgrep.

When invoked interactively with a prefix argument, or when PFX is non-nil,
set the cwd for the ripgrep process to `default-directory'. Otherwise use the
cwd as described by `helm-rg-default-directory'.

If PATHS is non-nil, ripgrep will search only those paths, relative to the
process's cwd. Otherwise, the process's cwd will be searched.

Note that ripgrep respects glob patterns from .gitignore, .rgignore, and .ignore
files, excluding files matching those patterns. This composes with the glob
defined by `helm-rg-default-glob-string', which only finds files matching the
glob, and can be overridden with `helm-rg--set-glob', which is defined in
`helm-rg-map'.

There are many more `defcustom' forms, which are visible by searching for \"defcustom\" in the
`helm-rg' source (which can be located using `find-function'). These `defcustom' forms set defaults
for options which can be modified while invoking `helm-rg' using the keybindings listed below.

The ripgrep command's help output can be printed into its own buffer for
reference with the interactive command `helm-rg-display-help'.

\\{helm-rg-map}"
  (interactive (list (helm-rg--get-thing-at-pt) current-prefix-arg nil))
  (let* ((helm-rg--current-dir
          (or helm-rg--current-dir
              (and pfx default-directory)
              (helm-rg--interpret-starting-dir helm-rg-default-directory)))
         ;; TODO: make some declarative way to ensure these variables are all initialized and
         ;; destroyed (an alist `defconst' should do the trick)!
         (helm-rg--glob-string
          (or helm-rg--glob-string
              helm-rg-default-glob-string))
         (helm-rg--extra-args
          (or helm-rg--extra-args
              helm-rg-default-extra-args))
         (helm-rg--paths-to-search
          (or helm-rg--paths-to-search
              (or paths (list helm-rg--current-dir))))
         (helm-rg--case-sensitivity
          (or helm-rg--case-sensitivity
              helm-rg-default-case-sensitivity)))
    ;; FIXME: make all the `defvar's into buffer-local variables (or give them local counterparts)?
    ;; the idea is that `helm-resume' can be applied and work with the async action -- currently it
    ;; tries to find a buffer which we killed in the cleanup here when we do the async action
    ;; (i think)
    (setq helm-rg--last-dir helm-rg--current-dir)
    (unwind-protect (helm-rg--do-helm-rg rg-pattern)
      (helm-rg--unwind-cleanup)))))

Sorry for the lengthy post, but this way its just copypasta for people.

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

No branches or pull requests

8 participants