From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#36850: 26.2; Customizing nnmail-expiry-wait-function doesn't work Date: Fri, 02 Aug 2019 16:08:52 +0300 Message-ID: <87v9vfzpcr.fsf@tcd.ie> References: <8036io5cx5.fsf@felesatra.moe> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="11941"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 36850@debbugs.gnu.org To: Allen Li Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Aug 02 15:10:16 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htXJz-0002oK-7L for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Aug 2019 15:10:11 +0200 Original-Received: from localhost ([::1]:34682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htXJy-0002mY-9Y for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Aug 2019 09:10:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46521) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1htXJs-0002lc-EZ for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 09:10:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1htXJq-0002rU-NR for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 09:10:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47259) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1htXJq-0002r5-9L for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 09:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1htXJq-0003gb-2V for bug-gnu-emacs@gnu.org; Fri, 02 Aug 2019 09:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Aug 2019 13:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36850 X-GNU-PR-Package: emacs Original-Received: via spool by 36850-submit@debbugs.gnu.org id=B36850.156475134914099 (code B ref 36850); Fri, 02 Aug 2019 13:10:02 +0000 Original-Received: (at 36850) by debbugs.gnu.org; 2 Aug 2019 13:09:09 +0000 Original-Received: from localhost ([127.0.0.1]:56078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htXIy-0003fJ-BU for submit@debbugs.gnu.org; Fri, 02 Aug 2019 09:09:08 -0400 Original-Received: from mail-wm1-f68.google.com ([209.85.128.68]:55056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htXIv-0003ej-Qb for 36850@debbugs.gnu.org; Fri, 02 Aug 2019 09:09:06 -0400 Original-Received: by mail-wm1-f68.google.com with SMTP id p74so67882789wme.4 for <36850@debbugs.gnu.org>; Fri, 02 Aug 2019 06:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=3kypoMM0PXVJP6TsyMkbT9fbKYYic4oTZ155Q3QNwEE=; b=bjpa+76o+X4FpK652lVMEY3mzf0ZZJkVOY9SsIbmoammO3jtYKfSINxeXj+nerqbez 7KzAbh4bERQjNlI4gXx7T1HYkdwB6qt9bU12cS0EzxklJm05Mmt/MrsOb4iuj44bvyzH aYTPcYDla9fDcVzoeNW7bVkfn47N+f9KPWrUnbAGgX63oCfZ6++JNFG3XGLvfa9brKR2 qSEsNXn8n2laz5LWLyG1hpcAKGnj1/97EvVJK+uOCVsDY/lld1nZj9H7n80+clpObqjy Mx+/Y+x/gHIlk3bkUUNy9qTWuhqR/si1YShlh94WyMOE2n/Umf0OrwiXIozJ/5rJsNzP ySsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=3kypoMM0PXVJP6TsyMkbT9fbKYYic4oTZ155Q3QNwEE=; b=aCJTRi3vFuyGzLDZMmL2D43l94SB/mCIYsiPjqdYrtRrhWbaeT3CzgjPMrjXEY7PA/ /6isRhG+QpEnE5y6USctgzg640PQcjDTUtVx35PFotuDdAeyIl9Em13o/WavT8gSHFGu 5AH1DUBw6sqI5NV/aNMFrnZ0cGy10+hXe65hVamjFDLcC1Vc91h8oJtjp6qNTrEG5D8B Ds1NutJRh+GokBhN1RE3UJb6wVHtqdx1Jk2KplZlH7V1VJjuvW6JUu1ANXqSyYAN+I8M ZSDpHl/Y5hMkS8il7WPKY33WquXr9wD3sbwj2jAjx1Jrhwk7SfGYTqtVIfkpCh0vqleG 2vug== X-Gm-Message-State: APjAAAWdrxkdQJdjogPacg01u8UYV/UlwKorqrI5P1NUpS2DJucMpdcv ty3SrgNOr4WOcDyE36nAX2+AQg== X-Google-Smtp-Source: APXvYqyXaUcIMvApNP0lTmMdJLdiiRFa6/ApwhsYet2nEavtnhdWclNyzDdIKT79VEX9QUZcBva3Wg== X-Received: by 2002:a05:600c:230c:: with SMTP id 12mr4375296wmo.166.1564751340026; Fri, 02 Aug 2019 06:09:00 -0700 (PDT) Original-Received: from localhost (adsl-131.91.140.89.tellas.gr. [91.140.89.131]) by smtp.gmail.com with ESMTPSA id z7sm73757669wrh.67.2019.08.02.06.08.58 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 06:08:59 -0700 (PDT) In-Reply-To: <8036io5cx5.fsf@felesatra.moe> (Allen Li's message of "Mon, 29 Jul 2019 22:06:30 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:164345 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable reassign 36850 emacs,gnus severity 36850 minor tags 36850 + patch quit Allen Li writes: > Attempting to customize nnmail-expiry-wait-function and selecting a > custom function results in the error: > > read: Symbol=E2=80=99s function definition is void: nnmail- Indeed, I don't understand why its custom :type was written that way. While looking at this, I noticed some room for clarification in the relevant docs. Are the following clarifications welcome and suitable for emacs-26? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-nnmail-expiry-wait-docs-and-custom-types.patch >From d0a0d10fff7e1310be63cc832ea6bcc7a0ff6784 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Fri, 2 Aug 2019 15:54:09 +0300 Subject: [PATCH] Fix nnmail-expiry-wait docs and custom :types * doc/misc/gnus.texi (Group Parameters, Expiring Mail): * lisp/gnus/gnus-cus.el (gnus-group-parameters): Clarify descriptions of nnmail-expiry, nnmail-expiry-wait, and nnmail-expiry-wait-function. * lisp/gnus/nnmail.el (nnmail-expiry-wait) (nnmail-expiry-wait-function): Clarify docstrings and fix custom :types (bug#36850). --- doc/misc/gnus.texi | 50 ++++++++++++++++++++++++------------------- lisp/gnus/gnus-cus.el | 8 +++---- lisp/gnus/nnmail.el | 35 +++++++++++++++--------------- 3 files changed, 50 insertions(+), 43 deletions(-) diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index dcba47aca0..32d98abd7e 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi @@ -2916,9 +2916,9 @@ Group Parameters If the group parameter has an element that looks like @code{(expiry-wait . 10)}, this value will override any @code{nnmail-expiry-wait} and @code{nnmail-expiry-wait-function} -(@pxref{Expiring Mail}) when expiring expirable messages. The value -can either be a number of days (not necessarily an integer) or the -symbols @code{never} or @code{immediate}. +settings (@pxref{Expiring Mail}) when expiring expirable messages. +The value can be either a number of days (not necessarily an integer), +or one of the symbols @code{never} or @code{immediate}. @item expiry-target @cindex expiry-target @@ -15878,40 +15878,46 @@ Expiring Mail @vindex nnmail-expiry-wait The @code{nnmail-expiry-wait} variable supplies the default time an -expirable article has to live. Gnus starts counting days from when the -message @emph{arrived}, not from when it was sent. The default is seven -days. +expirable article has to live. The value of this variable can be +either a number of days (not necessarily an integer), or one of the +symbols @code{immediate} or @code{never}, meaning an article is +immediately or never expirable, respectively. -Gnus also supplies a function that lets you fine-tune how long articles -are to live, based on what group they are in. Let's say you want to -have one month expiry period in the @samp{mail.private} group, a one day -expiry period in the @samp{mail.junk} group, and a six day expiry period -everywhere else: +Gnus starts counting days from when the message @emph{arrived}, not +from when it was sent. The default is seven days. @vindex nnmail-expiry-wait-function +The @code{nnmail-expiry-wait-function} variable lets you fine-tune how +long articles are to live, based on what group they are in. When set +to a function, its returned value, if non-@code{nil}, overrides that +of @code{nnmail-expiry-wait}. Otherwise, the value of +@code{nnmail-expiry-wait} is used instead. + +For example, let's say you want to have a one month expiry period in +the @samp{mail.private} group, a one day expiry period in the +@samp{mail.junk} group, and a six day expiry period everywhere else. +This can be achieved as follows: + @lisp (setq nnmail-expiry-wait-function (lambda (group) - (cond ((string= group "mail.private") + (cond ((string= group "mail.private") 31) - ((string= group "mail.junk") + ((string= group "mail.junk") 1) - ((string= group "important") + ((string= group "important") 'never) - (t + (t 6)))) @end lisp The group names this function is fed are ``unadorned'' group names---no @samp{nnml:} prefixes and the like. -The @code{nnmail-expiry-wait} variable and -@code{nnmail-expiry-wait-function} function can either be a number (not -necessarily an integer) or one of the symbols @code{immediate} or -@code{never}. - -You can also use the @code{expiry-wait} group parameter to selectively -change the expiry period (@pxref{Group Parameters}). +As an alternative to the variables @code{nnmail-expiry-wait} or +@code{nnmail-expiry-wait-function}, you can also use the +@code{expiry-wait} group parameter to selectively change the expiry +period (@pxref{Group Parameters}). @vindex nnmail-expiry-target The normal action taken when expiring articles is to delete them. diff --git a/lisp/gnus/gnus-cus.el b/lisp/gnus/gnus-cus.el index fb8b300e35..574b0c6913 100644 --- a/lisp/gnus/gnus-cus.el +++ b/lisp/gnus/gnus-cus.el @@ -140,10 +140,10 @@ gnus-group-parameters :format "%v")) "\ When to expire. -Overrides any `nnmail-expiry-wait' and `nnmail-expiry-wait-function' -when expiring expirable messages. The value can either be a number of -days (not necessarily an integer) or the symbols `never' or -`immediate'.") +Overrides any `nnmail-expiry-wait' or `nnmail-expiry-wait-function' +settings when expiring expirable messages. The value can be +either a number of days (not necessarily an integer), or one of +the symbols `never' or `immediate'.") (expiry-target (choice :tag "Expiry Target" :value delete diff --git a/lisp/gnus/nnmail.el b/lisp/gnus/nnmail.el index 0699e81812..f8248b0190 100644 --- a/lisp/gnus/nnmail.el +++ b/lisp/gnus/nnmail.el @@ -157,32 +157,33 @@ nnmail-default-file-modes (defcustom nnmail-expiry-wait 7 "Expirable articles that are older than this will be expired. -This variable can either be a number (which will be interpreted as a -number of days) -- this doesn't have to be an integer. This variable -can also be `immediate' and `never'." +This variable can be either a number of days (not necessarily an +integer), or one of the symbols `immediate' or `never', meaning +an article is immediately or never expirable, respectively. +For more granular control, see `nnmail-expiry-wait-function'." :group 'nnmail-expire - :type '(choice (const immediate) - (number :tag "days") - (const never))) + :type '(choice (const :tag "Immediate" immediate) + (const :tag "Never" never) + (number :tag "Days"))) (defcustom nnmail-expiry-wait-function nil - "Variable that holds function to specify how old articles should be before they are expired. -The function will be called with the name of the group that the expiry -is to be performed in, and it should return an integer that says how -many days an article can be stored before it is considered \"old\". -It can also return the values `never' and `immediate'. + "Function to determine how old articles should be before they are expired. +The function is called with the name of the group that the expiry +is to be performed in, and should return a value supported by +`nnmail-expiry-wait', which it overrides. If this variable is +nil, the value of `nnmail-expiry-wait' is used instead. E.g.: \(setq nnmail-expiry-wait-function - (lambda (newsgroup) - (cond ((string-match \"private\" newsgroup) 31) - ((string-match \"junk\" newsgroup) 1) - ((string-match \"important\" newsgroup) \\='never) - (t 7))))" + (lambda (group) + (cond ((string-match-p \"private\" group) 31) + ((string-match-p \"junk\" group) 1) + ((string-match-p \"important\" group) \\='never) + (t 7))))" :group 'nnmail-expire :type '(choice (const :tag "nnmail-expiry-wait" nil) - (function :format "%v" nnmail-))) + (function :tag "Custom function"))) (defcustom nnmail-expiry-target 'delete "Variable that says where expired messages should end up. -- 2.20.1 --=-=-= Content-Type: text/plain Thanks, -- Basil --=-=-=--