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

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

bug#16415: 24.3.50; Handle contiguous links correctly in shr [PATCH]


From: Nathan Trapuzzano
Subject: bug#16415: 24.3.50; Handle contiguous links correctly in shr [PATCH]
Date: Sat, 11 Jan 2014 07:50:14 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Nathan Trapuzzano <address@hidden> writes:

> `shr-next-link' and `shr-previous-link' currently skip over links that
> are contiguous with the current link.  The attached patch addressed this
> problem.
>
> When I say "contiguous", I'm talking in terms of Emacs "positions"--not
> in terms of HTML.

Use this one instead.  I clarified one of the comments and referenced a
bug number:

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: file:///home/nathan/opt/etc/bzr-repos/emacs/trunk/
# testament_sha1: 6cb8b589f64f1b09f140c539ef23d4305646a92e
# timestamp: 2014-01-11 07:48:46 -0500
# base_revision_id: address@hidden
# 
# Begin patch
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2014-01-10 20:19:31 +0000
+++ lisp/ChangeLog      2014-01-11 03:16:17 +0000
@@ -1,3 +1,8 @@
+2014-01-11  Nathan Trapuzzano  <address@hidden>
+
+       * lisp/net/shr.el (shr-next-link, shr-previous-link): Don't skip
+       over contiguous links.
+
 2014-01-10  Glenn Morris  <address@hidden>
 
        * emacs-lisp/authors.el (authors-fixed-entries):

=== modified file 'lisp/net/shr.el'
--- lisp/net/shr.el     2014-01-05 10:23:35 +0000
+++ lisp/net/shr.el     2014-01-11 12:48:32 +0000
@@ -242,8 +242,10 @@
 (defun shr-next-link ()
   "Skip to the next link."
   (interactive)
-  (let ((skip (text-property-any (point) (point-max) 'help-echo nil)))
-    (if (not (setq skip (text-property-not-all skip (point-max)
+  (let ((skip (and (get-text-property (point) 'help-echo)
+                   (or (next-single-property-change (point) 'help-echo)
+                       (point-max)))))
+    (if (not (setq skip (text-property-not-all (or skip (point)) (point-max)
                                               'help-echo nil)))
        (message "No next link")
       (goto-char skip)
@@ -254,11 +256,17 @@
   (interactive)
   (let ((start (point))
        (found nil))
-    ;; Skip past the current link.
-    (while (and (not (bobp))
-               (get-text-property (point) 'help-echo))
+    ;; Skip backwards past the current link.  Be carefule when the
+    ;; current link extends past the end of the narrowed region and
+    ;; point is at (point-max).  In such a case, we proceed as though
+    ;; point is _not_ looking at a link.  Cf. Emacs bug#16413.
+    (when (and (get-text-property (point) 'help-echo)
+               (not (and (eobp) (buffer-narrowed-p))))
+      (goto-char (or (previous-single-property-change
+                      (min (1+ (point)) (point-max)) 'help-echo)
+                     (point-min))))
+    (unless (bobp)
       (forward-char -1))
-    ;; Find the previous link.
     (while (and (not (bobp))
                (not (setq found (get-text-property (point) 'help-echo))))
       (forward-char -1))
@@ -267,10 +275,9 @@
          (message "No previous link")
          (goto-char start))
       ;; Put point at the start of the link.
-      (while (and (not (bobp))
-                 (get-text-property (point) 'help-echo))
-       (forward-char -1))
-      (forward-char 1)
+      (goto-char (or (previous-single-property-change
+                      (min (1+ (point)) (point-max)) 'help-echo)
+                     (point-min)))
       (message "%s" (get-text-property (point) 'help-echo)))))
 
 (defun shr-show-alt-text ()

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWU9sFaMABHF/gHA4uABY////
XiUMgL////BgCC+quzFADVUyAERVSCgEiRTaQ1GU8mp+k02phTymJoNqjRgIzaox6g5gCMExAMAm
CaMhoYBMEYmEpA1U/CKfpT0jQNNAAAAAAAA5gCMExAMAmCaMhoYBMEYmOYAjBMQDAJgmjIaGATBG
JhJICAAQ0QaGk8KTKfpE8oDRp6hpo/VMRhVomBDKL677TQTkiom/r41O/yb3E927Fiw7dnwPL8/6
frzpzCY1Ozpmhp2YTaQiTGjAXj6casqJlTiUu2uuROrpSAJIRbhVHzI8nEb0f/PMqYMn+M46S3B6
CpWkxpkea/QzGBmTMDYfdGtEDAhB5wbhF29zha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