GNU bug report logs - #19560
24.3.50; Handle adjacent links correctly in shr

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Sat, 10 Jan 2015 20:27:02 UTC

Severity: normal

Tags: fixed, patch

Merged with 16415

Found in version 24.3.50

Fixed in version 25.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ivan Shmakov <ivan <at> siamics.net>
To: 19560 <at> debbugs.gnu.org
Subject: bug#19560: shr.el: skips over adjacent links 
Date: Sat, 10 Jan 2015 20:25:58 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs
Severity: minor

	As of ec7605b4b137 (2015-01-10 16:54:24 +0000), the
	shr-next-link and shr-previous-link commands skip over adjacent
	links, as per the example MIMEd.

	With this same example, shr-previous-link also fails to deal
	with the link at the very beginning of the buffer.

	Please consider the patch MIMEd.

-- 
FSF associate member #7257  http://boycottsystemd.org/  … 3013 B6A0 230E 334A
[Message part 2 (text/html, inline)]
[Message part 3 (text/diff, inline)]
--- a/lisp/net/shr.el	2015-01-10 16:54:24 +0000
+++ b/lisp/net/shr.el	2015-01-10 20:20:24 +0000
@@ -265,8 +269,11 @@
 (defun shr-next-link ()
   "Skip to the next link."
   (interactive)
-  (let ((skip (text-property-any (point) (point-max) 'help-echo nil)))
+  (let* ((cur (get-text-property (point) 'help-echo))
+	 (skip (text-property-not-all (point) (point-max)
+				      'help-echo cur)))
     (if (or (eobp)
+	    (not skip)
 	    (not (setq skip (text-property-not-all skip (point-max)
 						   'help-echo nil))))
 	(message "No next link")
@@ -276,25 +283,28 @@
 (defun shr-previous-link ()
   "Skip to the previous link."
   (interactive)
-  (let ((start (point))
+  (let ((cur (get-text-property (point) 'help-echo))
+	(start (point))
 	(found nil))
     ;; Skip past the current link.
     (while (and (not (bobp))
-		(get-text-property (point) 'help-echo))
+		(when-let ((h-e (get-text-property (point) 'help-echo)))
+		  (eq cur h-e)))
       (forward-char -1))
     ;; Find the previous link.
-    (while (and (not (bobp))
-		(not (setq found (get-text-property (point) 'help-echo))))
+    (while (and (not (setq found (get-text-property (point) 'help-echo)))
+		(not (bobp)))
       (forward-char -1))
-    (if (not found)
+    (if (or (not found) (eq start (point)))
 	(progn
 	  (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)
+      (when (not (bobp))
+	(while (and (not (bobp))
+		    (eq found (get-text-property (point) 'help-echo)))
+	  (forward-char -1))
+	(forward-char 1))
       (message "%s" (get-text-property (point) 'help-echo)))))
 
 (defun shr-show-alt-text ()

This bug report was last modified 9 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.