Subject: bug#76595: closed (Re: bug#76595: 29.4; Problem getting RMAIL to detect a change to the value of `rmail-movemail-program'.)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 01 Mar 2025 13:48:03 +0000

Your bug report

#76595: 29.4; Problem getting RMAIL to detect a change to the value of `rmail-movemail-program'.

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
76595: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76595
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#76595: 29.4; Problem getting RMAIL to detect a change to the value of `rmail-movemail-program'.
From: Eli Zaretskii <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Sat, 01 Mar 2025 15:47:44 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Wed, 26 Feb 2025 15:37:59 -0500
> From:  <[email-masked]>
> Cc: [email-masked]
> 
> > Date: Wed, 26 Feb 2025 21:33:04 +0200
> > From: Eli Zaretskii <[email-masked]>
> > 
> > > From: <[email-masked]>
> > > 
> > > Emacs Maintainers,
> > > 
> > >   There is a problem with getting Emacs/Rmail to use the
> > > Mailutils version of ‘movemail’ if the value of
> > > ‘rmail-movemail-program’ is set after Rmail has been
> > > started.
> > 
> > To avoid these complications, either customize rmail-movemail-program
> > in your init file, so it is already set to the value 'mailutils' when
> > you start Rmail, or simply remove the version of 'movemail' that came
> > with Emacs, so that the only 'movemail' Rmail can find is that from
> > Mailutils.
> > 
> 
> Thank you for your response.
> 
> Yes, I understand how to resolve the problem (having spent a
> considerable amount of time tracking it down while assuming
> that I had made numerous mistakes).  The reason I sent in
> the report is that there is an error in Emacs, either in the
> documentation of how to use ‘movemail’ or in the rmail.el
> file, depending on what the maintainers want to change.
> 
> The problem as it is now is that the behavior of Emacs and
> the requirements for using movemail are not sufficiently
> well documented.  Either or both could be fixed.  If the
> code is not going to be changed, then the Emacs manual
> should be updated to document that a change to
> ‘rmail-movemail-program’ may not take effect until Emacs is
> restarted.
> 
> This is necessary so that new users of Rmail do not
> encounter the problem that I described in the problem
> report.  
> 
> A better solution might be to change the manual to say that
> M-x rmail [RET] is required after changing
> ‘rmail-movemail-program’, and to change (defun rmail ...) to
> (re-)initialize ‘rmail-movemail-variant-in-use’ to nil, but
> that is a choice for you maintainers.
> 
> Possibly, the following code could be moved into (defun
> rmail ...), also:
> 
> ;; Call for effect, to set rmail-movemail-program (if not set by the
> ;; user), and rmail-movemail-variant-in-use. Used by various functions.
> ;; I'm not sure if M-x rmail is the only entry point to this package.
> ;; If so, this can be moved there.
> (rmail-movemail-variant-p)

Thanks, I decided to document how to customize this variable safely.

I'm therefore closing this bug.

Subject: 29.4; Problem getting RMAIL to detect a change to the value of `rmail-movemail-program'.
From: <[email-masked]>
To: [email-masked]
Date: Wed, 26 Feb 2025 13:16:38 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs Maintainers,

  There is a problem with getting Emacs/Rmail to use the
Mailutils version of ‘movemail’ if the value of
‘rmail-movemail-program’ is set after Rmail has been
started.

- Start Emacs with `emacs -Q'.

- Verify that the user option `rmail-movemail-program' is set to nil
  (the default).

- Start Rmail: M-x rmail

- Check the value of the variable `rmail-movemail-variant-in-use',
  which is set in the function `rmail-movemail-variant-p':

  C-h v rmail-movemail-variant-in-use [RET]

  Confirm that its values is 'emacs.

- Quit Rmail: Type 'q' in the RMAIL buffer.

- Kill the RMAIL buffer: C-x k RMAIL [RET]

- Set the value of the user option `rmail-movemail-program' to the
  absolute path to the Mailutils `movemail' program.

  Optionally, set the value of user option
  `rmail-primary-inbox-list' to a mailbox with the `pops' protocol,
  that is, "pops://USERNAME:[PASSWORD]@HOSTNAME:[PORT]".

- Set a breakpoint in the function `rmail-movemail-variant-p'.

- Start Rmail with: M-x rmail [RET]

- Stepping through `rmail-movemail-variant-p', note that the value of
  the variable `rmail-movemail-variant-in-use' is 'emacs.  This
  prevents the function from setting `rmail-movemail-variant-in-use'
  to 'mailutils.  This, in turn, prevents Rmail from using
  `rmail-movemail-program' to retrieve mail from the location(s) in
  `rmail-primary-inbox-list'.

- Without setting `rmail-movemail-variant-in-use' manually, it is
  necessary for a user to exit Emacs and restart it, then set the
  value of `rmail-movemail-program' to the absolute path to the
  Mailutils `movemail' program *before* starting Rmail.

Possibly, the fix for this is to change the code in the function
`rmail-movemail-variant-p' to check for a non-nil value for the
user option `rmail-movemail-program' (which is done later in the
call to the function `rmail-autodetect').

Or, in the function ‘rmail’, code could be added to reset the value
of ‘rmail-movemail-variant-in-use’ to nil, and then update the
description of what to do when `rmail-movemail-program' is set or
changed (that is, re-run ‘rmail’ command).

>From (info "(emacs) Movemail"):

    The variable ‘rmail-movemail-program’ controls which version
    of ‘movemail’ to use.  If that is a string, it specifies the
    absolute file name of the ‘movemail’ executable.  If it is
    ‘nil’, Rmail searches for ‘movemail’ in the directories listed
    in ‘rmail-movemail-search-path’, then in ‘exec-path’
    (*note Shell::), then in ‘exec-directory’.

At a minimum, it seems that this variable should be reset
each time the command M-x rmail [RET] is given.  This would
not affect the run-time behavior of the `g' command
(`rmail-get-new-mail') in the RMAIL buffers, but would add
to the (re-)start time of RMAIL.

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.