2

I don't seem to be getting the completion behavior in Org Mode that the manual says I should get (or see (info "(org)Completion")). It says that M-<TAB> will offer various Org specific completions in certain locations, for example:

• At the beginning of a headline, complete TODO keywords.

• After \, complete TeX symbols supported by the exporter.

• After *, complete headlines in the current buffer.

And a few other things like that. And the manual then says that "When point is anywhere else, complete dictionary words using Ispell."

OK, so here is what I actually get:

  • Prior to Org 9.2 (I tried with 9.1.9), both M-<TAB> and C-M-i call pcomplete which does everything the manual says except the last thing about using Ispell!

  • On Org 9.2, M-<TAB> calls pcomplete which does everything the manual says except the last thing about Ispell; and C-M-i calls ispell-complete-word that, obviously, just does the Ispell thing.

Weirdly, I cannot figure out where C-M-i is being bound to ispell-complete-word (according to C-h k the binding is in org-mode-map, but the Org Mode source files don't seem to mention ispell-complete-word at all).

I've tested both Org 9.1.9 and Org 9.2 starting from emacs -Q, so this shouldn't be a problem with my configuration.

  1. Is the manual just wrong about the behavior of completion? In which case I should file a bug, I guess.

  2. The behavior described in the manual sounds pretty sweet! How do I get it? That is, a single keybinding to do the Org specific completions and if none are possible, then use Ispell.

  3. Just out of curiosity: how the hell is Org Mode 9.2 binding C-M-i to ispell-complete-word and how could I have discovered where it happens?

  • 1
    I was also fighting the same problem yesterday. It used to work for me, but no longer does. I think C-M-i is a global ispell binding (but I could not find where this is done either), which used to be overridden by the local map in Org mode. Curiously, in the Org mode source for v 9.2, you will find the binding for M-<TAB> and ESC <TAB>, but not for C-M-i. For the time being, I bound it manually to pcomplete in org-mode-map and it seems to work (except for calling ispell "anywhere else"). – gusbrs Jan 19 at 15:22
  • 2
    Regarding, 3. C-M-i is bound to ispell-complete-word in the text-mode-map here. outline-mode is derived from text-mode and org-mode from outline-mode. As for 1, I think it's a bug, as you say. 2 would indeed be cool. – aplaice Jan 21 at 12:19
  • 1
    Thanks for figuring out 3, @aplaice! If you type C-h k C-M-i in an Org Mode buffer, the help that pops out says the binding is found in org-mode-map, which you've taught me to not to take too literally. :) – Omar Jan 21 at 16:06
  • 2
    Actually, strictly speaking it is found in org-mode-map. :/ (If you inspect the variable org-mode-map you'll find it there...) Unfortunately, as you note, the help for C-M-i doesn't tell you that it was "inherited" from text-mode (I'm not sure if Emacs explicitly tracks this info); neither does the help for org-mode-map tell you that some of its binding were inherited from elsewhere. Only once you get to the help buffer for org-mode itself (linked to from org-mode-map) do you find out that outline-mode is org-mode's parent mode (and ditto for outline-mode -> text-mode). – aplaice Jan 21 at 17:25
2

Not exactly sure how the change of behaviour was introduced, but it should be fixed as of today: https://code.orgmode.org/bzg/org-mode/commit/5fe9e6cbeaea12c020eeb495223ce359825121b8

  • 1
    Just to be clear: that change is not supposed to make completion behave as described in the manual, it is just intended to make completion behave as it did prior to 9.2, right? – Omar Jan 29 at 21:05
  • 1
    @Omar That's what I take from the discussion in the Org mailing list (lists.gnu.org/archive/html/emacs-orgmode/2019-01/msg00395.html), even though this question was linked there. – gusbrs Jan 29 at 21:28
  • Can you add information on how to use these changes right now? – DoMiNeLa10 Jan 29 at 23:14
  • @DoMiNeLa10 I use this in my init file, it will be obsolete once a new version of org-plus-contrib is published (should be next week). (eval-after-load 'org '(define-key org-mode-map (kbd "M-TAB") #'pcomplete)) – johannes Jan 30 at 2:30
  • @Omar Right, the fallback completion is not happening still, this should be fixed - or the documentation instead – johannes Jan 30 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.