emacs (org-mode/helm-google) open links in eww? - emacs

I use emacs/ orgmode and helm-google.
When I open a page it opens it in google chrome. I would like it to open in eww. (ideally even have some way to have different hotkeys to open pages in either eww/chrome)
I tried to set var: browse-url-generic to 'eww', but no success.
I tried
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "eww")
(as per How to make emacs org-mode open links to sites in Google Chrome?) but no success.
I asked the author of helm-google about this in this post, awaiting a reply?

(setq browse-url-browser-function 'eww-browse-url)
should be what you're looking after.

You should be able to just set browse-url-browser-function to 'eww.
My suggestion would be to use the customize group and select eww (it is one of the choices in the menu for the browse-url-function. If that works, you can then look at it in the custom file to see how to set it manually. Once you have that, then you could try writing your own function which allows you to select the browser you want.

Follow code snippet can open "http://" "https://" with ewwonly in org-mode, instead of change default browser function to eww.
(eval-after-load 'ol
'(dolist (scheme '("http" "https"))
(org-link-set-parameters
scheme :follow (lambda (url arg) (eww (concat scheme ":" url) arg)))))

Related

Opening the VSC settings window from code

I'm working on a Visual Studio Code extension, where some settings are required for it to work properly. Right now, in case the user has forgotten something, I'm showing a warning message indicating this, and telling them to fix this property in the settings. I would, however, like to add a button that opens the settings page of that property.
However, after looking around for over an hour, I can't seem to find any support for this in the Api, or anyone else asking this question (which I find a bit weird?). If it really doesn't exist, I'd still expect at least 1 other person asking this somewhere, but as far as I can see there's absolutely nothing.
Is it possible to open the settings window (preferably even filtering them down to only my extension's properties/the one property that has to be filled in) from code?
Thanks in advance
I found it out myself after digging through the keybinds window. You can use the following to open the settings:
vscode.commands.executeCommand("workbench.action.openSettings2");
I did not, however, find how to pass a search query into it to open a specific place in the settings.
EDIT: You can use openSettings & add the search query as an extra argument to executeCommand. For example - if your property is defined as my.extension.property in package.json, you can use this:
vscode.commands.executeCommand("workbench.action.openSettings", "my.extension.property");

How to emulate a "Paste" in Selenium IDE add-on for Firefox?

With the help of the Selenium IDE add-on for Firefox, I'm trying to publish a post on Facebook that will include a link, the post should also contain the usual 'link preview' (image and/or description text) scraped from the website I'm sharing.
For this purpose I played around with the following commands to no avail: "type" ; "typeKeys" ; "SendKeys"... the result was actually expected because these commands mimic typing, and if you manually write a link (by typing it) while trying to publish a post on Facebook - the "link preview" (image and/or description) won't be loaded. I also tried to emulate pressing "ctrl + [a/c/v]" in 3 separate commands as a workaround after the link as a text was written in the 'update your status' field, but no luck with those. See the visual examples below:
Selenium IDE contains:
Store | https://9gag.com/ | link
[[bunch of irrelevant commands in-between]]
typeKeys | class=_1mf _1mj | ${link}
Result:
Screenshot 1 - imgur
If you publish the post this way, it'll end up like a plain text. Not a valid share. The thing I'm trying to achieve with Selenium IDE is what's shown on the screenshot below. You can achieve it by copying some absolute URL and pasting it (ctrl + v) inside the 'update your status' window on Facebook.
Result:
Screenshot 2- imgur
Important: Workarounds are welcome as always, but here's what's not welcome as a workaround from other off-topic non-Selenium related reasons:
Using this sharing form: facebook.com/sharer/sharer.php?u=[absolute URL you want to share]
Using the mobile/touch version of Facebook
Thank you in advance for your time, and for the potential solution.
You could try using a space or enter at the end of the URL.

Can't see dynamically loaded code in Chrome Developer Tools 22

When I dynamically load a snippet of html containing javascript via AJAX, I cannot see that content in the source tab in the developer tools window in Chrome 22.0.1229.94. Tellingly, I went here
https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints#js_dynamic
This page shows an example developer tools window which is out of date. There is a button on the page to load a dynamic script and it does not show up in the source tab when you do.
As a work-around, I have found that adding
debugger;
to the script and reloading it will cause it to pause in the dynamically loaded code, but unfortunately, all the line numbers are greyed out and you can't set any breakpoints within the debugger.
Am I missing something here or what?
Thanks,
Rob
When you use a library or javascript code that you have loaded it dynamically, you can use the phrase
//# sourceURL=foo.js
at the beginning of your javascript code that foo.js is the name that will be assigned it. debugger will show it with that name.
This is true in chrome, and I think in firebug too.
In this case you can place a breakpoint in the dynamically loaded javascript code.
Possible duplicate of:
Is possible to debug dynamic loading JavaScript by some debugger like WebKit, FireBug or IE8 Developer Tool?
Don't know if this works or not in chrome (This definitely doesn't work for me now, may be in the past).
//# sourceURL=foo.js
Working Solution
For your dynamically loaded script via ajax to appear in your chrome source tool, you need to add the following line at the start or end (I prefer) location of your script file:
//# sourceURL=foo.js
And your script with name foo.js will appear at the left pane of source tab under (no domain) dropdown
->localhost
-- source/src
->(no domain)
-- foo.js
Alternatively you can add the below line in your script anywhere between the scripts.
debugger;
In chrome, you can use " debugger; " statement to break at a statement when debugger panel is open. Chrome will simply ignore this if the debugger panel is closed.
This will help stop your script in debugging mode and you will see your script in source (debugging) panel with name like VM****.
Hope this helps.
You can use //# sourceURL. Chrome doesn't seem to be supporting //# sourceURL for inline scripts. However, it does work on eval expressions. This article gives more details about naming eval blocks and naming of any anonymous functions in your code.
Instead of using eval, you can try embedding a script tag or JSONP may be.
Varunkumar Nagarajan
for me it happened on nodejs project.
i restarted server and open in new tab my app and tada!..
Alternatively, to fix this problem you can open developer tool in a seprate window by clicking the icon. Now reload your script, and it will shown in script tab as expected. I know this is not a solution but a work arround.

