bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21012: 25.0.50; eww: last char of a line sometimes not fully visible


From: Eli Zaretskii
Subject: bug#21012: 25.0.50; eww: last char of a line sometimes not fully visible
Date: Fri, 10 Jul 2015 16:06:15 +0300

> From: Michael Heerdegen <michael_heerdegen@web.de>
> Cc: 21012@debbugs.gnu.org
> Date: Fri, 10 Jul 2015 14:55:01 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > The problem is that functions we have that can tell if that happens
> > require the relevant portion of the buffer to be displayed in some
> > window, so I think shr.el cannot use them.
> 
> FWIW, the whole thing is already displayed

Then please try this change and see if it gives good results:

--- lisp/net/shr.el~0   2015-05-10 07:23:55 +0300
+++ lisp/net/shr.el     2015-07-09 19:24:11 +0300
@@ -549,20 +578,42 @@
          (shr-fill-line)))
       (goto-char (point-max)))))
 
-(defun shr-vertical-motion (column)
+(defun shr-vertical-motion (column win-width)
   (if (not shr-use-fonts)
       (move-to-column column)
     (unless (eolp)
       (forward-char 1))
-    (vertical-motion (cons (/ column (frame-char-width)) 0))
-    (unless (eolp)
-      (forward-char 1))))
+    (let ((orig-y (cdr (nth 2 (posn-at-point)))))
+      (vertical-motion (cons (/ column (frame-char-width)) 0))
+      ;; If vertical-motion puts us on the next screen line, back up.
+      ;; This can happen when the character at the goal column is too
+      ;; wide to fit on the line.
+      (if (> (cdr (nth 2 (posn-at-point))) orig-y)
+          (backward-char 1))
+      (unless (eolp)
+        (let* ((posn (posn-at-point))
+               (ch-x (car (nth 2 posn)))
+               (ch-width (car (nth 9 posn)))
+               (ch-pos (nth 1 posn)))
+          (if (and (natnump ch-pos)
+                   (<= (+ ch-x ch-width) win-width))
+              (forward-char 1)))))))
 
 (defun shr-fill-line ()
   (let ((shr-indentation (get-text-property (point) 'shr-indentation))
        (continuation (get-text-property
                       (point) 'shr-continuation-indentation))
-       start)
+       start win-width)
+    (when shr-use-fonts
+      (setq win-width (window-body-width nil t))
+      ;; When we are filling to the window width, and the user
+      ;; disabled the fringes, an additional column is reserved for
+      ;; the continuation glyph, so we need to adjust the effective
+      ;; window-width for that.
+      (if (and (null shr-width)
+               (or (zerop (fringe-columns 'left))
+                   (zerop (fringe-columns 'right))))
+          (setq win-width (- win-width (frame-char-width)))))
     (put-text-property (point) (1+ (point)) 'shr-indentation nil)
     (let ((face (get-text-property (point) 'face))
          (background-start (point)))
@@ -572,7 +623,7 @@
                           `,(shr-face-background face))))
     (setq start (point))
     (setq shr-indentation (or continuation shr-indentation))
-    (shr-vertical-motion shr-internal-width)
+    (shr-vertical-motion shr-internal-width win-width)
     (when (looking-at " $")
       (delete-region (point) (line-end-position)))
     (while (not (eolp))
@@ -597,7 +648,7 @@
          (put-text-property background-start (point) 'face
                             `,(shr-face-background face))))
       (setq start (point))
-      (shr-vertical-motion shr-internal-width)
+      (shr-vertical-motion shr-internal-width win-width)
       (when (looking-at " $")
        (delete-region (point) (line-end-position))))))
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]