From e73981f7292618adb972b1195944e6b2997ce190 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 23 Aug 2021 02:51:09 +0100 Subject: notmuch: a better way of recovering the w3m keymap --- lib/net/jao-notmuch.el | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'lib/net') diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index d3c7841..316ece4 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -25,6 +25,8 @@ ;;; Code: (require 'outline) +(require 'mm-decode) +(require 'mm-view) (require 'notmuch) (require 'notmuch-tree) @@ -89,27 +91,13 @@ jao-notmuch-tree-beginning-of-buffer beginning-of-buffer) -(defun jao-notmuch-show-next-button () - (interactive) - (when (get-text-property (point) 'w3m-href-anchor) - (goto-char (next-single-property-change (point) 'w3m-href-anchor))) - (if-let (pos (next-single-property-change (point) 'w3m-href-anchor)) - (goto-char pos) - (forward-button 1))) - -(defun jao-notmuch-show-previous-button () - (interactive) - (if-let (pos (previous-single-property-change (point) 'w3m-href-anchor)) - (goto-char (previous-single-property-change pos 'w3m-href-anchor)) - (backward-button 1))) - (defun jao-notmuch--page-urls (res) (save-excursion (goto-char (point-min)) (let ((pos (point))) (while (setq pos (next-single-property-change pos 'w3m-href-anchor)) (when-let ((url (get-text-property pos 'w3m-href-anchor))) - (cl-pushnew url res))) + (when (stringp url) (cl-pushnew url res :test #'string=)))) res))) (defun jao-notmuch-browse-urls (&optional external) @@ -173,12 +161,17 @@ (add-hook 'notmuch-show-mode-hook #'jao-notmuch--setup-w3m-images) -(defun jao-notmuch-show-ret () - (interactive) - (if-let (url (or (get-text-property (point) 'w3m-href-anchor) - (thing-at-point-url-at-point))) - (browse-url url) - (notmuch-show-toggle-message))) +;; fix w3m renderer keymap +(defun jao-w3m-gnus-html-renderer (handle) + (let ((w3m-message-silent t) + (mm-inline-text-html-with-w3m-keymap t) + (mm-w3m-safe-url-regexp nil)) + (condition-case nil + (mm-inline-text-html-render-with-w3m handle) + (error (delete-region (point) (point-max)) + (mm-shr handle))))) + +(setq mm-text-html-renderer #'jao-w3m-gnus-html-renderer) ;; Keeping track of unread messages in current tree view -- cgit v1.2.3