emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] shr-fontified 38f1545 2/7: Rely more on `vertical-motion'


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] shr-fontified 38f1545 2/7: Rely more on `vertical-motion'
Date: Sat, 07 Feb 2015 04:09:51 +0000

branch: shr-fontified
commit 38f1545566d9f2058f95590d51d6e9a8f195f42c
Author: Lars Magne Ingebrigtsen <address@hidden>
Commit: Lars Magne Ingebrigtsen <address@hidden>

    Rely more on `vertical-motion'
    
    * lisp/net/shr.el (shr-goto-pixel-column): `vertical-motion' really
    does what it's supposed to.
---
 lisp/ChangeLog  |    5 +++++
 lisp/net/shr.el |   22 ++++++++--------------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8bf7567..3b16006 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-06  Lars Ingebrigtsen  <address@hidden>
+
+       * net/shr.el (shr-goto-pixel-column): `vertical-motion' really
+       does what it's supposed to.
+
 2015-02-05  Lars Ingebrigtsen  <address@hidden>
 
        * net/shr.el (shr-pixel-column): Base in `shr-glyph-widths'.
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 8faa2a0..aac4d20 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -521,9 +521,9 @@ size, and full-buffer size."
     (let ((max-width 0)
          (this-width 0))
       (shr-goto-pixel-column shr-internal-width)
-      (if (< (setq this-width (shr-pixel-column)) shr-internal-width)
-         (setq max-width (max max-width this-width))
-       (while (> this-width shr-internal-width)
+      (if (eolp)
+         (setq max-width (max max-width (shr-pixel-column)))
+       (while (not (eolp))
          ;; We have to do some folding.  First find the first
          ;; previous point suitable for folding.
          (let ((end (point)))
@@ -532,21 +532,15 @@ size, and full-buffer size."
              (delete-char -1))
            (insert "\n"))
          (shr-goto-pixel-column shr-internal-width)
-         (setq this-width (shr-pixel-column)
-               max-width (max max-width this-width))))
+         (setq max-width (max max-width (shr-pixel-column)))))
       max-width)))
 
 (defun shr-goto-pixel-column (pixels)
   (vertical-motion (cons (/ pixels (frame-char-width)) 0))
-  (if (> (shr-pixel-column) pixels)
-      (while (and (> (shr-pixel-column) pixels)
-                 (not (bolp)))
-       (forward-char -1))
-    (while (and (< (shr-pixel-column) pixels)
-               (not (eolp)))
-      (forward-char 1))
-    (unless (eolp)
-      (forward-char 1))))
+  ;; Vertical-motion goes to the char before or on the pixel, so
+  ;; advance one char.
+  (unless (eolp)
+    (forward-char 1)))
 
 (defun shr-find-fill-point (start)
   (let ((bp (point))



reply via email to

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