From patchwork Fri Dec 7 11:01:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 30576 Received: (qmail 89465 invoked by alias); 7 Dec 2018 11:02:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 89450 invoked by uid 89); 7 Dec 2018 11:02:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=UD:*.c, H*RU:209.85.128.65, Hx-spam-relays-external:209.85.128.65, *.c X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Dec 2018 11:02:00 +0000 Received: by mail-wm1-f65.google.com with SMTP id r11-v6so3927307wmb.2 for ; Fri, 07 Dec 2018 03:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id; bh=8b++7w5mTQ44bI18WYPv8fV6LdB6MsMko1QIc+nUbhI=; b=cpW8JyWETHmjwBC2CYETpLCfVCbaUe5c2L45OhDUr3+Q4UmtJ7SSaQ5g9ga9zHR6qV HW6z5k699oTv4IeQtO+3ssULa0bRlYCMqj0sm9R8p/IZ81Un3jwjOZvpgiNWv+LOpsUP NX+QzjmSAW7mjf+y8NsqaWmIQNXw3AHpT0vJtBuGEc4N2OBwKwqhL9DLukYZb0T8DAS+ ODTWmizIlsN17to9Q+JQZExmET3LW1pQDKeX+W8GuEMMpKemRLZdTde20OYB6CeovHoY D7GVhBZ671U26DyRdb2ZD78J9exn0gjDr/MeY9wXAYlqEVRHzQa+d/d9mjmXb4koHX8J M0Ug== Return-Path: Received: from localhost (host86-156-236-210.range86-156.btcentralplus.com. [86.156.236.210]) by smtp.gmail.com with ESMTPSA id o5sm8444471wmg.25.2018.12.07.03.01.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 03:01:57 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/emacs/dir-locals: Update settings for c++-mode Date: Fri, 7 Dec 2018 11:01:54 +0000 Message-Id: <20181207110154.2362-1-andrew.burgess@embecosm.com> X-IsSubscribed: yes I edit with emacs, and by default have `indent-tabs-mode` turned off. I've noticed for a while that every time I edit a gdb file I have to manual turn this setting back on, which is weird, because I'm sure that this used to just magically enable itself within GDB source files.... Turns out that either emacs changed behaviour, or this stopped working when we switched to c++. The .dir-locals.el file is what causes our *.c files to open in c++-mode, at least for me with emacs 26.1, switching mode in .dir-locals.el causes all of the settings from the original mode to be reset. So in our .dir-locals.el file we set `(indent-tabs-mode . t)` for c-mode, but not for c++-mode. This patch duplicates the settings list for c-mode into c++-mode. Thanks, Andrew --- The current .dir-locals file for GDB causes files that would usually open in c-mode (for example, files ending in .c) to open in c++-mode. However, all of the other settings applied for c-mode appear to get reset when the file is switched over to c++-mode. For example, we currently say: (c-mode . ((c-file-style . "GNU") (mode . c++) (indent-tabs-mode . t) (tab-width . 8) (c-basic-offset . 2) (eval . (c-set-offset 'innamespace 0)) )) (c++-mode . ((eval . (when (fboundp 'c-toggle-comment-style) (c-toggle-comment-style 1))))) So, when we enter c++-mode `indent-tabs-mode` is reset to its global value, as are all of the other settings listed for c-mode. This commit copies all of the settings (except the `mode` setting) from the c-mode list to the c++-mode list. The emacs documentation doesn't mention that `mode` causes this resetting behaviour, so, in case this is an emacs bug, I'm using emacs version 26.1. Having the settings duplicated shouldn't cause any problems except for a slight maintenance overhead. gdb/ChangeLog: * .dir-locals.el: Copy most of the settings from c-mode over to c++-mode. --- gdb/.dir-locals.el | 8 +++++++- gdb/ChangeLog | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el index 7e2b0cc3134..d5ca5b31095 100644 --- a/gdb/.dir-locals.el +++ b/gdb/.dir-locals.el @@ -27,5 +27,11 @@ (eval . (c-set-offset 'innamespace 0)) )) (c++-mode . ((eval . (when (fboundp 'c-toggle-comment-style) - (c-toggle-comment-style 1))))) + (c-toggle-comment-style 1))) + (indent-tabs-mode . t) + (tab-width . 8) + (c-file-style . "GNU") + (c-basic-offset . 2) + (eval . (c-set-offset 'innamespace 0)) + )) )