public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/emacs/dir-locals: Update settings for c++-mode
@ 2018-12-07 11:02 Andrew Burgess
  2018-12-07 17:38 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Burgess @ 2018-12-07 11:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Burgess

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))
+	      ))
 )

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] gdb/emacs/dir-locals: Update settings for c++-mode
  2018-12-07 11:02 [PATCH] gdb/emacs/dir-locals: Update settings for c++-mode Andrew Burgess
@ 2018-12-07 17:38 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2018-12-07 17:38 UTC (permalink / raw)
  To: Andrew Burgess; +Cc: gdb-patches

>>>>> "Andrew" == Andrew Burgess <andrew.burgess@embecosm.com> writes:

Andrew> gdb/ChangeLog:

Andrew> 	* .dir-locals.el: Copy most of the settings from c-mode over to
Andrew> 	c++-mode.

Thanks.  This is ok.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-07 17:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-07 11:02 [PATCH] gdb/emacs/dir-locals: Update settings for c++-mode Andrew Burgess
2018-12-07 17:38 ` Tom Tromey

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).