如何根据创建的消息的消息ID 在emacs / gnus中生成动态“Reply-To:”(和“From:”)标头?我想使用外部(perl)脚本根据“Messaged-ID:”标题生成动态+detail
部分。
user+detail@example.net
我已设法创建一个包含由我的外部脚本生成的内容的标头。该脚本将usenet组名称作为命令行参数。我也想传递message-id值。
我当前的代码
〜/ .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作为参数(my-script正确显式设置参数)
答案 0 :(得分:4)
;; 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-to
附近的其他引号和括号。对此的解释是函数在不同的时间运行,具体取决于它是作为符号还是作为带引号的s表达式给出。
message-setup-hook
时运行。这发生在message-mode-hook
中,即在创建新缓冲区并切换到message-mode
之后。造成这种情况的原因是在创建lambda函数期间有一些疯狂的引用/取消引用值。gnus-posting-styles
)如果应将新标头添加到每个新邮件中,也可以使用Reply-To
设置message-header-setup-hook
标头。需要定义自定义挂钩以为每条新消息添加标头。
(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))