From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: James Thomas via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69517: [PATCH] Make gnus cache work with group names having '/' Date: Thu, 14 Mar 2024 08:56:08 +0530 Message-ID: <8734sttrxr.fsf@gmx.net> References: <87wmqkcc9u.fsf@outlook.com> <86wmqbyews.fsf@gnu.org> <8734szul14.fsf@gmx.net> <874jde7j2c.fsf@ericabrahamsen.net> <87v85u5448.fsf@ericabrahamsen.net> Reply-To: James Thomas Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12639"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eric Abrahamsen , Eli Zaretskii To: 69517@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 14 04:27:52 2024 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 1rkbl1-00035K-88 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Mar 2024 04:27:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkbkg-00042w-Hl; Wed, 13 Mar 2024 23:27:30 -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 1rkbke-00042m-5X for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 23:27:28 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkbkc-0005yq-QZ for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 23:27:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rkblB-0004Vr-Tg for bug-gnu-emacs@gnu.org; Wed, 13 Mar 2024 23:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: James Thomas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Mar 2024 03:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69517 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 69517-submit@debbugs.gnu.org id=B69517.171038683817289 (code B ref 69517); Thu, 14 Mar 2024 03:28:01 +0000 Original-Received: (at 69517) by debbugs.gnu.org; 14 Mar 2024 03:27:18 +0000 Original-Received: from localhost ([127.0.0.1]:47690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkbkT-0004Um-Jh for submit@debbugs.gnu.org; Wed, 13 Mar 2024 23:27:18 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:43181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkbkR-0004UZ-3h for 69517@debbugs.gnu.org; Wed, 13 Mar 2024 23:27:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net; s=s31663417; t=1710386784; x=1710991584; i=jimjoe@gmx.net; bh=/QY8IyLHPUCQWUXmnwFKAJ7SPMB65F7kOmnnGWkfPJU=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:Date: References; b=AMYSTtBKcG5w5IVXOW399PksbwatYm7GnoHvwbW5bNMsVMA/m/hQVCIAdHVsuNNg UA2qhWBnHJSQKKEErR6MY6EPw5QV6TbxyeBPYb6oCdHJw3i2/I1gaTNc3J7RvuXiJ xQfZofeq48FnfFtHV8nFL6GLbAtM1vBbUH08G4+SmtPsXusE/VMsFsdmyjFZxjUfK b8QkP7tFAA3l80Nkd0dsZZd3OLT4lAeU5cBb6oxLVu13xzm6yTU5eZl5OAHECCifI y2MIRYwYl5CgmaGg53nEAscG8zr6d8cIsMldYajGvdcYJsDfm8FFJZlUWY9QZWbTg karNK+JOVagT1V/4lA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from user-Inspiron-15-5518 ([117.212.173.1]) by mail.gmx.net (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MiaY9-1r7z7g2ovH-00ffGu; Thu, 14 Mar 2024 04:26:24 +0100 In-Reply-To: <87v85u5448.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Sun, 10 Mar 2024 11:33:11 -0700") X-Provags-ID: V03:K1:fk0AV6tHo66reiGU02WTe1FZdCTmqhjAqqTJ9o4AGZFsrolBwbS 2oI/nMibn4GD63vlTq3vOjvHWYvTIUf89CgeeHl/qjhmMzB+EAHeg9d7V5iDqW0uDTlhy51 gLb7rqiB54I5YJMe9fTGW3jiYRwfP3CFxzNKK77am3PZI9KQKu3C7Y2hWBl22S6RfNS4k02 AKouKcy4+eCGurzxseWEQ== UI-OutboundReport: notjunk:1;M01:P0:5q8ygdtRwrU=;6o3zh73YijTjmTo9DAepQEh81o1 q9ipcw+HCESWzTywp/Jy+fazhcCXSrm++h9nUSFejlwTdGSaGu2aq8Lt+N1w9sJNcC4ycqYqH YGRaaR+KMma0iwnqTKzdFi6EkHFkeiW8qMgEYFmLIObhR6BK8ZlrJMkuHqA3ZiD2ZN6k3bTEi C5dDv45B3wQGUXK3JK66yJXd1z+R+pZI7umA7pvZFmIa2HhCRlJ1sEeZg1iP4jR9ay9SSnzOM t6bVW/VzMtI2gcUueGWx7WrOH7vMe+BFroOjUITeIYrmcnutKTzuz+QBKIZBYNeozcLnWNKUc NpmWrBBjYh1o2vhWZe3cdyaZcYm2QrI7jta9XIPRmrP4xM7/aqYJWhEfOQfvL1VBI8kj/DHDf MbKojFtCjUgYk41dgJvwCzEVVr9nxGaVjKIAp8oGNuipAiZO7fMsY9HmytItmKlhGAHRkzsLq pmxsxkCHHEz3E1bsYw8OHt3oyOXWX3zmwnznguHAyJkr2jj4n3d1tu6PLSqkqMf1e6U01kxtR XBV2yvnM5rXr4MjUX74VI/QJdWZZe9hqI6MyvqNQ/Bta57ZJW4Gh7nRIGaUkmLQj6LPziqznO 22vzIfvBDtMKMWbAC9UHkHbAgnUu/9NmQtpu9S8ru3OmLmJuT1E/LWovmvwz6VN7rQjRisGb5 LJ9ZFMY/yl5b8VbPFWEYE23IjX7pszY4NTXxywTzNE1NAN/UKoNWLRdRWVcYV2dWHtWAE91QD 9g/Bb6o2YN3zT/W9E8Op9wTpuxEvdF382QqAowyfDeGN3KfmjTjyXvay0j6aWVPz1Ak8yFuI 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:281577 Archived-At: --=-=-= Content-Type: text/plain Eric Abrahamsen wrote: > The real problem (well, one of the real problems) is that we should just > have two central routines for reading and writing active files, so that > there are only two places to keep in sync. Instead we have those two > places, and then a smattering of other functions in other places that do > something similar, and also have to be kept in sync, and I haven't done > that. At the very least I'll need to apply your patch from 65467. > > The other real problem is that gnus-cache is confused about whether it > wants to be a select method, or a modified version of article saving. > The presence of `gnus-use-long-file-name' indicates the latter, but the > manual's instructions about the nnml select method indicates the former. > > I think it should be a select method, which means that the group > directory should be created in "News/cache" the same way it is created > at the top level: with the "/" replaced by "_", and everything else > using the proper "left/right" group name. Perhaps "long file names" can > still play a role, but if so that should be via > `nnmail-use-long-file-names', and gnus-cache in general should behave > like a nnmail backend. Well, I have sort of, an approach based on my earlier patch: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-gnus-cache-work-with-group-names-having.patch Content-Transfer-Encoding: quoted-printable =46rom 0f5d693dc439b11294b3bde3dc9129bdf45a2179 Mon Sep 17 00:00:00 2001 From: James Thomas Date: Thu, 14 Mar 2024 08:42:00 +0530 Subject: [PATCH] Make gnus cache work with group names having '/' Make `gnus-cache-file-name` use the existing `nnmail-group-pathname`. * lisp/gnus/gnus-cache.el (gnus-cache-file-name) (gnus-cache-update-article): * lisp/gnus/nnmail.el (nnmail-group-pathname): =2D-- lisp/gnus/gnus-cache.el | 27 +++++++-------------------- lisp/gnus/nnmail.el | 3 ++- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/lisp/gnus/gnus-cache.el b/lisp/gnus/gnus-cache.el index 961219eee8f..7af02368d36 100644 =2D-- a/lisp/gnus/gnus-cache.el +++ b/lisp/gnus/gnus-cache.el @@ -443,23 +443,9 @@ gnus-cache-member-of-class (and (not unread) (not ticked) (not dormant) (memq 'read class)))) (defun gnus-cache-file-name (group article) - (expand-file-name - (if (stringp article) article (int-to-string article)) - (file-name-as-directory - (expand-file-name - (nnheader-translate-file-chars - (if (gnus-use-long-file-name 'not-cache) - group - (let ((group (nnheader-replace-duplicate-chars-in-string - (nnheader-replace-chars-in-string group ?/ ?_) - ?. ?_))) - ;; Translate the first colon into a slash. - (when (string-match ":" group) - (setq group (concat (substring group 0 (match-beginning 0)) - "/" (substring group (match-end 0))))) - (nnheader-replace-chars-in-string group ?. ?/))) - t) - gnus-cache-directory)))) + (nnmail-group-pathname + group gnus-cache-directory + (if (stringp article) article (int-to-string article)))) (defun gnus-cache-update-article (group article) "If ARTICLE is in the cache, remove it and re-enter it." @@ -699,9 +685,10 @@ gnus-cache-generate-active (file-name-as-directory (expand-file-name gnus-cache-directory)))) (directory-file-name directory)) - (nnheader-replace-chars-in-string - (substring (directory-file-name directory) (match-end 0)) - ?/ ?.))) + (url-unhex-string + (nnheader-replace-chars-in-string + (substring (directory-file-name directory) (match-end 0)) + ?/ ?.)))) nums alphs) (when top (gnus-message 5 "Generating the cache active file...") diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el index fef12eebe09..a9f5b89c6fe 100644 =2D-- a/lisp/gnus/nnmail.el +++ b/lisp/gnus/nnmail.el @@ -33,6 +33,7 @@ (require 'mail-source) (require 'mm-util) (require 'gnus-int) +(require 'browse-url) (autoload 'mail-send-and-exit "sendmail" nil t) @@ -627,7 +628,7 @@ nnmail-group-pathname (concat (let ((dir (file-name-as-directory (expand-file-name dir)))) (setq group (nnheader-replace-duplicate-chars-in-string - (nnheader-replace-chars-in-string group ?/ ?_) + (browse-url-url-encode-chars group "[/%]") ?. ?_)) (setq group (nnheader-translate-file-chars group)) ;; If this directory exists, we use it directly. =2D- 2.34.1 --=-=-= Content-Type: text/plain James Thomas wrote: > + (if (not nnmail-use-long-file-names) > + (nnheader-replace-chars-in-string group ?. ?/) > + group)) Since directory names cannot have '/' they used to be replaced by '_' in group names before conversion. But this makes it impossible, when generating (non-existent) active files to know whether a '_' in the directory name was _ or / originally. The above patch tries a possible solution inspired from [1] but would break existing users of the cache or agent (xref-find-references "nnmail-group-pathname") who have groups with % or / in their names. Seems to work in my limited testing. WDYT? Regards, James 1: https://stackoverflow.com/questions/9847288/is-it-possible-to-use-in-a-filename#answer-9847319 --=-=-=--