/[emacs]/emacs/lisp/textmodes/fill.el
ViewVC logotype

Diff of /emacs/lisp/textmodes/fill.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.155 by lektu, Tue Feb 4 13:30:44 2003 UTC revision 1.156 by monnier, Wed Apr 2 23:04:09 2003 UTC
# Line 627  space does not end a sentence, so don't Line 627  space does not end a sentence, so don't
627                     (string-match "\\`[ \t]*\\'" fill-prefix))                     (string-match "\\`[ \t]*\\'" fill-prefix))
628            (setq fill-prefix nil)))            (setq fill-prefix nil)))
629    
630        (save-restriction        (goto-char from)
631          (goto-char from)        (beginning-of-line)
         (beginning-of-line)  
632    
633          (if (not justify)         ; filling disabled: just check indentation        (if (not justify)   ; filling disabled: just check indentation
634              (progn            (progn
635                (goto-char from)              (goto-char from)
               (while (< (point) to)  
                 (if (and (not (eolp))  
                          (< (current-indentation) (current-left-margin)))  
                     (fill-indent-to-left-margin))  
                 (forward-line 1)))  
   
           (if use-hard-newlines  
               (remove-list-of-text-properties from to '(hard)))  
           ;; Make sure first line is indented (at least) to left margin...  
           (if (or (memq justify '(right center))  
                   (< (current-indentation) (current-left-margin)))  
               (fill-indent-to-left-margin))  
           ;; Delete the fill-prefix from every line.  
           (fill-delete-prefix from to fill-prefix)  
           (setq from (point))  
   
           ;; FROM, and point, are now before the text to fill,  
           ;; but after any fill prefix on the first line.  
   
           (fill-delete-newlines from to justify nosqueeze squeeze-after)  
   
           ;; This is the actual filling loop.  
           (goto-char from)  
           (let (linebeg)  
636              (while (< (point) to)              (while (< (point) to)
637                (setq linebeg (point))                (if (and (not (eolp))
638                (move-to-column (1+ (current-fill-column)))                         (< (current-indentation) (current-left-margin)))
639                (if (when (< (point) to)                    (fill-indent-to-left-margin))
640                      ;; Find the position where we'll break the line.                (forward-line 1)))
641                      (fill-move-to-break-point linebeg)  
642                      ;; Check again to see if we got to the end of          (if use-hard-newlines
643                      ;; the paragraph.              (remove-list-of-text-properties from to '(hard)))
644                      (skip-chars-forward " \t")          ;; Make sure first line is indented (at least) to left margin...
645                      (< (point) to))          (if (or (memq justify '(right center))
646                    ;; Found a place to cut.                  (< (current-indentation) (current-left-margin)))
647                    (progn              (fill-indent-to-left-margin))
648                      (fill-newline)          ;; Delete the fill-prefix from every line.
649                      (when justify          (fill-delete-prefix from to fill-prefix)
650                        ;; Justify the line just ended, if desired.          (setq from (point))
651                        (save-excursion  
652                          (forward-line -1)          ;; FROM, and point, are now before the text to fill,
653                          (justify-current-line justify nil t))))          ;; but after any fill prefix on the first line.
654    
655                  (goto-char to)          (fill-delete-newlines from to justify nosqueeze squeeze-after)
656                  (if (and (eolp) (or (not nosqueeze) justify))  
657                      (delete-horizontal-space))          ;; This is the actual filling loop.
658                  ;; Justify this last line, if desired.          (goto-char from)
659                  (if justify (justify-current-line justify t t))))))          (let (linebeg)
660          ;; Leave point after final newline.            (while (< (point) to)
661          (goto-char to))              (setq linebeg (point))
662        (unless (eobp)              (move-to-column (1+ (current-fill-column)))
663          (forward-char 1))              (if (when (< (point) to)
664                      ;; Find the position where we'll break the line.
665                      (fill-move-to-break-point linebeg)
666                      ;; Check again to see if we got to the end of
667                      ;; the paragraph.
668                      (skip-chars-forward " \t")
669                      (< (point) to))
670                    ;; Found a place to cut.
671                    (progn
672                      (fill-newline)
673                      (when justify
674                        ;; Justify the line just ended, if desired.
675                        (save-excursion
676                          (forward-line -1)
677                          (justify-current-line justify nil t))))
678    
679                  (goto-char to)
680                  ;; Justify this last line, if desired.
681                  (if justify (justify-current-line justify t t))))))
682          ;; Leave point after final newline.
683          (goto-char to)
684          (unless (eobp) (forward-char 1))
685        ;; Return the fill-prefix we used        ;; Return the fill-prefix we used
686        fill-prefix)))        fill-prefix)))
687    
# Line 748  If `fill-paragraph-function' is nil, ret Line 744  If `fill-paragraph-function' is nil, ret
744            (if (not (zerop (forward-paragraph)))            (if (not (zerop (forward-paragraph)))
745                ;; There's no paragraph at or after point: give up.                ;; There's no paragraph at or after point: give up.
746                (setq fill-pfx "")                (setq fill-pfx "")
             (or (bolp) (newline 1))  
747              (let ((end (point))              (let ((end (point))
748                    (beg (progn (backward-paragraph) (point))))                    (beg (progn (backward-paragraph) (point))))
749                (goto-char before)                (goto-char before)
# Line 828  can take care of filling.  JUSTIFY is us Line 823  can take care of filling.  JUSTIFY is us
823                     (paragraph-ignore-fill-prefix nil)                     (paragraph-ignore-fill-prefix nil)
824                     (fill-prefix comment-fill-prefix)                     (fill-prefix comment-fill-prefix)
825                     (after-line (if has-code-and-comment                     (after-line (if has-code-and-comment
826                                     (line-beginning-position 2)))                                     (line-beginning-position 2))))
827                     )                (setq end (progn (forward-paragraph) (point)))
               (setq end (progn  
                           (forward-paragraph)  
                           (or (bolp) (newline 1))  
                           (point)))  
828                ;; If this comment starts on a line with code,                ;; If this comment starts on a line with code,
829                ;; include that line in the filling.                ;; include that line in the filling.
830                (setq beg (progn (backward-paragraph)                (setq beg (progn (backward-paragraph)
831                                 (if (eq (point) after-line)                                 (if (eq (point) after-line)
832                                     (forward-line -1))                                     (forward-line -1))
833                                 (point))))                                 (point)))))
             )  
834    
835            ;; Find the fill-prefix to use.            ;; Find the fill-prefix to use.
836            (cond            (cond

Legend:
Removed from v.1.155  
changed lines
  Added in v.1.156

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26