diff options
| author | Lars Ingebrigtsen | 2018-04-13 23:49:58 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2018-04-13 23:49:58 +0200 |
| commit | 4575ae5a9c5589ac903362486951f0d36c8ff8ee (patch) | |
| tree | 116fdcc81ca8b803d9bd6d5b2d21fc0737ea71ad | |
| parent | 52a5bc89c92cb4be88d9ec6eb2df178560559320 (diff) | |
| download | emacs-4575ae5a9c5589ac903362486951f0d36c8ff8ee.tar.gz emacs-4575ae5a9c5589ac903362486951f0d36c8ff8ee.zip | |
Don't bind image commands on non-image links in Gnus
* lisp/gnus/mm-decode.el (mm--images-in-region-p): New utility
function.
(mm-convert-shr-links): Only use the shr image map on links that
contain images. This avoids binding commands like `r' on links
that don't need it.
| -rw-r--r-- | lisp/gnus/mm-decode.el | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el index 7ab84c0c83d..d8753e5a1d5 100644 --- a/lisp/gnus/mm-decode.el +++ b/lisp/gnus/mm-decode.el | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | (require 'mail-parse) | 26 | (require 'mail-parse) |
| 27 | (require 'mm-bodies) | 27 | (require 'mm-bodies) |
| 28 | (require 'shr) | ||
| 28 | (eval-when-compile (require 'cl-lib)) | 29 | (eval-when-compile (require 'cl-lib)) |
| 29 | 30 | ||
| 30 | (autoload 'gnus-map-function "gnus-util") | 31 | (autoload 'gnus-map-function "gnus-util") |
| @@ -1841,8 +1842,6 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t) | |||
| 1841 | (let ((inhibit-read-only t)) | 1842 | (let ((inhibit-read-only t)) |
| 1842 | (delete-region min max)))))))) | 1843 | (delete-region min max)))))))) |
| 1843 | 1844 | ||
| 1844 | (defvar shr-image-map) | ||
| 1845 | |||
| 1846 | (autoload 'widget-convert-button "wid-edit") | 1845 | (autoload 'widget-convert-button "wid-edit") |
| 1847 | (defvar widget-keymap) | 1846 | (defvar widget-keymap) |
| 1848 | 1847 | ||
| @@ -1856,7 +1855,10 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t) | |||
| 1856 | (widget-convert-button | 1855 | (widget-convert-button |
| 1857 | 'url-link start end | 1856 | 'url-link start end |
| 1858 | :help-echo (get-text-property start 'help-echo) | 1857 | :help-echo (get-text-property start 'help-echo) |
| 1859 | :keymap (setq keymap (copy-keymap shr-image-map)) | 1858 | :keymap (setq keymap (copy-keymap |
| 1859 | (if (mm--images-in-region-p start end) | ||
| 1860 | shr-image-map | ||
| 1861 | shr-map))) | ||
| 1860 | (get-text-property start 'shr-url)) | 1862 | (get-text-property start 'shr-url)) |
| 1861 | ;; Mask keys that launch `widget-button-click'. | 1863 | ;; Mask keys that launch `widget-button-click'. |
| 1862 | ;; Those bindings are provided by `widget-keymap' | 1864 | ;; Those bindings are provided by `widget-keymap' |
| @@ -1872,6 +1874,19 @@ text/html;\\s-*charset=\\([^\t\n\r \"'>]+\\)[^>]*>" nil t) | |||
| 1872 | (overlay-put overlay 'face nil)) | 1874 | (overlay-put overlay 'face nil)) |
| 1873 | (setq start end))))) | 1875 | (setq start end))))) |
| 1874 | 1876 | ||
| 1877 | (defun mm--images-in-region-p (start end) | ||
| 1878 | (let ((found nil)) | ||
| 1879 | (save-excursion | ||
| 1880 | (goto-char start) | ||
| 1881 | (while (and (not found) | ||
| 1882 | (< (point) end)) | ||
| 1883 | (let ((display (get-text-property (point) 'display))) | ||
| 1884 | (when (and (consp display) | ||
| 1885 | (eq (car display) 'image)) | ||
| 1886 | (setq found t))) | ||
| 1887 | (forward-char 1))) | ||
| 1888 | found)) | ||
| 1889 | |||
| 1875 | (defun mm-handle-filename (handle) | 1890 | (defun mm-handle-filename (handle) |
| 1876 | "Return filename of HANDLE if any." | 1891 | "Return filename of HANDLE if any." |
| 1877 | (or (mail-content-type-get (mm-handle-type handle) | 1892 | (or (mail-content-type-get (mm-handle-type handle) |