Add 2011 to FSF/AIST copyright years.
[bpt/emacs.git] / lisp / progmodes / cfengine.el
index 76b4efc..1c1589f 100644 (file)
@@ -1,16 +1,17 @@
 ;;; cfengine.el --- mode for editing Cfengine files
 
-;; Copyright (C) 2003 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+;; Free Software Foundation, Inc.
 
 ;; Author: Dave Love <fx@gnu.org>
 ;; Keywords: languages
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -84,6 +83,12 @@ This includes those for cfservd as well as cfagent."))
     ;; File, acl &c in group:   { token ... }
     ("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face)))
 
+(defconst cfengine-font-lock-syntactic-keywords
+  ;; In the main syntax-table, backslash is marked as a punctuation, because
+  ;; of its use in DOS-style directory separators.  Here we try to recognize
+  ;; the cases where backslash is used as an escape inside strings.
+  '(("\\(\\(?:\\\\\\)+\\)\"" 1 "\\")))
+
 (defvar cfengine-imenu-expression
   `((nil ,(concat "^[ \t]*" (eval-when-compile
                              (regexp-opt cfengine-actions t))
@@ -102,7 +107,8 @@ This includes those for cfservd as well as cfagent."))
 (defun cfengine-beginning-of-defun ()
   "`beginning-of-defun' function for Cfengine mode.
 Treats actions as defuns."
-  (end-of-line)
+  (unless (<= (current-column) (current-indentation))
+    (end-of-line))
   (if (re-search-backward "^[[:alpha:]]+: *$" nil t)
       (beginning-of-line)
     (goto-char (point-min)))
@@ -113,7 +119,7 @@ Treats actions as defuns."
 Treats actions as defuns."
   (end-of-line)
   (if (re-search-forward "^[[:alpha:]]+: *$" nil t)
-      (progn (forward-line -1) (end-of-line))
+      (beginning-of-line)
     (goto-char (point-max)))
   t)
 
@@ -174,7 +180,7 @@ Intended as the value of `indent-line-function'."
     (if (> (- (point-max) pos) (point))
        (goto-char (- (point-max) pos)))))
 
-;; This doesn't work too well in Emacs 21.2.  See 21.4 development
+;; This doesn't work too well in Emacs 21.2.  See 22.1 development
 ;; code.
 (defun cfengine-fill-paragraph (&optional justify)
   "Fill `paragraphs' in Cfengine code."
@@ -216,12 +222,12 @@ to the action header."
   ;; variable substitution:
   (modify-syntax-entry ?$ "." cfengine-mode-syntax-table)
   ;; Doze path separators:
-  (modify-syntax-entry ?\\ "_" cfengine-mode-syntax-table)
+  (modify-syntax-entry ?\\ "." cfengine-mode-syntax-table)
   ;; Otherwise, syntax defaults seem OK to give reasonable word
   ;; movement.
 
   (set (make-local-variable 'parens-require-spaces) nil)
-  (set (make-local-variable 'require-final-newline) t)
+  (set (make-local-variable 'require-final-newline) mode-require-final-newline)
   (set (make-local-variable 'comment-start)  "# ")
   (set (make-local-variable 'comment-start-skip)
        "\\(\\(?:^\\|[^\\\\\n]\\)\\(?:\\\\\\\\\\)*\\)#+[ \t]*")
@@ -235,12 +241,19 @@ to the action header."
   ;; functions in evaluated classes to string syntax, and then obey
   ;; syntax properties.
   (setq font-lock-defaults
-       '(cfengine-font-lock-keywords nil nil nil beginning-of-line))
+       '(cfengine-font-lock-keywords nil nil nil beginning-of-line
+          (font-lock-syntactic-keywords
+           . cfengine-font-lock-syntactic-keywords)))
   (setq imenu-generic-expression cfengine-imenu-expression)
   (set (make-local-variable 'beginning-of-defun-function)
        #'cfengine-beginning-of-defun)
-  (set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun))
+  (set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun)
+  ;; Like Lisp mode.  Without this, we lose with, say,
+  ;; `backward-up-list' when there's an unbalanced quote in a
+  ;; preceding comment.
+  (set (make-local-variable 'parse-sexp-ignore-comments) t))
 
 (provide 'cfengine)
 
+;; arch-tag: 6b931be2-1505-4124-afa6-9675971e26d4
 ;;; cfengine.el ends here