From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jacob Gerlach Newsgroups: gmane.emacs.help Subject: fill-paragraph with pre and postfix Date: Tue, 4 Nov 2014 22:00:14 -0500 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1415156510 27539 80.91.229.3 (5 Nov 2014 03:01:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 5 Nov 2014 03:01:50 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 05 04:01:43 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xlqqt-0005bz-5h for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Nov 2014 04:01:43 +0100 Original-Received: from localhost ([::1]:44061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xlqqs-0004B6-So for geh-help-gnu-emacs@m.gmane.org; Tue, 04 Nov 2014 22:01:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlqpV-0002qT-80 for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 22:00:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlqpT-0003vn-96 for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 22:00:17 -0500 Original-Received: from mail-qc0-x22b.google.com ([2607:f8b0:400d:c01::22b]:48032) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlqpT-0003vh-4Y for help-gnu-emacs@gnu.org; Tue, 04 Nov 2014 22:00:15 -0500 Original-Received: by mail-qc0-f171.google.com with SMTP id m20so12253340qcx.30 for ; Tue, 04 Nov 2014 19:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=kusq5p4RAQTDX56BiFY+ozWQaDIqMzdEIq2zc4+j4Ag=; b=Fp3UzJfllMzZ6PpQb+klmBPSRunr2g4OSzwwH9PNSzgOx7jBlgkFKnEsGoW8aHLxO1 WkBx6xmv2a9yOPws8zxMySGBlBPlojCerA94DUwE/YSTNgIHqKHoVTMUmqnCk0zupeYZ Btv6d28oJm5UrZz77VIYfJhKI5HI6Obsvh2IT0MfVM7QfNKUQy7UbauMtO7MR1Pmcy+C zmwCWhoQu9VVTvWjBWhq4ETfe7QyUKXh/J3o9YzDlIVk6c0E97nTsBxhDbcHMRCyvrG6 B2MQiFW+LRw2YJCJ2oJV8pSujzDbUgKIzSOoJ4yklI4TtRK6YNWrQSP6edKJMhE1okQK zl5Q== X-Received: by 10.140.84.177 with SMTP id l46mr77414739qgd.100.1415156414439; Tue, 04 Nov 2014 19:00:14 -0800 (PST) Original-Received: by 10.229.36.7 with HTTP; Tue, 4 Nov 2014 19:00:14 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::22b X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:100755 Archived-At: Hi list, A project I'm working on uses a handling function for some command line documentation: blk(" I want to format my documentation like this. "); In order to match the convention for our project, it should include the two leading spaces and be filled with spaces out to column 70. The only built in functionality I could find to help with this is "fill-prefix". Besides not handling the end of the line, I had some trouble where fill-paragrah didn't seem to actually fill at fill-column like I expected when I defined a custom prefix. So my first question is - have I missed a built in capability to do this? (Alternatively, is there a library in the repos?) Assuming the answer is no, I set out to write a function that would take a paragraph of text, fill the text, and wrap it in the function, but I ran in to some difficulties: (defun my-fill-and-wrap (start end) "Fills region and wrap in blk( \"...\");" (interactive "r") (let ((fill-column 70) (fill-prefix " blk( \"")) (goto-char start) (fill-paragraph) (save-excursion (while (< (point) end) (end-of-line) (insert-char " " (- 70 (- (line-end-position) (line-beginning-position)))) (insert "\");") (forward-line)))))) Executing this function seems to do nothing. No filling, or any change to the text for that matter. Any pointers on what I'm doing wrong would be greatly appreciated. Jake