unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* fill-paragraph with pre and postfix
@ 2014-11-05  3:00 Jacob Gerlach
  2014-11-05 11:34 ` Alexis
  0 siblings, 1 reply; 9+ messages in thread
From: Jacob Gerlach @ 2014-11-05  3:00 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-11-26  8:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05  3:00 fill-paragraph with pre and postfix Jacob Gerlach
2014-11-05 11:34 ` 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

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).