How to make emacs org-mode open links to sites in Google Chrome?

后端 未结 7 1750
梦谈多话
梦谈多话 2020-12-12 22:15

Google Chrome is set as the default browser, however it opens links in Firefox, which is undesired.

How to make org-mode to open links in

相关标签:
7条回答
  • 2020-12-12 22:34

    For chrubuntu, the google-chrome incantation as given above by Lex Fridman works with emacs 23.3.1, the default as of today. I suspect the chrubuntu configuration even when tickled to use chromium uses the wrong binary name.

    0 讨论(0)
  • 2020-12-12 22:42

    I am on MacOS and the browse-url-default-macos-browser does not work for me.

    My solution is:

    (setq browse-url-browser-function 'browse-url-chrome)
    (setq browse-url-chrome-program "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"))
    
    0 讨论(0)
  • 2020-12-12 22:43

    As @Trey suggests, you can set it to a generic browser bu instead of "chromium-browser" use "google-chrome", like this:

    (setq browse-url-browser-function 'browse-url-generic
          browse-url-generic-program "google-chrome")
    

    That worked for me with Emacs 23.2 and Chrome 12. Though it might be Chrome 13 by the time I'm done writing this answer ;-)

    0 讨论(0)
  • 2020-12-12 22:46

    I have a similar problem (although the other way around: I wanted emacs to open Firefox, but it opened Chromium).

    I'm using Ubuntu 12.04 (but already had the problem with 11.10). The solution below applies to Linux, maybe MacOS (?), probably not Windows.

    Setting browse-url-generic-program as suggested in other answers didn't work for me. Note also that my default browser is generally Firefox: that's what most other applications are using to open a URL, including xdg-open. So I was surprised that Emacs would do otherwise.

    I finally figured out that Emacs is using the sensible-browser (1) script. Looking at that script, I noticed that:

    • it first looks at the BROWSER environment variable;
    • else, it tries several other generic scripts, starting with gnome-www-browser

    It so happens that, on my machine, BROWSER is not set, but gnome-www-browser is a script apparently put there by chromium, and (naturally) running chromium.

    So, long stort short: putting the following line

    export BROWSER=firefox #or any brower of your choice

    in your .profile may help if Emacs is not using the correct browser.

    0 讨论(0)
  • 2020-12-12 22:47

    Emacs 23.2 doesn't directly support chrome, but it does support a "generic" browser, and something like this should work:

    (setq browse-url-browser-function 'browse-url-generic
          browse-url-generic-program "chromium-browser")
    

    You don't mention your OS, but if it's Windows or Mac, you can try:

    (setq browse-url-browser-function 'browse-url-default-windows-browser)
    (setq browse-url-browser-function 'browse-url-default-macosx-browser)
    

    And, if that doesn't work, there are other folks who have implemented 'browse-url-chrome. Google turned up the following links:

    • http://code.ohloh.net/search?s=browse-url-chrome&browser=Default
    0 讨论(0)
  • 2020-12-12 22:52

    Setting the browser function is very easy using the GUI:

    • In the menu, click Options > Customize Emacs > Top-level customization Group
    • Click on the link External (Interfacing to external utilities.)
    • Click on the link Browse Url (Use a web browser to look at a URL.)
    • Click on the small triangle to the left of Browse Url Browser Function, this reveals a Value Menu button and some help text
    • Click the Value Menu button
    • Choose your preference from the displayed menu
    • Move to the top of the buffer, click the button Apply and Save to save the change to your ~/.emacs file

    Done :-)

    0 讨论(0)
提交回复
热议问题