From 7501c0b65c6226ed354f61854af5dfc33c96bd51 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 19 Nov 2021 07:27:49 +0800 Subject: eww-conf.el: browser function improvement. * eww-conf.el (browse-url-browser-function): Use my own custom browser function. (durand-browse-url): Has the ability to open URL in an external browser if given a non-nil second argument, just like `shr-browse-url'. This is more convenient since some links cannot be properly opened in EWW. --- eww-conf.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'eww-conf.el') diff --git a/eww-conf.el b/eww-conf.el index 157dded..3faa82d 100644 --- a/eww-conf.el +++ b/eww-conf.el @@ -5,14 +5,14 @@ ;;; Commentary: -;; Simply configurations for the great Emacs Web Wowser +;; Simple configurations for the great Emacs Web Wowser ;;; Code: (require 'eww) (require 'shr) -(setq browse-url-browser-function #'eww-browse-url) +(setq browse-url-browser-function #'durand-browse-url) (setq browse-url-secondary-browser-function 'browse-url-default-browser) (setq eww-bookmarks-directory load-file-directory) @@ -23,6 +23,15 @@ (setq eww-suggest-uris '(eww-links-at-point thing-at-point-url-at-point)) (setq eww-browse-url-new-window-is-tab nil) +;;; Open URL in an external browser if given a prefix argument. + +(defun durand-browse-url (url &optional arg) + "Open URL in a browser. +If ARG is nil, open in EWW. Otherwise, open in an external browser." + (cond + (arg (funcall browse-url-secondary-browser-function url)) + ((eww-browse-url url)))) + ;;; Use pdf-view to view PDF files if available. (setq mailcap-prefer-mailcap-viewers nil) -- cgit v1.2.3-18-g5258