From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel Semyonov via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#64202: [PATCH] Gnus: Add back end for Atom feeds (nnatom) Date: Mon, 03 Jul 2023 03:00:14 +0300 Message-ID: <87pm59984x.fsf@dsemy.com> References: <87v8fhmgvw.fsf@dsemy.com> <87y1k76eip.fsf@dsemy.com> <87fs6epd6d.fsf@dsemy.com> <87bkh2p96o.fsf@dsemy.com> <83ilb4qb44.fsf@gnu.org> <87r0prkgsz.fsf@dsemy.com> <873525udhn.fsf@ericabrahamsen.net> Reply-To: Daniel Semyonov Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30935"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: cohen@bu.edu, larsi@gnus.org, Eli Zaretskii , 64202@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jul 03 02:03:24 2023 Return-path: Envelope-to: geb-bug-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 1qG72J-0007p5-Uj for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 03 Jul 2023 02:03:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qG720-0007VK-FH; Sun, 02 Jul 2023 20:03:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qG71z-0007V9-1M for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 20:03:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qG71y-00078e-Ol for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 20:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qG71y-00062L-7x for bug-gnu-emacs@gnu.org; Sun, 02 Jul 2023 20:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Semyonov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 03 Jul 2023 00:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64202 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64202-submit@debbugs.gnu.org id=B64202.168834256323176 (code B ref 64202); Mon, 03 Jul 2023 00:03:02 +0000 Original-Received: (at 64202) by debbugs.gnu.org; 3 Jul 2023 00:02:43 +0000 Original-Received: from localhost ([127.0.0.1]:32942 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qG71e-00061k-L5 for submit@debbugs.gnu.org; Sun, 02 Jul 2023 20:02:43 -0400 Original-Received: from dsemy.com ([46.23.89.208]:21683) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qG71b-00061T-AN for 64202@debbugs.gnu.org; Sun, 02 Jul 2023 20:02:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=dkim; bh=Rlv9WmXDJ1cWE BKM0Xg8xqy03AwwVfKmJG8Joz33qMs=; h=date:references:in-reply-to: subject:cc:to:from; d=dsemy.com; b=Pz1gaGyLcDgY/YIOu/jkIlbmcdePUdJpWYs t9lNaypLkUx0Wldjn1TqZsHT7q/lk3uGrud8VJ55zGfJZSdubjWvZhNDf+qP6WUs8IAJ74 fRDGCGxvYaUaoH91pUWRX4M8mc/eo+/qypLCRko+fjh0ZDE1V2u3++cu7D/7nB8O2+ZqUs hxo9NNxGzT8WErnlEYfx9tnbjhixGuOxVbqZ+/zqGGSf526aKXPBlVg+oCeiFLxBHNh8Wr nOcqFUMXZj6zqCVsboLFZnuUi5aMstLAD2wOmuucmACAUGajzMkARt5LgicbgwJj9WZsLk tkfL6M24r5QUIcr98bPCK5Vb1bQ== Original-Received: from coldharbour.home.arpa (bzq-79-180-56-116.red.bezeqint.net [79.180.56.116]) by dsemy.com (OpenSMTPD) with ESMTPSA id 22881505 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 3 Jul 2023 02:02:32 +0200 (CEST) Original-Received: from localhost (coldharbour.home.arpa [local]) by coldharbour.home.arpa (OpenSMTPD) with ESMTPA id 8c27eb6f; Mon, 3 Jul 2023 00:00:14 +0000 (UTC) In-Reply-To: <873525udhn.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 02 Jul 2023 15:59:00 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:264505 Archived-At: >>>>> Eric Abrahamsen writes: > Thanks again for working on this -- I'm getting around to trying > it out. I have a dumb first question: how do I create a Atom > group? I wanted to try it out with the US weather.gov feed for my > state: https://alerts.weather.gov/cap/wa.php?x=0 > I tried with "a" in the *Server* buffer, "G m" in the *Group* > buffer, but I guess neither allow for prompting the user for a > URL. You can use "B nnatom RET
RET" in the group buffer for this purpose. > I also added > (nnatom "alerts.weather.gov/cap/wa.php?x=0) > to my `gnus-secondary-select-methods' variable, but it said > "Server file alerts.weather.gov/cap/wa.php?x=0 not readable or > writable" when I restarted Gnus. I guess because we're going > straight to `nnatom-open-server', which reads a local file, > without ever fetching the file. We'd have to hit > `nnatom--parse-feed' to do that, but I don't see how we arrive > there without already having the server created. The server should be allowed to open without an existing local file, as long as that local file is writable, however... > What am I missing? You're not missing anything, you actually just reminded me of a bug I forgot to fix - the directory holding the local feed data isn't automatically created if it's missing, which causes 'file-writable-p' to return nil, preventing the server from opening. As a workaround, manually create an "atom" subdir under 'gnus-directory'. I'll fix this in the next version. However, this particular feed still doesn't work since the comment at the start of the feed changes the structure of the parsed representation of the feed when libxml is supported (this also made me realize I accidentally broke parsing without libxml in the last version, oops). This is very useful info, as this is the first feed I encountered like this, and I will fix both those issues too in the next version. As a quick fix, redefine 'nnatom--read-feed' as: (defun nnatom--read-feed (feed _) "Return a list structure representing FEED, or nil." (if (string-match-p "^https?://" feed) (nnheader-report nnatom-backend "Address shouldn't start with \"http://\" or \"https://\"") (with-temp-buffer (condition-case e (if (file-readable-p feed) (insert-file-contents feed) (mm-url-insert-file-contents (concat "https://" feed))) (file-error (nnheader-report nnatom-backend (cdr e))) (:success (when-let ((data (if (libxml-available-p) (libxml-parse-xml-region (point-min) (point-max)) (car (xml-parse-region (point-min) (point-max))))) (auth (list 'authors))) (when (eq (car data) 'top) (setq data (assq 'feed data))) (dom-add-child-before data auth) (catch :stop ; Collect feed authors, stop at first entry. (dolist (child (cdddr data) data) (let ((tag (car-safe child))) (if (eq tag 'entry) (throw :stop data) (and (or (eq tag 'author) (eq tag 'contributor)) (dom-add-child-before auth child)))))))))))) Thanks, Daniel