zsh-workers
 help / color / mirror / code / Atom feed
* Path to fix copy-earlier-word handling of numeric arguments
@ 2024-04-04  9:39 Huy Z
  2024-04-04 10:03 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Huy Z @ 2024-04-04  9:39 UTC (permalink / raw)
  To: zsh-workers

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

As initially submitted at https://github.com/zsh-users/zsh/pull/116 :

------------------------------------------------------------------------

As mentioned in the code comment:

   # 1 means last word, 2 second last, etc.

the numeric argument is supposed to be interpreted as an offset from the 
end.

The intended behavior is a lot more useful than the current behavior.


------------------------------------------------------------------------



diff --git a/Functions/Zle/copy-earlier-word 
b/Functions/Zle/copy-earlier-word
index 90e862da3..1262c0c82 100644
--- a/Functions/Zle/copy-earlier-word
+++ b/Functions/Zle/copy-earlier-word
@@ -11,7 +11,7 @@ setopt typesetsilent
  typeset -g __copyword
  if (( ${NUMERIC:-0} )); then
    # 1 means last word, 2 second last, etc.
-  (( __copyword = ${NUMERIC:-0} ))
+  (( __copyword = -${NUMERIC:-0} ))
    zstyle -s :$WIDGET widget __copywidget
  elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then
    (( __copyword-- ))

------------------------------------------------------------------------


[-- Attachment #2: Type: text/html, Size: 7119 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Path to fix copy-earlier-word handling of numeric arguments
  2024-04-04  9:39 Path to fix copy-earlier-word handling of numeric arguments Huy Z
@ 2024-04-04 10:03 ` Mikael Magnusson
  2024-04-04 10:10   ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2024-04-04 10:03 UTC (permalink / raw)
  To: Huy Z; +Cc: zsh-workers

On Thu, Apr 4, 2024 at 11:41 AM Huy Z <h-zsh@huyz.us> wrote:
>
> As initially submitted at https://github.com/zsh-users/zsh/pull/116 :
>
> ________________________________
>
> As mentioned in the code comment:
>
>   # 1 means last word, 2 second last, etc.
>
> the numeric argument is supposed to be interpreted as an offset from the end.
>
> The intended behavior is a lot more useful than the current behavior.

NAK on this, this is not only longstanding behavior, but also what is
actually documented in the manpage:
  words on the relevant history line.  With a numeric argument  N,  insert  the
  Nth  word  from  the history line; N may be negative to count from the end of
  the line.


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Path to fix copy-earlier-word handling of numeric arguments
  2024-04-04 10:03 ` Mikael Magnusson
@ 2024-04-04 10:10   ` Mikael Magnusson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2024-04-04 10:10 UTC (permalink / raw)
  To: Huy Z; +Cc: zsh-workers

On Thu, Apr 4, 2024 at 12:03 PM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> On Thu, Apr 4, 2024 at 11:41 AM Huy Z <h-zsh@huyz.us> wrote:
> >
> > As initially submitted at https://github.com/zsh-users/zsh/pull/116 :
> >
> > ________________________________
> >
> > As mentioned in the code comment:
> >
> >   # 1 means last word, 2 second last, etc.
> >
> > the numeric argument is supposed to be interpreted as an offset from the end.
> >
> > The intended behavior is a lot more useful than the current behavior.
>
> NAK on this, this is not only longstanding behavior, but also what is
> actually documented in the manpage:
>   words on the relevant history line.  With a numeric argument  N,  insert  the
>   Nth  word  from  the history line; N may be negative to count from the end of
>   the line.

If you feel the other way around is more useful, perhaps adding a
zstyle to configure it would be a good idea, eg
if zstyle -t :$WIDGET count-from-end; then ...; else ...; fi

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-04 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04  9:39 Path to fix copy-earlier-word handling of numeric arguments Huy Z
2024-04-04 10:03 ` Mikael Magnusson
2024-04-04 10:10   ` Mikael Magnusson

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).