purcell / whitespace-cleanup-mode

In Emacs, intelligently call whitespace-cleanup on save
125 stars 8 forks source link

Handling trailing spaces in markdown #14

Closed To1ne closed 5 years ago

To1ne commented 5 years ago

Cool package Steve!

At the moment I have whitespace-cleanup as a before-save-hook, but sometimes this is annoying with markdown files. From the markdown spec:

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

So my double whitespaces at the end of the line are eaten, when then shouldn't. So I was wondering if this package could handle them smarter.

It's not a real easy problem to tackle, so feel free to reject my feature request.

purcell commented 5 years ago

Note that whitespace-cleanup isn't part of this package -- it's a core Emacs function, which whitespace-cleanup-mode uses.

Whether trailing whitespace is trimmed is controlled by the whitespace-style variable, so I think that for your use case, you could use something like:

(add-hook 'markdown-mode-hook
          (lambda () (setq-local whitespace-style (delq 'trailing whitespace-style))))
To1ne commented 5 years ago

Thanks!!!