summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gnus.org16
-rw-r--r--init.org159
-rw-r--r--readme.org1
-rw-r--r--w3m.org20
4 files changed, 159 insertions, 37 deletions
diff --git a/gnus.org b/gnus.org
index 5a5fefa..bf5c30b 100644
--- a/gnus.org
+++ b/gnus.org
@@ -306,7 +306,8 @@
(total-expire . nil))
("^nnimap:feeds/fun"
;; (mm-text-html-renderer 'shr)
- (gnus-inhibit-images nil))
+ (gnus-inhibit-images nil)
+ (shr-blocked-images nil))
("^nnimap:feeds/\\(papers\\|programming\\|math\\|physics\\)$"
(expiry-wait . 30)
(jao-gnus--archiving-group "nnimap:trove/tech")
@@ -504,21 +505,14 @@
#+BEGIN_SRC emacs-lisp
;; use w3m for html mail
(defun jao-gnus-html-renderer (handle)
- (let ((w3m-message-silent t)
+ (let ((shr-use-colors nil)
+ (shr-use-fonts nil)
(fill-column (min (window-width) 110)))
- (mm-shr handle)
- ;; (condition-case nil
- ;; (mm-inline-text-html-render-with-w3m handle)
- ;; (error (delete-region (point) (point-max))
- ;; (mm-shr handle)))
- ))
+ (mm-shr handle)))
(setq gnus-button-url 'browse-url-generic
gnus-inhibit-images t
mm-text-html-renderer 'jao-gnus-html-renderer ;; 'w3m ;; 'shr
- shr-use-colors nil
- shr-use-fonts nil
- mm-w3m-safe-url-regexp nil
mm-discouraged-alternatives nil ;; '("text/html" "text/richtext")
mm-inline-large-images 'resize)
diff --git a/init.org b/init.org
index d065291..f8df648 100644
--- a/init.org
+++ b/init.org
@@ -2312,32 +2312,145 @@
name url cat name)))))
(message "No feeds found"))))
#+end_src
-*** emacs-w3m
- #+begin_src emacs-lisp
- (jao-load-org "w3m")
- #+end_src
*** eww
- #+BEGIN_SRC emacs-lisp
+ #+begin_src emacs-lisp
(use-package jao-eww-session
:custom ((jao-eww-session-duplicate-tabs 'ask)
(jao-eww-session-file "~/.emacs.d/eww-session.el")))
- (require 'eww)
- (define-key eww-mode-map "x" #'jao-rss-subscribe)
+ (use-package eww
+ :demand t
+ :custom ((eww-download-directory jao-browse-download-dir)
+ (eww-browse-url-new-window-is-tab nil)
+ (shr-width nil)
+ (shr-use-colors nil)
+ (shr-use-fonts nil)
+ (shr-max-width 130)
+ (shr-blocked-images ".*")
+ (shr-max-image-proportion 0.9))
+ :config
+ (defun prot-eww--rename-buffer ()
+ (let ((name (if (eq "" (plist-get eww-data :title))
+ (plist-get eww-data :url)
+ (plist-get eww-data :title))))
+ (rename-buffer (format "*%s # eww*" name) t)))
+
+ (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
+ (advice-add 'eww-back-url :after #'prot-eww--rename-buffer)
+ (advice-add 'eww-forward-url :after #'prot-eww--rename-buffer)
+
+ (defun jao-eww--close ()
+ (interactive nil eww-mode)
+ (kill-current-buffer)
+ (when-let (b (car (jao-eww-session--list-buffers)))
+ (switch-to-buffer b)))
+
+ (defun jao-eww--turn-images-on ()
+ (interactive nil eww-mode)
+ (let ((shr-blocked-images nil))
+ (eww-reload)))
+
+ (defun jao-eww--next-image ()
+ (interactive)
+ (when-let (p (text-property-search-forward 'image-displayer nil nil t))
+ (goto-char (prop-match-beginning p))))
+
+ :bind (:map eww-mode-map (("d" . eww-download)
+ ("D" . jao-download)
+ ("g" . jao-eww-browse-dwim)
+ ("I" . jao-eww--turn-images-on)
+ ("j" . jao-eww-visit-url-on-page)
+ ("J" . jao-eww-jump-to-url-on-page)
+ ("L" . eww-forward-url)
+ ("N" . jao-eww--next-image)
+ ("r" . eww-reload)
+ ("S" . jao-eww-session-load)
+ ("W" . jao-eww--close)
+ ("x" . jao-rss-subscribe)
+ ("C-c C-w" . jao-eww--close))))
(defun jao-eww-browse-url (url &rest r)
"Browse URL using eww."
(jao-afio--goto-www)
(select-window (frame-first-window))
- (eww url 4))
-
- (setq eww-download-directory "~/var/download"
- eww-browse-url-new-window-is-tab nil
- shr-max-width 130
- shr-width nil
- shr-max-image-proportion 0.9
- jao-browse-url-function #'jao-eww-browse-url)
- #+END_SRC
+ (let* ((url (url-encode-url url))
+ (bf (seq-find `(lambda (b)
+ (with-current-buffer b
+ (string= ,url
+ (url-encode-url (eww-current-url)))))
+ (jao-eww-session--list-buffers))))
+ (if bf (switch-to-buffer bf) (eww url 4))))
+
+ (setq jao-browse-url-function #'jao-eww-browse-url)
+ (setq browse-url-browser-function jao-browse-url-function)
+
+ (defun jao-eww-browse-dwim (url &optional arg)
+ "Visit a URL, maybe from `eww-prompt-history', with completion.
+
+ With optional prefix ARG (\\[universal-argument]) open URL in the
+ same buffer.
+
+ If URL does not look like a valid link, run a web query using
+ `eww-search-prefix'."
+ (interactive
+ (list
+ (completing-read "Run EWW on: "
+ (setq eww-prompt-history
+ (cl-remove-duplicates eww-prompt-history
+ :test #'string=))
+ nil nil nil 'eww-prompt-history)
+ current-prefix-arg))
+ (eww url (if arg nil 4)))
+
+ (defun jao-eww--at-link ()
+ (and (get-text-property (point) 'shr-url)
+ (not (get-text-property (point) 'eww-form))))
+
+ (defun jao-eww--previous-url ()
+ (text-property-search-backward 'shr-url nil nil t))
+
+ (defun jao-eww--pp-link ()
+ (format "%s @ %s"
+ (button-label (point))
+ (propertize (get-text-property (point) 'shr-url) 'face 'link)))
+
+ (defun jao-eww-visit-url-on-page (&optional arg)
+ "Visit URL from list of links in the page using completion."
+ (interactive "P")
+ (when (derived-mode-p 'eww-mode)
+ (let ((links))
+ (save-excursion
+ (goto-char (point-max))
+ (while (jao-eww--previous-url)
+ (when (jao-eww--at-link) (push (jao-eww--pp-link) links))))
+ (let* ((selection (completing-read "Browse: " links nil t))
+ (url (replace-regexp-in-string ".*@ " "" selection)))
+ (eww url (if arg 4 nil))))))
+
+ (defun jao-eww-jump-to-url-on-page ()
+ "Jump to URL position in the page using completion."
+ (interactive)
+ (when (derived-mode-p 'eww-mode)
+ (let ((links))
+ (save-excursion
+ (goto-char (point-max))
+ (while (jao-eww--previous-url)
+ (when (jao-eww--at-link)
+ (push (format "%s ~ %d" (jao-eww--pp-link) (point)) links))))
+ (let* ((selection (completing-read "Jump to URL in page: " links nil t))
+ (position (replace-regexp-in-string ".*~ " "" selection))
+ (point (string-to-number position)))
+ (goto-char point)))))
+
+ (defun jao-eww--append-html (oldfn &rest args)
+ (let ((p (apply oldfn args)))
+ (when (stringp p)
+ (let ((r (if (string-match-p ".*\\.html$" p) p (concat p ".html"))))
+ (kill-new (format "[[doc:%s]]" r))
+ r))))
+
+ (advice-add 'eww-make-unique-file-name :around #'jao-eww--append-html)
+ #+end_src
* Shells
*** shell modes
#+begin_src emacs-lisp
@@ -3192,12 +3305,20 @@
#+END_SRC
*** Geiser
#+BEGIN_SRC emacs-lisp
- (when (file-exists-p "~/usr/jao/geiser/src")
+ ;; (when (file-exists-p "~/usr/jao/geiser/src")
+ ;; (load-file (expand-file-name "~/usr/jao/geiser/src/elisp/geiser.el")))
+ (jao-load-path "~/usr/jao/geiser/src/elisp")
+ (use-package geiser
+ :init
(setq geiser-repl-history-filename "~/.emacs.d/cache/geiser-history")
(setq geiser-repl-startup-time 20000)
(setq geiser-debug-auto-display-images-p t)
- (setq geiser-chez-binary "scheme")
- (load-file (expand-file-name "~/usr/jao/geiser/src/elisp/geiser.el")))
+ (setq geiser-chez-binary "scheme"))
+
+ (use-package geiser-mit)
+
+ (jao-load-path "~/usr/jao/geiser/racket")
+ (use-package geiser-racket)
#+END_SRC
*** Lisp
#+begin_src emacs-lisp
diff --git a/readme.org b/readme.org
index c0ce607..6f4a035 100644
--- a/readme.org
+++ b/readme.org
@@ -65,6 +65,5 @@
- [[./blog.org][blog.org]]: blogging using org-static-blog.
- [[./gnus.org][gnus.org]]: tangled to gnus.el automatically by init.org, so that it's
ready for loading by Gnus.
-- [[./w3m.org][w3m.org]]: configuration for emacs-w3m.
- [[./exwm.org][exwm.org]]: configuration for exwm, loaded when ~jao-exwmn-enable~ is
called.
diff --git a/w3m.org b/w3m.org
index fd6e8da..dc25c98 100644
--- a/w3m.org
+++ b/w3m.org
@@ -169,16 +169,12 @@
(or (jao-w3m-find-url url)
(w3m-goto-url-new-session url)))
-
-
(defun jao-w3m-do-browse ()
"Use the generic browse-url with URL at point."
(interactive)
(let ((uri (or (w3m-anchor) (w3m-image) w3m-current-url)))
(browse-url uri)))
-
-
(defun jao-w3m-download (arg)
(interactive "P")
(jao-download (w3m-anchor) arg))
@@ -225,7 +221,7 @@
".reddit.com"))
#+end_src
* Email
- #+BEGIN_SRC emacs-lisp
+ #+begin_src emacs-lisp
(defun jao-w3m-gmail-mark-all (unmark)
(interactive "P")
(goto-char (point-min))
@@ -245,7 +241,19 @@
(message-goto-body)
(insert "\n\n<" (with-current-buffer wb w3m-current-url) ">\n")
(message-goto-to))))
- #+END_SRC
+
+ (defun jao-w3m-gnus-html-renderer (handle)
+ (let ((w3m-message-silent t)
+ (mm-w3m-safe-url-regexp nil)
+ (shr-use-colors nil)
+ (shr-use-fonts nil)
+ (fill-column (min (window-width) 110)))
+ (condition-case nil
+ (mm-inline-text-html-render-with-w3m handle)
+ (error (delete-region (point) (point-max))
+ (mm-shr handle)))))
+
+ #+end_src
* Proxies
#+BEGIN_SRC emacs-lisp
(defun jao-w3m-activate-proxy ()