help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Word wrap


From: Bingham, Jay
Subject: RE: Word wrap
Date: Tue, 29 Jan 2002 14:21:30 -0600

If you had just said what you wanted in the first place everyone would
have been a lot cooler about it. :)
There is another function that may be more like what you want:
.fill-region-as-paragraph

Actually I do have a couple of functions that I wrote that you might
find useful.  They both use fill-region-as-paragraph with a non-nil
justify argument, which lines up the right margin of the region being
filled.  If you don't want that just change third argument in the
function call from 0 to nil.  Here are the descriptions of them.

;;      fill-just-region - 
;;              A function that fill-justifies a region leaving
everything 
;;              on the line to the left of the start of the region
untouched.
;;      fill-just-this-para - 
;;              A function that fill-justifies the paragraph following
the 
;;              current cursor position, leaving everything on the line
to 
;;              the left of the cursor untouched.

Here are the actual functions:

;;;======<Interactive
Function>===============================================
;;
;; Function: fill-just-region
;;   Fill justify the region leaving everything on the line to the left
of the
;;  start of the region untouched.
;;
;; Psuedo code:
;;  goto to the start of the region
;;  when the region does not start in column 0 insert a new line and pad
to
;;   the starting column
;;  set the start of the region to fill
;;  set the end of the region to fill
;;  goto the end of the region
;;  fill the region
;;  delete the new line and pad if it was added
;;  recenter the line
;;
(defun fill-just-region (beg end)
  "Fill justify the region leaving everything left of the start
untouched.
Fill justify the region leaving everything on the line to the left of
the
start of the region untouched."
  (interactive "r")
  (let ((m1)
        (m2)
        (col))
    (goto-char beg)
    (when (> (setq col (current-column)) 0)
      (insert "\n")
      (insert-char ?  col))
    (setq m1 (point))
    (setq m2 (+ end col 1))
    (goto-char m2)
    (fill-region-as-paragraph m1 m2 0 nil)
    (delete-region beg m1)
    (recenter)))


;;;======<Interactive
Function>===============================================
;;
;; Function: fill-just-this-para
;;   Fill justify the paragraph following the current cursor position,
;;   leaving everything on the line to the left of the cursor untouched.
;;
;; Psuedo code:
;;  when the cursor is not column 0 insert a new line and pad to the
starting
;;   column
;;  set the start of the region to fill
;;  find the end of the paragraph
;;  set the end of the region to fill
;;  fill the region
;;  delete the new line and pad if it was added
;;  recenter the line
;;
(defun fill-just-this-para ()
  "Fill justify this paragraph leaving everything left of the cursor
untouched.
Fill justify the paragraph following the current cursor position leaving
everything on the line to the left of the cursor untouched."
  (interactive)
  (let ((beg (point))
        m1
        m2
        col)
    (when (> (setq col (current-column)) 0)
      (insert "\n")
      (insert-char ?  col))
    (setq m1 (point))
    (setq m2 (- (search-forward "\n\n" nil 'move) 2))
    (fill-region-as-paragraph m1 m2 0 nil)
    (delete-region beg m1)
    (recenter)))


Good luck
J_)
C_)ingham
.    COMPAQ NonStop Integrity Systems
.    Austin, TX
. Language is the apparel in which your thoughts parade in public.
. Never clothe them in vulgar and shoddy attire. -Dr. George W. Crane-

 -----Original Message-----
From:   Peter S Galbraith [mailto:address@hidden 
Sent:   Tuesday, 29 January, 2002 1:55 p
To:     address@hidden
Cc:     address@hidden
Subject:        Re: Word wrap 

> I am editing content in an HTML file (or an email, for that matter).
> I decide to go back and change around a paragraph, add some stuff,
take
> out stuff, whatever. 

>                    then I wind up with ragged lines

> 
>      > If I type email, I use line breaks.
> 
> What if you are writing a longer email, and want to go back and change
> stuff (see above)?  Lines become ragged and if you change something
> early in a paragraph, you have to correct more carriage returns.

Sounds like you want to fill-paragraph, bound to M-q.  Of course, it
helps if the major-mode you are using set it up appropriately.

Or am I missing something.

_______________________________________________
Help-gnu-emacs mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/help-gnu-emacs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]