help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying newlines as whitespaces on a region.


From: Daniel P. Gomez
Subject: Displaying newlines as whitespaces on a region.
Date: Wed, 27 Mar 2019 00:35:44 +0100
User-agent: mu4e 1.1.0; emacs 26.1

Dear Emacs friends,

I use Org mode for prose and keep my files under version control (VC). To keep VC diffs simple and meaningful, I would like to write a single sentence in each line, as shown in the following example (between dashes):

---
* A heading

This is an example.
In the example each sentence is in a newline.
Sentences within a paragraph look ugly when separated by newlines, though.

Two newlines represent a paragraph, just as in LaTeX.
---

Although writing one sentence per line is good for VC, it is hardly convenient for reading and writing, because this is not how people are used to prose, generally.

Currently the question arose whether it'd be possible to have Emacs display newline characters as whitespaces. A naive solution could be achieved by tweaking the variable =whitespace-display-mappings= and activating =whitespace-newline-mode=, which is a part of Emacs. Unfortunately, however, this solution has a series of drawbacks. First, it is no longer possible to visually differentiate between paragraphs, as they'd be displayed as sentences separated by two whitespaces. Second, headings and org src blocks get clumped.

Would anyone know how to have =whitespace-newline-mode= only substitute newlines for whitespaces in sentences outside of org blocks, tables and headings and only for sentences followed by other sentences (effectively allowing for paragraph breaks)? More generally, would anyone know of a solution to this problem even if using other packages other than whitespace.el?

Ideally the example above would be displayed in the buffer as:

---
* A heading

This is an example. In the example each sentence is in a newline. Sentences within a paragraph look ugly when separated by newlines, though.

Two newlines represent a paragraph, just as in LaTeX.
---

Thank you.

Yours,

Daniel Gomez



reply via email to

[Prev in Thread] Current Thread [Next in Thread]