Hi there,
I'm current stuck on advicing the `magit-status' and have no idea what is wrong.
Here's my program:
(defadvice magit-status (after york (dir) activate)
(message "bbb"))
At the end of `magit-status' function I insert another "message":
(defun magit-status (dir)
"Open a Magit status buffer for the Git repository containing
DIR. If DIR is not within a Git repository, offer to create a
Git repository in DIR.
Interactively, a prefix argument means to ask the user which Git
repository to use even if `default-directory' is under Git control.
Two prefix arguments means to ignore `magit-repo-dirs' when asking for
user input."
(interactive (list (if current-prefix-arg
(magit-read-top-dir
(> (prefix-numeric-value current-prefix-arg)
4))
(or (magit-get-top-dir default-directory)
(magit-read-top-dir nil)))))
(magit-save-some-buffers)
(let ((topdir (magit-get-top-dir dir)))
(unless topdir
(when (y-or-n-p (format "There is no Git repository in %S. Create one? "
dir))
(magit-init dir)
(setq topdir (magit-get-top-dir dir))))
(when topdir
(let ((buf (or (magit-find-status-buffer topdir)
(generate-new-buffer
(concat "*magit: "
(file-name-nondirectory
(directory-file-name topdir)) "*")))))
(funcall magit-status-buffer-switch-function buf)
(magit-mode-init topdir 'magit-status-mode #'magit-refresh-status)))
;; insert message here
(message "aaa")))
But when I run "M-x magit-status", I got the error:
"call-interactively: Symbol's value as variable is void: magit-status"
I have no idea why advicing `maigt-status' gives me this error, and the strange
thing is that sometimes it worked, but most of the time it doesn't. Can anybody
here give me an explanation on this?
Thanks,
York