In my Emacs config, I have set Firefox to be the browser to open URLs with,

  (setq browse-url-browser-function 'browse-url-firefox)

Now, I have one org-mode file, in which I would like to open URLs with a different program (mpv, to be precise).

What I'm currently trying is a buffer-local variable, indicated by a mode line

# -*- browse-url-browser-function: 'browse-url-chromium -*-

at the top of my org file. However, whenever I click on an org-mode link pointing to a URL (or, just click on a URL, for that matter), I get an error

Debugger entered--Lisp error: (wrong-type-argument listp quote)
  (lambda (path) (browse-url (concat "https:" path)))("//www.google.com/")
  org-open-at-mouse((mouse-2 (#<window 1244 on testfile.org> 192 (163 . 95) 82295534 nil 192 (20 . 4) nil (3 . 9) (8 . 19))))
  funcall-interactively(org-open-at-mouse (mouse-2 (#<window 1244 on yoga.org> 192 (163 . 95) 82295534 nil 192 (20 . 4) nil (3 . 9) (8 . 19))))
  call-interactively(org-open-at-mouse nil nil)

I would appreciate any pointer towards how I can resolve this.


3 Answers 3


Error is caused by this quote:

# -*- browse-url-browser-function: 'browse-url-chromium -*-

It shouldn't be there.

Open video path in MPV on *nix OS's

Add this line to the init file(.emacs), or evaluate in Scratch buffer

(org-add-link-type "mpv" (lambda (path) (browse-url-xdg-open path)))

browse-url-xdg-open uses xdg-open program that exists on all *nix desktops("X Desktop Group"). It check file extension to decide which program on desktop should open that path.

Custom link in org mode:


mpv: prefix, or any other defined by org-add-link-type
Actually it would open any file according to MIME type known to xdg-open. It would be MPV video player for a video file if it's configured as a default player on a desktop.

  • 2
    You can have Emacs create this line for you if not sure of the syntax. Try: M-x add-file-local-variable-prop-line, which will prompt you for the variable and the value to set.
    – glucas
    Commented Jan 12, 2019 at 19:25

Like you, I could not figure out how to directly assign a function to a file variable using mode lines. What I ended up having to do was define a function that set the local variables that I wanted, and use a Local Variables: section at the end of the file to call the function.

  (defun set-mpv-local-variables ()
    "Set local variables for using mpv"
    (set (make-local-variable 'browse-url-browser-function) 'browse-url-chromium))

Then at the bottom of your org document add:

# Local Variables:
# eval: (set-mpv-local-variables)
# End:


If you only want to set one variable, just inlining the set expression may be enough, but if you need to set more than one local variable, I'd split it out into a separate function as I did here.


A link abbreviation

#+LINK: mpv elisp:(browse-url-xdg-open "%s")

in the .org file is a neat way to add a custom link type such as mpv: just for the current .org file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.