ba78fc9367
This change adds the ob-cfengine3 package to the cfengine layer enabling execution of cfengine3 SRC blocks inside of org-mode. |
||
---|---|---|
.. | ||
img | ||
packages.el | ||
README.org |
CFEngine layer
Description
This layer makes working with CFEngine policy easier:
- Syntax highlighting
- On the fly syntax checks (via
syntax-checking
layer) - Auto completion (via
auto-completion
layer) - Execution of
cfengine3
SRC
blocks inorg-mode
(via ob-cfengine3 package)
Install
Add cfengine
to the dotspacemacs-configuration-layers
in your ~/.spacemacs
to use this layer.
Configuration
Set file permission on save
Here is a function to set permissions to 600 on save, this can help avoid errors like:
File ./example.cf (owner 1000) is writable by others (security exception)
(defun cfengine-permissions-policy-owner-only ()
"If file starts with a shebang, make `buffer-file-name' executable"
(save-excursion
(set-file-modes buffer-file-name #o600)
(message (concat "Made " buffer-file-name " accessibly only by the owner (600)."))))
(add-hook 'after-save-hook 'cfengine-permissions-policy-owner-only nil 'make-it-local)
Indendation
If you like attributes to be intended from the promiser set Indentation amount
from anchor
to 2
. For example:
bundle agent main
{
vars:
"promiser"
string => "value",
comment => "Indented 2 spaces from promiser";
}
cfengine3
SRC
blocks in org-mode
Add cfengine to the list of languages loaded by org-babel.
(defun dotspacemacs/user-config ()
(with-eval-after-load 'org
(org-babel-do-load-languages
'org-babel-load-languages
'(
(cfengine . t)))
)
)
Alternatively configure org-mode to load support for any languages encountered automatically.
(defun dotspacemacs/user-config ()
(with-eval-after-load 'org
(defadvice org-babel-execute-src-block (around load-language nil activate)
"Load language if needed"
(let ((language (org-element-property :language (org-element-at-point))))
(unless (cdr (assoc (intern language) org-babel-load-languages))
(add-to-list 'org-babel-load-languages (cons (intern language) t))
(org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
ad-do-it))
)
)
Enable syntax highlighting and tab stops as if you were editing in the native mode within SRC blocks.
(defun dotspacemacs/user-config ()
(with-eval-after-load 'org
(setq org-src-tab-acts-natively t)
(setq org-src-fontify-natively t)
)
)
Execution of cfengine3
SRC
blocks
With the insertion point inside the SRC block press ,,
or CTRL-c Ctrl-c
bundle agent main
{
reports:
"Hello World!";
}
R: Hello World!
See the ob-cfengine3 README for information on controlling inclusion of the
stdlib, definition of classes and controlling the bundlesequence
using header
args.
To suppress the confirmation when executing a block set
(setq org-confirm-babel-evaluate nil)
in dotspacemacs/user-config()
.
Key bindings
Key Binding | Description |
---|---|
SPC m j |
Reformats JSON string |