From 0263216ec39d0914f17b662a3e45b4163ab6cc78 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 14 Apr 2018 00:17:36 +0200 Subject: [PATCH] Don't bind image commands on eww non-image links * lisp/net/eww.el (eww-link-keymap): Only inherit the normal shr keymap. (eww-image-link-keymap): New keymap with the image bindings. (eww-tag-a): Use the appropriate one on links (bug#30148). --- lisp/net/eww.el | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lisp/net/eww.el b/lisp/net/eww.el index cb7390f4724..49bf10d4ebe 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -224,6 +224,11 @@ See also `eww-form-checkbox-selected-symbol'." "When this regex is found in the URL, it's not a keyword but an address.") (defvar eww-link-keymap + (let ((map (copy-keymap shr-map))) + (define-key map "\r" 'eww-follow-link) + map)) + +(defvar eww-image-link-keymap (let ((map (copy-keymap shr-image-map))) (define-key map "\r" 'eww-follow-link) map)) @@ -551,7 +556,11 @@ Currently this means either text/html or application/xhtml+xml." (eww-handle-link dom) (let ((start (point))) (shr-tag-a dom) - (put-text-property start (point) 'keymap eww-link-keymap))) + (put-text-property start (point) + 'keymap + (if (mm-images-in-region-p start (point)) + eww-image-link-keymap + eww-link-keymap)))) (defun eww-update-header-line-format () (setq header-line-format -- 2.39.2