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

Meaning of $BUFFER (was Re: PATCH: _list completer)



On Mar 24, 12:42pm, Sven Wischnowsky wrote:
} Subject: RE: PATCH: _list completer
}
} 
} Andrej Borsenkow wrote:
} 
} > But completion widget is a ZLE widget in the first place? And every
} > user-defined ZLE widget has some special parameters automatically setup -
} > and that includes BUFFER that does exactly what you need.
} 
} Err...  `BUFFER' only gives the current line, not the whole multi-line 
} buffer.

Not entirely true.  $BUFFER gives the whole multi-line buffer if you're
in a true multi-line edit, e.g. after backing up in the history to a
multi-line entry or after executing push-line-or-edit.

What we don't currently have is a way to get at all lines as far back
as the PS1 prompt when you're at a PS2 or more deeply nested prompt.

I would have expected this to work:

	function get_BUFFER {
	  zle push-input
	  zle get-line
	  echo $BUFFER
	}
	zle -N get-BUFFER get_BUFFER

But the whole function aborts after the `zle push-input` and never gets
as far as the `zle get-line`.  There appears to be a whole lot of work
left to make sure that widgets calling other widgets behaves sanely.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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