help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: functions to download mailing list archives


From: Óscar Fuentes
Subject: Re: functions to download mailing list archives
Date: Mon, 13 Jun 2022 18:46:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

GH <project@gnuhacker.org> writes:

> I dont know how. Maybe some like:
>
> #+begin_src elisp
>
> (defun lists-mbox-recursive-url-list (url-head id date)
>   (with-current-buffer "*eww*"
>     (shr-next-link)
>     (let ((url (thing-at-point 'url)))
>       (if (string-match (format "%s/archive/mbox/%s/%s\\(.+\\)" url-head id 
> date)
>                       url)
>         (add-to-list url-list url)))
>     (if (save-excursion (shr-next-link))
>       (lists-mbox-recursive-url-list url-head id date)
>       url-list)))
>
>
> (let ((url-list '()))
>   (with-current-buffer "*eww*"
>     (beginning-of-buffer)
>     (lists-mbox-recursive-url-list "https://lists.gnu.org"; "help-gnu-emacs" 
> 201)))
>
> #+end_src
>
> But return an error that I dont understand:
>
> Debugger entered--Lisp error: (setting-constant nil)
>   add-to-list(nil
> "https://lists.gnu.org/archive/mbox/help-gnu-emacs/...";)
>
>   (if (string-match (format "%s/archive/mbox/%s/%s\\(.+\\)" url-head id date) 
> url) (add-to-list url-list url))
>   (let ((url (thing-at-point 'url))) (if (string-match (format 
> "%s/archive/mbox/%s/%s\\(.+\\)" url-head id date) url) (add-to-list url-list 
> url)))
>   (save-current-buffer (set-buffer "*eww*") (shr-next-link) (let ((url
> (thing-at-point 'url))) (if (string-match (format
> "%s/archive/mbox/%s/%s\\(.+\\)" url-head id date) url) (add-to-list
> url-list url))) (if (save-excursion (shr-next-link))
> (lists-mbox-recursive-url-list url-head id date) url-list))
>   lists-mbox-recursive-url-list("https://lists.gnu.org"; "help-gnu-emacs" 201)
>
> ...
>
> What mean "error: (setting-constant nil)"

You are trying to mutate a constant (the symbol `nil').

You need to quote the list variable:

(add-to-list 'url-list url)

Other problem with your code is that you still are using function
recursion.

What I was suggesting was something like this:

(defun lists-mbox-recursive-url-list (url-list)
  (dolist (url url-list)
    ;; get the url's content
    ;; do wathever you want with the url's content (save it, ...)
    ;; for each URL of interest inside the content:
      ;; The `t' at the end of add-to-list means to append the new element:
      (add-to-list 'url-list new-url t)))

(lists-mbox-recursive-url-list (list "https://lists.gnu.org/whatever";))

You need to adapt the above to your specific requirements (build the URL
depending on the mailing list, date, etc) but the general structure of
the task is there.

See how there is no function recursion, so no problem with
max-lisp-eval-depth. And add-to-list checks that the element you are
adding is not already in the list, so no problem with cyclic references:
you visit each URL only once.



reply via email to

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