Problem advicing `magit-status'

101 views
Skip to first unread message

York Zhao

unread,
Jun 19, 2012, 10:44:11 AM6/19/12
to magit
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

PJ Weisberg

unread,
Jun 20, 2012, 12:22:18 AM6/20/12
to York Zhao, magit
On Tue, Jun 19, 2012 at 7:44 AM, York Zhao <gtdpl...@gmail.com> wrote:
> Hi there,
>
> I'm current stuck on advicing the `magit-status' and have no idea what is wrong.
> Here's my program:

It works fine for me. Try doing 'M-x toggle-debug-on-error' before
you run magit-status. The backtrace might at least give a hint where
the error is coming from.

-PJ

Gehm's Corollary to Clark's Law: Any technology distinguishable from
magic is insufficiently advanced.

York Zhao

unread,
Jun 20, 2012, 11:08:47 AM6/20/12
to PJ Weisberg, magit
> It works fine for me.  Try doing 'M-x toggle-debug-on-error' before
> you run magit-status.  The backtrace might at least give a hint where
> the error is coming from.

Thank you very much for the reply. I did try `toggle-debug-on-error' but didn't
help much, however, I toggled debug on again before running "M-x magit-status"
and I didn't get the original error message "call-interactively: Symbol's value
as variable is void: magit-status", instead, I got:

Debugger entered--Lisp error: (void-variable magit-status)
magit-status("<path to some repository>")
call-interactively(magit-status nil nil)

When I first wrote my advicing function everything worked perfectly, but the
next day it no longer worked. Afterwards it worked for one or two times, but
most of the time it didn't work. Therefor, could you try a few more times?

Thanks,
York
Reply all
Reply to author
Forward
0 new messages