0

我已经覆盖erc-match-message了函数 erc-mode 并将它放在我的 .emacs 文件中erc

error in process filter: Wrong number of arguments: (lambda (match-type
nickuserhost msg notification) (interactive) (if (and (eq match-type
(quote current-nick)) (not notification)) (progn (async-exec-command 
"mpg123 -q /home/kuba/Pobrane/beep-8.mp3") (notify "ERC" msg)))), 3

我的钩子函数如下所示:

(defun mention-notify (match-type nickuserhost msg notification)
  (interactive)
  (if (and (eq match-type 'current-nick)
           (not notification))
      (progn
        (async-exec-command "mpg123 -q /home/kuba/Pobrane/beep-8.mp3")
        (notify "ERC" msg))))

(一个额外的notification参数)当我erc-match-message使用eval-last-sexp.

我有这个

(require 'erc)
(defun erc-match-message ()
   ;; my overwritten function that's defined in erc.el
   ...)
(defun mention-notify (match-type nickuserhost msg notification)
   ;; notify hook handler
   ...)
(defun irc ()
  "Connect to the freenode"
  (interactive)
  (erc :server "barjavel.freenode.net"
       :port 6667
       :nick "jcubic"
       :password "<PASS>"))

(global-set-key (kbd "C-c i")  'irc)

为什么 .emacs 文件中定义的函数不会覆盖使用 require 添加的外部文件中定义的函数?

4

2 回答 2

1

erc-match-message实际上是在 中定义的erc-match.el,之后可能会以某种方式加载。尝试(require 'erc-match)在重新定义之前添加。

于 2012-07-01T18:14:43.570 回答
1

我建议您使用defadvice来更改函数的定义。即使在定义函数之前,它也会正确处理您遇到更改定义的情况。

于 2012-07-02T15:08:01.113 回答