如何生成动态“回复​​:”基于“Message-ID:”? [+细节] [英] How to generate dynamic "Reply-To:" based on "Message-ID:"? [+detail]

查看:137
本文介绍了如何生成动态“回复​​:”基于“Message-ID:”? [+细节]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据创建的邮件的Message-ID ,您如何在emacs / gnus中生成动态回复​​:(和发件人:)头文件?我想使用外部(perl)脚本根据Messaged-ID:标题生成一个动态的 + detail 部分。

user+detail@example.net

我设法创建一个标题,内容是由我的外部脚本生成的。脚本获取usenet组名作为命令行参数。我想传递消息ID值。

I have managed to create a header with content generated by my external script. The script gets usenet group name as command line parameter. I would like to pass it the message-id value too.

我目前的代码

〜/ .emacs:

My current code
~/.emacs :

'(gnus-posting-styles ("^pl\\.test$" ("Reply-To" message-make-reply-to)))

〜/ .gnus

(defun message-make-reply-to()
  (my-script ".../reply-to.pl" (message-fetch-field "Message-Id")))

(defun my-script(path &optional param) ....

问题:脚本没有收到message-id作为参数(我的脚本正确显示设置参数)

The problem: the script does not receive message-id as its parameter (my-script gets correctly explicitly set parameter)

推荐答案

;; Make sure the Message-ID header is present in newly created messages
(setq message-generate-headers-first '(Message-ID))

;; Prevent emacs from resetting the Message-ID before the message is sent.
(setq message-deletable-headers
      (remove 'Message-ID message-deletable-headers))

(setq gnus-posting-styles
      '(("^pl\\.test$"
         ("Reply-To" '(message-make-reply-to)))))

请注意在 message-make周围的附加报价和括号-reply到。这个解释是这个函数是在不同的时间运行的,这取决于它是作为一个符号还是一个引用的s表达式。

Note the additional quote and parentheses around message-make-reply-to. The explanation for this is that the function is run at different times, depending on whether it's given as a symbol or as a quoted s-expression.


  • 如果作为符号给出,当lambda函数添加到 message-setup-hook 时,它将运行。在 message-mode-hook 中,即在创建新缓冲区并切换到消息模式之后, 。这样做的原因是在创建lambda函数时引用了一些值得注意的值。

  • 如果以引用的sexpr作为引用,评估将被延迟,直到缓冲区填满初始值为止。它接近在消息设置中运行的最后一个代码。

  • If given as symbol, it is run when a lambda function is added to message-setup-hook. That happens in a message-mode-hook, i.e. right after the new buffer is created and switched into message-mode. The cause for this is some wild quoting/unquoting of values during creation of the lambda function.
  • If given as a quoted sexpr, evaluation is delayed until after the buffer is filled with initial values. It is close to the last code which is run on message setup.

如果新标题应添加到每个新消息中, Reply-To 头也可以使用 message-header-setup-hook 设置。需要定义一个自定义钩子来为每个新消息添加标题。

In cases where the new header should be added to every new message, the Reply-To header can also be set using the message-header-setup-hook. A custom hook needs to be defined to add the header for each new message.

(defun reply-to-message-header-setup-hook ()
  (let* ((msg-id (message-fetch-field "Message-ID"))
         (reply-to (my-script ".../reply-to-pl" msg-id)))
    (message-add-header (concat "Reply-To: " reply-to))))

;; Call the hook every time a new message is created
(add-hook 'message-header-setup-hook 'reply-to-message-header-setup-hook)

;; Make sure the Message-ID header is present in newly created messages
(setq message-generate-headers-first '(Message-ID))

这篇关于如何生成动态“回复​​:”基于“Message-ID:”? [+细节]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