On Tue, 17 Apr 2018, Aditya Mahajan wrote: > On Tue, 17 Apr 2018, Hans Hagen wrote: > >> On 4/17/2018 12:01 AM, Aditya Mahajan wrote: >>> All features of the filter and vim modules work with the latest beta, >>> except for one final bug: leading spaces are stripped from the buffer. >>> >>> \starttext >>> >>> \startbuffer[test] >>>     Leading spaces >>> \stopbuffer >>> >>> \savebuffer[file=test-temp.tmp, prefix=no, list=test] >>> >>> \stoptext >>> >>> The leading spaces are stripped before the buffer is saved to the file >>> temp.tmp. Is it possible for the leading space NOT to be stripped? (If >>> not, I'll just document this as a feature :-). >> >> \samplefile{ward} >> \startnarrower >> \samplefile{ward} >> \startbuffer[test] >> Leading spaces >> And some more >> \stopbuffer >> \typebuffer[test] >> \stopnarrower >> \samplefile{ward} >> >> \startbuffer[test] >> Leading spaces >> And some more >> \stopbuffer >> \typebuffer[test] >> >> it is actually a feature to align the left edge relative to the least >> indented so that we can use them inside other constructs >> >> Now, as you're not afraid of low level code: >> >> \unprotect >> >> \unexpanded\def\StartAditya >> {\buff_pickup >> {Aditya}% >> {StartAditya}% >> {StopAditya}% >> {}% >> {\savebuffer[file=test-temp.tmp,prefix=no,list=Aditya]}% >> \zerocount} > > This is perfect as I am already using `\grabbufferdata` in my code. I can > easily adapt it to use `\buff_pickup` instead. Thanks!. > >> Does what you want but of course it's sort of ugly for a module to do that. >> What we can do is this which is still ugly but picking up verbatim is >> always ugly: >> >> \def\buff_start_indeed#1#2#3#4% >> {\edef\p_strip{\namedbufferparameter{#1}\c!strip}% >> >> \normalexpanded{\buff_pickup{#2}{#3}{#4}{}{\buff_stop{#4}}\ifx\p_strip\v!no\zerocount\else\plusone\fi}} >> >> \protect > I want this to be configurable at runtime and the vim module already has code > that enables `strip=yes` and `strip=no` options (I do this via a function in > vim so that it works with both mkii and mkiv; although I don't think that > anyone uses the mkii module any longer). I added `strip=yes` option to the filter module, which is now the default option. See "Stripping leading whitespace" in the module documentation (https://github.com/adityam/filter). This is a MkIV only feature and I will not implement it in MkII. I also made `strip=yes` to be the default in t-vim (to be consistent with t-filter). In t-vim, the `strip` option works with both mkii and mkiv. Aditya