[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#55845] [PATCH 0/1] Improve pager selection logic when less is not i

From: Taiju HIGASHI
Subject: [bug#55845] [PATCH 0/1] Improve pager selection logic when less is not installed
Date: Thu, 09 Jun 2022 00:09:16 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux)

Hi Tobias,

Thank you kindly for your detailed explanation.

Tobias Geerinckx-Rice <> writes:

> Hi again,
> Taiju HIGASHI 写道:
>> I understand that I can delay the evaluation timing if I make it a
>> procedure, but is my understanding correct that the number of calls
>> will
>> remain the same because it will be evaluated each time the
>> `call-with-paginated-output-port` procedure is called?
> Previously, it would have been evaluated even if
> call-with-paginated-output-port was never called at all.
> As for the >0 calls case: yes… but when do we expect
> call-with-paginated-output-port to be called more than once per run?
> The use case for this code is to do something, then display it in a
> pager and exit.  I think calling it multiple times in one run would
> imply bad UX.
> Do I misunderstand?

No, you don't.
As you said, my implementation was a bad idea, as
call-with-paginated-output-port is executed even when it is not needed.
It seems unlikely that call-with-paginated-output-port will be called
more than once in a single process. I did not have enough insight.

>> I agree with your point that it would be better to make it a
>> procedure,
>> as it would be more eco-friendly to not have to evaluate when
>> or PAGER is specified.
> I wish the rest of Guix were so efficient that it mattered :-)
> [/me is waiting for ‘guix pull’ as I reply to multiple mails, on
> battery…]
> Regardless, not calling a procedure at all is even more efficient and
> IMO more readable here.

I agree.

>> You mean that the $PATH lookup in open-pipe can be suppressed?
> Yes.  OPEN-PIPE* won't need to stat $PATH at all if we give it
> "/run/current-system/profile/bin/less" instead of "less".
> (It's not relevant to the above, but my previously reply mistakenly
> mentioned a shell ― there is no shell involved with OPEN-PIPE*, only
> with OPEN-PIPE.  Sorry.)

No problem. I'm sorry I'm the one who asked a ton of questions.

>> I will just write what you have told me, but may I continue to
>> modify
>> the patch?
> Of course!  Curious how, though.

I have also received a response from Maxime and plan to include the
following information.

(define (find-available-pager)
  "Returns the program name or path of an available pager.
If neither less nor more is installed, return an empty string so that
call-with-paginated-output-port will not call pager."
  (or (getenv "GUIX_PAGER")
      (getenv "PAGER")
      (which "less")
      (which "more")
      "" ;; Returns an empty string so that call-with-paginated-output-port 
does not call pager.

(define* (call-with-paginated-output-port proc
                                          #:key (less-options "FrX"))
  (let ((pager-command-line (find-available-pager)))

However, I can't submit the v2 patch yet because I don't know how to
implement the integration test.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]