changeset 17588:9ff04de067ce

improve .dir-locals.el * .dir-local.el: Don't fail if buffer-file-name returns nil. Use str-match-p instead of str-match. Simplify logic.
author Rüdiger Sonderfeld <ruediger@c-plusplus.de>
date Fri, 04 Oct 2013 23:32:38 +0200
parents a13ff4521538
children c3aadd228c37
files .dir-locals.el
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.dir-locals.el	Mon Oct 07 08:07:55 2013 -0700
+++ b/.dir-locals.el	Fri Oct 04 23:32:38 2013 +0200
@@ -2,9 +2,10 @@
       ((c-file-style . "gnu")
        (indent-tabs-mode . nil)
        (fill-column . 72)
-       (eval . (when (string-match "\\.h\\'" (buffer-file-name))
-                 (unless (string-match "/gnulib/" (buffer-file-name))
-                   (c++-mode)
-                   (c-set-style "gnu"))))))
+       (eval . (when (and (buffer-file-name)
+                          (string-match-p "\\.h\\'" (buffer-file-name))
+                          (not (string-match-p "/gnulib/" (buffer-file-name))))
+                 (c++-mode)
+                 (c-set-style "gnu")))))
  (change-log-mode . ((indent-tabs-mode . t)))
  (makefile-mode . ((indent-tabs-mode . t))))