(repos-count-screen-lines): Narrow without changing point-min

* lisp/reposition.el (repos-count-screen-lines): Narrow without
changing point-min.  It wasn't necessary for vertical-motion to
work, and it had some adverse effects on how font-lock rules were
applied
(https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg00522.html).
This can also be an alternative fix for bug#38049.
This commit is contained in:
Dmitry Gutov 2019-11-14 23:41:07 +02:00
parent c455e609bd
commit 6a2a371c28

View file

@ -170,12 +170,13 @@ first comment line visible (if point is in a comment)."
;;; Auxiliary functions
;; Return number of screen lines between START and END.
(defun repos-count-screen-lines (start end)
(save-excursion
(save-restriction
(narrow-to-region start end)
(goto-char (point-min))
(narrow-to-region (point-min) end)
(goto-char start)
(vertical-motion (- (point-max) (point-min))))))
;; Return number of screen lines between START and END; returns a negative