I have a code for changing a paragraph of auto filled text into a paragraph with one sentence per line, where each sentence stretches out in its full length. This code is perfect when composing and analyzing prose.
However, the code has one annoying and unintended side effect if I use it with org-mode. If my text has any starred headlines, these will collapses when I use the code. Then I loose track of where my writing point is.
The code is attached below. I am grateful for any help removing this side effect.
(defun myfun-split-para-at-sentence-ends () "Split current paragraph into lines with one sentence each. Then turn off `auto-fill-mode'." (interactive) (let ((mode major-mode)) (unwind-protect (progn (text-mode) (save-excursion (let ((emacs-lisp-docstring-fill-column t) (fill-column (point-max))) (fill-paragraph)) (let ((bop (progn (backward-paragraph) (point))) (eop (progn (forward-paragraph) (point)))) (goto-char bop) (while (< (point) eop) (forward-sentence) (delete-horizontal-space) (insert "\n"))))) (funcall mode))) (auto-fill-mode -1)) (define-minor-mode split-para-mode "Toggle between a filled paragraph and one split into sentences." nil nil nil (if (not split-para-mode) (myfun-split-para-at-sentence-ends) (auto-fill-mode 1) (fill-paragraph))) (global-set-key "\C-s" 'split-para-mode)