【问题标题】:rewrite outgoing messages/posts by external program/filter通过外部程序/过滤器重写传出消息/帖子
【发布时间】:2015-10-05 09:03:15
【问题描述】:

我想通过外部过滤器重写完全组合的 emacs-gnus 消息/帖子(标题和正文) (外部程序/脚本,STDIN 到 STDOUT)。
怎么做?

【问题讨论】:

    标签: email emacs elisp emacs24 gnus


    【解决方案1】:

    将你的函数添加到message-send-hook:

    (add-hook 'message-send-hook 'my-message-rewrite)
    (defun my-message-rewrite ()
      "Pipe the current message buffer through the command and replace it with the output."
      (shell-command-on-region (point-min) (point-max)
                               "my command line with args"
                               t t))
    

    显然您不必求助于 shell 命令,您的 lisp 函数可以做的更多。

    注意事项:

    1. 这个钩子“很早就”运行;您可能想改用 message-send-mail-hook - 它运行“非常晚”。

    2. 让我重申一下:你在这里逆流游泳。你确实想要这样做。请在 emacs.SE 上提出一个单独的问题,描述您的 perl 脚本的作用,您将看到使用 Lisp 完成它是多么容易。

    【讨论】:

    • 我的 perl 技能比我的 (e)lisp 技能要好得多 :-)
    • 曾几何时我也说过类似的话。从那以后我学得更好。 Lisp 功能强大得多,更易于使用、调试、开发和学习!
    • 脚本似乎收到了onlt消息体。我想重写完整的消息(标题和正文) - 抱歉不够精确。
    • 对不起,我希望经典的“空行”作为标题/正文分隔符。 Emacs-gnus 使用不同的东西:-)
    • 确实如此,这也是不做你正在做的事情的另一个原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    • 2013-03-04
    • 2020-12-17
    • 2021-03-17
    • 2017-09-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多