From ee9789c061998abb810974d1a27ef90026db8eba Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 3 Nov 2021 03:38:53 +0000 Subject: experimenting with eww as main browser again --- eww.org | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'eww.org') diff --git a/eww.org b/eww.org index ea3c359..5284102 100644 --- a/eww.org +++ b/eww.org @@ -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) ""))) + (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 -- cgit v1.2.3