diff mbox series

Add .pd extension to c_exts.

Message ID f6ecfce1-9d60-2d26-9361-f9876e5446d6@suse.cz
State New
Headers show
Series Add .pd extension to c_exts. | expand

Commit Message

Martin Liška Aug. 30, 2019, 10:58 a.m. UTC
Hi.

I would like to add .pd to c_exts so that one
can have correctly set tab width, etc.

Ready for trunk?
Thanks,
Martin

contrib/ChangeLog:

2019-08-30  Martin Liska  <mliska@suse.cz>

	* vimrc: Add .pd extension.
---
 contrib/vimrc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Biener Aug. 30, 2019, 12:09 p.m. UTC | #1
On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote:
>
> Hi.
>
> I would like to add .pd to c_exts so that one
> can have correctly set tab width, etc.

But then it will auto-indent with too much spaces, no?

Richard.

> Ready for trunk?
> Thanks,
> Martin
>
> contrib/ChangeLog:
>
> 2019-08-30  Martin Liska  <mliska@suse.cz>
>
>         * vimrc: Add .pd extension.
> ---
>  contrib/vimrc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
>
Martin Liška Aug. 30, 2019, 12:30 p.m. UTC | #2
On 8/30/19 2:09 PM, Richard Biener wrote:
> But then it will auto-indent with too much spaces, no?

