From patchwork Tue Sep 16 16:38:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Gribov X-Patchwork-Id: 390114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EE27014011B for ; Wed, 17 Sep 2014 02:38:57 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=WS0LFbnDDQ91kSqGt h7NU+EFetxFSOKOhwqlxtoQre070Y+B6f2M7sHKg3kz3RNOQMl6DBTK4gmczwzpz wHk55NgeBBDYFZJPTXjdZPskVXcsGdnAEKoCke3ANYl8hyaSHGnJDiUEmIMsBAf9 SeZ+MzRhwHGCeLPlh8mVHBSqWA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=sqo/RDv8GnYzS+qmlhaSbVr ag2Q=; b=mCbQMIl9r0iVJUm4rTOt8dFLNhYK7ouzaoA+BCb0JUi5HqnxFk02Uzz f98hxciSkgL68aawg6eUqj9PnxktirxzwoAUz+7Is+FWOHpihRQot/CAXbuBNKrv FsB1xyPDN8P2JEVy5xUqzsQMS2SwzSjm9QhM6XtbOADYLvZl2UxI= Received: (qmail 7585 invoked by alias); 16 Sep 2014 16:38:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 7564 invoked by uid 89); 16 Sep 2014 16:38:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Tue, 16 Sep 2014 16:38:46 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NC000H9H6DCEQ20@mailout1.w1.samsung.com> for gcc-patches@gcc.gnu.org; Tue, 16 Sep 2014 17:41:36 +0100 (BST) Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 8A.08.25543.19768145; Tue, 16 Sep 2014 17:38:41 +0100 (BST) Received: from [106.109.9.145] by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NC000DFB68HW080@eusync4.samsung.com>; Tue, 16 Sep 2014 17:38:41 +0100 (BST) Message-id: <541867A2.6020405@samsung.com> Date: Tue, 16 Sep 2014 20:38:58 +0400 From: Yury Gribov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-version: 1.0 To: GCC Patches Cc: Laurynas Biveinis , Jeff Law , Segher Boessenkool , Richard Biener , Bernhard Reutner-Fischer , Trevor Saunders , Mike Stump Subject: [PATCHv3] Vimrc config with GNU formatting References: <540863C1.4000909@samsung.com> <54100735.5040700@samsung.com> In-reply-to: <54100735.5040700@samsung.com> Content-type: multipart/mixed; boundary=------------020106050601030709000306 X-IsSubscribed: yes Hi all, This is the third version of the patch. A list of changes since last version: * move config to contrib so that it's _not_ enabled by default (current score is 2/1 in favor of no Vim config by default) * update Makefile.in to make .local.vimrc if developer asks for it * disable autoformatting for flex files * fix filtering of non-GNU sources (libsanitizer) * added some small fixes in cinoptions based on feedback from community As noted by Richard, the config does not do a good job of formatting unbound {} blocks e.g. void foo () { int x; { // I'm an example of bad bad formatting } } but it seems to be the best we can get with Vim's cindent (and I don't think anyone seriously considers writing a custom indentexpr). Ok to commit? -Y commit 67219512dac9a5cc14eea8f157222a226044dd72 Author: Yury Gribov Date: Thu Sep 4 16:55:44 2014 +0400 2014-09-16 Laurynas Biveinis Yury Gribov Vim config with GNU formatting. contrib/ * vimrc: New file. / * .gitignore: Added .local.vimrc. * Makefile.tpl (.local.vimrc): New target. * Makefile.in: Regenerate. diff --git a/.gitignore b/.gitignore index e9b56be..252b8b0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ POTFILES TAGS TAGS.sub +.local.vimrc + .gdbinit .gdb_history diff --git a/Makefile.in b/Makefile.in index d6105b3..e573069 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2384,6 +2384,11 @@ mail-report-with-warnings.log: warning.log chmod +x $@ echo If you really want to send e-mail, run ./$@ now +# Local Vim config + +vimrc: + (cd $(srcdir); $(LN_S) contrib/vimrc .local.vimrc) + # Installation targets. .PHONY: install uninstall diff --git a/Makefile.tpl b/Makefile.tpl index f7c7e38..d050694 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -867,6 +867,11 @@ mail-report-with-warnings.log: warning.log chmod +x $@ echo If you really want to send e-mail, run ./$@ now +# Local Vim config + +vimrc: + (cd $(srcdir); $(LN_S) contrib/vimrc .local.vimrc) + # Installation targets. .PHONY: install uninstall diff --git a/contrib/vimrc b/contrib/vimrc new file mode 100644 index 0000000..7287bd1 --- /dev/null +++ b/contrib/vimrc @@ -0,0 +1,43 @@ +" Code formatting settings for Vim. +" +" To enable this for GCC files by default, install thinca's localrc plugin +" and do +" $ make .local.vimrc +" Or if you dislike plugins, add autocmd in your .vimrc: +" :au BufNewFile,BufReadPost path/to/gcc/* :so path/to/gcc/.local.vimrc +" Or just source file manually every time if you are masochist: +" :so .local.vimrc +" +" Copyright (C) 2014 Free Software Foundation, Inc. +" +" This program is free software; you can redistribute it and/or modify +" it under the terms of the GNU General Public License as published by +" the Free Software Foundation; either version 3 of the License, or +" (at your option) any later version. +" +" This program is distributed in the hope that it will be useful, +" but WITHOUT ANY WARRANTY; without even the implied warranty of +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +" GNU General Public License for more details. +" +" You should have received a copy of the GNU General Public License +" along with this program. If not, see . + +function! SetStyle() + let l:fname = expand("%:p") + if stridx(l:fname, 'libsanitizer') != -1 + return + endif + 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 shiftwidth=2 + setlocal softtabstop=2 + setlocal cinoptions=>2s,n-s,{s,^-s,:s,=s,g0,f0,hs,p2s,t0,+s,(0,u0,w1,m0 + setlocal textwidth=79 + setlocal formatoptions-=ro formatoptions+=cql + endif +endfunction + +call SetStyle()