About using vartabstop

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

About using vartabstop

Lifepillar
There's a meme (if it may be called so) circulating on Twitter
about using Fibonacci sequences for indentation. Just for fun,
I wanted to see if it could be implemented using the vartabs
feature. I thought that this would do it (for C files):

set shiftwidth=0
set noexpandtab
set vartabstop=1,1,2,3,5,8,13,21,34
set autoindent
set smartindent
set ft=c

With the above settings, it appears that the value of tabstop
is used. This seems to agree with shiftwidth's documentation:
“When [shiftwidth is] zero the 'ts' value will be used”, but
not with tabstop's help: “the value of 'tabstop' will be
ignored while 'vartabstop' is set”. Putting together the two,
I would expect the above to use vartabstop.

Am I missing something?

Thanks,
Life.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

David Woodfall
On Wednesday 29 August 2018 18:47,
Lifepillar <[hidden email]> put forth the proposition:
> There's a meme (if it may be called so) circulating on Twitter
> about using Fibonacci sequences for indentation. Just for fun,
> I wanted to see if it could be implemented using the vartabs
> feature. I thought that this would do it (for C files):
>
> set shiftwidth=0
> set noexpandtab

Won't this change *all* tab indents to the same size? Surely you need
to use expandtab?

> set vartabstop=1,1,2,3,5,8,13,21,34
> set autoindent
> set smartindent
> set ft=c
>
> With the above settings, it appears that the value of tabstop
> is used. This seems to agree with shiftwidth's documentation:
> “When [shiftwidth is] zero the 'ts' value will be used”, but
> not with tabstop's help: “the value of 'tabstop' will be
> ignored while 'vartabstop' is set”. Putting together the two,
> I would expect the above to use vartabstop.
>
> Am I missing something?

I think it may need more work than that, but I may be wrong.

You may need to indentexpr to a custom function and use that
to set ind.

See :help indentexpr

-Dave

--

> I get the following error messages at bootup, could anyone tell me
> what they mean?
> fcntl_setlk() called by process 51 (lpd) with broken flock() emulation
They mean that you have not read the documentation when upgrading the
kernel.
  -- seen on c.o.l.misc

                                                            .--.  oo
                                                           (____)//
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

Christian Brabandt
In reply to this post by Lifepillar

On Mi, 29 Aug 2018, Lifepillar wrote:

> There's a meme (if it may be called so) circulating on Twitter
> about using Fibonacci sequences for indentation. Just for fun,
> I wanted to see if it could be implemented using the vartabs
> feature. I thought that this would do it (for C files):
>
> set shiftwidth=0
> set noexpandtab
> set vartabstop=1,1,2,3,5,8,13,21,34
> set autoindent
> set smartindent
> set ft=c
>
> With the above settings, it appears that the value of tabstop
> is used. This seems to agree with shiftwidth's documentation:
> “When [shiftwidth is] zero the 'ts' value will be used”, but
> not with tabstop's help: “the value of 'tabstop' will be
> ignored while 'vartabstop' is set”. Putting together the two,
> I would expect the above to use vartabstop.
>
> Am I missing something?

I am not sure. It might be, that the functionality of using the tabstop
setting when shiftwidth is zero is indeed missing from vartabstop,
because this was done some time after the vartab patch has been created
and that feature has than not made it back into the vartabs patch.

I'll have a look at it in more detail later.

Best,
Christian
--
In der Politik ist nicht alles richtig, was rechtens ist.
                -- Rezzo Schlauch

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

David Woodfall
In reply to this post by David Woodfall
On Thu, 30 Aug 2018 00:20:18 +0100
David Woodfall <[hidden email]> wrote:

> On Wednesday 29 August 2018 18:47,
> Lifepillar <[hidden email]> put forth the proposition:
> > There's a meme (if it may be called so) circulating on Twitter
> > about using Fibonacci sequences for indentation. Just for fun,
> > I wanted to see if it could be implemented using the vartabs
> > feature. I thought that this would do it (for C files):
> >
> > set shiftwidth=0
> > set noexpandtab  
>
> Won't this change *all* tab indents to the same size? Surely you need
> to use expandtab?
>
> > set vartabstop=1,1,2,3,5,8,13,21,34
> > set autoindent
> > set smartindent
> > set ft=c
> >
> > With the above settings, it appears that the value of tabstop
> > is used. This seems to agree with shiftwidth's documentation:
> > “When [shiftwidth is] zero the 'ts' value will be used”, but
> > not with tabstop's help: “the value of 'tabstop' will be
> > ignored while 'vartabstop' is set”. Putting together the two,
> > I would expect the above to use vartabstop.
> >
> > Am I missing something?  
>
> I think it may need more work than that, but I may be wrong.
>
> You may need to indentexpr to a custom function and use that
> to set ind.
>
> See :help indentexpr

