diff mbox series

[bug#39384] gnu: Add emacs-rg.

Message ID 87pnexrrwf.fsf@lafreniere.xyz
State Accepted
Headers show
Series [bug#39384] gnu: Add emacs-rg. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job

Commit Message

LaFreniere, Joseph Feb. 2, 2020, 2:21 p.m. UTC
Thank you for the fast feedback!

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> Nitpick: I think the trend is to align `base32' with the string.

> You may want to lint your package. In particular, the synopsis 
> should be
> akin to "Search tool based ..."

> The description must start with a full sentence, e.g., "rg.el" 
> is an
> Emacs search package...

> Texinfo requires two spaces after the full stop.

> Ditto. Besides, the quote after "users" looks suspicious. You 
> should use
> a regular quote.

A patch file is attached that addresses all of the above feedback. 
The output of `guix lint emacs-rg` is now clean on my system; 
thank you for making me aware of that utility.

The only part of the package I'm uncertain about is declaring 
ripgrep as a propagated dependency.  ripgrep is not needed for 
this Emacs package to be able to byte-compile successfully, but 
`rg` does not need to be on PATH for the package to be useful at 
all.  So while I imagine the majority of the uses-cases would want 
to have ripgrep installed locally, it's definitely plausible that 
one could only ever want to use emacs-rg via TRAMP in which case 
pulling in ripgrep would be completely unnecessary.

Please let me know what you think.

--
Joseph LaFreniere

Comments

Efraim Flashner Feb. 2, 2020, 6:47 p.m. UTC | #1
On Sun, Feb 02, 2020 at 08:21:52AM -0600, LaFreniere, Joseph wrote:
> Thank you for the fast feedback!
> 
> Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:
> > Nitpick: I think the trend is to align `base32' with the string.
> 
> > You may want to lint your package. In particular, the synopsis should be
> > akin to "Search tool based ..."
> 
> > The description must start with a full sentence, e.g., "rg.el" is an
> > Emacs search package...
> 
> > Texinfo requires two spaces after the full stop.
> 
> > Ditto. Besides, the quote after "users" looks suspicious. You should use
> > a regular quote.
> 
> A patch file is attached that addresses all of the above feedback. The
> output of `guix lint emacs-rg` is now clean on my system; thank you for
> making me aware of that utility.
> 
> The only part of the package I'm uncertain about is declaring ripgrep as a
> propagated dependency.  ripgrep is not needed for this Emacs package to be
> able to byte-compile successfully, but `rg` does not need to be on PATH for
> the package to be useful at all.  So while I imagine the majority of the
> uses-cases would want to have ripgrep installed locally, it's definitely
> plausible that one could only ever want to use emacs-rg via TRAMP in which
> case pulling in ripgrep would be completely unnecessary.
> 
> Please let me know what you think.

Is it possible to patch the invocations of `rg` to refer to ripgrep
directly?
LaFreniere, Joseph Feb. 3, 2020, 3:41 a.m. UTC | #2
Efraim Flashner <efraim@flashner.co.il> writes:
> Is it possible to patch the invocations of `rg` to refer to 
> ripgrep directly?

Thank you for the input, but I don't understand what you mean by 
"referring to ripgrep directly".  Can you elaborate on that 
proposal and how it would help resolve the question of whether to 
include ripgrep as a propagated input?

--
Joseph LaFreniere
Efraim Flashner Feb. 4, 2020, 9:58 a.m. UTC | #3
On Sun, Feb 02, 2020 at 09:41:41PM -0600, LaFreniere, Joseph wrote:
> 
> Efraim Flashner <efraim@flashner.co.il> writes:
> > Is it possible to patch the invocations of `rg` to refer to ripgrep
> > directly?
> 
> Thank you for the input, but I don't understand what you mean by "referring
> to ripgrep directly".  Can you elaborate on that proposal and how it would
> help resolve the question of whether to include ripgrep as a propagated
> input?

We want to have ripgrep as a regular input, so at the point in the code
where it searches through PATH for the rg binary we patch it to refer to
the specific binary. One example of this is in (gnu packages emacs-xyz),
with emacs-nov-el.
LaFreniere, Joseph Feb. 5, 2020, 3:08 a.m. UTC | #4
Efraim Flashner <efraim@flashner.co.il> writes:
> We want to have ripgrep as a regular input, so at the point in 
> the code
> where it searches through PATH for the rg binary we patch it to 
> refer to
> the specific binary. One example of this is in (gnu packages 
> emacs-xyz),
> with emacs-nov-el.

Ah, I see what you mean now.  But wouldn't hard-coding the path to 
ripgrep in that way prevent the package from being able to use 
remote systems' ripgrep binaries when running over TRAMP?

--
Joseph LaFreniere
Efraim Flashner Feb. 5, 2020, 7:13 a.m. UTC | #5
On February 5, 2020 3:08:11 AM UTC, "LaFreniere, Joseph" <joseph@lafreniere.xyz> wrote:
>
>Efraim Flashner <efraim@flashner.co.il> writes:
>> We want to have ripgrep as a regular input, so at the point in 
>> the code
>> where it searches through PATH for the rg binary we patch it to 
>> refer to
>> the specific binary. One example of this is in (gnu packages 
>> emacs-xyz),
>> with emacs-nov-el.
>
>Ah, I see what you mean now.  But wouldn't hard-coding the path to 
>ripgrep in that way prevent the package from being able to use 
>remote systems' ripgrep binaries when running over TRAMP?
>

Unfortunately that's not something I know. I remember that for the tramp package itself there were some changes related to PATH to make it work when connecting between a Guix System and a foreign one. Hopefully someone knows the answer.
Marius Bakke Feb. 5, 2020, 9:33 p.m. UTC | #6
"LaFreniere\, Joseph" <joseph@lafreniere.xyz> writes:

> Efraim Flashner <efraim@flashner.co.il> writes:
>> We want to have ripgrep as a regular input, so at the point in 
>> the code
>> where it searches through PATH for the rg binary we patch it to 
>> refer to
>> the specific binary. One example of this is in (gnu packages 
>> emacs-xyz),
>> with emacs-nov-el.
>
> Ah, I see what you mean now.  But wouldn't hard-coding the path to 
> ripgrep in that way prevent the package from being able to use 
> remote systems' ripgrep binaries when running over TRAMP?

Perhaps we could patch it to do both?  Use the store prefix if it
exists, and fall back to searching in PATH?
LaFreniere, Joseph Feb. 7, 2020, 12:47 a.m. UTC | #7
Marius Bakke <mbakke@fastmail.com> writes:
> "LaFreniere\, Joseph" <joseph@lafreniere.xyz> writes:
>> Ah, I see what you mean now.  But wouldn't hard-coding the path 
>> to
>> ripgrep in that way prevent the package from being able to use
>> remote systems' ripgrep binaries when running over TRAMP?
>
> Perhaps we could patch [emacs-rg] to do both?  Use the store 
> prefix if it
> exists, and fall back to searching in PATH?

What would be the advantage of that over just searching PATH to 
start with?

--
Joseph LaFreniere
Efraim Flashner Feb. 7, 2020, 10:54 a.m. UTC | #8
On Thu, Feb 06, 2020 at 06:47:23PM -0600, LaFreniere, Joseph wrote:
> 
> Marius Bakke <mbakke@fastmail.com> writes:
> > "LaFreniere\, Joseph" <joseph@lafreniere.xyz> writes:
> > > Ah, I see what you mean now.  But wouldn't hard-coding the path to
> > > ripgrep in that way prevent the package from being able to use
> > > remote systems' ripgrep binaries when running over TRAMP?
> > 
> > Perhaps we could patch [emacs-rg] to do both?  Use the store prefix if
> > it
> > exists, and fall back to searching in PATH?
> 
> What would be the advantage of that over just searching PATH to start with?

It will still work even if you don't have ripgrep specifically
installed.
LaFreniere, Joseph Feb. 8, 2020, 10:23 p.m. UTC | #9
Efraim Flashner <efraim@flashner.co.il> writes:
> On Thu, Feb 06, 2020 at 06:47:23PM -0600, LaFreniere, Joseph 
> wrote:
>>
>> Marius Bakke <mbakke@fastmail.com> writes:
>> > "LaFreniere\, Joseph" <joseph@lafreniere.xyz> writes:
>> > > Ah, I see what you mean now.  But wouldn't hard-coding the 
>> > > path to
>> > > ripgrep in that way prevent the package from being able to 
>> > > use
>> > > remote systems' ripgrep binaries when running over TRAMP?
>> >
>> > Perhaps we could patch [emacs-rg] to do both?  Use the store 
>> > prefix if
>> > it
>> > exists, and fall back to searching in PATH?
>>
>> What would be the advantage of that over just searching PATH to 
>> start with?
>
> It will still work even if you don't have ripgrep specifically
> installed.

Can you point me to the Guix documentation where the functionality 
you're describing is explained?  I have read through the 
description of package inputs in section 6.2.1 of Guix's manual, 
but I still do not explain what advantage patching the search path 
offers.

My understanding is that if we want to preserve both local and 
remote-via-TRAMP functionality, we can either
- just include ripgrep as a propagated input, or
- include ripgrep as a propagated input _and_ patch the package to 
  look for ripgrep in a hardcoded location (for local) as well as 
  PATH (for TRAMP).

Both options would have ripgrep included as propagated input.  As 
soon as ripgrep is installed in a user's profile, its binary will 
be available on PATH.  If that is correct, then I don't see any 
advantage to patching in a hardcoded path to ripgrep.

--
Joseph LaFreniere
Efraim Flashner Feb. 9, 2020, 1:28 p.m. UTC | #10
On Sat, Feb 08, 2020 at 04:23:08PM -0600, LaFreniere, Joseph wrote:
> 
> Efraim Flashner <efraim@flashner.co.il> writes:
> > On Thu, Feb 06, 2020 at 06:47:23PM -0600, LaFreniere, Joseph wrote:
> > > 
> > > Marius Bakke <mbakke@fastmail.com> writes:
> > > > "LaFreniere\, Joseph" <joseph@lafreniere.xyz> writes:
> > > > > Ah, I see what you mean now.  But wouldn't hard-coding the > >
> > > path to
> > > > > ripgrep in that way prevent the package from being able to > >
> > > use
> > > > > remote systems' ripgrep binaries when running over TRAMP?
> > > >
> > > > Perhaps we could patch [emacs-rg] to do both?  Use the store >
> > > prefix if
> > > > it
> > > > exists, and fall back to searching in PATH?
> > > 
> > > What would be the advantage of that over just searching PATH to
> > > start with?
> > 
> > It will still work even if you don't have ripgrep specifically
> > installed.
> 
> Can you point me to the Guix documentation where the functionality you're
> describing is explained?  I have read through the description of package
> inputs in section 6.2.1 of Guix's manual, but I still do not explain what
> advantage patching the search path offers.

I'm not sure I can find a spot in the manual where it is detailed. It
comes down to the difference between "search for this program in PATH"
and "call this program located at this location". By calling the rg
at it's exact path rg doesn't need to be installed directly.

> My understanding is that if we want to preserve both local and
> remote-via-TRAMP functionality, we can either
> - just include ripgrep as a propagated input, or
> - include ripgrep as a propagated input _and_ patch the package to  look for
> ripgrep in a hardcoded location (for local) as well as  PATH (for TRAMP).

The second option is to include ripgrep as an input and patch the
package to look for it at a hardcoded location (for local) as well as
PATH (for TRAMP).

> Both options would have ripgrep included as propagated input.  As soon as
> ripgrep is installed in a user's profile, its binary will be available on
> PATH.  If that is correct, then I don't see any advantage to patching in a
> hardcoded path to ripgrep.
> 
> --
> Joseph LaFreniere
diff mbox series

Patch

From 9a17c333ceee4bb72dcb1ee36aaf45a7d2ce4276 Mon Sep 17 00:00:00 2001
From: Joseph LaFreniere <joseph@lafreniere.xyz>
Date: Sat, 1 Feb 2020 14:23:36 -0600
Subject: [PATCH] gnu: Add emacs-rg.

* gnu/packages/emacs-xyz.scm (emacs-rg): New variable.
---
 gnu/packages/emacs-xyz.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index f95ad26e4b..29928364e0 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -134,6 +134,7 @@ 
   #:use-module (gnu packages package-management)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pdf)
+  #:use-module (gnu packages rust-apps)
   #:use-module (gnu packages scheme)
   #:use-module (gnu packages speech)
   #:use-module (gnu packages xiph)
@@ -2751,6 +2752,32 @@  column by drawing a thin line down the length of the editing window.")
      "This Emacs package allows managing multiple grep buffers.")
     (license license:gpl3+)))
 
+(define-public emacs-rg
+  (package
+    (name "emacs-rg")
+    (version "1.8.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dajva/rg.el.git")
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0k7x5z7mh9flwih35cqy8chs54rack3nswdcpw5wcpgv6xim227y"))))
+    (build-system emacs-build-system)
+    (propagated-inputs
+     `(("emacs-s" ,emacs-s)
+       ("emacs-wgrep" ,emacs-wgrep)
+       ("ripgrep" ,ripgrep)))
+    (home-page "https://rgel.readthedocs.io/en/latest/")
+    (synopsis "Search tool based on @code{ripgrep}")
+    (description
+     "@code{rg} is an Emacs search package based on the @code{ripgrep} command
+line tool.  It allows one to interactively search based on the editing context
+then refine or modify the search results.")
+    (license license:gpl3+)))
+
 (define-public emacs-inf-ruby
   (package
     (name "emacs-inf-ruby")
-- 
2.25.0