* fill down
@ 2017-11-05 6:13 Emanuel Berg
0 siblings, 0 replies; only message in thread
From: Emanuel Berg @ 2017-11-05 6:13 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: emacs-devel
I just wrote this. Or actually it was a couple
of days ago. The idea with the "down" approach
is so that manual edits after fill above won't
be undone (for example putting together the
last two words in "You owe me 500 SEK" on the
same line). Also with DWIM region and heavy use
of the numeric/prefix/universal argument.
There is more to be added - upcase and
downcase, just whatever you can think of - with
minimal effort or change to the code - just
whatever it is, that should be added...
All comments welcome how to improve it,
for sure!
(defun fill-down (&optional justify)
"Fill the current paragraph from the current line down.\n
With mark active, act upon the region instead.\n
With \\[universal-argument] before invocation, JUSTIFY fully.
With \\[universal-argument] twice, remove full justification. (Or just try to fill it!)
With \\[universal-argument] thrice, center.
With any more \\[universal-argument] than that, the sky is the limit!"
(interactive "P")
(let*((area (if (region-active-p)
`(,(region-beginning) ,(region-end))
`(,(line-beginning-position) ,(save-excursion
(forward-paragraph)
(point)))))
(start (car area))
(end (cadr area)) )
;; C-u C-u -> unjustify
(if (equal justify '(16))
(canonically-space-region start end)
(fill-region start end
;; can't use cl-case here as compares with `elq' - bummer!
(cond ((equal justify '(0)) nil) ; fill
((equal justify '(4)) 'full) ; C-u -> justify
((equal justify '(64)) 'center)) ; C-u C-u C-u -> center
))))
--
underground experts united
http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-05 6:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-05 6:13 fill down Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).