Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

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

Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

ISHIKAWA,chiaki
Hi folks,

Would people mind/accept if I submit a patch to replace all the
irregular emacs mode lines in *.cpp, and *.h files?

I am using GNU Emacs editor, and every time I try to modify a source
file with emacs mode line that is NOT IN LINE with the latest
clang-format coding style, I have to manually adjust the indentation.
This is too much of a bother.

To wit, under mailnews directory, we have the following emacs mode lines.
I search for them and sort them and print the number of occurrences.

find mailnews -type f -name "*.[cph]*" -print | xargs fgrep -h -- '-*-'
| sort | uniq -c
       1   /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*-
       1  C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       1 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil;
tab-width: 40 -*-
       1 /* -*- Mode:
       1 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil;
c-basic-offset: 4 -*- */
      15 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil;
c-basic-offset: 2 -*-
     261 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil;
c-basic-offset: 2 -*- */
       4 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil;
c-basic-offset: 4 -*- */
       2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 2 -*-
      85 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 2 -*- */
       4 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*-
     119 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*- */
      18 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil;
c-basic-offset: 2 -*- */
       1 /* -*- Mode: C; tab-width: 4 -*-
       8 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 2 -*-
      92 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 2 -*- */
       1 /* -*- Mode: idl; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*-
       1 print '''/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil;
c-basic-offset: 4 -*- */


I *THINK* the correct mode line is indeed the most popular

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2
-*- */


There are python and IDL generated files, it seems and I will keep them
untouched.

I think I will work on mailnews directory most in the rest of the year,
and so I will modify only the files under that directory. Other
directories (except for ldap) seem to be under better control in this
regard.

Comments?

Chiaki


_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

Jörg Knobloch
On 20 Oct 2019 00:55, ISHIKAWA,chiaki wrote:
> I think I will work on mailnews directory most in the rest of the
> year, and so I will modify only the files under that directory. Other
> directories (except for ldap) seem to be under better control in this
> regard.
>
> Comments?

Let's fix it. :-)

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

ISHIKAWA,chiaki
On 2019/10/20 8:21, Jörg Knobloch wrote:
> On 20 Oct 2019 00:55, ISHIKAWA,chiaki wrote:
>> I think I will work on mailnews directory most in the rest of the
>> year, and so I will modify only the files under that directory. Other
>> directories (except for ldap) seem to be under better control in this
>> regard.
>>
>> Comments?
>
> Let's fix it. :-)


Thank you for the feedback. :-)

I filed a patch to the following bugzilla.

https://bugzilla.mozilla.org/show_bug.cgi?id=1590131
Add *correct/proper* emacs mode line to *.cpp and *.h files in the C-C
TB source tree.

I only handled mailnews subdirectory, but due to the reasons mentioned
there, I think this should suffice for now.

TIA

BTW, I noticed the following bugzilla entries.

[1] Somebody has to modify M-C source tree in one go.
https://bugzilla.mozilla.org/show_bug.cgi?id=534442
Add Emacs modelines to patches


[2] Somebody has to take care of vim users.
https://bugzilla.mozilla.org/show_bug.cgi?id=754136
Add emacs/vim modelines to files in NSS


_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

Onno Ekker-2
On Mon, Oct 21, 2019 at 4:48 PM ISHIKAWA,chiaki <[hidden email]> wrote:

>
> On 2019/10/20 8:21, Jörg Knobloch wrote:
> > On 20 Oct 2019 00:55, ISHIKAWA,chiaki wrote:
> >> I think I will work on mailnews directory most in the rest of the
> >> year, and so I will modify only the files under that directory. Other
> >> directories (except for ldap) seem to be under better control in this
> >> regard.
> >>
> >> Comments?
> >
> > Let's fix it. :-)
>
>
> Thank you for the feedback. :-)
>
> I filed a patch to the following bugzilla.
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=1590131
> Add *correct/proper* emacs mode line to *.cpp and *.h files in the C-C
> TB source tree.
>
> I only handled mailnews subdirectory, but due to the reasons mentioned
> there, I think this should suffice for now.
>
> TIA
>
> BTW, I noticed the following bugzilla entries.
>
> [1] Somebody has to modify M-C source tree in one go.
> https://bugzilla.mozilla.org/show_bug.cgi?id=534442
> Add Emacs modelines to patches
>
>
> [2] Somebody has to take care of vim users.
> https://bugzilla.mozilla.org/show_bug.cgi?id=754136
> Add emacs/vim modelines to files in NSS

I think this should be fixed by removing the mode lines altogether,
along with any mode lines that are there for vim.
I don't think Emacs needs those anymore than vim does, and they can be
added as default in your .emacsrc and/or .vimrc, instead of adding
them to each and every source file you need to edit.

