1

Sometimes I read an article in my browser (qutebrowser) and think, oh "that article would be nice to work on in emacs". I can call scripts from the browser, and hand them the visited URL.

Is it possible to call emacs (or even better emacsclient, as I always have a server running) so, that it opens the given URL in eww?

I found that I can start emacs with a function to call, but not how to hand this function a parameter from outside. For emacsclient I didn' find even that possibility

DrOps
  • 33
  • 5

2 Answers2

2

To get it to work with qutebrowser i just had to put in the file ~/.local/share/qutebrowser/userscripts/viewineww like this:

#! /bin/bash 
emacsclient --eval "(eww \"$QUTE_URL\")" 

make the file executable , and bind it in qutebrowser with:

 :bind de spawn --userscript viewineww
DrOps
  • 33
  • 5
0

You can eval arbitrary lisp with the --eval option of emacsclient. So you should be able to do something like this from the shell (season appropriately to call it from the browser):

    URL="https://google.com"
    emacsclient --eval "(eww \"$URL\")"

The outer double quotes allow the shell to expand the URL variable. The escaped inner double quotes make the value of the URL variable into a string, which is what the eww function expects.

NickD
  • 5,937
  • 1
  • 21
  • 38