It looks like someone else saw that twitter post :)

https://github.com/dodie/vim-fibo-indent

Related:

https://github.com/dodie/vim-disapprove-deep-indentation

ಠ_ಠ

-Dave

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

h_east
In reply to this post by Christian Brabandt
Hi,

2018-8-30(Thu) 14:36:09 UTC+9 Christian Brabandt:

> On Mi, 29 Aug 2018, Lifepillar wrote:
>
> > There's a meme (if it may be called so) circulating on Twitter
> > about using Fibonacci sequences for indentation. Just for fun,
> > I wanted to see if it could be implemented using the vartabs
> > feature. I thought that this would do it (for C files):
> >
> > set shiftwidth=0
> > set noexpandtab
> > set vartabstop=1,1,2,3,5,8,13,21,34
> > set autoindent
> > set smartindent
> > set ft=c
> >
> > With the above settings, it appears that the value of tabstop
> > is used. This seems to agree with shiftwidth's documentation:
> > “When [shiftwidth is] zero the 'ts' value will be used”, but
> > not with tabstop's help: “the value of 'tabstop' will be
> > ignored while 'vartabstop' is set”. Putting together the two,
> > I would expect the above to use vartabstop.
> >
> > Am I missing something?
>
> I am not sure. It might be, that the functionality of using the tabstop
> setting when shiftwidth is zero is indeed missing from vartabstop,
> because this was done some time after the vartab patch has been created
> and that feature has than not made it back into the vartabs patch.
>
> I'll have a look at it in more detail later.
I also tried Fibonacci indent with the vartabstop option yesterday. 😃
https://twitter.com/h_east/status/1034606768226070528 (Japanese)

It worked well for files already indented with tabs, but auto indentation in insert mode did not work well.

I investigated for a moment but I could not fix it.
Probably we will fix it by modifying tabstop_padding().

--
Best regards,
Hirohito Higashi (h_east)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

Christian Brabandt
In reply to this post by Christian Brabandt

On Do, 30 Aug 2018, Christian Brabandt wrote:

>
> On Mi, 29 Aug 2018, Lifepillar wrote:
>
> > There's a meme (if it may be called so) circulating on Twitter
> > about using Fibonacci sequences for indentation. Just for fun,
> > I wanted to see if it could be implemented using the vartabs
> > feature. I thought that this would do it (for C files):
> >
> > set shiftwidth=0
> > set noexpandtab
> > set vartabstop=1,1,2,3,5,8,13,21,34
> > set autoindent
> > set smartindent
> > set ft=c
> >
> > With the above settings, it appears that the value of tabstop
> > is used. This seems to agree with shiftwidth's documentation:
> > “When [shiftwidth is] zero the 'ts' value will be used”, but
> > not with tabstop's help: “the value of 'tabstop' will be
> > ignored while 'vartabstop' is set”. Putting together the two,
> > I would expect the above to use vartabstop.
> >
> > Am I missing something?
>
> I am not sure. It might be, that the functionality of using the tabstop
> setting when shiftwidth is zero is indeed missing from vartabstop,
> because this was done some time after the vartab patch has been created
> and that feature has than not made it back into the vartabs patch.
>
> I'll have a look at it in more detail later.
Indeed, that's the problem. The vartab option is not taken into account
when the shiftwidth option is set to zero.

Attached is a patch, that fixes the issue.

However, it currently fails test86.in with the following error:
--- test86.ok   2018-11-14 13:32:51.652857566 +0100
+++ test86.failed       2018-11-14 16:48:10.638090709 +0100
@@ -297,6 +297,9 @@
   wopts2! KeyError
   wopts3! KeyError
   p/bopts1: 8
+  inv: 3! error
+  bopts1! error
+  bopts2! error
   G: 8
   W: 1:0 2:2 3:8 4:1
   B: 1:0 2:2 3:8 4:1

I don't understand the python code in there to know what this does. Sorry.

Best,
Christian
--
Zeig mir deine Uhr, und ich sage dir, wie spät es ist.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

0001-Return-correct-tabstop-setting-when-sw-0.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: About using vartabstop

Bram Moolenaar

Christian Brabandt wrote:

