all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jacob Gerlach <jacobgerlach@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: fill-paragraph with pre and postfix
Date: Tue, 4 Nov 2014 22:00:14 -0500	[thread overview]
Message-ID: <CAA6UvuF=bGVcBgrko=OC4+L-+varqNcef4_rZvYZvr9mVZ-JXQ@mail.gmail.com> (raw)

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


             reply	other threads:[~2014-11-05  3:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-05  3:00 Jacob Gerlach [this message]
2014-11-05 11:34 ` fill-paragraph with pre and postfix Alexis
     [not found]   ` <CAA6UvuGBeVzLqqvzY5E8DX7kuMtRiJBuP6-AORsrjPR1uuxTtg@mail.gmail.com>
2014-11-05 12:18     ` Jacob Gerlach
2014-11-06  3:45       ` Alexis
2014-11-10 15:24         ` Jacob Gerlach
2014-11-11  0:19           ` Alexis
     [not found]             ` <CAA6UvuEQYgVUkgWD_MkU_mnjYVt6PSXA72RSe9S2YOJmxnNOUg@mail.gmail.com>
2014-11-11  8:26               ` Alexis
2014-11-24 19:26                 ` Jacob Gerlach
2014-11-26  8:48                   ` Alexis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAA6UvuF=bGVcBgrko=OC4+L-+varqNcef4_rZvYZvr9mVZ-JXQ@mail.gmail.com' \
    --to=jacobgerlach@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.