unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: 14670@debbugs.gnu.org
Subject: bug#14670: Highlight visited links
Date: Thu, 27 Jun 2013 02:27:42 +0300	[thread overview]
Message-ID: <87ehbojvv4.fsf@mail.jurta.org> (raw)
In-Reply-To: <87r4fx20rj.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 20 Jun 2013 01:28:48 +0300")

This patch adds the support for links in virtual Info nodes
rendered by shr.el.  A virtual Info node function can just
call `shr-insert-document' and this patch supports the
fontification and navigation for links added by the renderer.

=== modified file 'lisp/info.el'
--- lisp/info.el	2013-05-27 22:42:11 +0000
+++ lisp/info.el	2013-06-24 22:30:15 +0000
@@ -3114,10 +3145,10 @@ (defun Info-next-reference (&optional re
 	    (old-pt (point))
 	    (case-fold-search t))
 	(or (eobp) (forward-char 1))
-	(or (Info-next-reference-or-link pat 'link)
+	(or (Info-next-reference-or-link pat 'shr-url)
 	    (progn
 	      (goto-char (point-min))
-	      (or (Info-next-reference-or-link pat 'link)
+	      (or (Info-next-reference-or-link pat 'shr-url)
 		  (progn
 		    (goto-char old-pt)
 		    (user-error "No cross references in this node")))))
@@ -3141,10 +3172,10 @@ (defun Info-prev-reference (&optional re
       (let ((pat "\\*note[ \n\t]+\\([^:]+\\):\\|^\\* .*:\\|[hf]t?tps?://")
 	    (old-pt (point))
 	    (case-fold-search t))
-	(or (Info-prev-reference-or-link pat 'link)
+	(or (Info-prev-reference-or-link pat 'shr-url)
 	    (progn
 	      (goto-char (point-max))
-	      (or (Info-prev-reference-or-link pat 'link)
+	      (or (Info-prev-reference-or-link pat 'shr-url)
 		  (progn
 		    (goto-char old-pt)
 		    (user-error "No cross references in this node")))))
@@ -3863,6 +3919,8 @@ (defun Info-try-follow-nearest-node (&op
 If FORK is non-nil, it is passed to `Info-goto-node'."
   (let (node)
     (cond
+     ((and (setq node (get-text-property (point) 'shr-url))
+	   (not (eq node t)))
+      (Info-goto-node node fork))
      ((setq node (Info-get-token (point) "[hf]t?tps?://"
 				 "\\([hf]t?tps?://[^ \t\n\"`({<>})']+\\)"))
       (browse-url node)
@@ -4701,6 +4764,18 @@ (defun Info-fontify-node ()
             (add-text-properties (1- (match-beginning 2)) (match-end 2)
                                  '(invisible t front-sticky nil rear-nonsticky t)))))
 
+      ;; Fontify links
+      (goto-char (point-min))
+      (when (or not-fontified-p fontify-visited-p)
+	(let ((beg (next-single-property-change (point-min) 'shr-url))
+	      (end nil))
+	  (while (and beg (setq end (next-single-property-change beg 'shr-url)))
+	    (add-text-properties beg end
+				 `(font-lock-face info-xref
+				   mouse-face highlight
+				   help-echo "mouse-2: go to this node"))
+	    (setq beg (next-single-property-change end 'shr-url)))))
+
       ;; Fontify cross references
       (goto-char (point-min))
       (when (or not-fontified-p fontify-visited-p)
@@ -4969,7 +5053,7 @@ (defun Info-fontify-node ()
           (while (re-search-forward "\\(([0-9]+)\\)" nil t)
             (add-text-properties (match-beginning 0) (match-end 0)
                                  `(font-lock-face info-xref
-                                   link t
+                                   shr-url t
                                    mouse-face highlight
                                    help-echo
                                    ,(if (< (point) limit)







  reply	other threads:[~2013-06-26 23:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-19 22:28 bug#14670: Highlight visited links Juri Linkov
2013-06-26 23:27 ` Juri Linkov [this message]
2013-06-27  2:41   ` Stefan Monnier
2013-06-27 23:35     ` Juri Linkov
2016-02-24  4:56       ` Lars Ingebrigtsen
2019-06-27 11:13         ` Lars Ingebrigtsen

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=87ehbojvv4.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=14670@debbugs.gnu.org \
    /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).