public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Set emacs default mode for the GDB directory to C++
@ 2016-12-16 19:29 Antoine Tremblay
  2016-12-16 19:41 ` [PATCH v2] " Antoine Tremblay
  0 siblings, 1 reply; 6+ messages in thread
From: Antoine Tremblay @ 2016-12-16 19:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

Since GDB has switched to C++ but the file names are still .c emacs does
not load the proper mode when opening files in the gdb directory.

This patch fixes that by enabling c++ mode.

This patch also fixes indentation tweaks as discussed in this thread:
https://sourceware.org/ml/gdb-patches/2016-12/msg00074.html

Indent with gdb-code-style.el included and the .dir-locals.el is as such:

namespace TestNameSpace {

class test
{
public:
  test test() {}

  int m_a;
};

struct teststruct
{
  int a;
}
}

gdb/ChangeLog:

	* .dir-locals.el: Set c++ mode for the directory and set indent
	properly.
	* gdb-code-style.el: Set c-set-offset 'innamespace as a safe value
	to be used in .dir-locals.el.
---
 gdb/.dir-locals.el    | 7 ++++++-
 gdb/gdb-code-style.el | 4 ++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el
index fbd9309aef..8ac52393fc 100644
--- a/gdb/.dir-locals.el
+++ b/gdb/.dir-locals.el
@@ -20,5 +20,10 @@
 	      (indent-tabs-mode . t)))
  (nil . ((bug-reference-url-format . "http://sourceware.org/bugzilla/show_bug.cgi?id=%s")))
  (c-mode . ((c-file-style . "GNU")
-	    (indent-tabs-mode . t)))
+	    (mode . c++)
+	    (indent-tabs-mode . t)
+	    (tab-width . 8)
+	    (c-basic-offset . 2)
+	    (eval . (c-set-offset 'innamespace [0]))
+	    ))
 )
diff --git a/gdb/gdb-code-style.el b/gdb/gdb-code-style.el
index 6099c1d4b8..7070170f55 100644
--- a/gdb/gdb-code-style.el
+++ b/gdb/gdb-code-style.el
@@ -74,4 +74,8 @@
   )
 (add-hook 'c-mode-common-hook 'gdb-comment-hook)
 
+;; Set c-set-offset 'innamespace as a safe value to be used in .dir-locals.el.
+(setq safe-local-variable-values
+      '((eval c-set-offset 'innamespace [0])
+	(c-offsets-alist (innamespace .[0]))))
 ;;; gdb-code-style.el ends here
-- 
2.11.0

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

* [PATCH v2] Set emacs default mode for the GDB directory to C++
  2016-12-16 19:29 [PATCH] Set emacs default mode for the GDB directory to C++ Antoine Tremblay
@ 2016-12-16 19:41 ` Antoine Tremblay
  2016-12-16 22:25   ` Doug Evans via gdb-patches
  0 siblings, 1 reply; 6+ messages in thread
From: Antoine Tremblay @ 2016-12-16 19:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: Antoine Tremblay

* In this v2:
 I forgot I needed to add to the safe-local-variable-values list rather than just set it.. this version fixes that..
 
Since GDB has switched to C++ but the file names are still .c emacs does
not load the proper mode when opening files in the gdb directory.

This patch fixes that by enabling c++ mode.

This patch also fixes indentation tweaks as discussed in this thread:
https://sourceware.org/ml/gdb-patches/2016-12/msg00074.html

Indent with gdb-code-style.el included and the .dir-locals.el is as such:

namespace TestNameSpace {

class test
{
public:
  test test() {}

  int m_a;
};

struct teststruct
{
  int a;
}
}

gdb/ChangeLog:

	* .dir-locals.el: Set c++ mode for the directory and set indent
	properly.
	* gdb-code-style.el: Set c-set-offset 'innamespace as a safe value
	to be used in .dir-locals.el.
---
 gdb/.dir-locals.el    | 7 ++++++-
 gdb/gdb-code-style.el | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el
index fbd9309aef..8ac52393fc 100644
--- a/gdb/.dir-locals.el
+++ b/gdb/.dir-locals.el
@@ -20,5 +20,10 @@
 	      (indent-tabs-mode . t)))
  (nil . ((bug-reference-url-format . "http://sourceware.org/bugzilla/show_bug.cgi?id=%s")))
  (c-mode . ((c-file-style . "GNU")
-	    (indent-tabs-mode . t)))
+	    (mode . c++)
+	    (indent-tabs-mode . t)
+	    (tab-width . 8)
+	    (c-basic-offset . 2)
+	    (eval . (c-set-offset 'innamespace [0]))
+	    ))
 )
diff --git a/gdb/gdb-code-style.el b/gdb/gdb-code-style.el
index 6099c1d4b8..2864072b93 100644
--- a/gdb/gdb-code-style.el
+++ b/gdb/gdb-code-style.el
@@ -74,4 +74,9 @@
   )
 (add-hook 'c-mode-common-hook 'gdb-comment-hook)
 
+;; Set c-set-offset 'innamespace as a safe value to be used in .dir-locals.el.
+(setq safe-local-variable-values
+      (cons safe-local-variable-values
+	    '((eval c-set-offset 'innamespace [0])
+	      (c-offsets-alist (innamespace .[0])))))
 ;;; gdb-code-style.el ends here
-- 
2.11.0

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

* Re: [PATCH v2] Set emacs default mode for the GDB directory to C++
  2016-12-16 19:41 ` [PATCH v2] " Antoine Tremblay
