Function: eww-follow-link

eww-follow-link is an interactive and byte-compiled function defined in eww.el.gz.

Signature

(eww-follow-link &optional EXTERNAL MOUSE-EVENT)

Documentation

Browse the URL at point, optionally the position of MOUSE-EVENT.

EXTERNAL is the prefix argument. If called interactively with C-u (universal-argument) pressed once, browse the URL using eww-browse-with-external-browser. If called interactively, with C-u (universal-argument) pressed twice, browse in new buffer.

Probably introduced at or before Emacs version 28.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/net/eww.el.gz
(defun eww-follow-link (&optional external mouse-event)
  "Browse the URL at point, optionally the position of MOUSE-EVENT.

EXTERNAL is the prefix argument.  If called interactively with
\\[universal-argument] pressed once, browse the URL using
`eww-browse-with-external-browser'.  If called interactively, with
\\[universal-argument] pressed twice, browse in new buffer."
  (interactive
   (list current-prefix-arg last-nonmenu-event)
   eww-mode)
  (mouse-set-point mouse-event)
  (let* ((orig-url (get-text-property (point) 'shr-url))
         (url (eww--transform-url orig-url))
         target)
    (cond
     ((not url)
      (message "No link under point"))
     ((string-match-p eww-use-browse-url url)
      ;; This respects the user options `browse-url-handlers'
      ;; and `browse-url-mailto-function'.
      (browse-url url))
     ((and (consp external) (<= (car external) 4))
      (eww-browse-with-external-browser url)
      (shr--blink-link))
     ;; This is a #target url in the same page as the current one.
     ((and (setq target (url-target (url-generic-parse-url url)))
	   (eww-same-page-p url (plist-get eww-data :url)))
      (let ((old-data eww-data)
            (point (point)))
	(eww-save-history)
        (eww--before-browse)
        ;; Copy previous `eww-data', since everything but the URL will
        ;; stay the same, and we don't re-render the document.
        (setq eww-data (copy-sequence old-data))
	(plist-put eww-data :url url)
        (goto-char (point-min))
        (if-let* ((match (text-property-search-forward 'shr-target-id target #'member)))
            (goto-char (prop-match-beginning match))
          (goto-char (if (equal target "top")
                         (point-min)
                       point)))))
     (t
      (eww-browse-url orig-url external)))))