diff options
Diffstat (limited to 'lisp/progmodes/cfengine.el')
| -rw-r--r-- | lisp/progmodes/cfengine.el | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 74b81b0cd01..11eb0eeaf49 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el | |||
| @@ -30,11 +30,13 @@ | |||
| 30 | ;; The CFEngine 3.x support doesn't have Imenu support but patches are | 30 | ;; The CFEngine 3.x support doesn't have Imenu support but patches are |
| 31 | ;; welcome. | 31 | ;; welcome. |
| 32 | 32 | ||
| 33 | ;; By default, CFEngine 3.x syntax is used. | ||
| 34 | |||
| 33 | ;; You can set it up so either `cfengine2-mode' (2.x and earlier) or | 35 | ;; You can set it up so either `cfengine2-mode' (2.x and earlier) or |
| 34 | ;; `cfengine3-mode' (3.x) will be picked, depending on the buffer | 36 | ;; `cfengine3-mode' (3.x) will be picked, depending on the buffer |
| 35 | ;; contents: | 37 | ;; contents: |
| 36 | 38 | ||
| 37 | ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-mode)) | 39 | ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode)) |
| 38 | 40 | ||
| 39 | ;; OR you can choose to always use a specific version, if you prefer | 41 | ;; OR you can choose to always use a specific version, if you prefer |
| 40 | ;; it: | 42 | ;; it: |
| @@ -181,7 +183,7 @@ This includes those for cfservd as well as cfagent.") | |||
| 181 | ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face) | 183 | ("$(\\([[:alnum:]_]+\\))" 1 font-lock-variable-name-face) |
| 182 | ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face) | 184 | ("${\\([[:alnum:]_]+\\)}" 1 font-lock-variable-name-face) |
| 183 | ;; Variable definitions. | 185 | ;; Variable definitions. |
| 184 | ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) | 186 | ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) |
| 185 | ;; File, acl &c in group: { token ... } | 187 | ;; File, acl &c in group: { token ... } |
| 186 | ("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face))) | 188 | ("{[ \t]*\\([^ \t\n]+\\)" 1 font-lock-constant-face))) |
| 187 | 189 | ||
| @@ -189,9 +191,9 @@ This includes those for cfservd as well as cfagent.") | |||
| 189 | `( | 191 | `( |
| 190 | ;; Defuns. This happens early so they don't get caught by looser | 192 | ;; Defuns. This happens early so they don't get caught by looser |
| 191 | ;; patterns. | 193 | ;; patterns. |
| 192 | (,(concat "\\<" cfengine3-defuns-regex "\\>" | 194 | (,(concat "\\_<" cfengine3-defuns-regex "\\_>" |
| 193 | "[ \t]+\\<\\([[:alnum:]_.:]+\\)\\>" | 195 | "[ \t]+\\_<\\([[:alnum:]_.:]+\\)\\_>" |
| 194 | "[ \t]+\\<\\([[:alnum:]_.:]+\\)" | 196 | "[ \t]+\\_<\\([[:alnum:]_.:]+\\)" |
| 195 | ;; Optional parentheses with variable names inside. | 197 | ;; Optional parentheses with variable names inside. |
| 196 | "\\(?:(\\([^)]*\\))\\)?") | 198 | "\\(?:(\\([^)]*\\))\\)?") |
| 197 | (1 font-lock-builtin-face) | 199 | (1 font-lock-builtin-face) |
| @@ -212,10 +214,10 @@ This includes those for cfservd as well as cfagent.") | |||
| 212 | ("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face) | 214 | ("[@$]{\\([[:alnum:]_.:]+\\)}" 1 font-lock-variable-name-face) |
| 213 | 215 | ||
| 214 | ;; Variable definitions. | 216 | ;; Variable definitions. |
| 215 | ("\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) | 217 | ("\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1 font-lock-variable-name-face) |
| 216 | 218 | ||
| 217 | ;; Variable types. | 219 | ;; Variable types. |
| 218 | (,(concat "\\<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\>") | 220 | (,(concat "\\_<" (eval-when-compile (regexp-opt cfengine3-vartypes t)) "\\_>") |
| 219 | 1 font-lock-type-face))) | 221 | 1 font-lock-type-face))) |
| 220 | 222 | ||
| 221 | (defvar cfengine2-imenu-expression | 223 | (defvar cfengine2-imenu-expression |
| @@ -223,9 +225,9 @@ This includes those for cfservd as well as cfagent.") | |||
| 223 | (regexp-opt cfengine2-actions t)) | 225 | (regexp-opt cfengine2-actions t)) |
| 224 | ":[^:]") | 226 | ":[^:]") |
| 225 | 1) | 227 | 1) |
| 226 | ("Variables/classes" "\\<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1) | 228 | ("Variables/classes" "\\_<\\([[:alnum:]_]+\\)[ \t]*=[ \t]*(" 1) |
| 227 | ("Variables/classes" "\\<define=\\([[:alnum:]_]+\\)" 1) | 229 | ("Variables/classes" "\\_<define=\\([[:alnum:]_]+\\)" 1) |
| 228 | ("Variables/classes" "\\<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1)) | 230 | ("Variables/classes" "\\_<DefineClass\\>[ \t]+\\([[:alnum:]_]+\\)" 1)) |
| 229 | "`imenu-generic-expression' for CFEngine mode.") | 231 | "`imenu-generic-expression' for CFEngine mode.") |
| 230 | 232 | ||
| 231 | (defun cfengine2-outline-level () | 233 | (defun cfengine2-outline-level () |
| @@ -338,7 +340,7 @@ Intended as the value of `indent-line-function'." | |||
| 338 | Treats body/bundle blocks as defuns." | 340 | Treats body/bundle blocks as defuns." |
| 339 | (unless (<= (current-column) (current-indentation)) | 341 | (unless (<= (current-column) (current-indentation)) |
| 340 | (end-of-line)) | 342 | (end-of-line)) |
| 341 | (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t) | 343 | (if (re-search-backward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t) |
| 342 | (beginning-of-line) | 344 | (beginning-of-line) |
| 343 | (goto-char (point-min))) | 345 | (goto-char (point-min))) |
| 344 | t) | 346 | t) |
| @@ -347,7 +349,7 @@ Treats body/bundle blocks as defuns." | |||
| 347 | "`end-of-defun' function for Cfengine 3 mode. | 349 | "`end-of-defun' function for Cfengine 3 mode. |
| 348 | Treats body/bundle blocks as defuns." | 350 | Treats body/bundle blocks as defuns." |
| 349 | (end-of-line) | 351 | (end-of-line) |
| 350 | (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\>") nil t) | 352 | (if (re-search-forward (concat "^[ \t]*" cfengine3-defuns-regex "\\_>") nil t) |
| 351 | (beginning-of-line) | 353 | (beginning-of-line) |
| 352 | (goto-char (point-max))) | 354 | (goto-char (point-max))) |
| 353 | t) | 355 | t) |
| @@ -366,7 +368,7 @@ Intended as the value of `indent-line-function'." | |||
| 366 | 368 | ||
| 367 | (cond | 369 | (cond |
| 368 | ;; Body/bundle blocks start at 0. | 370 | ;; Body/bundle blocks start at 0. |
| 369 | ((looking-at (concat cfengine3-defuns-regex "\\>")) | 371 | ((looking-at (concat cfengine3-defuns-regex "\\_>")) |
| 370 | (indent-line-to 0)) | 372 | (indent-line-to 0)) |
| 371 | ;; Categories are indented one step. | 373 | ;; Categories are indented one step. |
| 372 | ((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$")) | 374 | ((looking-at (concat cfengine3-category-regex "[ \t]*\\(#.*\\)*$")) |
| @@ -583,7 +585,7 @@ on the buffer contents" | |||
| 583 | (save-restriction | 585 | (save-restriction |
| 584 | (goto-char (point-min)) | 586 | (goto-char (point-min)) |
| 585 | (while (not (or (eobp) v3)) | 587 | (while (not (or (eobp) v3)) |
| 586 | (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>"))) | 588 | (setq v3 (looking-at (concat cfengine3-defuns-regex "\\_>"))) |
| 587 | (forward-line))) | 589 | (forward-line))) |
| 588 | (if v3 (cfengine3-mode) (cfengine2-mode)))) | 590 | (if v3 (cfengine3-mode) (cfengine2-mode)))) |
| 589 | 591 | ||