Gnus development mailing list
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: ding@gnus.org
Subject: Re: Command for browsing article URLs?
Date: Tue, 22 Jan 2019 15:45:14 -0800	[thread overview]
Message-ID: <87pnso9rzp.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <874la1yjjo.fsf@ericabrahamsen.net>

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> On Friday, 18 Jan 2019 at 10:04, Eric Abrahamsen wrote:
>>> I'll filter those out in advance, but would also like to know what was
>>> producing that particular gnus-data. What message were you on when you
>>> got that error? I.e., the offending data was:
>>
>> These were the active places (i.e. where I can TAB to and do something
>> on) in an email that includes previous messages, things highlighted by
>> gnus especially when using the mechanisms in gnus for hiding part of a
>> citation.  The particular message was the previous one you had posted to
>> this group (mailing list but I'm reading it via gwene/gmane).
>
> Well that's weird, when I use the command on that message, it offers me
> the "Eric Abrahamsen wrote:" text as a link I can click, and toggles
> visibility of the quote as you'd expect. I'll try to figure this out.

Nope, wasn't able to figure it out. I can't find any messages that
return that kind of marker structure for me.

Here's one more version that might handle that case properly for you,
and at the very least shouldn't error.


(defun gnus-article-browse-url (arg)
  "Scan the current article body for links, and offer to browse them.
With prefix ARG, also collect links from message headers.

Links are opened using `widget-button-press'.  If only one link
is found, browse that directly, otherwise use completion to
select a link."
  (interactive "P")
  (let ((opened (and (gnus-buffer-live-p gnus-article-buffer)
		     (get-buffer-window gnus-article-buffer t)
		     ;; We might have opened an article, but then moved to
		     ;; a different summary line.
		     (= gnus-current-article (gnus-summary-article-number))))
	pt urls target)
    (unless opened
      (gnus-summary-select-article)
      (gnus-configure-windows 'article))
    (gnus-with-article-buffer
      (if arg
	  (goto-char (point-min))
	(article-goto-body)
	;; Back up a char, in case body starts with a widget.
	(backward-char))
      (setq pt (point))
      (while (progn (widget-forward 1)
		    (> (point) pt))
	(setq pt (point))
	(when-let ((u (cond
		       ((get-text-property (point) 'shr-url))
		       ((get-text-property (point) 'gnus-string))
		       ((let ((dat (get-text-property (point) 'gnus-data)))
			  (pcase dat
			    ('nil nil)
			    ((and (pred stringp) (pred (string-match-p "^>")))
			     ;; This is a "so-and-so wrote:" quote.
			     (buffer-substring-no-properties
			      (line-beginning-position) (line-end-position)))
			    ;; Does a marker always signify the
			    ;; signature?  We may never know.
			    ((pred markerp)
			     "<signature>")
			    ;; What is this, exactly?
			    (`(((,(and (pred markerp) start) .
				 ,(and (pred markerp) end))) _)
			     (buffer-substring-no-properties start end))
			    ;; There are more weird cases, add as
			    ;; necessary.
			    ((pred stringp) dat)))))))
	  (push (cons u pt) urls)))
      (setq target
	    (assoc (cond ((= (length urls) 1)
			  (caar urls))
			 ((> (length urls) 1)
			  (completing-read "URL to browse: "
					   (setq urls (nreverse (delete-dups urls)))
					   nil t)))
		   urls))
      (if target
	  (funcall-interactively #'widget-button-press (1+ (cdr target)))
	(message "No URLs found.")))
    ;; Now what?  If we're not in the *Summary* buffer anymore (i.e.,
    ;; pressing the button created a new buffer), do nothing.
    ;; Otherwise, if the article wasn't opened to begin with, close it
    ;; after we follow the link.
    (when (get-buffer-window gnus-summary-buffer)
      (gnus-summary-expand-window opened))))




  reply	other threads:[~2019-01-22 23:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-07 18:03 Eric Abrahamsen
2019-01-07 20:15 ` Eric S Fraga
2019-01-07 21:53   ` Eric Abrahamsen
2019-01-08 17:07 ` Haider Rizvi
2019-01-08 20:53   ` Eric Abrahamsen
2019-01-10 18:47     ` Haider Rizvi
2019-01-10 22:27       ` Eric Abrahamsen
2019-01-10 17:53   ` Eric Abrahamsen
2019-01-10 22:46     ` Eric Abrahamsen
2019-01-11 10:17     ` Eric S Fraga
2019-01-11 20:38       ` Eric Abrahamsen
2019-01-18  9:24         ` Eric S Fraga
2019-01-18  9:32         ` Eric S Fraga
2019-01-18 18:04           ` Eric Abrahamsen
2019-01-19 11:08             ` Eric S Fraga
2019-01-21 18:03               ` Eric Abrahamsen
2019-01-22 23:45                 ` Eric Abrahamsen [this message]
2019-01-30  8:13                   ` Eric S Fraga
2019-01-30 19:23                     ` Eric Abrahamsen
2019-01-31  8:38                       ` Eric S Fraga
2019-01-31 17:18                         ` Eric Abrahamsen
2019-01-31 17:25                           ` Eric S Fraga
2019-01-31 17:49                             ` Eric Abrahamsen
2019-01-31 18:31                               ` Eric S Fraga
2019-06-22 10:30         ` Lars Ingebrigtsen
2019-01-22 20:50 ` Clemens Schüller
2019-01-22 20:59   ` Eric Abrahamsen
2019-02-10  8:55     ` Clemens Schüller

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnso9rzp.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).