> > On Mi, 29 Aug 2018, Lifepillar wrote:
> >
> > > There's a meme (if it may be called so) circulating on Twitter
> > > about using Fibonacci sequences for indentation. Just for fun,
> > > I wanted to see if it could be implemented using the vartabs
> > > feature. I thought that this would do it (for C files):
> > >
> > > set shiftwidth=0
> > > set noexpandtab
> > > set vartabstop=1,1,2,3,5,8,13,21,34
> > > set autoindent
> > > set smartindent
> > > set ft=c
> > >
> > > With the above settings, it appears that the value of tabstop
> > > is used. This seems to agree with shiftwidth's documentation:
> > > “When [shiftwidth is] zero the 'ts' value will be used”, but
> > > not with tabstop's help: “the value of 'tabstop' will be
> > > ignored while 'vartabstop' is set”. Putting together the two,
> > > I would expect the above to use vartabstop.
> > >
> > > Am I missing something?
> >
> > I am not sure. It might be, that the functionality of using the tabstop
> > setting when shiftwidth is zero is indeed missing from vartabstop,
> > because this was done some time after the vartab patch has been created
> > and that feature has than not made it back into the vartabs patch.
> >
> > I'll have a look at it in more detail later.
>
> Indeed, that's the problem. The vartab option is not taken into account
> when the shiftwidth option is set to zero.
>
> Attached is a patch, that fixes the issue.
>
> However, it currently fails test86.in with the following error:
> --- test86.ok   2018-11-14 13:32:51.652857566 +0100
> +++ test86.failed       2018-11-14 16:48:10.638090709 +0100
> @@ -297,6 +297,9 @@
>    wopts2! KeyError
>    wopts3! KeyError
>    p/bopts1: 8
> +  inv: 3! error
> +  bopts1! error
> +  bopts2! error
>    G: 8
>    W: 1:0 2:2 3:8 4:1
>    B: 1:0 2:2 3:8 4:1
>
> I don't understand the python code in there to know what this does. Sorry.

When compiled with the "abort on internal error" flag, I see an ml_get() error:

#2  0x000055555582ad8f in iemsgn (s=0x555555843628 "E315: ml_get: invalid lnum:
%ld", n=2009) at message.c:802
#3  0x000055555566a294 in ml_get_buf (buf=0x555555e88c30, lnum=2009, will_change
=0) at memline.c:2500
#4  0x000055555581de5a in getvcol (wp=0x555555b02dc0, pos=0x555555b02df8, start=
0x0, cursor=0x555555b02ea0, end=0x0) at charset.c:1303
#5  0x000055555581e461 in getvvcol (wp=0x555555b02dc0, pos=0x555555b02df8, start
=0x0, cursor=0x555555b02ea0, end=0x0) at charset.c:1500
#6  0x00005555556912df in validate_virtcol_win (wp=0x555555b02dc0) at move.c:822
#7  0x0000555555691286 in validate_virtcol () at move.c:810
#8  0x00005555555bd958 in get_nolist_virtcol () at edit.c:10690
#9  0x00005555556d055d in get_sw_value (buf=0x555555e88c30) at option.c:13089
#10 0x000055555567fbd2 in parse_cino (buf=0x555555e88c30) at misc1.c:7132
#11 0x00005555556c7f6a in set_num_option (opt_idx=294, varp=0x555555e8a578 "\003
", value=3, errbuf=0x0, errbuflen=0, opt_flags=4) at option.c:9126
#12 0x00005555556c984c in set_option_value (name=0x7fffee5f96e4 "shiftwidth", nu
mber=3, string=0x0, opt_flags=4) at option.c:9954
#13 0x00005555557e3539 in set_option_value_err (key=0x7fffee5f96e4 "shiftwidth",
 numval=3, stringval=0x0, opt_flags=4) at if_py_both.h:3464
#14 0x00005555557e36c7 in set_option_value_for (key=0x7fffee5f96e4 "shiftwidth",
 numval=3, stringval=0x0, opt_flags=4, opt_type=2, from=0x555555e88c30) at if_py
_both.h:3506
#15 0x00005555557e3af5 in OptionsAssItem (self=0x7fffee65fb90, keyObject=0x7fffe
e5f96c0, valObject=0x7ffff7f4ec50) at if_py_both.h:3597
#16 0x00007ffff16b2739 in PyEval_EvalFrameEx () from /usr/lib/x86_64-linux-gnu/l
ibpython2.7.so.1.0

--
5 out of 4 people have trouble with fractions.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.