* Completing strings from history? @ 2001-03-26 14:20 John Cooper 2001-03-26 14:34 ` Peter Stephenson 0 siblings, 1 reply; 6+ messages in thread From: John Cooper @ 2001-03-26 14:20 UTC (permalink / raw) To: zsh-users [ZSH_VERSION is 4.0.1-pre-2] Typing `foo<ESC-/>' (bound to _history-complete-older) finds the most recent word in the history beginning "foo". Typing <ESC-/> again appears to do nothing. Is it possible to set things up so that repeatedly typing <ESC-/> cycles back through all matches in the history? (ala Emacs' dabbrev-expand) Thanks, --- John ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Completing strings from history? 2001-03-26 14:20 Completing strings from history? John Cooper @ 2001-03-26 14:34 ` Peter Stephenson 2001-03-26 15:25 ` Adam Spiers ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Peter Stephenson @ 2001-03-26 14:34 UTC (permalink / raw) To: zsh-users > Typing `foo<ESC-/>' (bound to _history-complete-older) finds the most recent > word in the history beginning "foo". Typing <ESC-/> again appears to do > nothing. > > Is it possible to set things up so that repeatedly typing <ESC-/> cycles back > through all matches in the history? (ala Emacs' dabbrev-expand) You can do this by setting the `stop' style, which is so called because it stops when it has reached as far back into the history as it can (unlike normal menu completion which would continue cycling). zstyle ':completion:history-words:*' stop 1 You should also be able to turn on menu completion just in this context, but I couldn't get that to work with a brief try, for some reason. What doesn't work which probably ought to is that if you type `\e,' (_history-complete-newer) it should cycle back in the other direction. Probably nobody thought about it at the time. -- Peter Stephenson <pws@csr.com> Software Engineer CSR Ltd., Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Completing strings from history? 2001-03-26 14:34 ` Peter Stephenson @ 2001-03-26 15:25 ` Adam Spiers 2001-03-26 15:52 ` John Cooper 2001-03-26 16:19 ` Bart Schaefer 2 siblings, 0 replies; 6+ messages in thread From: Adam Spiers @ 2001-03-26 15:25 UTC (permalink / raw) To: zsh-users Peter Stephenson (pws@csr.com) wrote: > What doesn't work which probably ought to is that if you type `\e,' > (_history-complete-newer) it should cycle back in the other direction. > Probably nobody thought about it at the time. Works for me with: zstyle ':completion:*:history-words' stop verbose ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Completing strings from history? 2001-03-26 14:34 ` Peter Stephenson 2001-03-26 15:25 ` Adam Spiers @ 2001-03-26 15:52 ` John Cooper 2001-03-26 16:47 ` Adam Spiers 2001-03-26 16:19 ` Bart Schaefer 2 siblings, 1 reply; 6+ messages in thread From: John Cooper @ 2001-03-26 15:52 UTC (permalink / raw) To: Peter Stephenson; +Cc: zsh-users Peter Stephenson <pws@csr.com> writes: > > Typing `foo<ESC-/>' (bound to _history-complete-older) finds the most recent > > word in the history beginning "foo". Typing <ESC-/> again appears to do > > nothing. > > > > Is it possible to set things up so that repeatedly typing <ESC-/> cycles back > > through all matches in the history? (ala Emacs' dabbrev-expand) > > You can do this by setting the `stop' style, which is so called because it > stops when it has reached as far back into the history as it can (unlike > normal menu completion which would continue cycling). > > zstyle ':completion:history-words:*' stop 1 Ideally, I'd prefer <ESC-/> to cycle back through the history _and_ have it cycle round after reaching the end of the history. Is this possible? With the above zstyle, I find that hitting <ESC-/> after having reached the oldest history item prohibits <ESC-,> from taking my forwards again, and similarly, hitting <ESC-,> after cycling forwards to the most recent item prohibits <ESC-/> from taking me backwards again. Two more questions: 1. Is it possible to turn off the beep that's emitted every time I type <ESC-/>? 2. Can all matching words be displayed as per normal completions (then I'd see whether it's worth continuing to bang on <ESC-/> a few more times)? Thanks again, --- John ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Completing strings from history? 2001-03-26 15:52 ` John Cooper @ 2001-03-26 16:47 ` Adam Spiers 0 siblings, 0 replies; 6+ messages in thread From: Adam Spiers @ 2001-03-26 16:47 UTC (permalink / raw) To: zsh-users John Cooper (john.cooper@eu.citrix.com) wrote: > Peter Stephenson <pws@csr.com> writes: > > > Typing `foo<ESC-/>' (bound to _history-complete-older) finds the most recent > > > word in the history beginning "foo". Typing <ESC-/> again appears to do > > > nothing. > > > > > > Is it possible to set things up so that repeatedly typing <ESC-/> cycles back > > > through all matches in the history? (ala Emacs' dabbrev-expand) > > > > You can do this by setting the `stop' style, which is so called because it > > stops when it has reached as far back into the history as it can (unlike > > normal menu completion which would continue cycling). > > > > zstyle ':completion:history-words:*' stop 1 Actually the intention was that repeatedly typing <ESC-/> always cycled back, and that the stop style would stop cycling when it hit the end-stops. In other words, the default behaviour I intended when I wrote it was the behaviour you want, but unfortunately it seems to be broken. > With the above zstyle, I find that hitting <ESC-/> after having reached the > oldest history item prohibits <ESC-,> from taking my forwards again, and > similarly, hitting <ESC-,> after cycling forwards to the most recent item > prohibits <ESC-/> from taking me backwards again. This is also a bug, I think. > Two more questions: > > 1. Is it possible to turn off the beep that's emitted every time I > type <ESC-/>? This is maybe also a bug. Argh! It doesn't happen for me, presumably because of one of the other zstyles I have set. Not sure which though. > 2. Can all matching words be displayed as per normal completions > (then I'd see whether it's worth continuing to bang on <ESC-/> a > few more times)? The `list' style controls that. I think the reason this is all such a mess is because there's no internal mechanism for controlling the behaviour of automenu when it reaches the start or end of the match list, so it had to be reimplemented in the shell function. Ideally the `stop' style would be implemented in the core of the completion code to control this, and which would greatly simplify the current nastiness that is _history_complete_word. It would also leave the core engine in charge of deciding when to generate the match list, rather than the current _history_complete_word_gen_matches. We could also then move the verbosity control from the `stop' style (which can currently be `true' or `verbose') into the `verbosity' style, which would make much more sense. Sven? ;-) Incidentally, the `Completion System Configuration' section in the info pages is enormous; how about splitting it up into smaller chunks? That way the xrefs from the `Style and Tag Index' would be much more helpful, as they would land you directly on (or at least, a lot closer to) the text concerning the style or tag you are looking up. Or can the info format do something equivalent to <a name="..."> ? Sorry, this is getting a bit -worker-ish again... ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Completing strings from history? 2001-03-26 14:34 ` Peter Stephenson 2001-03-26 15:25 ` Adam Spiers 2001-03-26 15:52 ` John Cooper @ 2001-03-26 16:19 ` Bart Schaefer 2 siblings, 0 replies; 6+ messages in thread From: Bart Schaefer @ 2001-03-26 16:19 UTC (permalink / raw) To: zsh-users On Mar 26, 2:34pm, Peter Stephenson wrote: } Subject: Re: Completing strings from history? } } > Is it possible to set things up so that repeatedly typing <ESC-/> } > cycles back through all matches in the history? (ala Emacs' } > dabbrev-expand) } } You can do this by setting the `stop' style, which is so called } because it stops when it has reached as far back into the history as } it can (unlike normal menu completion which would continue cycling). } } zstyle ':completion:history-words:*' stop 1 Hmm, this works, but it's a bit strange -- it beeps every time there's a completion, and stops beeping when it has run out of completions (which I think is because it believes it has found a unique match). You can at least see what it's doing if you use: zstyle ':completion:history-words:*' stop verbose } You should also be able to turn on menu completion just in this context, } but I couldn't get that to work with a brief try, for some reason. Turning on menu completion should have approximately the same effect as the `stop' style. (I'm not sure if that's intentional, or if the intent was instead to cycle, but the function doesn't differentiate between the `stop' style and menu completion.) However, _history_complete_word tests for menu completion by examining compstate[insert], not by examining a style, and _history_complete_word is a widget wrapper around _main_complete, so the only way that you can get compstate[insert] to be `menu' is to `setopt menucomplete' and also to `unsetopt automenu' (I think). Finally, the manual entry for the `stop' style is a little misleading: If it's set to ANYTHING, you get stopping-menu behavior, with the extra effect of `verbose' as described; setting the style to `false' or `0' won't do what's implied. } What doesn't work which probably ought to is that if you type `\e,' } (_history-complete-newer) it should cycle back in the other direction. The function attempts to do that, but it gets it wrong in the boundary conditions; that is, if you've ever actually reached the beginning or the end of the history, you lose the ability to reverse direction. Maybe that was intentional too (no point in showing you the entire history more than once) but somehow I doubt it. The following patch makes `setopt menucomplete' cycle through the history; the `return 0' are an attempt to stop the accursed beeping, but that does not work for some reason. Someone more immersed in the completion code than I will have to work out the other problems; I don't have more time this morning to fiddle with it. Index: Completion/Commands/_history_complete_word =================================================================== --- Completion/Commands/_history_complete_word 2001/02/28 17:05:07 1.24 +++ Completion/Commands/_history_complete_word 2001/03/26 16:14:23 @@ -56,19 +56,32 @@ if [[ "$direction" == 'older' ]]; then if [[ compstate[old_insert] -eq $_hist_menu_length || "$_hist_stop" == 'oldest' ]]; then - _hist_stop='oldest' [[ "$stop" = verbose ]] && _message 'beginning of history reached' + if [[ -n "$stop" ]]; then + _hist_stop='oldest' + else + compstate[old_list]=keep + (( compstate[insert] = 1 )) + return 0 + fi elif [[ "$_hist_stop" == 'newest' ]]; then zle -Rc _history_complete_word_gen_matches else compstate[old_list]=keep (( compstate[insert] = compstate[old_insert] + 1 )) + return 0 fi elif [[ "$direction" == 'newer' ]]; then if [[ compstate[old_insert] -eq 1 || "$_hist_stop" == 'newest' ]]; then - _hist_stop='newest' + if [[ -n "$stop" ]]; then + _hist_stop='newest' + else + compstate[old_list]=keep + (( compstate[insert] = $_hist_menu_length )) + return 0 + fi [[ "$stop" = verbose ]] && _message 'end of history reached' elif [[ "$_hist_stop" == 'oldest' ]]; then zle -Rc @@ -76,6 +89,7 @@ else compstate[old_list]=keep (( compstate[insert] = compstate[old_insert] - 1 )) + return 0 fi fi else -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-03-26 16:47 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-03-26 14:20 Completing strings from history? John Cooper 2001-03-26 14:34 ` Peter Stephenson 2001-03-26 15:25 ` Adam Spiers 2001-03-26 15:52 ` John Cooper 2001-03-26 16:47 ` Adam Spiers 2001-03-26 16:19 ` 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).