summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-11-19 07:27:49 +0800
committerJSDurand <mmemmew@gmail.com>2021-11-19 07:27:49 +0800
commit7501c0b65c6226ed354f61854af5dfc33c96bd51 (patch)
tree9ea7acc8b8de6ed4d1f802b5ce5e013330664041
parentf7b6fcb307d07d01f238188752cce0dc4c4cc9db (diff)
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.
-rw-r--r--eww-conf.el13
1 files changed, 11 insertions, 2 deletions
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)