/company-org-block

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

👉 Support this work via GitHub Sponsors

company-org-block

Buy me a coffee ☕

Insert Emacs org blocks with completion (via company mode).

When enabled, the character “<” triggers company completion of org blocks.

hello-company-org-block.gif

Install

Use your preferred way to add company-org-block to company-backends.

MELPA

company-org-block is available on MELPA.

https://melpa.org/packages/company-org-block-badge.svg

  1. Install via M-x package-install.
  2. 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)))

use-package

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)))))

Block edit style

You can configure what happens immediately after inserting a block, you have the option to configure the style via company-org-block-edit-style.

Auto (default)

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.

automatic.gif

Prompt

Ask me (via yes-or-no-p) after insertion.

(setq company-org-block-edit-style 'prompt)

prompted.gif

No edit

noedit.gif

Prefer no editing after insertion? Set to ‘inline.

(setq company-org-block-edit-style 'inline)

Supported languages

company-org-block draws completion candidates from org-babel-load-languages. The more languages added, the more completions you’ll see.

Support this work

👉 Support my work via GitHub Sponsors