如何编写一个函数,当有人在 Emacs 的 irc 上提及我时通知我
我有这个功能
(defun mention-notify (match-type nickuserhost msg)
(interactive)
(if (and (eq match-type 'current-nick)
(eq (string-match "^-NickServ-" msg) nil) ;this is probably not needed
(eq (string-match "^\\*\\*\\*" msg) nil))
(progn
(shell-command "mpg123 -q /home/kuba/Pobrane/beep-8.mp3")
(notify "ERC" msg))))
(add-hook 'erc-text-matched-hook 'mention-notify)
,但它执行命令,即使它的消息从 ***
开始。我在这里做错了什么?这个函数应该是什么样子的?
我阅读了该页面,但它只显示了如何发送所有提及的通知,甚至从服务器发送通知。例如:
*** #
或
*** jcubic 已将 jcubic 的模式更改为 +i
看来当我检查时对于 'current-nick
- msg 不是整个消息,而是包含我的昵称的子字符串,我尝试检查关键字而不是当前昵称,并检查我总是使用的昵称是否出现在文本中,但是使用关键字根本不起作用。
I have this function
(defun mention-notify (match-type nickuserhost msg)
(interactive)
(if (and (eq match-type 'current-nick)
(eq (string-match "^-NickServ-" msg) nil) ;this is probably not needed
(eq (string-match "^\\*\\*\\*" msg) nil))
(progn
(shell-command "mpg123 -q /home/kuba/Pobrane/beep-8.mp3")
(notify "ERC" msg))))
(add-hook 'erc-text-matched-hook 'mention-notify)
But it execute command even it message start from ***
. What I'm doing wrong here? How this function should look like?
I read that page but it only show how to send notification for all mentions, even from server. like:
*** Users on #<chanel>: jcubic...
or
*** jcubic has changed mode for jcubic to +i
It seams that when I check for 'current-nick
- msg is not the whole message but substring containing my nick, I try to check for keyword instead of current-nick and check if my nick that I always use appear in the text but using keyword doesn't work at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能还想看看 Sauron:
http://www.emacswiki.org/emacs/Sauron
You might also want to look at Sauron:
http://www.emacswiki.org/emacs/Sauron
我将 erc-match-message 函数从 erc.el 文件复制到我的 .emacs 文件中,并添加了一个标志来挂钩
如果消息是 erc 系统消息 - 以
** 开头则设置最后一个标志*
所以现在我可以在我的钩子中检查这个标志UPDATE 我也不想接收来自 -NickServ- 的消息,所以我添加了这个
I copied
erc-match-message
function from erc.el file into my .emacs file and I added one flag to hooklast flag is set if message is erc system message - starts with
***
so now I can check this flag in my hookUPDATE I also didn't want to recive message from -NickServ- so I add this
在 Google 上快速搜索 " erc提及通知” 产生一堆示例代码来完全执行您的操作想要。
A quick google search for "erc mention notify" yields a bunch of example code to do exactly what you want.