根据当前文件夹设置 Mutt 的默认保存文件夹

根据当前文件夹设置 Mutt 的默认保存文件夹

我想配置 Mutt,以便默认保存文件夹根据当前文件夹而变化:

  • 当阅读文件夹=account1/Unsorted=account1/Important下的任何其他子文件夹中的消息时=account1/,我希望默认保存文件夹(s按消息索引时建议的文件夹)为=account1/INBOX

  • 同样,对于 的子文件夹=account2/,我希望默认保存文件夹是=account2/INBOX等。

我该如何配置 Mutt 来做到这一点?

  • save-hook如果它有一种与文件夹名称匹配的方法(我认为没有),它似乎会很有用。
  • 如果它有一种设置保存文件夹的方法,它似乎folder-hook会很有用,但是没有可以用钩子设置的保存文件夹设置(有record,但那是用于传出消息的)。

答案1

更新:据报道,使用了以下两行

folder-hook +account1 unhook save-hook
folder-hook +account1 save-hook . +account1/INBOX

对每个帐户重复。


如您所知,Mutt 是通过.muttrc文件配置的。你看man muttrc,其他人的模式都在那里。我也没有在那里看到文件夹模式,但搜索save我在其他地方找到的

 Note that these expandos are supported in "save-hook", "fcc-hook" and "fcc-save-hook", too.

以及以上

              %b     filename of the original message folder (think mailbox)
              %B     the list to which the letter was sent, or else the folder name (%b).
              %O     original  save  folder where mutt would formerly have stashed the message: list name or
                     recipient name if not sent to a list

其中一些可能会被使用,但我不知道patterns如何以任何方式匹配固定字符串而不是消息。


使用 can make procmail(或任何扰乱您收到的邮件的内容)添加自定义标题行并使用-h它进行测试。


我认为你的解决方案将使用

     folder-hook [!]regexp command
              When  mutt enters a folder which matches regexp (or, when regexp is preceded by an exclamation
              mark, does not match regexp), the given command is executed.

              When several folder-hooks match a given mail folder, they are executed in the order  given  in
              the configuration file.

可能是这样的

folder-hook account1 unhook *
folder-hook account1 save-hook ~A   =account1/INBOX
or
folder-hook account1      save-hook  ".*"  =account1/INBOX
folder-hook ^=account1.*  save-hook  ........... ???


UPDATE: Reportedly, the following two lines were used as solution (and seem to work)
folder-hook +account1 unhook save-hook
folder-hook +account1 save-hook . +account1/INBOX
# repeated for each separate account
# Note: We know the documentation for folder-hook says "regexp", but using +account (for some given account) seems to work too for whatever reason

最近的不太可能save-hook优先,所以我添加了 unhook (将其更改为unhook save-hook或任何您测试的工作)

    unhook [ *  | hook-type ]
              This  command will remove all hooks of a given type, or all hooks when "*" is used as an argu-
              ment.  hook-type can be any of the -hook commands documented above.


以下信息可能对于具有更简单需求并以某种方式来到此页面的其他用户有用:

     save_address
              Type: boolean
              Default: no

              If set, mutt will take the sender's full address when choosing a default folder for  saving  a
              mail. If $save_name or $force_name is set too, the selection of the Fcc folder will be changed
              as well.

      save_name
              Type: boolean
              Default: no

              This  variable  controls how copies of outgoing messages are saved.  When set, a check is made
              to see if a mailbox specified by the recipient address exists (this is done by searching for a
              mailbox  in  the  $folder  directory with the username part of the recipient address).  If the
              mailbox exists, the outgoing message will be saved to that mailbox, otherwise the  message  is
              saved to the $record mailbox.

              Also see the $force_name variable.

An example:
set save_address=yes


请告诉我和其他人你是如何解决这个问题的。

相关内容