* Re: C style alist question? [not found] ` <837ec7bpe4.fsf@gnu.org> @ 2019-04-11 1:16 ` Ergus 2019-04-11 8:28 ` Alan Mackenzie 2019-04-11 14:22 ` Eli Zaretskii 0 siblings, 2 replies; 4+ messages in thread From: Ergus @ 2019-04-11 1:16 UTC (permalink / raw) To: emacs-devel; +Cc: help-gnu-emacs (I send to both mailing lists because it is related with a previous thread, but the right destination for this mail is the devels mailing list) Hi guys: The issue I was facing with indentations was related actually with the fact that once an offset is set (for example in the init file) it is ignored in some cases by c-set-style because it is not "from style" anymore. Does it makes sense (or is not too difficult) to provide an option (or a parameter in c-set-style) that allows the user to overwrite all the previous offsets with the values from the new style, in spite of if it is not "from style"? Maybe it already exist? Another question: Actually emacs C indentation with tabs follows the following policy: It add as many tabs as possible and then align with spaces until the desired column is reached. ==================== -------> is a tab . is a space ==================== ``` int function(int var1, ------->.....double b, ------->.....double c) { ------->for (int i = 0; i < 10; ++i) ------->------->myprintf ("%d\n", ------->------->------->..i); } ``` But other common policies around are: 1) add only tabs (and ignore the small mismatch in some cases) int function(int var1, ------->double b, ------->double c) { ------->for (int i = 0; i < 10; ++i) ------->------->myprintf ("%d\n", ------->------->------->i); } 2) Use tabs (but only for indentation) and spaces to align int function(int var1, .............double b) { ------->for (int i = 0; i < 10; ++i) ------->------->myprintf ("%d\n", ------->------->..........i); } The last one is specially useful in C++ where templates and long type names usually forces to break functions and expressions (and templated types inside functions declarations) on multiple lines; because they keep the alignment in different editors (or different emacs with different tab-width). Is it some variable/policy or method to produce 1 or 2 with what is already there?? Thanks in advance, Ergus. On Sat, Apr 06, 2019 at 09:48:19AM +0300, Eli Zaretskii wrote: >> Date: Sat, 6 Apr 2019 05:26:38 +0200 >> From: Ergus <spacibba@aol.com> >> >> I usually edit code in two styles; the linux kernel style and now the >> emacs style. But I have seen that there are some mismatches between the >> style alists and the "official" styles. > >Sorry, I don't understand what are "style alists" and the "official >styles". Please elaborate on that. > >> For example: >> >> When I open an emacs' C source code I see details like the fill-column >> is 70 instead of 78. >> >> In the kernel style the indent-tabs-mode is not set to t. > >Our style is defined by the .dir-locals.el file you see in the >repository. indent-tabs-mode is t only in Emacs Lisp mode. > >> So, is it possible to fix this in order to bring a better and easier >> user initial experience with the right default values? > >Fix how? Change our style? I think that'd be a hard change to sell, >because the current defaults were discussed several times and are a >kind of compromise between different preferences, but you need to >raise this on emacs-devel, not here. > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C style alist question? 2019-04-11 1:16 ` C style alist question? Ergus @ 2019-04-11 8:28 ` Alan Mackenzie 2019-04-11 14:22 ` Eli Zaretskii 1 sibling, 0 replies; 4+ messages in thread From: Alan Mackenzie @ 2019-04-11 8:28 UTC (permalink / raw) To: Ergus; +Cc: help-gnu-emacs, emacs-devel Hello, Ergus. On Thu, Apr 11, 2019 at 03:16:59 +0200, Ergus wrote: > (I send to both mailing lists because it is related with a previous > thread, but the right destination for this mail is the devels mailing > list) > Hi guys: > The issue I was facing with indentations was related actually with the > fact that once an offset is set (for example in the init file) it is > ignored in some cases by c-set-style because it is not "from style" > anymore. The answer here is Read The Fantastic Manual. :-) In particular, the CC Mode manual, page "Config Basics", explains how settings made in different ways get resolved, and which one "wins". > Does it makes sense (or is not too difficult) to provide an option (or a > parameter in c-set-style) that allows the user to overwrite all the > previous offsets with the values from the new style, in spite of if it > is not "from style"? Maybe it already exist? The thinking is that users, mostly, will be using the style system, or possibly setting buffer local values in hooks (e.g. c-mode-common-hook). And that anybody setting the global value of a style variable Really Means It. To supply the option you're suggesting would be quite difficult, yes, since it would mean rethinking the entire way CC Mode handles the style variables. To the five ways of setting style variables listed on that manual page, could (should) be added the directory local settings. The interaction between them all is quite involved. I would ask you to read that manual page thoroughly, and see if it provides you with a way to configure CC Mode adequate to your needs. If not, then maybe we could come back to the question. > Another question: [ For another reply :-] > Thanks in advance, > Ergus. -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C style alist question? 2019-04-11 1:16 ` C style alist question? Ergus 2019-04-11 8:28 ` Alan Mackenzie @ 2019-04-11 14:22 ` Eli Zaretskii 2019-04-11 15:00 ` Ergus 1 sibling, 1 reply; 4+ messages in thread From: Eli Zaretskii @ 2019-04-11 14:22 UTC (permalink / raw) To: Ergus; +Cc: emacs-devel > Date: Thu, 11 Apr 2019 03:16:59 +0200 > From: Ergus <spacibba@aol.com> > Cc: help-gnu-emacs@gnu.org > > But other common policies around are: > > 1) add only tabs (and ignore the small mismatch in some cases) > > int function(int var1, > ------->double b, > ------->double c) > { > ------->for (int i = 0; i < 10; ++i) > ------->------->myprintf ("%d\n", > ------->------->------->i); > } AFAIU, this is the 'linux' style in CC Mode. > 2) Use tabs (but only for indentation) and spaces to align > > int function(int var1, > .............double b) > { > ------->for (int i = 0; i < 10; ++i) > ------->------->myprintf ("%d\n", > ------->------->..........i); > } And this is the 'bsd' style. Can you use these built-in styles to get what you want? Or did I misunderstand what you are looking for? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: C style alist question? 2019-04-11 14:22 ` Eli Zaretskii @ 2019-04-11 15:00 ` Ergus 0 siblings, 0 replies; 4+ messages in thread From: Ergus @ 2019-04-11 15:00 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel On Thu, Apr 11, 2019 at 05:22:10PM +0300, Eli Zaretskii wrote: >> Date: Thu, 11 Apr 2019 03:16:59 +0200 >> From: Ergus <spacibba@aol.com> >> Cc: help-gnu-emacs@gnu.org >> >> But other common policies around are: >> >> 1) add only tabs (and ignore the small mismatch in some cases) >> >> int function(int var1, >> ------->double b, >> ------->double c) >> { >> ------->for (int i = 0; i < 10; ++i) >> ------->------->myprintf ("%d\n", >> ------->------->------->i); >> } > >AFAIU, this is the 'linux' style in CC Mode. No, the linux style is the first example I inserted in my mail. With some spaces to align. Like this (or at least this is what I get) int function(int var1, ------->.....double b, ------->.....double c) { ------->for (int i = 0; i < 10; ++i) ------->------->myprintf ("%d\n", ------->------->------->..i); } The indent-tabs-mode inserts "as many tabs as possible" and then aligns with spaces. > >> 2) Use tabs (but only for indentation) and spaces to align >> >> int function(int var1, >> .............double b) >> { >> ------->for (int i = 0; i < 10; ++i) >> ------->------->myprintf ("%d\n", >> ------->------->..........i); >> } > >And this is the 'bsd' style. > bsd style defines 4 spaces after tabulator align for continuation lines, not alineation with spaces. >Can you use these built-in styles to get what you want? Or did I >misunderstand what you are looking for? According with Alan's mail the policy is not included and it needs a workaround he sent in his email as an answer to a mail from 2008. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-11 15:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20190406032636.7ftf2ua54uhy2k7e@Ergus> [not found] ` <837ec7bpe4.fsf@gnu.org> 2019-04-11 1:16 ` C style alist question? Ergus 2019-04-11 8:28 ` Alan Mackenzie 2019-04-11 14:22 ` Eli Zaretskii 2019-04-11 15:00 ` Ergus
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).