From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help,gmane.emacs.devel Subject: fill down Date: Sun, 05 Nov 2017 07:13:03 +0100 Message-ID: <86bmkhqmmo.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1509862439 5618 195.159.176.226 (5 Nov 2017 06:13:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Nov 2017 06:13:59 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cc: emacs-devel@gnu.org To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 05 07:13:54 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBEBt-0001B9-RE for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Nov 2017 07:13:53 +0100 Original-Received: from localhost ([::1]:43108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBEC1-0003Qb-57 for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Nov 2017 01:14:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBEBQ-0003QE-P6 for help-gnu-emacs@gnu.org; Sun, 05 Nov 2017 01:13:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBEBN-0005cm-JI for help-gnu-emacs@gnu.org; Sun, 05 Nov 2017 01:13:24 -0500 Original-Received: from [195.159.176.226] (port=54877 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBEBN-0005cM-CC for help-gnu-emacs@gnu.org; Sun, 05 Nov 2017 01:13:21 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eBEBD-0007YJ-FC for help-gnu-emacs@gnu.org; Sun, 05 Nov 2017 07:13:11 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Followup-To: gmane.emacs.help Original-Lines: 43 Original-X-Complaints-To: usenet@blaine.gmane.org Mail-Copies-To: never Cancel-Lock: sha1:wTVtxcBlgjNTn6h4CTvWF8tg7Hc= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116126 gmane.emacs.devel:223464 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