Emacs: mediawiki save error

I've just started to use mediawiki.el to edit out internal wiki page. I've set it up as described. I connect to the wiki, Edit the file I want. When I want to submit my edits I hit C-x C-s, it prompts me for a summary, but after it I get the following error:
let*: The server encountered an error: (unknown_action) Unrecognized value for parameter 'action': edit
Any idea what am I doing wrong? Thank you very much!
Per this thread, the error most likely means that you either have an ancient version of MediaWiki (not likely), or that you have the API disabled.
To enable editing though the API, you need to set $wgEnableAPI and $wgEnableWriteAPI to true in LocalSettings.php of your wiki.

How can I use specific protocol (in my case : txmt) with Org mode?

I have TextMate running on Mac, and it has txmt protocol, that I can use as on web browser such as txmt://open/?url=file:///Users/smcho/smcho/bin/rst2html. I can use TextMate for editing rst2html.
However, when I tried to use this protocol with Org-mode as [txmt://open/?url=file:///Users/smcho/smcho/bin/rst2html], instead of opening TextMate, the rst2html binary is running.
I tried
(setq org-link-abbrev-alist
'(
("edit" . "txmt://open/?url=file://%s")
))
to use [edit:/Users/smcho/smcho/bin/rst2html], but I get the same result.
How can I use specific protocol (in my case : txmt) with Org mode?
ADDED
It's not using protocol, but one can run open and edit some file with this command.
("edit" . "shell:/usr/local/bin/mate %s")
I believe org-mode can only handle links specified on this page (and maybe a few other link types, e.g. links to git repos, courtesy of contrib packages). I'm not a TextMate/Apple user, but it seems to me that txmt:// protocol in the question is just a handler TextMate sets up for the installed browsers; you can't expect this to work with org.
The real question is -- can you set up a link so that a particular file is opened in TextMate. The most straightforward way is to issue a shell command that will open the file in TextMate. Using org-link-abbrev-alist, you could do something like ("edit" . "shell:/path/to/textmate_binary %s &"). You'll also want to use (setq org-confirm-shell-link-function nil) to suppress the confirmation prompt.
In general, it is always possible to create custom link types as described here; this involves writing the handler function in elisp. In this case, this would be a call to start TextMate using e.g. start-process. This would be a cleaner solution, but probably not worth the extra effort. In customizing org link handlers, it is usually sufficient to set up shortcuts via org-link-abbrev-alist, or set up handlers based on extension via org-file-apps.
This is an old question, but I recently had a similar issue with links to Papers.app on my Mac (http://www.mekentosj.com). Papers provides a link protocol ("papers2:")for referring to documents in its Library, for example: "papers2://publication/uuid/4319127A-3FD5-4DB9-A3F8-1881AC937B74"
I wanted to be able to store these links in my org-mode document and have org open Papers.app when this link is visited. (\C-c\C-o)
On the Mac, you can specify links like this as the argument to the "open" shell command, and the appropriate application handles them.
The code below configures org-mode to send any link that looks like it has a protocol to "open" via the shell. The documentation for org-open-link-functions indicates that this hook is called after known external links are handled, but before textual searches begin.
This configuration should work for the original TextMate question with no modification.
(defun org-pass-link-to-system (link)
(if (string-match "^[a-zA-Z0-9]+:" link)
(shell-command (concat "open " link))
nil)
)
(add-hook 'org-open-link-functions 'org-pass-link-to-system)