Idiomdrottning’s homepage

Hardening newlines

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)
    (fn (if (any empty? (list (car x) (scadr x)))
          (print (car x))
          (print (car x) "  ")))
    ((over (strse x " +$" "")) (read-lines))))

use-hard-newlines mode

Here’s a function to harden all newlines in the region:

(defun harden-region (start end)
  (interactive "r")
  (when use-hard-newlines
      (goto-char start)
      (while (< (point) (min (point-max) end))
         (- (point) 1) (point))))))