Sometimes I just want all newlines in a region to become hardened, for example when writing code or poetry.
I have this brev snippet that I run with shell-command-on-region
:
(make-sloppy-tree-accessor scadr)
(define (poetry-md)
(pair-fold
(fn (if (any empty? (list (car x) (scadr x)))
(print (car x))
(print (car x) " ")))
(void)
((over (strse x " +$" "")) (read-lines))))
use-hard-newlines
modeHere’s a function to harden all newlines in the region:
(defun harden-region (start end)
(interactive "r")
(when use-hard-newlines
(save-excursion
(goto-char start)
(while (< (point) (min (point-max) end))
(end-of-line)
(forward-char)
(set-hard-newline-properties
(- (point) 1) (point))))))