Lumail - The console email client

Lua primitives: on_reply_transform_subject()

NOTE: Lumail-legacy has been superseded by Lumail 2.x, which has a wholly unified Lua API.

When you reply to an email traditionally the subject of your reply becomes:

Re: your mail.

i.e. A "Re:" prefix is added, if not already present.

This function is called when you hit reply() on an existing message, and allows you to transform the subject. The default implementation behaves as you would expect, for example:

-- If the function "on_reply_transform_subject" is defined it will
-- be invoked when a message is replied to.
-- The intention is that you return an updated subject.
-- Here we just add "Re: " if missing, stripping any existing chain
-- of "Re: Re: Re: foo.."
function on_reply_transform_subject( sub )

   -- Empty subject?  Setup a default.
   if ( string.len( sub ) < 1 ) then
      return "No subject"

   -- Remove (repeated) "Re:" from the start of string.
   while( string.find(sub, "^Re:" ) ) do
      sub = string.gsub( sub, "^[rR][eE]:[ \t]+", "" );

   -- Add the prefix.
   return "Re: " .. sub



This function has been available since version 0.21.