;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/fill-incal.el (require 'message) (setq sentence-end-double-space nil) (setq fill-nobreak-predicate '(fill-single-char-nobreak-p fill-single-word-nobreak-p) ) (let ((fill-col 62)) (setq-default fill-column fill-col) (setq message-fill-column fill-col) ) ;; region (defun fill-down (beg end &optional justify) "Fill the current paragraph from the current line down. \nWith mark active, act upon the region instead. \nWith \\[universal-argument], remove full justification." (interactive (if (use-region-p) (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (save-excursion (forward-paragraph) (point) ) current-prefix-arg) )) (if (and justify (equal justify '(4))) ; C-u -> unjustify (canonically-space-region beg end) (fill-region beg end) )) ; no C-u -> fill (defun unfill-region (beg end) "Unfill the region, joining text paragraphs into a single line. \nhttp://emacswiki.org/emacs/unfillregion" (interactive "*r") (let ((fill-column (point-max))) (fill-region beg end) )) ;; buffer (defun fill-buffer () "Fill all paragraphs in the buffer." (interactive) (fill-region (point-min) (point-max)) ) (defun unfill-buffer () "Unfill all paragraphs in the buffer." (interactive) (unfill-region (point-min) (point-max)) ) (provide 'fill-incal)