aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2013-07-08 20:30:50 +0300
committerEli Zaretskii2013-07-08 20:30:50 +0300
commitab49d60b09ee8f011a85bac29dc6e24a98569b54 (patch)
tree8f30fd07f5bc2f570032c17973c587f74cd25bef
parente4b1e5afb4793638ca103cc1ba70c83a8a756e54 (diff)
downloademacs-ab49d60b09ee8f011a85bac29dc6e24a98569b54.tar.gz
emacs-ab49d60b09ee8f011a85bac29dc6e24a98569b54.zip
Improve scrolling when line-spacing is non-nil.
lisp/simple.el (line-move-partial, line-move): Account for line-spacing.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/simple.el65
2 files changed, 55 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c34cab68426..a04079ced24 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12013-07-08 Eli Zaretskii <eliz@gnu.org>
2
3 * simple.el (line-move-partial, line-move): Account for
4 line-spacing.
5
12013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org> 62013-07-08 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 7
3 * net/shr.el (shr-map): Reinstate the `u' key binding, since it's 8 * net/shr.el (shr-map): Reinstate the `u' key binding, since it's
diff --git a/lisp/simple.el b/lisp/simple.el
index 69c3926f091..1baf0eb6d4e 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4764,15 +4764,27 @@ The value is a floating-point number."
4764 (this-height (nth 0 this-lh)) 4764 (this-height (nth 0 this-lh))
4765 (this-ypos (nth 2 this-lh)) 4765 (this-ypos (nth 2 this-lh))
4766 (dfh (default-font-height)) 4766 (dfh (default-font-height))
4767 py vs) 4767 (lsp (if (display-graphic-p)
4768 (or line-spacing
4769 (default-value 'line-spacing)
4770 (frame-parameter nil 'line-spacing)
4771 0)
4772 0))
4773 py vs rowh dlh)
4774 (if (floatp lsp)
4775 (setq lsp (* dfh lsp)))
4776 ;; Default height of a text line, accounting for the default
4777 ;; face's font and line-spacing, if any.
4778 (setq dlh (+ dfh lsp))
4768 (when (or (null lh) 4779 (when (or (null lh)
4769 (>= rbot dfh) 4780 (>= rbot dlh)
4770 (<= ypos (- dfh)) 4781 (<= ypos (- dlh))
4771 (null this-lh) 4782 (null this-lh)
4772 (<= this-ypos (- dfh))) 4783 (<= this-ypos (- dlh)))
4773 (unless lh 4784 (unless lh
4774 (let ((wend (pos-visible-in-window-p t nil t))) 4785 (let ((wend (pos-visible-in-window-p t nil t)))
4775 (setq rbot (nth 3 wend) 4786 (setq rbot (nth 3 wend)
4787 rowh (nth 4 wend)
4776 vpos (nth 5 wend)))) 4788 vpos (nth 5 wend))))
4777 (unless this-lh 4789 (unless this-lh
4778 (let ((wstart (pos-visible-in-window-p nil nil t))) 4790 (let ((wstart (pos-visible-in-window-p nil nil t)))
@@ -4789,14 +4801,14 @@ The value is a floating-point number."
4789 (cond 4801 (cond
4790 ;; If last line of window is fully visible, and vscrolling 4802 ;; If last line of window is fully visible, and vscrolling
4791 ;; more would make this line invisible, move forward. 4803 ;; more would make this line invisible, move forward.
4792 ((and (or (< (setq vs (window-vscroll nil t)) dfh) 4804 ((and (or (< (setq vs (window-vscroll nil t)) dlh)
4793 (null this-height) 4805 (null this-height)
4794 (<= this-height dfh)) 4806 (<= this-height dlh))
4795 (or (null rbot) (= rbot 0))) 4807 (or (null rbot) (= rbot 0)))
4796 nil) 4808 nil)
4797 ;; If cursor is not in the bottom scroll margin, and the 4809 ;; If cursor is not in the bottom scroll margin, and the
4798 ;; current line is is not too tall, move forward. 4810 ;; current line is is not too tall, move forward.
4799 ((and (or (null this-height) (<= this-height dfh)) 4811 ((and (or (null this-height) (<= this-height dlh))
4800 vpos 4812 vpos
4801 (> vpos 0) 4813 (> vpos 0)
4802 (< py 4814 (< py
@@ -4806,15 +4818,26 @@ The value is a floating-point number."
4806 ;; or clear vscroll and move forward at end of tall image. 4818 ;; or clear vscroll and move forward at end of tall image.
4807 ((> vs 0) 4819 ((> vs 0)
4808 (when (or (and rbot (> rbot 0)) 4820 (when (or (and rbot (> rbot 0))
4809 (and this-height (> this-height dfh))) 4821 (and this-height (> this-height dlh)))
4810 (set-window-vscroll nil (+ vs dfh) t))) 4822 (set-window-vscroll nil (+ vs dlh) t)))
4811 ;; If cursor just entered the bottom scroll margin, move forward, 4823 ;; If cursor just entered the bottom scroll margin, move forward,
4812 ;; but also vscroll one line so redisplay won't recenter. 4824 ;; but also optionally vscroll one line so redisplay won't recenter.
4813 ((and vpos 4825 ((and vpos
4814 (> vpos 0) 4826 (> vpos 0)
4815 (= py (min (- (window-screen-lines) scroll-margin 1) 4827 (= py (min (- (window-screen-lines) scroll-margin 1)
4816 (1- vpos)))) 4828 (1- vpos))))
4817 (set-window-vscroll nil dfh t) 4829 ;; Don't vscroll if the partially-visible line at window
4830 ;; bottom has the default height (a.k.a. "just one more text
4831 ;; line"): in that case, we do want redisplay to behave
4832 ;; normally, i.e. recenter or whatever.
4833 ;;
4834 ;; Note: ROWH + RBOT from the value returned by
4835 ;; pos-visible-in-window-p give the total height of the
4836 ;; partially-visible glyph row at the end of the window. As
4837 ;; we are dealing with floats, we disregard sub-pixel
4838 ;; discrepancies between that and DLH.
4839 (if (and rowh rbot (>= (- (+ rowh rbot) dlh) 1))
4840 (set-window-vscroll nil dlh t))
4818 (line-move-1 arg noerror to-end) 4841 (line-move-1 arg noerror to-end)
4819 t) 4842 t)
4820 ;; If there are lines above the last line, scroll-up one line. 4843 ;; If there are lines above the last line, scroll-up one line.
@@ -4823,7 +4846,7 @@ The value is a floating-point number."
4823 t) 4846 t)
4824 ;; Finally, start vscroll. 4847 ;; Finally, start vscroll.
4825 (t 4848 (t
4826 (set-window-vscroll nil dfh t))))))) 4849 (set-window-vscroll nil dlh t)))))))
4827 4850
4828 4851
4829;; This is like line-move-1 except that it also performs 4852;; This is like line-move-1 except that it also performs
@@ -4857,13 +4880,25 @@ The value is a floating-point number."
4857 ;; If we moved into a tall line, set vscroll to make 4880 ;; If we moved into a tall line, set vscroll to make
4858 ;; scrolling through tall images more smooth. 4881 ;; scrolling through tall images more smooth.
4859 (let ((lh (line-pixel-height)) 4882 (let ((lh (line-pixel-height))
4860 (dfh (default-font-height))) 4883 (dfh (default-font-height))
4884 (lsp (if (display-graphic-p)
4885 (or line-spacing
4886 (default-value 'line-spacing)
4887 (frame-parameter nil 'line-spacing)
4888 0)
4889 0))
4890 dlh)
4891 ;; DLH is the default height of a text line, accounting
4892 ;; for the default face's font and line-spacing, if any.
4893 (if (floatp lsp)
4894 (setq lsp (* dfh lsp)))
4895 (setq dlh (+ dfh lsp))
4861 (if (and (< arg 0) 4896 (if (and (< arg 0)
4862 (< (point) (window-start)) 4897 (< (point) (window-start))
4863 (> lh dfh)) 4898 (> lh dlh))
4864 (set-window-vscroll 4899 (set-window-vscroll
4865 nil 4900 nil
4866 (- lh dfh) t)))) 4901 (- lh dlh) t))))
4867 (line-move-1 arg noerror to-end))))) 4902 (line-move-1 arg noerror to-end)))))
4868 4903
4869;; Display-based alternative to line-move-1. 4904;; Display-based alternative to line-move-1.