Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make firefox compatible #130

Merged
merged 2 commits into from Nov 26, 2017
Merged

Make firefox compatible #130

merged 2 commits into from Nov 26, 2017

Conversation

dakra
Copy link
Contributor

@dakra dakra commented Jul 25, 2017

So here is the fixes from the other PR #129 rebased and without the formatting changes.
You can pick and choose any commit you want if you want to update in smaller steps.
It's all not heavily tested. More a 'works for me in Firefox', so please test first.

manifest.json Outdated
"options_page": "fancy-settings/source/index.html",
"options_ui": {
"page": "fancy-settings/source/index.html",
"browser_style": true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems brower_style is Firefox only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see only browser_style is not supported which is not really needed anyway. https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/options_ui#Browser_compatibility

@@ -11,7 +11,7 @@ function localMessageHandler(msg, port) {

// Test for the presence of an Edit Server
function test_server() {
var port = chrome.extension.connect();
var port = browser.runtime.connect();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks on Chrome: Uncaught ReferenceError: browser is not defined
at Object.test_server (settings.js:14)
at Object. (mootools-core.js:1436)
at Array.forEach ()
at Function.forEach (mootools-core.js:211)
at Array.each (mootools-core.js:324)
at Object.fireEvent (mootools-core.js:1434)
at Object.wrapper.extend.$owner (mootools-core.js:1316)
at Object. (setting.js:161)
at HTMLInputElement.defn (mootools-core.js:3703)

So maybe this isn't as cross-platform as it should be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stsquad
Copy link
Owner

stsquad commented Jul 25, 2017

@dakra I'm afraid I can't merge this as it breaks in Chrome. I'm quite happy to make the extension cross platform if we can but I can't break it's working case in the process. Please test on both Chrome and Firefox on your next PR.

@dakra
Copy link
Contributor Author

dakra commented Jul 25, 2017

@stsquad I make some shims for the browser calls.
Unfortunately I was not really able to test it in chrome.
I tried to shim it (like now), then I tried mozillas
webextension-polyfill but
all didn't work till I realised even if I checkout your master branch it doesn't
really work (button not appearing). So maybe you check quick?!

Thanks!

@stiv-sigmal
Copy link

So, how can we use it if Firefox? Any *.xpi files? Any topics on addons.mozilla.org?

@stsquad
Copy link
Owner

stsquad commented Nov 12, 2017

I've just tested the master branch on Chrome and it still works. I fixed a minor typo that was throwing up a warning. However with this branch merged all functionality is lost (edit button goes away). Errors include:

 Uncaught ReferenceError: browser is not defined
 Uncaught ReferenceError: browser is not defined

@stiv-sigmal
Copy link

Is this obstacle to make two different, bun similar extentions for chrome and firefox? To anyone: you, Dakra? As far as I understand, Dakra have made extention for firefox for self, so he has working xpi file. Am I wrong? Or may be I just shoud write direct to Dakra's repository?

@stsquad
Copy link
Owner

stsquad commented Nov 12, 2017

@stiv-sigmal I'm sure it's possible but I'm waiting for a tested PR that doesn't break the existing functionality.

@dakra
Copy link
Contributor Author

dakra commented Nov 13, 2017

@stiv-sigmal @stsquad I'll check again the next few days and try to figure out
why chrome is not working.

The "problem" is only that I don't use chrome and don't want to spend too much
time on fixing it so we have a single version that works in both.

Anyway, I'll upload the xpi I'm using daily for Firefox (I'm writing this in
Emacs) so you can at least test it @stiv-sigmal

@dakra
Copy link
Contributor Author

dakra commented Nov 13, 2017

@stsquad @stiv-sigmal ok, I rebased to current master and fixed some things. (now I make a correct typeof browser === 'undefined' check).

In my quick test it worked fine in chrome as well as in firefox.
Attached is the zip for Firefox for @stiv-sigmal
edit_with_emacs-1.14.zip

Since it's unsigned you have to set
xpinstall.signatures.required to false in about:config
(which only works in the developer edition or nightly).

For this zip I added

"applications": {
    "gecko": { "id": "edit-with-emacs@1.14" }
}

to mainfest.json but I think if you upload it to amo it's not necessary (not sure though)

@@ -56,7 +56,11 @@
sendResponse({});
}

chrome.extension.onRequest.addListener(processRequest);
// Check for Firefox compatibility
if (typeof browser === 'undefined') {
Copy link
Owner

@stsquad stsquad Nov 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's obviously wrong.

Fixed now.

@zw963
Copy link

zw963 commented Nov 26, 2017

Cool, is there any release date for this feature ?

@stsquad stsquad merged commit 94ac1ba into stsquad:master Nov 26, 2017
@stsquad
Copy link
Owner

stsquad commented Nov 26, 2017

@zw963: well it's merged now - if @dakra is willing to run a test package for firefox I'll tag a release. It's been a while ;-)

@dakra
Copy link
Contributor Author

dakra commented Nov 27, 2017

@stsquad Thanks, good to hear :)

@stiv-sigmal @zw963 Here's the latest version.
I self-signed it so you can easily install it without having to toggle any config flags or having to use Firefox nightly.
(I had to zip it because github doesn't allow me to attach xpi extensions. So unzip and install in firefox)
edit_with_emacs-1.14-an+fx.xpi.gz

It works for me but I guess not very well tested with different setups.
Please try it out and report :)

@zw963
Copy link

zw963 commented Nov 27, 2017

Hi, It seem like worked for Firefox 48 developer Edition, but have some limit:

  • if not exist a emacs frame opened, could not create a new frame to edit it when click.
  • edit button is missing in textarea (tested when reply this issue in github)
  • when exit current frame when press Ctrl-X Ctrl-S, will invoke edit frame again, repeatly.
    I could not exit this edit frame completely, even, when I first edit this reply
    in edit frame, after several times Ctrl-X Ctrl-S, what I edit in this edit sever
    is override by previous old content, cause many input missing.
  • when open edit buffer, seem like markdown font-lock is not render correct.

my emacs config

(require 'edit-server)
(setq edit-server-url-major-mode-alist '(
                                         ("github\\.com" . markdown-mode)
                                         ("ruby-china" . markdown-mode)
                                         ("gitlab" . markdown-mode)
                                         )
      edit-server-port "9293"
      )
(when (and (require 'edit-server nil t) (daemonp))
  (edit-server-start)
  (add-hook 'edit-server-start-hook (lambda ()
                                      (local-set-key [(control c) (return)] 'org-ctrl-c-ret)
                                      (local-set-key [(control c) (?\r)] 'org-ctrl-c-ret)
                                      ))
  )

extension config

show edit button. (not work)
alt hotkey (work)

@zw963
Copy link

zw963 commented Nov 27, 2017

Seem like when I press Ctrl-x Ctrl-s, emacs not response with correct response,
because my textarea is still keep background yellow.
when I move mouse cursor upon little icon in toolbar, I can see:
"Awaiting edit request in focus"

@zw963
Copy link

zw963 commented Nov 27, 2017

emacs 25.3.1

Thanks

@gregoa
Copy link

gregoa commented Nov 27, 2017

@dakra seems to work for me, thanks! tested on two machines, both running firefox 57, and on both tested at https://paste.debian.net

  1. windows 10, server from http://opencoder.net/edit-server, editor set to notepad++.exe
  2. debian unstable, both with http://opencoder.net/edit-server and pycl.py, editor: a wrapper that calls xterm -e joe

the only minimal glitch I noticed is that the edit button is placed a bit far from the textarea, but that's only cosmetical.

@stsquad
Copy link
Owner

stsquad commented Nov 27, 2017

@zw963 those sound like issues with the edit-server. Where do you get your copy from?

@stsquad
Copy link
Owner

stsquad commented Nov 27, 2017

@gregoa the img button is now in a

which in theory should make it easier to position with CSS. However this is a little beyond my CSS skills at the moment.

@dakra
Copy link
Contributor Author

dakra commented Nov 28, 2017

if not exist a emacs frame opened, could not create a new frame to edit it
when click.

Hmm, that doesn't happen to me. I can just have the daemon running and
it always pops up a new frame.

edit button is missing in textarea (tested when reply this issue in github)

Oh, now that you say it, it's missing here as well.
I can see the edit button in all other <textarea> inputs though
and it works fine if I click the 'edit in emacs' button from the
toolbar. That's what I use most of the time.
Does it work on other sites?

when exit current frame when press Ctrl-X Ctrl-S, will invoke edit frame again, repeatly.
I could not exit this edit frame completely, even, when I first edit this reply
in edit frame, after several times Ctrl-X Ctrl-S, what I edit in this edit sever
is override by previous old content, cause many input missing.

You can save and close with 'C-c C-c' and discard with 'C-c C-k'.
'C-x C-s' updates the textarea with the current text.
Think the close and reopen of the emacs frame happens in chrome as
well @stsquad?!

when open edit buffer, seem like markdown font-lock is not render correct.

What does not correct mean?
Also I think for github and gitlab at least you want
to set your mode to gfm-mode instead of markdown-mode.

Thanks.

@zw963
Copy link

zw963 commented Nov 28, 2017

when open edit buffer, seem like markdown font-lock is not render correct.

What does not correct mean?
Also I think for github and gitlab at least you want
to set your mode to gfm-mode instead of markdown-mode.

Sorry, this issue seem like from markdown-mode.

if not exist a emacs frame opened, could not create a new frame to edit it
when click.

Hmm, that doesn't happen to me. I can just have the daemon running and
it always pops up a new frame.

It not worked for me. BTW: I use firefox and emacs on openSUSE 42.3.

@zw963 those sound like issues with the edit-server. Where do you get your copy from?

From this github project. current hash is: 43ec769

@stsquad
Copy link
Owner

stsquad commented Nov 29, 2017

@zw963 OK can you raise a separate bug for this. The C-x C-s save behaviour is a little hokey - basically we close the existing session to update the text area and then immediately re-open a new session to continue editing. You might find C-u M-x edit-server-start will give you more indication of what is going on.

@zw963
Copy link

zw963 commented Nov 29, 2017

@stsquad , hi, i add new issue for C-x C-s, though that maybe not a bug.

@DirkSchmitt
Copy link

Please release a version to https://addons.mozilla.org/de/firefox/.
It may not be finished, but better to have it then to miss it ;-)

@stsquad
Copy link
Owner

stsquad commented Dec 7, 2017

I'm happy for @dakra to upload to the store as he knows about the process.

@DirkSchmitt
Copy link

I just checked the availability of the extension on https://addons.mozilla.org/de/firefox/ – it is still not available.
@dakra - is there a show stopper ?

@zw963
Copy link

zw963 commented Dec 19, 2017

Maybe forgot to upload ...

@dakra
Copy link
Contributor Author

dakra commented Dec 19, 2017

@DirkSchmitt sorry, only show stopper is busy Christmas times ;)
I'll upload it later today and post update here.

@dakra
Copy link
Contributor Author

dakra commented Dec 19, 2017

@DirkSchmitt @zw963 https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/

I think invoking the edit via the context menu is somewhat buggy.. I always use
the buttons or M-Enter.

Don't think I have time this year to investigate further.

Also I want to change the addon slug to only 'edit-with-emacs',
AMO said that url was already taken even though I deleted the test upload from
earlier.

@zw963
Copy link

zw963 commented Dec 19, 2017

I think invoking the edit via the context menu is somewhat buggy.. I always use
the buttons or M-Enter.

me too. always use M-Enter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants