zsh-workers
 help / color / mirror / code / Atom feed
* zsh request
@ 1996-11-21  8:57 Huy Le
  1996-11-21 10:54 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Huy Le @ 1996-11-21  8:57 UTC (permalink / raw)
  To: zsh-workers

I have a couple of keybinding requests:

1) insert-second-to-last-word (in the same spirit as insert-last word,
which I use constantly)

2) that expand-cmd-path be repeatable so that everytime you invoke it,
the expansion changes to the next possible path for that command.
For example, if
  bindkey    '^P' expand-cmd-path
  PATH=/home/huyle/bin:/usr/local/bin:/bin
then
% make bob
^P
% /home/huyle/bin/make bob
^P
% /usr/local/bin/make bob
^P
% /bin/make bob
^P
% /home/huyle/bin/make bob

Thanks,
    Huy


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

* Re: zsh request
  1996-11-21  8:57 zsh request Huy Le
@ 1996-11-21 10:54 ` Bart Schaefer
  1996-11-22 16:09   ` insert-last-word (was Re: zsh request)  JD Laub
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 1996-11-21 10:54 UTC (permalink / raw)
  To: Huy Le, zsh-workers

On Nov 21, 12:57am, Huy Le wrote:
} Subject: zsh request
}
} I have a couple of keybinding requests:
} 
} 1) insert-second-to-last-word (in the same spirit as insert-last word,
} which I use constantly)

I think making insert-last-word read its prefix argument as a word
position would be preferable.  In the current code, insert-last-word
ignores the prefix, so this is a reasonably compatible change.

Drawback:  Word 0 is the command name, but ESC 1 ESC _ must count
from the right to be compatible with the past implementation (zsh is
not able to distinguish the 1 prefix from no prefix at all).  This
means all positive numbers should count from the right; which is OK
because the name is after all insert-last-word, so ESC 2 ESC _ means
insert the second word back from the end.  (Then you use bindkey -s
to put this on a single keystroke; presto, insert-second-last-word.)

So of course negative prefixes count from the left, with the slight
oddity that ESC 0 ESC _ also counts from the left (giving you the
command name).

*** Src/zle_hist.c.0	Sun Jul 28 13:48:29 1996
--- Src/zle_hist.c	Thu Nov 21 02:25:07 1996
***************
*** 483,490 ****
  	feep();
  	return;
      }
!     s = he->text + he->words[2*he->nwords-2];
!     t = he->text + he->words[2*he->nwords-1];
      save = *t;
      *t = '\0';			/* ignore trailing whitespace */
  
--- 483,499 ----
  	feep();
  	return;
      }
!     if (zmult > 0) {
! 	zmult = he->nwords - (zmult - 1);
!     } else {
! 	zmult = 1 - zmult;
!     }
!     if (zmult < 1 || zmult > he->nwords) {
! 	feep();
! 	return;
!     }
!     s = he->text + he->words[2*zmult-2];
!     t = he->text + he->words[2*zmult-1];
      save = *t;
      *t = '\0';			/* ignore trailing whitespace */
  

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* insert-last-word (was Re: zsh request)
  1996-11-21 10:54 ` Bart Schaefer
@ 1996-11-22 16:09   `  JD Laub
  1996-11-22 18:09     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From:  JD Laub @ 1996-11-22 16:09 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer writes:
> } 1) insert-second-to-last-word (in the same spirit as insert-last word,
> } which I use constantly)
> 
> [...] ESC 1 ESC _ must count
> from the right to be compatible with the past implementation (zsh is
> not able to distinguish the 1 prefix from no prefix at all).

Not that I'm objecting to the implementation, but I'm curious: gotmult
gets set if the user supplied a prefix, with zmult storing the actual
prefix.  Am I missing something?
-- 
J.D. Laub (Laubster) |"I think you're very, very, very, very, very,
jdl@iasi.com         |very, very, very, very, ..." - Flying Lizards


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

* Re: insert-last-word (was Re: zsh request)
  1996-11-22 16:09   ` insert-last-word (was Re: zsh request)  JD Laub
@ 1996-11-22 18:09     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 1996-11-22 18:09 UTC (permalink / raw)
  To:  JD Laub, zsh-workers

On Nov 22,  9:09am,  JD Laub wrote:
} Subject: insert-last-word (was Re: zsh request)
}
} Bart Schaefer writes:
} > not able to distinguish the 1 prefix from no prefix at all).
} 
} Not that I'm objecting to the implementation, but I'm curious: gotmult
} gets set if the user supplied a prefix, with zmult storing the actual
} prefix.  Am I missing something?

No, I am.  It's been so long since I changed any zle functions, I'd
forgotten that it existed; there are only two places outside zle_vi.c
where it's tested, so I didn't spot it when looking at other functions
that use zmult ...

I still think the way I did it is the best way, though.  With gotmult,
it could be changed so that -1 was the last word, -2 the second-last,
etc., as with array subscripting; but since the name of the function
is insert-LAST-word, I think it makes sense to count from the right
without having to type that extra `ESC -'.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

end of thread, other threads:[~1996-11-22 18:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-21  8:57 zsh request Huy Le
1996-11-21 10:54 ` Bart Schaefer
1996-11-22 16:09   ` insert-last-word (was Re: zsh request)  JD Laub
1996-11-22 18:09     ` Bart Schaefer

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