home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

config-web.el (3750B)


      1 ;;; config-web.el --- -*- lexical-binding: t; -*-
      2 ;;; Commentary:
      3 ;;; Web related configuration, notably the built-in web browser.
      4 ;;; Code:
      5 
      6 ;; (use-package shr
      7 ;;   :config
      8 ;;   (setq shr-use-fonts nil)
      9 ;;   (setq shr-use-colors nil)
     10 ;;   (setq shr-bullet "• ")
     11 ;;   (setq shr-folding-mode t)
     12 ;; 
     13 ;;   (setq shr-max-image-proportion 0.7)
     14 ;;   (setq shr-image-animate nil)
     15 ;;   (setq shr-width (current-fill-column)))
     16 ;; 
     17 ;; (use-package shr-tag-pre-highlight
     18 ;;   :after shr
     19 ;;   :config
     20 ;;   (add-to-list 'shr-external-rendering-functions
     21 ;;                '(pre . shr-tag-pre-highlight))
     22 ;;   (when (version< emacs-version "26")
     23 ;;     (with-eval-after-load 'eww
     24 ;;       (advice-add 'eww-display-html :around
     25 ;;                   'eww-display-html--override-shr-external-rendering-functions))))
     26 ;; 
     27 ;; (use-package eww
     28 ;;   :commands (eww
     29 ;;              eww-browse-url
     30 ;;              eww-search-words
     31 ;;              eww-open-in-new-buffer
     32 ;;              eww-open-file
     33 ;;              vde/eww-visit-history)
     34 ;;   :config
     35 ;;   (setq eww-restore-desktop nil)
     36 ;;   (setq eww-desktop-remove-duplicates t)
     37 ;;   (setq eww-header-line-format "%u")
     38 ;;   (setq eww-search-prefix "https://duckduckgo.com/html/?q=")
     39 ;;   (setq url-privacy-level '(email agent cookies lastloc))
     40 ;;   (setq eww-download-directory "~/desktop/downloads/")
     41 ;;   (setq eww-suggest-uris
     42 ;;         '(eww-links-at-point
     43 ;;           thing-at-point-url-at-point))
     44 ;;   (setq eww-bookmarks-directory "~/.emacs.d/eww-bookmarks/")
     45 ;;   (setq eww-history-limit 150)
     46 ;;   (setq eww-use-external-browser-for-content-type
     47 ;;         "\\`\\(video/\\|audio/\\|application/pdf\\)")
     48 ;;   (setq eww-browse-url-new-window-is-tab nil)
     49 ;;   (setq eww-form-checkbox-selected-symbol "[X]")
     50 ;;   (setq eww-form-checkbox-symbol "[ ]")
     51 ;; 
     52 ;;   ;; eww-view-source
     53 ;; 
     54 ;;   (defvar vde/eww-mode-global-map
     55 ;;     (let ((map (make-sparse-keymap)))
     56 ;;       (define-key map "s" 'eww-search-words)
     57 ;;       (define-key map "o" 'eww-open-in-new-buffer)
     58 ;;       (define-key map "f" 'eww-open-file)
     59 ;;       map)
     60 ;;     "Key map to scope `eww' bindings for global usage.
     61 ;; The idea is to bind this to a prefix sequence, so that its
     62 ;; defined keys follow the pattern of <PREFIX> <KEY>.")
     63 ;;   :bind-keymap ("C-x w" . vde/eww-mode-global-map)
     64 ;;   :bind (:map eww-mode-map
     65 ;;               ("n" . next-line)
     66 ;;               ("p" . previous-line)
     67 ;;               ("f" . forward-char)
     68 ;;               ("b" . backward-char)
     69 ;;               ("B" . eww-back-url)
     70 ;;               ("N" . eww-next-url)
     71 ;;               ("P" . eww-previous-url)))
     72 
     73 (use-package browse-url
     74   :after eww
     75   :config
     76 
     77   (defun browse-url-xdg-desktop-portal (url &rest args)
     78     "Open URL via a portal backend."
     79     (dbus-call-method :session
     80                       "org.freedesktop.portal.Desktop"
     81                       "/org/freedesktop/portal/desktop"
     82                       "org.freedesktop.portal.OpenURI"
     83                       "OpenURI"
     84                       "" url '(:array :signature "{sv}")))
     85   (setopt browse-url-browser-function #'browse-url-xdg-desktop-portal)
     86   ;; (setq browse-url-browser-function #'eww-browse-url)
     87 
     88   ;; (setq browse-url-generic-program "google-chrome-stable")
     89   (setq browse-url-handlers '(("^https://gitlab.com.*" . browse-url-firefox)
     90                               ("^https://github.com.*" . browse-url-default-browser)
     91                               ("^https://issues.redhat.com.*" . browse-url-default-browser)
     92                               ("^https://.*redhat.com.*" . browse-url-default-browser)
     93                               ("^https://docs.jboss.org.*" . browse-url-default-browser)
     94                               (".*" . eww-browse-url))))
     95 
     96 (provide 'config-web)
     97 ;;; config-web.el ends here