From: "Óscar Fuentes" <ofv@wanadoo.es>
To: GH <project@gnuhacker.org>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: functions to download mailing list archives
Date: Mon, 13 Jun 2022 18:46:33 +0200 [thread overview]
Message-ID: <871qvscxzq.fsf@telefonica.net> (raw)
In-Reply-To: <87h74ozqcn.fsf@gnu.org> (GH's message of "Mon, 13 Jun 2022 14:43:04 +0200")
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.
next prev parent reply other threads:[~2022-06-13 16:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-12 22:30 functions to download mailing list archives GH
2022-06-12 23:04 ` Óscar Fuentes
2022-06-13 12:43 ` GH
2022-06-13 16:46 ` Óscar Fuentes [this message]
2022-06-13 18:41 ` GH
2022-06-13 22:09 ` Óscar Fuentes
2022-06-14 9:58 ` GH
2022-06-14 10:26 ` Emanuel Berg
2022-06-16 0:13 ` GH
2022-06-16 4:23 ` Emanuel Berg
2022-06-16 12:27 ` GH
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=871qvscxzq.fsf@telefonica.net \
--to=ofv@wanadoo.es \
--cc=help-gnu-emacs@gnu.org \
--cc=project@gnuhacker.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 read-only IMAP folder(s) and NNTP newsgroup(s).