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

Indented tables get wrapped by fill functions

Open saf-dmitry opened this issue 7 years ago • 1 comments

Indented pipe tables like this

    | Right | Left | Center | Default |
    |------:|:-----|:------:|---------|
    |    12 | 12   | 12     | 12      |
    |   123 | 123  | 123    | 123     |
    |     1 | 1    | 1      | 1       |

or GFM tables like this

    Right | Left | Center | Default
    -----:|:-----|:------:|--------
       12 | 12   | 12     | 12     
      123 | 123  | 123    | 123    
        1 | 1    | 1      | 1      

get wrapped by paragraph filling commands and functions like M-q (fill-paragraph).

Expected Behavior

Paragraph filling commands should ignore table lines.

Actual Behavior

Paragraph filling commands work on table lines like on ordinary text.

Suggested Solution

Add markdown-table-at-point-p predicate function to fill-nobreak-predicate hook:

(add-hook 'fill-nobreak-predicate
          #'markdown-table-at-point-p nil t)

Software Versions

  • Markdown Mode: From Git on 2018-01-10
  • Emacs: 24.3
  • OS: Ubuntu Linux 14.4

saf-dmitry avatar Feb 05 '18 09:02 saf-dmitry

I also have this problem with tables and fill.

I'm using doom emacs and tried adding the following to my config.el, which didn't seem to work:

(setq-hook! 'markdown-mode-hook
  fill-nobreak-predicate (cons #'markdown-table-at-point-p nil t
                               fill-nobreak-predicate))

vancleve avatar Aug 19 '22 19:08 vancleve