After trying the accepted solution a while back (which ended up not working for me) and then giving up after about 6 months, I went back and found a simple solution.
(defun trigger-org-company-complete ()
"Begins company-complete in org-mode buffer after pressing #+ chars."
(interactive)
(if (string-equal "#" (string (preceding-char)))
(progn
(insert "+")
(company-complete))
(insert "+")))
(eval-after-load 'org '(define-key org-mode-map
(kbd "+") 'trigger-org-company-complete))
While this is certainly hacky, it's been working well for me, and it didn't require doing any complex parsing.
This works by only calling the function when the +
character is entered in an org-mode buffer. Then, trigger-org-company-complete
checks the preceding character, and if it's a #
character, the +
character is inserted and company-complete
is called. If the previous character is not #
, the +
is only inserted, and everything behaves as normal.
You can see the behavior below. When just entering the #
character, nothing happens. When #
precedes a +
, company-complete
is triggered, and when just a +
character is entered, nothing happens.
(I zoomed in a lot, which is why it's distorted)


