aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-04-23 21:55:15 +0000
committerRichard M. Stallman1998-04-23 21:55:15 +0000
commit9fc0913c1018fbfdc0009013b58745de4fa5726d (patch)
tree033f1d954913715e40120733d2ad8d00650a6207
parentf438538138a524421eefdd00a4591037a70c138e (diff)
downloademacs-9fc0913c1018fbfdc0009013b58745de4fa5726d.tar.gz
emacs-9fc0913c1018fbfdc0009013b58745de4fa5726d.zip
(justify-current-line): Use new algorithm to apportion the spaces to be added.
-rw-r--r--lisp/textmodes/fill.el41
1 files changed, 24 insertions, 17 deletions
diff --git a/lisp/textmodes/fill.el b/lisp/textmodes/fill.el
index 4320dc8a739..9a96711ba76 100644
--- a/lisp/textmodes/fill.el
+++ b/lisp/textmodes/fill.el
@@ -793,7 +793,13 @@ otherwise it is made canonical."
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)
@@ -874,23 +880,24 @@ otherwise it is made canonical."
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)))