From 84c3cfad9b2d2c503a798c350b7bd51dd50eb625 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 12 Dec 2017 14:15:09 -0500 Subject: [PATCH] [emacs] Org-mode keyword company completion --- .emacs.d/emacs.org | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.emacs.d/emacs.org b/.emacs.d/emacs.org index 78b0a71..40ce269 100644 --- a/.emacs.d/emacs.org +++ b/.emacs.d/emacs.org @@ -748,6 +748,28 @@ Taken from [[http://pragmaticemacs.com/emacs/wrap-text-in-an-org-mode-block/][Pr ;;bind to key (define-key org-mode-map (kbd "C-<") 'org-begin-template) #+END_SRC +**** Complete keywords with Company +Taken from https://emacs.stackexchange.com/a/30691. + +#+name: packages +#+BEGIN_SRC emacs-lisp + (defun org-keyword-backend (command &optional arg &rest ignored) + (interactive (list 'interactive)) + (cl-case command + (interactive (company-begin-backend 'org-keyword-backend)) + (prefix (and (eq major-mode 'org-mode) + (cons (company-grab-line "^#\\+\\(\\w*\\)" 1) + t))) + (candidates (mapcar #'upcase + (cl-remove-if-not + (lambda (c) (string-prefix-p arg c)) + (pcomplete-completions)))) + (ignore-case t) + (duplicates t))) + + (add-to-list 'company-backends 'org-keyword-backend) + (add-hook 'org-mode-hook 'company-mode) +#+END_SRC **** Exporting ***** LaTeX #+name: packages