unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 21012@debbugs.gnu.org
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	[thread overview]
Message-ID: <83bnfkb1rs.fsf@gnu.org> (raw)
In-Reply-To: <874mlcgoka.fsf@web.de>

> 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	other threads:[~2015-07-10 13:06 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 18:10 bug#21012: 25.0.50; eww: last char of a line sometimes not fully visible Michael Heerdegen
2015-07-08 20:03 ` Eli Zaretskii
2015-07-08 20:24   ` Michael Heerdegen
2015-07-09  2:38     ` Eli Zaretskii
2015-07-09 11:01       ` Michael Heerdegen
2015-07-09 14:43         ` Eli Zaretskii
2015-07-09 19:42           ` Michael Heerdegen
2015-07-09 15:34       ` Eli Zaretskii
2015-07-09 20:06         ` Michael Heerdegen
2015-07-10  6:03           ` Eli Zaretskii
2015-07-10 12:55             ` Michael Heerdegen
2015-07-10 13:06               ` Eli Zaretskii [this message]
2015-07-10 14:16                 ` Michael Heerdegen
2015-07-10 14:43                   ` Eli Zaretskii
2015-07-10 18:04                     ` Michael Heerdegen
2015-07-10 18:45                       ` Eli Zaretskii
2015-07-10 19:19                         ` Michael Heerdegen
2015-07-10 19:31                           ` Eli Zaretskii
2015-07-11 12:02                             ` Michael Heerdegen
2015-07-11 13:45                               ` Eli Zaretskii
2015-07-20 16:33                                 ` Michael Heerdegen
2015-07-20 16:34                                   ` Eli Zaretskii
2015-07-21 18:49                                     ` Michael Heerdegen
2015-09-25  4:00                                       ` Katsumi Yamaoka
2015-09-25 14:45                                         ` Michael Heerdegen
2015-09-28 21:30                                           ` Michael Heerdegen
2015-09-29  5:37                                             ` Eli Zaretskii
2015-10-03  8:08                                               ` Michael Heerdegen
2015-10-03  9:42                                                 ` Eli Zaretskii
2015-10-03 12:41                                                   ` Michael Heerdegen
2015-10-04  6:31                                                     ` Michael Heerdegen
2015-10-04  7:09                                                       ` Eli Zaretskii
2015-10-04  7:11                                                       ` Michael Heerdegen
2015-10-04  7:39                                                         ` Michael Heerdegen
2015-10-04  8:49                                                           ` Eli Zaretskii
2015-10-04 10:18                                                             ` Michael Heerdegen
2015-07-08 20:31   ` Michael Heerdegen
2015-10-07  6:34 ` bug#21012: Close Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bnfkb1rs.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=21012@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).