Function: line-move-partial
line-move-partial is a byte-compiled function defined in simple.el.gz.
Signature
(line-move-partial ARG NOERROR &optional TO-END)
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
;; Returns non-nil if partial move was done.
(defun line-move-partial (arg noerror &optional _to-end)
(if (< arg 0)
;; Move backward (up).
;; If already vscrolled, reduce vscroll
(let ((vs (window-vscroll nil t))
(dlh (default-line-height)))
(when (> vs dlh)
(set-window-vscroll nil (- vs dlh) t)))
;; Move forward (down).
(let* ((lh (window-line-height -1))
(rowh (car lh))
(vpos (nth 1 lh))
(ypos (nth 2 lh))
(rbot (nth 3 lh))
(this-lh (window-line-height))
(this-height (car this-lh))
(this-ypos (nth 2 this-lh))
(dlh (default-line-height))
(wslines (window-screen-lines))
(edges (window-inside-pixel-edges))
(winh (- (nth 3 edges) (nth 1 edges) 1))
py vs last-line)
(if (> (mod wslines 1.0) 0.0)
(setq wslines (round (+ wslines 0.5))))
(when (or (null lh)
(>= rbot dlh)
(<= ypos (- dlh))
(null this-lh)
(<= this-ypos (- dlh)))
(unless lh
(let ((wend (pos-visible-in-window-p t nil t)))
(setq rbot (nth 3 wend)
rowh (nth 4 wend)
vpos (nth 5 wend))))
(unless this-lh
(let ((wstart (pos-visible-in-window-p nil nil t)))
(setq this-ypos (nth 2 wstart)
this-height (nth 4 wstart))))
(setq py
(or (nth 1 this-lh)
(let ((ppos (posn-at-point))
col-row)
(setq col-row (posn-actual-col-row ppos))
(if col-row
(- (cdr col-row) (window-vscroll))
(cdr (posn-col-row ppos))))))
;; VPOS > 0 means the last line is only partially visible.
;; But if the part that is visible is at least as tall as the
;; default font, that means the line is actually fully
;; readable, and something like line-spacing is hidden. So in
;; that case we accept the last line in the window as still
;; visible, and consider the margin as starting one line
;; later.
(if (and vpos (> vpos 0))
(if (and rowh
(>= rowh (default-font-height))
(< rowh dlh))
(setq last-line (min (- wslines scroll-margin) vpos))
(setq last-line (min (- wslines scroll-margin 1) (1- vpos)))))
(cond
;; If last line of window is fully visible, and vscrolling
;; more would make this line invisible, move forward.
((and (or (< (setq vs (window-vscroll nil t)) dlh)
(null this-height)
(<= this-height dlh))
(or (null rbot) (= rbot 0)))
nil)
;; If cursor is not in the bottom scroll margin, and the
;; current line is not too tall, or if there's a continuation
;; line below this one, move forward.
((and (or (null this-height) (<= this-height winh))
vpos
(> vpos 0)
(or (< py last-line)
(display--line-is-continued-p)))
nil)
;; When already vscrolled, we vscroll some more if we can,
;; or clear vscroll and move forward at end of tall image.
((> vs 0)
(when (or (and rbot (> rbot 0))
(and this-height (> this-height dlh)))
(set-window-vscroll nil (+ vs dlh) t)))
;; If cursor just entered the bottom scroll margin, move forward,
;; but also optionally vscroll one line so redisplay won't recenter.
((and vpos
(> vpos 0)
(= py last-line))
;; Don't vscroll if the partially-visible line at window
;; bottom is not too tall (a.k.a. "just one more text
;; line"): in that case, we do want redisplay to behave
;; normally, i.e. recenter or whatever.
;;
;; Note: ROWH + RBOT from the value returned by
;; pos-visible-in-window-p give the total height of the
;; partially-visible glyph row at the end of the window. As
;; we are dealing with floats, we disregard sub-pixel
;; discrepancies between that and DLH.
(if (and rowh rbot (>= (- (+ rowh rbot) winh) 1))
(set-window-vscroll nil dlh t))
(line-move-1 arg noerror)
t)
;; If there are lines above the last line, scroll-up one line.
((and vpos (> vpos 0))
(scroll-up 1)
t)
;; Finally, start vscroll.
(t
(set-window-vscroll nil dlh t)))))))