From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: functions to download mailing list archives Date: Mon, 13 Jun 2022 18:46:33 +0200 Message-ID: <871qvscxzq.fsf@telefonica.net> References: <87r13tikgn.fsf@gnu.org> <878rq1cwl9.fsf@telefonica.net> <87h74ozqcn.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8864"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Help GNU Emacs To: GH Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 13 18:47:10 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o0nDa-000264-91 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 13 Jun 2022 18:47:10 +0200 Original-Received: from localhost ([::1]:55556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o0nDY-0007gY-Py for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 13 Jun 2022 12:47:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0nD9-0007f1-Qi for help-gnu-emacs@gnu.org; Mon, 13 Jun 2022 12:46:43 -0400 Original-Received: from relayout01.e.movistar.es ([86.109.101.201]:39119 helo=relayout01-redir.e.movistar.es) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o0nD6-00037m-Km for help-gnu-emacs@gnu.org; Mon, 13 Jun 2022 12:46:43 -0400 Original-Received: from sky (104.red-81-39-17.dynamicip.rima-tde.net [81.39.17.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 4LMHXB2QKfzfbrJ; Mon, 13 Jun 2022 18:46:34 +0200 (CEST) In-Reply-To: <87h74ozqcn.fsf@gnu.org> (GH's message of "Mon, 13 Jun 2022 14:43:04 +0200") X-TnetOut-Country: IP: 81.39.17.104 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 4LMHXB2QKfzfbrJ.AC547 X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1655743595.60588@gZJJWhNbFWcxSbhb6F5gqw Received-SPF: softfail client-ip=86.109.101.201; envelope-from=ofv@wanadoo.es; helo=relayout01-redir.e.movistar.es X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:137802 Archived-At: GH 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.