;; The CFEngine 3.x support doesn't have Imenu support but patches are
;; welcome.
+;; By default, CFEngine 3.x syntax is used.
+
;; You can set it up so either `cfengine2-mode' (2.x and earlier) or
;; `cfengine3-mode' (3.x) will be picked, depending on the buffer
;; contents:
-;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-mode))
+;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode))
;; OR you can choose to always use a specific version, if you prefer
;; it:
("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face)
("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
- ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
+ ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; File, acl &c in group: { token ... }
("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face)))
`(
;; Defuns. This happens early so they don't get caught by looser
;; patterns.
- (,(concat "\\<" cfengine3-defuns-regex "\\>"
- "[ \t]+\\<\\([[:alnum:]_.:]+\\)\\>"
- "[ \t]+\\<\\([[:alnum:]_.:]+\\)"
+ (,(concat "\\_<" cfengine3-defuns-regex "\\_>"
+ "[ \t]+\\_<\\([[:alnum:]_.:]+\\)\\_>"
+ "[ \t]+\\_<\\([[:alnum:]_.:]+\\)"
;; Optional parentheses with variable names inside.
"\\(?:(\\([^)]*\\))\\)?")
(1 font-lock-builtin-face)
("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face)
;; Variable definitions.
- ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
+ ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face)
;; Variable types.
- (,(concat "\\<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\>")
+ (,(concat "\\_<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\_>")
1 font-lock-type-face)))
(defvar cfengine2-imenu-expression
(regexp-opt cfengine2-actions t))
":[^:]")
1)
- ("Variables/classes" "\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1)
- ("Variables/classes" "\\<define=\\([[:alnum:]_]+\\)" 1)
- ("Variables/classes" "\\<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1))
+ ("Variables/classes" "\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1)
+ ("Variables/classes" "\\_<define=\\([[:alnum:]_]+\\)" 1)
+ ("Variables/classes" "\\_<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1))
"`imenu-generic-expression' for CFEngine mode.")
(defun cfengine2-outline-level ()
Treats body/bundle blocks as defuns."
(unless (<= (current-column) (current-indentation))
(end-of-line))
- (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
+ (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
(beginning-of-line)
(goto-char (point-min)))
t)
"`end-of-defun' function for Cfengine 3 mode.
Treats body/bundle blocks as defuns."
(end-of-line)
- (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t)
+ (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t)
(beginning-of-line)
(goto-char (point-max)))
t)
(cond
;; Body/bundle blocks start at 0.
- ((looking-at (concat cfengine3-defuns-regex "\\>"))
+ ((looking-at (concat cfengine3-defuns-regex "\\_>"))
(indent-line-to 0))
;; Categories are indented one step.
((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$"))
(defun cfengine-common-syntax (table)
;; The syntax defaults seem OK to give reasonable word movement.
- (modify-syntax-entry ?w "_" table)
(modify-syntax-entry ?# "<" table)
(modify-syntax-entry ?\n ">#" table)
(modify-syntax-entry ?\" "\"" table) ; "string"
(save-restriction
(goto-char (point-min))
(while (not (or (eobp) v3))
- (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>")))
+ (setq v3 (looking-at (concat cfengine3-defuns-regex "\\_>")))
(forward-line)))
(if v3 (cfengine3-mode) (cfengine2-mode))))