👉 Support this work via GitHub Sponsors
Insert Emacs org blocks with completion (via company mode).
When enabled, the character “<” triggers company completion of org blocks.
Use your preferred way to add company-org-block to company-backends.
company-org-block is available on MELPA.
- Install via M-x package-install.
- Require, set edit style, and add company backend:
(require 'company-org-block)
(setq company-org-block-edit-style 'auto) ;; 'auto, 'prompt, or 'inline
(add-hook 'org-mode-hook
(lambda ()
(add-to-list (make-local-variable 'company-backends)
'company-org-block)))
Alternatively, can also install via use-package with something like:
(use-package company-org-block
:ensure t
:custom
(company-org-block-edit-style 'auto) ;; 'auto, 'prompt, or 'inline
:hook ((org-mode . (lambda ()
(setq-local company-backends '(company-org-block))
(company-mode +1)))))
You can configure what happens immediately after inserting a block, you have the option to configure the style via company-org-block-edit-style.
Automatically edit, no prompt. May seem excessive at first, but I’ve become heavily reliant on this style. Give it some time.
Note: This is the default. No need to set company-org-block-edit-style to ‘auto.
Ask me (via yes-or-no-p) after insertion.
(setq company-org-block-edit-style 'prompt)
Prefer no editing after insertion? Set to ‘inline.
(setq company-org-block-edit-style 'inline)
company-org-block draws completion candidates from org-babel-load-languages. The more languages added, the more completions you’ll see.