Re: RFC: add .dir-locals.el

Yao Qi
2012-04-11T23:33:37Z

On 03/27/2012 02:52 AM, Tom Tromey wrote:
> This adds a .dir-locals.el to gdb. This will cause Emacs to
> automatically pick up the correct settings for various variables, so
> that users won't have to configure Emacs for editing gdb.
>
> These settings won't affect any files outside of gdb.

Do you think it is useful to add some code here to check code style or
check ARI rules?

The patch below shows two ARI checks we can do in emacs. The benefit
is that code is checked automatically during writing, instead of being
pointed out by reviewers.

With this change, when emacs opens gdb files for the first time, it
prompts to ask apply risky local variables. Not sure GDB contributors
using emacs are comfortable with this or not.

I have other emacs lisp snippets to do other checks, and personally, I
find they are quite useful. If this is acceptable, I'll push them out
one by one.

--
Yao (é½å°§)

* gdb/.dir-locals.el: Check improper functions and include
files.

diff --git a/gdb/.dir-locals.el b/gdb/.dir-locals.el
index 8eca9e0..c41bb1a 100644
--- a/gdb/.dir-locals.el
+++ b/gdb/.dir-locals.el
@@ -20,5 +20,16 @@
(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)))
+ (indent-tabs-mode . t)
+ (eval . (progn
+ ;; Don't use these functions. Their alternatives are better.
+ ;; This list of functions are from ARI rules.
+ (font-lock-add-keywords
+ nil
+ '(("\\<\\(\\(xasprintf\\|abort\\|vasprintf\\|strerror\\|strdup\\|asprintf\\|sprintf\\)[ ]*\(\\)" 1 font-lock-warning-face t)))
+ ;; Don't include these files.
+ (font-lock-add-keywords
+ nil
+ '(("\\<include[ ]*\\(<\\(stat\\|dirent\\|wait\\|sys/wait\\|assert\\)\\.h>\\)" 1 font-lock-warning-face t)))
+ ))))
)