diff options
-rw-r--r-- | email.org | 15 | ||||
-rw-r--r-- | eww.org | 46 | ||||
-rw-r--r-- | init.org | 11 | ||||
-rw-r--r-- | w3m.org | 3 |
4 files changed, 58 insertions, 17 deletions
@@ -207,6 +207,21 @@ '((jao-icalendar-import-buffer "application/ics") ("viewpdf.sh %s" "application/pdf"))))) #+end_src +* multipart html renderer + #+begin_src emacs-lisp + + (defun jao-w3m-html-renderer (handle) + (let ((w3m-message-silent t) + (mm-w3m-safe-url-regexp nil)) + (condition-case nil + (mm-inline-text-html-render-with-w3m handle) + (error (delete-region (point) (point-max)) + (let ((shr-use-fonts nil) + (shr-use-colors nil)) + (mm-shr handle)))))) + + ;; (setq mm-text-html-renderer #'jao-w3m-html-renderer) + #+end_src * bbdb #+begin_src emacs-lisp (use-package bbdb @@ -68,13 +68,10 @@ (seq-map (lambda (b) (with-current-buffer b (let ((tl (or (plist-get eww-data :title) "")) - (url (or (eww-current-url) "<no url>"))) + (url (or (eww-current-url) (buffer-name)))) (propertize (if (string-blank-p tl) url tl) 'buffer b 'url url)))) - (seq-filter (lambda (b) - (eq 'eww-mode - (buffer-local-value 'major-mode b))) - (buffer-list)))))) + (seq-filter #'jao-www--buffer-p (buffer-list)))))) (jao-consult-add-buffer-source 'jao-eww-buffer-source "Web" ?e)) #+end_src * Images @@ -109,10 +106,6 @@ (interactive) (jao-eww-reopen t)) #+end_src -* eww-lnum - #+begin_src emacs-lisp - (use-package eww-lnum :ensure t) - #+end_src * Sessions #+begin_src emacs-lisp (use-package jao-eww-session @@ -127,7 +120,9 @@ (eww-download-directory jao-sink-dir) (eww-header-line-format nil) (eww-form-checkbox-selected-symbol "☒") - (eww-search-prefix "https://search.brave.com/search?q=") + (eww-auto-rename-buffer 'title) + (eww-buffer-name-length 180) + ;; (eww-search-prefix "https://search.brave.com/search?q=") (shr-width nil) (shr-use-colors nil) (shr-use-fonts nil) @@ -141,11 +136,10 @@ :bind (:map eww-mode-map (("b" . eww-back-url) ("B" . eww-forward-url) - ("c" . jao-eww-copy-link) ("d" . eww-download) ("D" . jao-download) - ("f" . eww-lnum-follow) - ("F" . eww-lnum-universal) + ("f" . link-hint-open-link) + ("F" . embark-on-link) ("j" . jao-eww-visit-url-on-page) ("J" . jao-eww-jump-to-url-on-page) ("L" . eww-forward-url) @@ -161,7 +155,33 @@ ("q" . jao-eww-close) ("x" . jao-rss-subscribe) ("y" . jao-eww-copy-link) + ("\\" . eww-view-source) ("C-c C-w" . jao-eww-close) ("M-i" . eww-toggle-images)))) #+end_src +* Fixes for shr image rendering + #+begin_src emacs-lisp + (require 'shr) + + (defun jao-shr--kill-nl (p) + (save-excursion + (goto-char p) + (when (looking-at-p "\n") (delete-char 1)))) + + (defun jao-shr-tag-img (fn &rest args) + (let ((p (point))) + (prog1 (apply fn args) + (when (> (point) p) (jao-shr--kill-nl p))))) + + (defun jao-shr-insert (fn &rest args) + (let ((p (when (and (not (bolp)) + (get-text-property (1- (point)) 'image-url)) + (point)))) + (prog1 (apply fn args) + (when (and p (> (point) p)) (jao-shr--kill-nl p))))) + + (advice-add 'shr-tag-img :around #'jao-shr-tag-img) + (advice-add 'shr-insert :around #'jao-shr-insert) + + #+end_src @@ -1442,7 +1442,16 @@ #+END_SRC *** Web browsers #+begin_src emacs-lisp - (jao-load-org "w3m") + (setq shr-use-fonts nil + shr-use-colors nil) + + (defun jao-www--buffer-p (b) + (with-current-buffer b + (or (derived-mode-p 'w3m-mode 'eww-mode) + (member (buffer-local-value 'exwm-class-name b) '("vlc" "mpv"))))) + + ;; (jao-load-org "w3m") + (jao-load-org "eww") #+end_src *** Browse URL #+begin_src emacs-lisp @@ -72,9 +72,6 @@ (with-eval-after-load "w3m-util" (with-eval-after-load "consult" (defvar jao-consult-w3m-buffer-history nil) - (defun jao-www--buffer-p (b) - (or (eq 'w3m-mode (buffer-local-value 'major-mode b)) - (member (buffer-local-value 'exwm-class-name b) '("vlc" "mpv")))) (defun jao-www--item (b) (with-current-buffer b (propertize (or w3m-current-title (buffer-name)) |