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 ++++++++++++++--------------------- notmuch.org | 11 +++++++---- w3m.org | 15 --------------- 3 files changed, 21 insertions(+), 40 deletions(-) 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 diff --git a/notmuch.org b/notmuch.org index cb20bc1..c144c8a 100644 --- a/notmuch.org +++ b/notmuch.org @@ -286,15 +286,18 @@ :bind (:map notmuch-show-mode-map - (("h" . jao-notmuch-goto-tree-buffer) - ("TAB" . jao-notmuch-show-next-button) - ("S-TAB" . jao-notmuch-show-previous-button) - ("RET" . jao-notmuch-show-ret)))) + (("h" . jao-notmuch-goto-tree-buffer)))) #+end_src * search #+begin_src emacs-lisp (use-package notmuch-search + :init (setq notmuch-search-result-format + '(("date" . "%12s ") + ("count" . "%-7s ") + ("authors" . "%-35s") + ("subject" . "%-100s") + ("tags" . "(%s)"))) :bind (:map notmuch-search-mode-map (("RET" . notmuch-tree-from-search-thread) ("M-RET" . notmuch-search-show-thread)))) diff --git a/w3m.org b/w3m.org index b96b370..6a6b57f 100644 --- a/w3m.org +++ b/w3m.org @@ -67,21 +67,6 @@ (kill-new (format "[[doc:%s][%s]] ([[%s][original]])" basename title url)))) #+end_src -* Email - #+begin_src emacs-lisp - (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))))) - - (setq mm-text-html-renderer #'jao-w3m-gnus-html-renderer) - #+end_src * Narrowing #+begin_src emacs-lisp (with-eval-after-load "w3m-util" -- cgit v1.2.3