Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: history related suggestions



"Kiddle, Oliver" wrote:
> I'm not convinced by the zle set-local-history system for toggling between
> local and shared history. I (and I would think most people) will bind one
> set of keys to shared history operations and another set to local ones
> rather than binding a key to toggle the history mode.

You're supposed to use a widget function rather than bind it directly.
(What's happened to the manual entry for set-local-history in the zle
documentation?  It doesn't seem to say anywhere how it works.)

this-with-local-history() {
  local savnum=$NUMERIC
  NUMERIC=1
  zle set-local-history
  NUMERIC=$savnum
  zle the-normal-this-command
  NUMERIC=0
  zle set-local-history
}
zle -N this-with-local-history
bindkey '...' this-with-local-history

(this will all become smoother when argument handling becomes standardised
anyway).

> With argument handling
> hopefully being added to zle widgets (which I think is a great idea), I
> think it would be better to ditch set-local-history and add an option to
> each of the history related widgets specifying whether to use shared or
> local history.

It might be a nice idea to add this.

> Along with this, I would suggest that parameter expansion be
> done on the zle widget arguments each time the widget is run. This would
> allow users to do:
> bindkey '^[[A' up-line-or-history '$history_toggle'
> and then change the $history_toggle variable to select between local and
> shared history.

That sort of thing should certainly be done inside functions.

up-line-or-history-switch() {
  zle up-line-or-history $history_toggle
}
zle -N up-line-or-history-switch
bindkey '^[[A' up-line-or-history-switch

Extra levels of expansion tend to make things a bit of a mess, and in my
experience you always get to the point where you need the extra flexibility
of a function anyway.  (Cf. S. Wischnowsky, Collected New Completion
Mailings, Zsh Workers Mailing List 1999, passim.)

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author