Onno
_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

Mark Banner-4
On 22/10/2019 07:21, Onno Ekker wrote:
> I think this should be fixed by removing the mode lines altogether,
> along with any mode lines that are there for vim.
> I don't think Emacs needs those anymore than vim does, and they can be
> added as default in your .emacsrc and/or .vimrc, instead of adding
> them to each and every source file you need to edit.

I definitely agree with this, what with modern editor set-ups and
configurations, as well as the fact we use clang-format now, this would
seem less necessary.

For reference, Firefox had a discussion about this last year, although
it fizzled out due to no-one pushing it forward:

https://groups.google.com/forum/#!topic/mozilla.dev.platform/16PBaXgDlsA

Mark

_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

ISHIKAWA,chiaki
On 2019/10/22 15:36, Mark Banner wrote:

> On 22/10/2019 07:21, Onno Ekker wrote:
>> I think this should be fixed by removing the mode lines altogether,
>> along with any mode lines that are there for vim.
>> I don't think Emacs needs those anymore than vim does, and they can be
>> added as default in your .emacsrc and/or .vimrc, instead of adding
>> them to each and every source file you need to edit.
>
> I definitely agree with this, what with modern editor set-ups and
> configurations, as well as the fact we use clang-format now, this
> would seem less necessary.
>
> For reference, Firefox had a discussion about this last year, although
> it fizzled out due to no-one pushing it forward:
>
> https://groups.google.com/forum/#!topic/mozilla.dev.platform/16PBaXgDlsA
>
> Mark

That is a possible approach, too.

I also noticed vim mode line is missing in many files, too.

So whatever the general consensus should be materialized and then pushed
to the tree.

In the meantime, incorrect emacs mode lines are pain for emacs users,
and at least the patch took care of the issue *FOR NOW*.

So what do we do as the next step?


_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird
Reply | Threaded
Open this post in threaded view
|

Re: Inserting 'CORRECT' emacs mode line for *.cpp, *.h files in C-C

ISHIKAWA,chiaki
On 2019/10/23 10:41, ISHIKAWA,chiaki wrote:

> On 2019/10/22 15:36, Mark Banner wrote:
>> On 22/10/2019 07:21, Onno Ekker wrote:
>>> I think this should be fixed by removing the mode lines altogether,
>>> along with any mode lines that are there for vim.
>>> I don't think Emacs needs those anymore than vim does, and they can be
>>> added as default in your .emacsrc and/or .vimrc, instead of adding
>>> them to each and every source file you need to edit.
>>
>> I definitely agree with this, what with modern editor set-ups and
>> configurations, as well as the fact we use clang-format now, this would
>> seem less necessary.
>>
>> For reference, Firefox had a discussion about this last year, although it
>> fizzled out due to no-one pushing it forward:
>>
>> https://groups.google.com/forum/#!topic/mozilla.dev.platform/16PBaXgDlsA
>>
>> Mark
>
> That is a possible approach, too.
>
> I also noticed vim mode line is missing in many files, too.
>
> So whatever the general consensus should be materialized and then pushed to
> the tree.
>
> In the meantime, incorrect emacs mode lines are pain for emacs users, and at
> least the patch took care of the issue *FOR NOW*.
>
> So what do we do as the next step?
>
>

Here is my take.

I, as an emacs user, has put google-c-style.el in my home directory, and
has put something like the following in my emacs startup file.

(load-file "/home/vagrant/.emacs.d/google-c-style.el")
(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)
(add-hook 'c++-mode-common-hook 'google-set-c-style)
(add-hook 'c-mode-common-hook 'google-make-newline-indent)

This is good for editing C-C source tree, and M-C tree as well.

But come to think of it, this is problematic when I want to hack GNU project
source files (I do occasionally, things like CCACHE, valgrind source files,
etc.)
This is because my setting above will try to apply google programming style
to every C++ file including GNU project source files as well.

So a clever integration of introducing google programming style using
a hook in .dir-locales.el would be desirable as noted in the mailing list
discussion quoted above.


>> https://groups.google.com/forum/#!topic/mozilla.dev.platform/16PBaXgDlsA
>>

Also, a deficiency of .dir-locals.el is mentioned there in, but "Perfection
is the enemy of good".
I  suppose a good integration of google-c-style.el with .dir-locals.el that
could be put at the top-most comm/ directory is a great improvement.

Just my two cents worth.

Sorry, I can't spend time tinkering with .dir-locals.el for now.


_______________________________________________
dev-apps-thunderbird mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-thunderbird