diff options
| author | Ted Zlatanov | 2011-09-25 07:52:53 -0400 |
|---|---|---|
| committer | Ted Zlatanov | 2011-09-25 07:52:53 -0400 |
| commit | f3f9834230b2cf021984c639072ce5cb377643f0 (patch) | |
| tree | bc277326997ce6a44741879ba4cedfa701afb29f /lisp | |
| parent | bb72ce91987bea078a4aa72b198759975c126399 (diff) | |
| download | emacs-f3f9834230b2cf021984c639072ce5cb377643f0.tar.gz emacs-f3f9834230b2cf021984c639072ce5cb377643f0.zip | |
* lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience function.
* lisp/progmodes/cfengine.el (cfengine-auto-mode): Add convenience
function that picks between cfengine 2 and 3 support
automatically. Update docs accordingly.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cfengine.el | 33 |
2 files changed, 31 insertions, 8 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 662dd7a7f99..086b6c5b230 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2011-09-25 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 2 | |||
| 3 | * progmodes/cfengine.el (cfengine-auto-mode): Add convenience | ||
| 4 | function that picks between cfengine 2 and 3 support | ||
| 5 | automatically. Update docs accordingly. | ||
| 6 | |||
| 1 | 2011-09-22 Ken Manheimer <ken.manheimer@gmail.com> | 7 | 2011-09-22 Ken Manheimer <ken.manheimer@gmail.com> |
| 2 | 8 | ||
| 3 | * allout.el (allout-this-command-hid-stuff): Buffer-local variable | 9 | * allout.el (allout-this-command-hid-stuff): Buffer-local variable |
diff --git a/lisp/progmodes/cfengine.el b/lisp/progmodes/cfengine.el index 7989c60f80c..eea822328f1 100644 --- a/lisp/progmodes/cfengine.el +++ b/lisp/progmodes/cfengine.el | |||
| @@ -26,16 +26,21 @@ | |||
| 26 | ;; Provides support for editing GNU Cfengine files, including | 26 | ;; Provides support for editing GNU Cfengine files, including |
| 27 | ;; font-locking, Imenu and indention, but with no special keybindings. | 27 | ;; font-locking, Imenu and indention, but with no special keybindings. |
| 28 | 28 | ||
| 29 | ;; Possible customization for auto-mode selection: | 29 | ;; The CFEngine 3.x support doesn't have Imenu support but patches are |
| 30 | ;; (push '(("^cfagent.conf\\'" . cfengine-mode)) auto-mode-alist) | 30 | ;; welcome. |
| 31 | ;; (push '(("^cf\\." . cfengine-mode)) auto-mode-alist) | ||
| 32 | ;; (push '(("\\.cf\\'" . cfengine-mode)) auto-mode-alist) | ||
| 33 | 31 | ||
| 34 | ;; Or, if you want to use the CFEngine 3.x support: | 32 | ;; You can set it up so either cfengine-mode (2.x and earlier) or |
| 33 | ;; cfengine3-mode (3.x) will be picked, depending on the buffer | ||
| 34 | ;; contents: | ||
| 35 | 35 | ||
| 36 | ;; (push '(("^cfagent.conf\\'" . cfengine3-mode)) auto-mode-alist) | 36 | ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode)) |
| 37 | ;; (push '(("^cf\\." . cfengine3-mode)) auto-mode-alist) | 37 | |
| 38 | ;; (push '(("\\.cf\\'" . cfengine3-mode)) auto-mode-alist) | 38 | ;; OR you can choose to always use a specific version, if you prefer |
| 39 | ;; it | ||
| 40 | |||
| 41 | ;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine3-mode)) | ||
| 42 | ;; (add-to-list 'auto-mode-alist '("^cf\\." . cfengine-mode)) | ||
| 43 | ;; (add-to-list 'auto-mode-alist '("^cfagent.conf\\'" . cfengine-mode)) | ||
| 39 | 44 | ||
| 40 | ;; This is not the same as the mode written by Rolf Ebert | 45 | ;; This is not the same as the mode written by Rolf Ebert |
| 41 | ;; <ebert@waporo.muc.de>, distributed with cfengine-2.0.5. It does | 46 | ;; <ebert@waporo.muc.de>, distributed with cfengine-2.0.5. It does |
| @@ -466,6 +471,18 @@ to the action header." | |||
| 466 | #'cfengine-beginning-of-defun) | 471 | #'cfengine-beginning-of-defun) |
| 467 | (set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun)) | 472 | (set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun)) |
| 468 | 473 | ||
| 474 | ;;;###autoload | ||
| 475 | (defun cfengine-auto-mode () | ||
| 476 | "Choose between `cfengine-mode' and `cfengine3-mode' depending | ||
| 477 | on the buffer contents" | ||
| 478 | (let ((v3 nil)) | ||
| 479 | (save-restriction | ||
| 480 | (goto-char (point-min)) | ||
| 481 | (while (not (or (eobp) v3)) | ||
| 482 | (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>"))) | ||
| 483 | (forward-line))) | ||
| 484 | (if v3 (cfengine3-mode) (cfengine-mode)))) | ||
| 485 | |||
| 469 | (provide 'cfengine3) | 486 | (provide 'cfengine3) |
| 470 | (provide 'cfengine) | 487 | (provide 'cfengine) |
| 471 | 488 | ||