zsh-workers
 help / color / mirror / code / Atom feed
From: Marlon Richert <marlon.richert@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Increase $COLUMNS when generating long option completions
Date: Sat, 7 Aug 2021 22:55:32 +0300	[thread overview]
Message-ID: <CAHLkEDsLUijwAuZdy=wPok3DkRNH2Ew418R0TS2nPu_E=NqFbQ@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZyoK=-Sw856QkS7FV=4gzVqu5p=kAtPDSEgnMJGVqhXw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

On Fri, Aug 6, 2021 at 2:44 AM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Thu, Aug 5, 2021 at 11:12 AM Marlon Richert <marlon.richert@gmail.com> wrote:
> >
> > I don't know if it makes sense to always set
> > COLUMNS in _call_program, because it is not always called to produce
> > visual output. On the other hand, if you think it won't hurt, then
> > yes, that might be a better option.
>
> I can't think of a case where it would be an issue ... if the program
> isn't producing output meant for the terminal, it shouldn't be
> bothered by either the presence or absence of $COLUMNS.  I'm now
> pondering whether your original method does either a better or a worse
> (or neither) job if the called program uses a remote shell or the
> like.
>
> > I made it 999, rather than $COLUMNS, because the output is cached and
> > terminal emulators can be resized.
>
> Hrm.  That sounds like a problem with the cache validation rules, but
> I suppose setting a large value of COLUMNS is a reasonable safeguard.

How does this patch look to you?

[-- Attachment #2: 0001-Set-COLUMNS-in-_call_program-to-ensure-cached-comman.txt --]
[-- Type: text/plain, Size: 1423 bytes --]

From 1912a575fbdf34e4937eeea9387807351342fc37 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@users.noreply.github.com>
Date: Sat, 7 Aug 2021 22:52:21 +0300
Subject: [PATCH] Set $COLUMNS in _call_program to ensure cached command output
 is sufficiently wide

---
 Completion/Base/Utility/_call_program | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program
index 73f3ef6d2..cc7c9adf9 100644
--- a/Completion/Base/Utility/_call_program
+++ b/Completion/Base/Utility/_call_program
@@ -1,6 +1,7 @@
 #autoload +X
 
-local curcontext="${curcontext}" tmp err_fd=-1 clocale='_comp_locale;'
+local cmd clocale='_comp_locale;' cols='COLUMNS=999' curcontext="${curcontext}"
+local -i err_fd=-1
 local -a prefix
 
 if [[ "$1" = -p ]]; then
@@ -22,14 +23,14 @@ fi
 
 {	# Begin "always" block
 
-if zstyle -s ":completion:${curcontext}:${1}" command tmp; then
-  if [[ "$tmp" = -* ]]; then
-    eval $clocale "$tmp[2,-1]" "$argv[2,-1]"
+if zstyle -s ":completion:${curcontext}:${1}" command cmd; then
+  if [[ "$cmd" = -* ]]; then
+    eval $clocale $cols "$cmd[2,-1]" "$argv[2,-1]"
   else
-    eval $clocale $prefix "$tmp"
+    eval $clocale $cols $prefix "$cmd"
   fi
 else
-  eval $clocale $prefix "$argv[2,-1]"
+  eval $clocale $cols $prefix "$argv[2,-1]"
 fi 2>&$err_fd
 
 } always {
-- 
2.30.1 (Apple Git-130)


  reply	other threads:[~2021-08-07 19:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 19:24 Marlon Richert
2021-08-01 23:06 ` Bart Schaefer
2021-08-03 14:05   ` Marlon Richert
2021-08-04  1:12     ` Lawrence Velázquez
2021-08-04  3:48       ` Bart Schaefer
2021-08-04  6:51       ` Marlon Richert
2021-08-04  7:19         ` Lawrence Velázquez
2021-08-05  6:19           ` Marlon Richert
2021-08-05  6:24             ` Bart Schaefer
2021-08-05 18:11               ` Marlon Richert
2021-08-05 23:44                 ` Bart Schaefer
2021-08-07 19:55                   ` Marlon Richert [this message]
2021-08-07 22:41                     ` Bart Schaefer
2021-08-10 19:04                       ` Marlon Richert
2021-08-10 19:17                         ` Marlon Richert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHLkEDsLUijwAuZdy=wPok3DkRNH2Ew418R0TS2nPu_E=NqFbQ@mail.gmail.com' \
    --to=marlon.richert@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).