Function: pixel-fill-find-fill-point

pixel-fill-find-fill-point is a byte-compiled function defined in pixel-fill.el.gz.

Signature

(pixel-fill-find-fill-point START)

Documentation

Find a place suitable for breaking the current line.

START should be the earliest buffer position that should be considered
(typically the start of the line), and this function will search
backward in the current buffer from the current position.

Source Code

;; Defined in /usr/src/emacs/lisp/textmodes/pixel-fill.el.gz
(defun pixel-fill-find-fill-point (start)
  "Find a place suitable for breaking the current line.
START should be the earliest buffer position that should be considered
(typically the start of the line), and this function will search
backward in the current buffer from the current position."
  (let ((bp (point))
	(end (point))
	failed)
    (while (not
            (or (setq failed (<= (point) start))
		(eq (preceding-char) ?\s)
		(eq (following-char) ?\s)
		(pixel-fill--char-breakable-p (preceding-char))
		(pixel-fill--char-breakable-p (following-char))
		(and (pixel-fill--char-kinsoku-bol-p (preceding-char))
		     (pixel-fill--char-breakable-p (following-char))
		     (not (pixel-fill--char-kinsoku-bol-p (following-char))))
		(pixel-fill--char-kinsoku-eol-p (following-char))
		(bolp)))
      (backward-char 1))
    (if failed
	;; There's no breakable point, so we give it up.
	(let (found)
	  (goto-char bp)
          ;; Don't overflow the window edge, even if
          ;; `pixel-fill-respect-kinsoku' is t.
	  (when pixel-fill-respect-kinsoku
	    (while (setq found (re-search-forward
				"\\(\\c>\\)\\| \\|\\c<\\|\\c|"
				(line-end-position) 'move)))
	    (if (and found
		     (not (match-beginning 1)))
		(goto-char (match-beginning 0)))))
      (or
       (eolp)
       ;; Don't put kinsoku-bol characters at the beginning of a line,
       ;; or kinsoku-eol characters at the end of a line.
       (cond
        ;; Don't overflow the window edge, even if `pixel-fill-respect-kinsoku'
        ;; is t.
	((not pixel-fill-respect-kinsoku)
	 (while (and (not (eq (preceding-char) ?\s))
		     (or (pixel-fill--char-kinsoku-eol-p (preceding-char))
                         (pixel-fill--char-kinsoku-bol-p (following-char))))
	   (backward-char 1))
	 (when (setq failed (<= (point) start))
	   ;; There's no breakable point that doesn't violate kinsoku,
	   ;; so we look for the second best position.
	   (while (and (progn
			 (forward-char 1)
			 (<= (point) end))
		       (progn
			 (setq bp (point))
			 (pixel-fill--char-kinsoku-eol-p (following-char)))))
	   (goto-char bp)))
	((pixel-fill--char-kinsoku-eol-p (preceding-char))
	 ;; Find backward the point where kinsoku-eol characters begin.
	 (let ((count 4))
	   (while
	       (progn
		 (backward-char 1)
		 (and (> (setq count (1- count)) 0)
		      (not (eq (preceding-char) ?\s))
		      (or (pixel-fill--char-kinsoku-eol-p (preceding-char))
			  (pixel-fill--char-kinsoku-bol-p (following-char)))))))
	 (when (setq failed (<= (point) start))
	   ;; There's no breakable point that doesn't violate kinsoku,
	   ;; so we go to the second best position.
	   (if (looking-at "\\(\\c<+\\)\\c<")
	       (goto-char (match-end 1))
	     (forward-char 1))))
	((pixel-fill--char-kinsoku-bol-p (following-char))
	 ;; Find forward the point where kinsoku-bol characters end.
	 (let ((count 4))
	   (while (progn
		    (forward-char 1)
		    (and (>= (setq count (1- count)) 0)
			 (pixel-fill--char-kinsoku-bol-p (following-char))
			 (pixel-fill--char-breakable-p (following-char))))))))
       (when (eq (following-char) ?\s)
	 (forward-char 1))))
    (not failed)))