From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.help Subject: C style alist question? Date: Sat, 6 Apr 2019 05:26:38 +0200 Message-ID: <20190406032636.7ftf2ua54uhy2k7e@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="84429"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: NeoMutt/20180716 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Apr 06 05:27:08 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCbz1-000LpG-Oi for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Apr 2019 05:27:07 +0200 Original-Received: from localhost ([127.0.0.1]:49968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCbz0-0001JI-Kr for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Apr 2019 23:27:06 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:50199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hCbyl-0001JD-MB for help-gnu-emacs@gnu.org; Fri, 05 Apr 2019 23:26:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hCbyi-0005T4-JS for help-gnu-emacs@gnu.org; Fri, 05 Apr 2019 23:26:50 -0400 Original-Received: from sonic313-22.consmr.mail.ir2.yahoo.com ([77.238.179.189]:34485) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hCbyh-0005RG-Qx for help-gnu-emacs@gnu.org; Fri, 05 Apr 2019 23:26:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1554521204; bh=YA5sv1LprFl57vusFNjAYX6y07l34WanRWmOJUA06wQ=; h=Date:From:To:Subject:From:Subject; b=J/FLY1IFpOLWOp/x7SyaSv7t79thd28drlbIotMvDry9o+jtM8unyc97lnEQtf1g5VhyzFXVAq/P34euUABcqjnKHk1mRPPDeQhl2A+8iR+aIm72qd0LSJajNAfHJhyCrHgxFm/BkIoFBzk9Z7BcMAukL8MewI72gWN2zEbm6frCt3DqKvih7vDdkIaQ02j6JLNeXeSZezT2bvbYkgYbrLdVUbPY5CQTYB4R0eZf0GQAFtfpapkGn70F8bxS6zuQ9qWPjdgwHb6iIC3qfZQoItiHCI/Ll7s5eVN8qnnEX+Tf8Akpke/uLCptVX7E1a/g6msUSTLyFBGnoK6ce5u/Iw== X-YMail-OSG: TJslVKcVM1kpHtx6faBUqWaJQouNycvt5Qv7uIsdwnJH4JjW_oGwxQiuCpexTSW 2gBUEsn.LkQ5a1XV1Dx0XZ1.FoEmO2.WWnj5vrfVhqaTOL2SoOdQNqE2a_RyK6u2tfMGc6eMwV8e t7GEHTr.R22qGtzn0GPz1meEW5dbOo50jIJU2naJOCkt8KWctZAsbFqbqwNBoEZTUrBghcPJjcxz xSwsEyJXKhsKhQv_OCIfh5OYTxXihfdJDGte7rI1afNPXZHT7.9.GadlkF_Ott_QAkJK87RxwF9S gNXw23Vu9oJM49k7qDyyo59xjU.ThvMCbT0s_1dE9KP0zCDp.6m0o1dJoFUt8Ewr1G4RmGO48EbJ jCcLY5qXEKNzj_sOd7jeMXwhnzeOLk_Zy6djzW3BeZkcnHjraEUJBExN5OBxxH2evZsoqH3tLT_p AFrr49WskRmfS78EfMU.Ik0X60BBHCUxG2WOEPPepk.JYy3fNbxECYYd1Ai0upXvhI2sdu2_Li7T hlg0zFoMS2Udi7Nf6Di54QmvXgulyyL3cL8VsW5DcWzSMiTEawhu2VLFJXiniHIi6SxkxmHddgXw W23v1tahb_JO9R___LfkEnIfQ04gXWMIFklrVwExDnAqx0dZVSs5uTseGRl_2SzzTQzwdlpd95up F_9VR9LpR8MRx_El9ZbHavdy2PSN5okzTzGwBPwFFfxvBYGJQ3nCG7TS3aSuWrnZayBLOuYrrCnu hPSj8NjNFdVifEd3Gh_XXInGMhbTNt168HH9TNlWlgjPHBCpExBxj1xul.0L3GVPRwWFeq8Z5_dW PeCyu.VQwqQsuDW_eq3ozbz3noaegVYDi_6kDMpTSo Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ir2.yahoo.com with HTTP; Sat, 6 Apr 2019 03:26:44 +0000 Original-Received: from 2.152.205.184.dyn.user.ono.com (EHLO Ergus) ([2.152.205.184]) by smtp406.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 60f01fac8f26928a46c67e12b75ee050 for ; Sat, 06 Apr 2019 03:26:40 +0000 (UTC) Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 77.238.179.189 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:119910 Archived-At: Hi all: 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. Which is very uncomfortable when I need to switch constantly or I have open different styled files at the same time because I set some variables that then are not taken from the style. In the emacs wiki (I know is not official, but is the first we use because there are more examples to copy-paste-test) they set some of the variables outside the style, so when the user switches he gets a wrong style. 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. So, is it possible to fix this in order to bring a better and easier user initial experience with the right default values? In fact in the linux kernel coding style page there is a fix for the default style that has been there for years: ``` (defun c-lineup-arglist-tabs-only (ignored) "Line up argument lists by tabs, not spaces" (let* ((anchor (c-langelem-pos c-syntactic-element)) (column (c-langelem-2nd-pos c-syntactic-element)) (offset (- (1+ column) anchor)) (steps (floor offset c-basic-offset))) (* (max steps 1) c-basic-offset))) (add-hook 'c-mode-common-hook (lambda () ;; Add kernel style (c-add-style "linux-tabs-only" '("linux" (c-offsets-alist (arglist-cont-nonempty c-lineup-gcc-asm-reg c-lineup-arglist-tabs-only)))))) (add-hook 'c-mode-hook (lambda () (let ((filename (buffer-file-name))) ;; Enable kernel mode for the appropriate files (when (and filename (string-match (expand-file-name "~/src/linux-trees") filename)) (setq indent-tabs-mode t) (setq show-trailing-whitespace t) (c-set-style "linux-tabs-only"))))) ``` I know all this can be customized by the user, (now I know more or less how). But in the beginning it was a bit difficult to start, and still there are some details that takes a lot of time to know how to configure. For example: c-lineup-gcc-asm-reg, c-lineup-close-parenm, c-lineup-arglist-intro-after-paren... what are those, where are them? But also: what's the point with bringing a linux style that needs to be fixed by all the users that needs it? Could anyone help me to fix this, or fix the defaults in Emacs to follow the specifications? What's the recommended configuration when we need to switch constantly? Because now as I set the tabwidth and the indent-style outside a style, when I switch I only get a mixed useless style. Thanks in advance Ergus.