info-gnus-english
[Top][All Lists]
Advanced

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

Re: How to access HTML DOM/source of MIME part?


From: Tim Landscheidt
Subject: Re: How to access HTML DOM/source of MIME part?
Date: Thu, 18 Jun 2020 02:50:30 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

>>> Something to be aware of is that, sometime not too long ago, Lars
>>> re-implemented links in article bodies using widgets instead of buttons.

>> The other way around -- they used to be widgets, and they're now
>> buttons.

> Sure enough, I didn't really know what I was talking about :) But at
> least that points to a likely source of Tim's problem: he's trying to
> use button commands in a version of Emacs/Gnus that is still using
> widgets?

Maybe :-).  Anyway, I found a solution for one of my news-
letters that states the number of entries in its subject and
then has two links per entry with one link containing one
information and the other link containing another informa-
tion and additional (older) entries following that:

| (let
|     ((subject (gnus-summary-article-subject)))
|   (if (string-match "^\\([0-9]+\\) new entries$" subject)
|       (let
|           ((number-of-entries-todo (string-to-number (match-string 1 
subject))))
|         (gnus-with-article-buffer
|           (article-goto-body)
|           (let
|               ((article-body-start (point))
|                last-field1
|                last-url)
|             (while (> number-of-entries-todo 0)
|               (widget-forward 1)
|               (if (< (point) article-body-start)
|                   (error "Moved past the wrap!"))
|               (let
|                   ((url-at-point (button-get (button-at (point)) 'shr-url))
|                    (widget-label (let
|                                      ((widget-properties (cdr (widget-at))))
|                                    (buffer-substring-no-properties (plist-get 
widget-properties :from) (plist-get widget-properties :to)))))
|                 (when (string-match "^https://domain.com/some-prefix/"; 
url-at-point)
|                   (if (not (string= last-url url-at-point))
|                       (setq last-field1 widget-label
|                             last-url url-at-point)
|                     (setq number-of-entries-todo (- number-of-entries-todo 1))
|                     (if (y-or-n-p (format "Browse %s (%s)? " widget-label 
last-field1))
|                         (browse-url url-at-point)))))))))))

Now:

a) The formula for widget-label feels way too complicated,
   but I did not find a predefined function for that pur-
   pose.  Did I miss something?

b) I use this code as part of gnus-select-article-hook.
   widget-forward does move point internally, but does not
   update/recenter the display.  Is this due to
   gnus-with-article-buffer?  What is the best way to make
   the *Article* buffer follow point's movement?

TIA,
Tim



reply via email to

[Prev in Thread] Current Thread [Next in Thread]