]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't bind image commands on eww non-image links
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 13 Apr 2018 22:17:36 +0000 (00:17 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 13 Apr 2018 22:17:36 +0000 (00:17 +0200)
* 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

index cb7390f47247ea4336ba61260317b5120d3688f0..49bf10d4ebe47bcc235e05a353d5292010a01070 100644 (file)
@@ -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