vermiculus / sx.el

Stack Exchange for Emacs
http://stackapps.com/q/3950
709 stars 40 forks source link

sx-open-link does not work with browse-url-browser-function #323

Closed jabranham closed 7 years ago

jabranham commented 7 years ago

I'm trying to get it set up to where if I open a stackexchange link in Emacs it uses sx.el instead of firefox or eww or whatever. I currently have this:

(push '(".*stackexchange.*" . sx-open-link) browse-url-browser-function)

In my config. But when I do C-c C-o on a link to follow it, I get this error:

apply: Wrong number of arguments: (1 . 1), 2

If I do M-x sx-open-link and yank the link in, everything works great.

vermiculus commented 7 years ago

What are the arguments being passed to it? The error means that sx-open-link takes exactly one mandatory argument, but it was passed two arguments.


Also, this is really neat! I'll have to make the same setup in my own configuration once this is working 😄

jabranham commented 7 years ago

Wow, that was fast. Thanks!

Andre0991 commented 6 years ago

I'm late to the party, but here's an useful customisation: if possible, open SE links from eww using sx.el:

(defun andre-eww-follow-link-maybe-sx (orig-fun &rest args)
  (let ((url (get-text-property (point) 'shr-url)))
    (if (or
         (string-match ".*\.stackexchange\.com" url)
         (string-match ".*\.stackoverflow\.com" url))
        (sx-open-link url)
      (apply orig-fun args))))

(advice-add 'eww-follow-link :around #'andre-eww-follow-link-maybe-sx)

OK, not so fast. This won't work for URLs from a Google Search.

vermiculus commented 6 years ago

I'm surprised eww doesn't use browse-url.