@ 2016-12-16 22:25   ` Doug Evans via gdb-patches
  2016-12-19 12:24     ` [PATCH v3] " Antoine Tremblay
  0 siblings, 1 reply; 6+ messages in thread
From: Doug Evans via gdb-patches @ 2016-12-16 22:25 UTC (permalink / raw)
  To: Antoine Tremblay; +Cc: gdb-patches

On Fri, Dec 16, 2016 at 11:40 AM, Antoine Tremblay
<antoine.tremblay@ericsson.com> wrote:
> gdb/ChangeLog:
>
>         * .dir-locals.el: Set c++ mode for the directory and set indent
>         properly.
>         * gdb-code-style.el: Set c-set-offset 'innamespace as a safe value
>         to be used in .dir-locals.el.

LGTM

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

* [PATCH v3] Set emacs default mode for the GDB directory to C++
  2016-12-16 22:25   ` Doug Evans via gdb-patches
@ 2016-12-19 12:24     ` Antoine Tremblay
  2016-12-20 13:04       ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: Antoine Tremblay @ 2016-12-19 12:24 UTC (permalink / raw)
  To: dje, gdb-patches; +Cc: Antoine Tremblay

* In this v3:
The namespace indent should be 0 (no indent) rather then [0] (indent to column 0)
fixed that.
OK with that change ?


Since GDB has switched to C++ but the file names are still .c emacs does
not load the proper mode when opening files in the gdb directory.

This patch fixes that by enabling c++ mode.

This patch also fixes indentation tweaks as discussed in this thread:
https://sourceware.org/ml/gdb-patches/2016-12/msg00074.html

Indent with gdb-code-style.el included and the .dir-locals.el is as such:

namespace TestNameSpace {

class test
{
public:
  test test() {}

  int m_a;
};

struct teststruct
{
  int a;
}
}

gdb/ChangeLog:

	* .dir-locals.el: Set c++ mode for the directory and set indent
	properly.
	* gdb-code-style.el: Set c-set-offset 'innamespace as a safe value
	to be used in .dir-locals.el.
---
 gdb/.dir-locals.el    | 7 ++++++-
 gdb/gdb-code-style.el | 5 +++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el
index fbd9309aef..c32846a137 100644
--- a/gdb/.dir-locals.el
+++ b/gdb/.dir-locals.el
@@ -20,5 +20,10 @@
 	      (indent-tabs-mode . t)))
  (nil . ((bug-reference-url-format . "http://sourceware.org/bugzilla/show_bug.cgi?id=%s")))
  (c-mode . ((c-file-style . "GNU")
-	    (indent-tabs-mode . t)))
+	    (mode . c++)
+	    (indent-tabs-mode . t)
+	    (tab-width . 8)
+	    (c-basic-offset . 2)
+	    (eval . (c-set-offset 'innamespace 0))
+	    ))
 )
diff --git a/gdb/gdb-code-style.el b/gdb/gdb-code-style.el
index 6099c1d4b8..9221dd048c 100644
--- a/gdb/gdb-code-style.el
+++ b/gdb/gdb-code-style.el
@@ -74,4 +74,9 @@
   )
 (add-hook 'c-mode-common-hook 'gdb-comment-hook)
 
+;; Set c-set-offset 'innamespace as a safe value to be used in .dir-locals.el.
+(setq safe-local-variable-values
+      (cons safe-local-variable-values
+	    '((eval c-set-offset 'innamespace 0)
+	      (c-offsets-alist (innamespace .0)))))
 ;;; gdb-code-style.el ends here
-- 
2.11.0

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

* Re: [PATCH v3] Set emacs default mode for the GDB directory to C++
  2016-12-19 12:24     ` [PATCH v3] " Antoine Tremblay
@ 2016-12-20 13:04       ` Pedro Alves
  2016-12-20 13:46         ` Antoine Tremblay
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2016-12-20 13:04 UTC (permalink / raw)
  To: Antoine Tremblay, dje, gdb-patches

On 12/19/2016 12:23 PM, Antoine Tremblay wrote:
> * In this v3:
> The namespace indent should be 0 (no indent) rather then [0] (indent to column 0)
> fixed that.
> OK with that change ?

OK.

Thanks,
Pedro Alves

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

* Re: [PATCH v3] Set emacs default mode for the GDB directory to C++
  2016-12-20 13:04       ` Pedro Alves
@ 2016-12-20 13:46         ` Antoine Tremblay
  0 siblings, 0 replies; 6+ messages in thread
From: Antoine Tremblay @ 2016-12-20 13:46 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Antoine Tremblay, dje, gdb-patches


Pedro Alves writes:

> On 12/19/2016 12:23 PM, Antoine Tremblay wrote:
>> * In this v3:
>> The namespace indent should be 0 (no indent) rather then [0] (indent to column 0)
>> fixed that.
>> OK with that change ?
>
> OK.

Pushed in, thx.

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

end of thread, other threads:[~2016-12-20 13:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-16 19:29 [PATCH] Set emacs default mode for the GDB directory to C++ Antoine Tremblay
2016-12-16 19:41 ` [PATCH v2] " Antoine Tremblay
2016-12-16 22:25   ` Doug Evans via gdb-patches
2016-12-19 12:24     ` [PATCH v3] " Antoine Tremblay
2016-12-20 13:04       ` Pedro Alves
2016-12-20 13:46         ` Antoine Tremblay

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