Mercurial > emacs
comparison lisp/textmodes/fill.el @ 21727:88afa87063ff
(justify-current-line): Use new algorithm to apportion the spaces to be added.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 23 Apr 1998 21:55:15 +0000 |
parents | a9e9f674c9c9 |
children | 74d1c031f824 |
comparison
equal
deleted
inserted
replaced
21726:1771dc61b028 | 21727:88afa87063ff |
---|---|
791 fp-end ; point at end of fill prefix | 791 fp-end ; point at end of fill prefix |
792 beg ; point at beginning of line's text | 792 beg ; point at beginning of line's text |
793 end ; point at end of line's text | 793 end ; point at end of line's text |
794 indent ; column of `beg' | 794 indent ; column of `beg' |
795 endcol ; column of `end' | 795 endcol ; column of `end' |
796 ncols) ; new indent point or offset | 796 ncols ; new indent point or offset |
797 (nspaces 0) ; number of spaces between words | |
798 ; in line (not space characters) | |
799 fracspace ; fractional amount of space to be | |
800 ; added between each words | |
801 (curr-fracspace 0) ; current fractional space amount | |
802 count) | |
797 (end-of-line) | 803 (end-of-line) |
798 ;; Check if this is the last line of the paragraph. | 804 ;; Check if this is the last line of the paragraph. |
799 (if (and use-hard-newlines (null eop) | 805 (if (and use-hard-newlines (null eop) |
800 (get-text-property (point) 'hard)) | 806 (get-text-property (point) 'hard)) |
801 (setq eop t)) | 807 (setq eop t)) |
872 (save-restriction | 878 (save-restriction |
873 (narrow-to-region beg end) | 879 (narrow-to-region beg end) |
874 (or nosqueeze | 880 (or nosqueeze |
875 (canonically-space-region beg end)) | 881 (canonically-space-region beg end)) |
876 (goto-char (point-max)) | 882 (goto-char (point-max)) |
883 ;; count word spaces in line | |
884 (while (search-backward " " nil t) | |
885 (setq nspaces (1+ nspaces)) | |
886 (skip-chars-backward " ")) | |
877 (setq ncols (- fc endcol)) | 887 (setq ncols (- fc endcol)) |
878 ;; Ncols is number of additional spaces needed | 888 ;; Ncols is number of additional space chars needed |
879 (if (> ncols 0) | 889 (if (and (> ncols 0) (> nspaces 0) (not eop)) |
880 (if (and (not eop) | 890 (progn |
881 (search-backward " " nil t)) | 891 (setq curr-fracspace (+ ncols (/ (1+ nspaces) 2)) |
882 (while (> ncols 0) | 892 count nspaces) |
883 (let ((nmove (+ 3 (random 3)))) | 893 (while (> count 0) |
884 (while (> nmove 0) | 894 (skip-chars-forward " ") |
885 (or (search-backward " " nil t) | 895 (insert-and-inherit |
886 (progn | 896 (make-string (/ curr-fracspace nspaces) ?\ )) |
887 (goto-char (point-max)) | 897 (search-forward " " nil t) |
888 (search-backward " "))) | 898 (setq count (1- count) |
889 (skip-chars-backward " ") | 899 curr-fracspace |
890 (setq nmove (1- nmove)))) | 900 (+ (% curr-fracspace nspaces) ncols))))))) |
891 (insert-and-inherit " ") | |
892 (skip-chars-backward " ") | |
893 (setq ncols (1- ncols))))))) | |
894 (t (error "Unknown justification value")))) | 901 (t (error "Unknown justification value")))) |
895 (goto-char pos) | 902 (goto-char pos) |
896 (move-marker pos nil))) | 903 (move-marker pos nil))) |
897 nil) | 904 nil) |
898 | 905 |