Appendix A. Editing CFEngine 3 Configurations in Emacs

Ted Zlatanov

If you are an Emacs user, you will not be surprised to learn that there is an Emacs mode for editing CFEngine configuration files. In this Appendix you will learn how to set up and use the CFEngine editing mode in Emacs.

Setting Up

You need GNU Emacs 23.1 or higher. Earlier versions or XEmacs may work as well, but have not been extensively tested.

First, you need to download cfengine.el from Emacs currently includes an older version of this file. Emacs 24.2 and higher, when released, will include the latest version, but 24.1 and earlier do not, so you need to manually download it.

Assuming you have downloaded the library to your computer, you can add it to your load path. Follow the generic instructions from the Emacs wiki, or just put the following code in your .emacs file:

(autoload 'cfengine-mode "cfengine" "cfengine editing" t)
(add-to-list 'load-path "/directory/where/the/library/lives/")

You will probably want to tell Emacs to associate .cf files with the cfengine-mode, although that could cause problems if you use other files ending with .cf. See for more information or just add the following line to your .emacs file:

(add-to-list 'auto-mode-alist '("\\.cf\\'" . cfengine-mode))

If you use other files ending with .cf and would prefer not to associate this extension with cfengine-mode by default, ...

Get Learning CFEngine 3 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.