It's doesn't understand the lisp-like notation
(foo
 (bar
  (baz

so no auto-indentation is happening.

Martin
Alexander Monakov Aug. 30, 2019, 12:31 p.m. UTC | #3
On Fri, 30 Aug 2019, Richard Biener wrote:

> On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote:
> >
> > Hi.
> >
> > I would like to add .pd to c_exts so that one
> > can have correctly set tab width, etc.
> 
> But then it will auto-indent with too much spaces, no?

I think it's fine, the script does

  setlocal cindent
  setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0

so it's a bit smarter than indenting everything by 2 spaces :)

So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev
"plugin" directory, it might be more natural to add gcc-match indent rules
there.

Alexander
Richard Biener Aug. 30, 2019, 12:54 p.m. UTC | #4
On Fri, Aug 30, 2019 at 2:31 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>
>
>
> On Fri, 30 Aug 2019, Richard Biener wrote:
>
> > On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote:
> > >
> > > Hi.
> > >
> > > I would like to add .pd to c_exts so that one
> > > can have correctly set tab width, etc.
> >
> > But then it will auto-indent with too much spaces, no?
>
> I think it's fine, the script does
>
>   setlocal cindent
>   setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
>
> so it's a bit smarter than indenting everything by 2 spaces :)
>
> So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev
> "plugin" directory, it might be more natural to add gcc-match indent rules
> there.

Yeah, that would be better than claiming .pd is C ...

Richard.

>
> Alexander
Martin Liška Sept. 2, 2019, 7:45 a.m. UTC | #5
On 8/30/19 2:54 PM, Richard Biener wrote:
> On Fri, Aug 30, 2019 at 2:31 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>>
>>
>>
>> On Fri, 30 Aug 2019, Richard Biener wrote:
>>
>>> On Fri, Aug 30, 2019 at 12:58 PM Martin Liška <mliska@suse.cz> wrote:
>>>>
>>>> Hi.
>>>>
>>>> I would like to add .pd to c_exts so that one
>>>> can have correctly set tab width, etc.
>>>
>>> But then it will auto-indent with too much spaces, no?
>>
>> I think it's fine, the script does
>>
>>   setlocal cindent
>>   setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
>>
>> so it's a bit smarter than indenting everything by 2 spaces :)
>>
>> So +1 from me for the patch, but note that now we have a contrib/vim-gcc-dev
>> "plugin" directory, it might be more natural to add gcc-match indent rules
>> there.
> 
> Yeah, that would be better than claiming .pd is C ...
> 
> Richard.
> 
>>
>> Alexander

Yep, I'm going to apply following patch that does it properly for the gcc-match
file type.

Martin
Alexander Monakov Sept. 2, 2019, 9:56 a.m. UTC | #6
On Mon, 2 Sep 2019, Martin Liška wrote:

> Yep, I'm going to apply following patch that does it properly for the gcc-match
> file type.

So just to make sure I understand correctly why you need this:

you use some other value of 'tabstop' in Vim, and need to reset it back to its
default value of 8, as assumed by coding standards in GCC?

If that's the case, we should look into overriding 'tabstop' for all files in
the gcc tree, including .md files, not just .pd and C/C++ files, right?

Thanks.
Alexander
Martin Liška Sept. 2, 2019, 10:37 a.m. UTC | #7
On 9/2/19 11:56 AM, Alexander Monakov wrote:
> On Mon, 2 Sep 2019, Martin Liška wrote:
> 
>> Yep, I'm going to apply following patch that does it properly for the gcc-match
>> file type.
> 
> So just to make sure I understand correctly why you need this:
> 
> you use some other value of 'tabstop' in Vim, and need to reset it back to its
> default value of 8, as assumed by coding standards in GCC?

Yes, that was my motivation.

> 
> If that's the case, we should look into overriding 'tabstop' for all files in
> the gcc tree, including .md files, not just .pd and C/C++ files, right?

Can be done but we don't have any 'au BufRead *.md' rule right now.

Martin

> 
> Thanks.
> Alexander
>
Alexander Monakov Sept. 2, 2019, 11:08 a.m. UTC | #8
On Mon, 2 Sep 2019, Martin Liška wrote:

> > If that's the case, we should look into overriding 'tabstop' for all files in
> > the gcc tree, including .md files, not just .pd and C/C++ files, right?
> 
> Can be done but we don't have any 'au BufRead *.md' rule right now.

The solution I had in mind was to set expected formatting for all files in our
local vimrc like this:

--- a/contrib/vimrc
+++ b/contrib/vimrc
@@ -31,17 +31,17 @@ function! SetStyle()
   if stridx(l:fname, 'libsanitizer') != -1
     return
   endif
+  setlocal tabstop=8
+  setlocal softtabstop=2
+  setlocal shiftwidth=2
+  setlocal noexpandtab
+  setlocal textwidth=80
+  setlocal formatoptions-=ro formatoptions+=cqlt
   let l:ext = fnamemodify(l:fname, ":e")
   let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
   if index(l:c_exts, l:ext) != -1
     setlocal cindent
-    setlocal tabstop=8
-    setlocal softtabstop=2
-    setlocal shiftwidth=2
-    setlocal noexpandtab
     setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
-    setlocal textwidth=80
-    setlocal formatoptions-=ro formatoptions+=cqlt
   endif
 endfunction


Alexander
Martin Liška Sept. 2, 2019, 12:05 p.m. UTC | #9
On 9/2/19 1:08 PM, Alexander Monakov wrote:
> On Mon, 2 Sep 2019, Martin Liška wrote:
> 
>>> If that's the case, we should look into overriding 'tabstop' for all files in
>>> the gcc tree, including .md files, not just .pd and C/C++ files, right?
>>
>> Can be done but we don't have any 'au BufRead *.md' rule right now.
> 
> The solution I had in mind was to set expected formatting for all files in our
> local vimrc like this:
> 
> --- a/contrib/vimrc
> +++ b/contrib/vimrc
> @@ -31,17 +31,17 @@ function! SetStyle()
>    if stridx(l:fname, 'libsanitizer') != -1
>      return
>    endif
> +  setlocal tabstop=8
> +  setlocal softtabstop=2
> +  setlocal shiftwidth=2
> +  setlocal noexpandtab
> +  setlocal textwidth=80
> +  setlocal formatoptions-=ro formatoptions+=cqlt
>    let l:ext = fnamemodify(l:fname, ":e")
>    let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
>    if index(l:c_exts, l:ext) != -1
>      setlocal cindent
> -    setlocal tabstop=8
> -    setlocal softtabstop=2
> -    setlocal shiftwidth=2
> -    setlocal noexpandtab
>      setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
> -    setlocal textwidth=80
> -    setlocal formatoptions-=ro formatoptions+=cqlt
>    endif
>  endfunction
> 
> 
> Alexander
> 

Works for me, please include the reversion of r275295.

Thanks,
Martin
diff mbox series

Patch

diff --git a/contrib/vimrc b/contrib/vimrc
index 7c0c5878c63..a9ec46bf52f 100644
--- a/contrib/vimrc
+++ b/contrib/vimrc
@@ -32,7 +32,7 @@  function! SetStyle()
     return
   endif
   let l:ext = fnamemodify(l:fname, ":e")
-  let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
+  let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java', 'pd']
   if index(l:c_exts, l:ext) != -1
     setlocal cindent
     setlocal tabstop=8