[PATCH v2] emacs: show: possible w3m/invisibility workaround

Mark Walters markwalters1009 at gmail.com
Thu Jan 10 15:56:59 PST 2013


There is a bug in the current notmuch code with w3m and invisible
parts. w3m sets a keymap, and if we have a hidden [text/html] point
at the start of the following line still gets this w3m keymap which
causes some strange effects. For example, RET gives an error "No URL
at Point" rather than hiding the message, <down> goes to the next link
rather than just down a line.

These keybinding are also inconvenient when the text/html part is
displayed so we replace the w3m keymap by notmuch-show-mode-map.

This is only likely to be a problem for emacs 23 as shr is preferred
as html renderer on emacs 24.
---
This is probably better than v1 as this keeps the users chosen
renderer and justs overrides the (in my opinion) inconvenient (for
notmuch-show use) keymap w3m provides.

There are some questions:

1) does anyone use w3m with notmuch and really want the keymap not overridden?

2) is copying notmuch-show-mode-map needed?

3) notmuch-show-mode-map is not defined at this point in notmuch-show
(but obviously is when the function is called). What is the best way
to avoid a compile warning?

This seems to me like a plausible basis for a solution for 0.15. This is not a
full fix but does hide the problem. Moreover even with a genuine fix
for the invisibility corner cases I think this might be desirable for
the case when the text/html part is displayed.

Best wishes

Mark


 emacs/notmuch-show.el |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5751d98..8443c54 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -818,6 +818,19 @@ message at DEPTH in the current thread."
 (defun notmuch-show-insert-part-inline-patch-fake-part (msg part content-type nth depth declared-type)
   (notmuch-show-insert-part-*/* msg part "text/x-diff" nth depth "inline patch"))
 
+(defun notmuch-show-insert-part-text/html (msg part content-type nth depth declared-type)
+  ;; text/html to work around bugs in renderers and our invisibile
+  ;; parts code. In particular w3m sets up a keymap which "leaks"
+  ;; outside the invisible region and causes strange effects in
+  ;; notmuch. The w3m keymap is rather odd for notmuch use: several
+  ;; keys conflict with notmuch-show-mode-map so just override by
+  ;; notmuch-show-mode-map.
+  (let ((w3m-minor-mode-map (when (eq mm-text-html-renderer 'w3m)
+			      (copy-keymap notmuch-show-mode-map))))
+    (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))
+    (notmuch-mm-display-part-inline msg part nth content-type notmuch-show-process-crypto))
+  t)
+
 (defun notmuch-show-insert-part-*/* (msg part content-type nth depth declared-type)
   ;; This handler _must_ succeed - it is the handler of last resort.
   (notmuch-show-insert-part-header nth content-type declared-type (plist-get part :filename))
-- 
1.7.9.1



More information about the notmuch mailing list