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

From: <[email-masked]>
Date: Wed, 26 Feb 2025 13:16:38 -0500

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.