RenWenshan / emacs-moz-controller

Control Firefox from Emacs
GNU General Public License v3.0
70 stars 8 forks source link

moz-controller-get-current-url returns nil #4

Closed GregorZattler closed 8 years ago

GregorZattler commented 10 years ago

I set up emacs and Iceweasel with moz-repl and emacs-moz-controller. According to the mode line the current buffer is in MozCtrl minor mode. But "C-c m l" does nothing.

I am able to telnet from the terminal to the repl and issue "gBrowser.contentWindow.location.href" and it actually returns the currents tabs url.

But evaluating "(moz-controller-get-current-url)" in the MozCtrl minor mode buffer returns nil.

While

(comint-send-string (inferior-moz-process) "getBrowser().mTabContainer.advanceSelectedTab(-1, true);")

works

(comint-send-string (inferior-moz-process) "'#moz-controller-get-current-url# ' + gBrowser.contentWindow.location.href;" )

returns nil. Like

(comint-send-string (inferior-moz-process) "gBrowser.contentWindow.location.href;" )

which also returns nil.

My elisp is minimal therefore I do not see how the expected return value should end up in the kill ring at all?

RenWenshan commented 10 years ago

Thanks for reporting this issue. Can you M-x run-mozilla to get the MozRepl in Emacs, then paste the execute the following expression to see whether it returns the expected result (aka, #moz-controller-get-current-url# http://...

'#moz-controller-get-current-url# ' + gBrowser.contentWindow.location.href;

GregorZattler commented 10 years ago

Hi Wenshan,

Yes, this works:

repl> '#moz-controller-get-current-url# ' + gBrowser.contentWindow.location.href; "#moz-controller-get-current-url# about:home"

later:

repl> '#moz-controller-get-current-url# ' + gBrowser.contentWindow.location.href; "#moz-controller-get-current-url# https://www.google.de/?gfe_rd=cr&ei=zAw3VKyNBofo-gbohYHIBg"

Ciao, Gregor

-... --- .-. . -.. ..--.. ...-.-

RenWenshan commented 10 years ago

@GregorZattler that looks right, could you please update to the latest moz-controller and try again. After pressing "C-c m l", the URL should show up in the mini-buffer.

GregorZattler commented 10 years ago

Hi Wenshan,

Yes, now it works. This will be a very helpful feature. Thanks for your help.

Ciao, Gregor

-... --- .-. . -.. ..--.. ...-.-

GregorZattler commented 10 years ago

Hi Ren,

there is still an issue, moz-controller-get-current-url works, but only sometimes. Perhaps this is related to my usage of several iceweasel profiles. I start iceweasel with one profile, tart the moz-repl, close this profile, start another one, start moz-repl and at least in this situation moz-controller-get-current-url returns nil.

This is with a fresh checkout of moz-controller, emacs version 24.3.94.7. For the attached screen shot moz-controller-get-current-url-works-but-kill-ring-empty I started emacs like so: emacs-snapshot -Q -l ~/.emacs.d/el-get/moz-repl/moz.el -l ~/src/emacs-moz-controller/moz-controller.el

Thanks for looking into this. Gregor P.S.: I hope I got the salutation right and "Ren" is your given name.

RenWenshan commented 10 years ago

@GregorZattler If there are multiple instances of Firefox running, *MozRepl* would communicated with the one started first.

But this is not your case, because you have #moz-controller-get-current-url# about:blank" in *MozRepl*, which means the command ran successfully and got the correct result.

So I guess the problem occurred in the filter function moz-controller-repl-filter.

I'll try to reproduce the problem you're having.

P.S.: Wenshan is my given name