[emacs] Org-mode keyword company completion

This commit is contained in:
Correl Roush 2017-12-12 14:15:09 -05:00
parent c76e77e47e
commit 84c3cfad9b

View file

@ -748,6 +748,28 @@ Taken from [[http://pragmaticemacs.com/emacs/wrap-text-in-an-org-mode-block/][Pr
;;bind to key ;;bind to key
(define-key org-mode-map (kbd "C-<") 'org-begin-template) (define-key org-mode-map (kbd "C-<") 'org-begin-template)
#+END_SRC #+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 **** Exporting
***** LaTeX ***** LaTeX
#+name: packages #+name: packages