markdown-mode icon indicating copy to clipboard operation
markdown-mode copied to clipboard

Can't use TAB to do completion via tab-always-indent set to complete

Open hmelman opened this issue 3 years ago • 0 comments

I'm using corfu and cape which isn't that important other than I'm using completion-at-point to do spell checking in a markdown buffer. M-C-i is bound to completion-at-point and works fine. But I also have tab-always-indent set to complete because I like TAB to do completion as well as indenting.

In markdown-mode TAB is bound to markdown-cycle which calls indent-for-tab-command which says it checks tab-always-indent. But markdown-indent-function is set to the standard markdown-indent-line and it doesn't seem to play well when tab-always-indent is set to complete. I'm not sure why, it seem that it has to do with never returning noindent.

I'd like TAB to indent if at the beginning of a line or before any non-whitespace character, otherwise I'd like it to do completion, particularly in a list item. This isn't a correct fix but it does do what I want, I've changed the end of markdown-cycle to be:

   ;; Otherwise, indent as appropriate
   (t
    (if (or (bolp) (looking-back "^[ \t]*" 16))
        (indent-for-tab-command)
      (completion-at-point)))))

I tried following the markdown-cycle and markdown-indent-line code but got a little lost.

markdown-mode 2.6-dev in the macport of Emacs 28.1 on macOS 12.5

hmelman avatar Jul 30 '22 04:07 hmelman