diff options
author | Ted Zlatanov <tzz@lifelogs.com> | 2011-09-25 07:52:53 -0400 |
---|---|---|
committer | Ted Zlatanov <tzz@lifelogs.com> | 2011-09-25 07:52:53 -0400 |
commit | f3f9834230b2cf021984c639072ce5cb377643f0 (patch) | |
tree | bc277326997ce6a44741879ba4cedfa701afb29f /lisp/progmodes/cfengine.el | |
parent | bb72ce91987bea078a4aa72b198759975c126399 (diff) | |
download | emacs-f3f9834230b2cf021984c639072ce5cb377643f0.tar.gz emacs-f3f9834230b2cf021984c639072ce5cb377643f0.tar.bz2 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/progmodes/cfengine.el')
-rw-r--r-- | lisp/progmodes/cfengine.el | 33 |
1 files changed, 25 insertions, 8 deletions
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 @@ ;; Provides support for editing GNU Cfengine files, including ;; font-locking, Imenu and indention, but with no special keybindings. -;; Possible customization for auto-mode selection: -;; (push '(("^cfagent.conf\\'" . cfengine-mode)) auto-mode-alist) -;; (push '(("^cf\\." . cfengine-mode)) auto-mode-alist) -;; (push '(("\\.cf\\'" . cfengine-mode)) auto-mode-alist) +;; The CFEngine 3.x support doesn't have Imenu support but patches are +;; welcome. -;; Or, if you want to use the CFEngine 3.x support: +;; You can set it up so either cfengine-mode (2.x and earlier) or +;; cfengine3-mode (3.x) will be picked, depending on the buffer +;; contents: -;; (push '(("^cfagent.conf\\'" . cfengine3-mode)) auto-mode-alist) -;; (push '(("^cf\\." . cfengine3-mode)) auto-mode-alist) -;; (push '(("\\.cf\\'" . cfengine3-mode)) auto-mode-alist) +;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-auto-mode)) + +;; OR you can choose to always use a specific version, if you prefer +;; it + +;; (add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine3-mode)) +;; (add-to-list 'auto-mode-alist '("^cf\\." . cfengine-mode)) +;; (add-to-list 'auto-mode-alist '("^cfagent.conf\\'" . cfengine-mode)) ;; This is not the same as the mode written by Rolf Ebert ;; <ebert@waporo.muc.de>, distributed with cfengine-2.0.5. It does @@ -466,6 +471,18 @@ to the action header." #'cfengine-beginning-of-defun) (set (make-local-variable 'end-of-defun-function) #'cfengine-end-of-defun)) +;;;###autoload +(defun cfengine-auto-mode () + "Choose between `cfengine-mode' and `cfengine3-mode' depending +on the buffer contents" + (let ((v3 nil)) + (save-restriction + (goto-char (point-min)) + (while (not (or (eobp) v3)) + (setq v3 (looking-at (concat cfengine3-defuns-regex "\\>"))) + (forward-line))) + (if v3 (cfengine3-mode) (cfengine-mode)))) + (provide 'cfengine3) (provide 'cfengine) |