mu4e/view: Restore URL activation, TAB

Make URL activation work again (with mouse, M-RET), and TAB in
gnus-view.

Fixes: #1946.
This commit is contained in:
Dirk-Jan C. Binnema 2021-03-16 17:13:36 +02:00
parent 08890dee2d
commit 7f244ee454
3 changed files with 12 additions and 34 deletions

View File

@ -478,10 +478,10 @@ list."
"A map of some number->url so we can jump to url by number.")
(put 'mu4e~view-link-map 'permanent-local t)
(defvar mu4e-view-clickable-urls-keymap
(defvar mu4e-view-active-urls-keymap
(let ((map (make-sparse-keymap)))
(define-key map [mouse-1] 'mu4e~view-browse-url-from-binding)
(define-key map [?\M-\r] 'mu4e~view-browse-url-from-binding)
(define-key map (kbd "M-<return>") 'mu4e~view-browse-url-from-binding)
map)
"Keymap used for the urls inside the body.")
@ -514,12 +514,11 @@ Meant to be evoked from interactive commands."
(get-text-property
(posn-point posn)
prop
(window-buffer (posn-window posn)))
))
(window-buffer (posn-window posn)))))
(get-text-property (point) prop)))
;; this is fairly simplistic...
(defun mu4e~view-make-urls-clickable ()
(defun mu4e~view-activate-urls ()
"Turn things that look like URLs into clickable things.
Also number them so they can be opened using `mu4e-view-go-to-url'."
(let ((num 0))
@ -539,7 +538,7 @@ Also number them so they can be opened using `mu4e-view-go-to-url'."
`(face mu4e-link-face
mouse-face highlight
mu4e-url ,url
keymap ,mu4e-view-clickable-urls-keymap
keymap ,mu4e-view-active-urls-keymap
help-echo
"[mouse-1] or [M-RET] to open the link"))
(overlay-put ov 'after-string

View File

@ -79,8 +79,8 @@
(mu4e-view-mode)
(gnus-article-prepare-display))
(setq mu4e~gnus-article-mime-handles gnus-article-mime-handles)
;; `mu4e-view-mode' derive from `gnus-article-mode'.
(mu4e~view-make-urls-clickable)
(mu4e~view-activate-urls)
;; `mu4e-view-mode' derives from `gnus-article-mode'.
(setq gnus-article-decoded-p gnus-article-decode-hook)
(set-buffer-modified-p nil)
(add-hook 'kill-buffer-hook #'mu4e~view-kill-buffer-hook-fn)))
@ -226,12 +226,7 @@ with no charset."
(define-key map (kbd "SPC") 'mu4e-view-scroll-up-or-next)
(define-key map (kbd "<home>") 'beginning-of-buffer)
(define-key map (kbd "<end>") 'end-of-buffer)
(define-key map (kbd "RET")
(lambda()
(interactive)
(if (eq (get-text-property (point) 'gnus-callback) 'gnus-button-push)
(widget-button-press (point))
(mu4e-scroll-up))))
(define-key map (kbd "RET") 'mu4e-scroll-up)
(define-key map (kbd "<backspace>") 'mu4e-scroll-down)
;; navigation between messages
@ -340,6 +335,8 @@ with no charset."
map)
"Keymap for mu4e-view mode")
(set-keymap-parent mu4e-view-mode-map button-buffer-map)
(defcustom mu4e-view-mode-hook nil
"Hook run when entering Mu4e-View mode."
:options '(turn-on-visual-line-mode)
@ -390,6 +387,7 @@ Gnus' article-mode."
(gnus-article-prepare-display)
(buffer-string))))
(defun mu4e-view-save-attachment (&optional arg)
"Save mime parts from current mu4e gnus view buffer.
@ -430,11 +428,6 @@ attachments is done with `completing-read-multiple', in this case use
do (mm-save-part-to-file h (expand-file-name f dir))))
(message "No attached files found"))))
;;; Actions
;;;
(provide 'mu4e-view-gnus)
;;; mu4e-view.el ends here

View File

@ -165,7 +165,7 @@ found."
(goto-char (point-min))
(mu4e~fontify-cited)
(mu4e~fontify-signature)
(mu4e~view-make-urls-clickable)
(mu4e~view-activate-urls)
(mu4e~view-show-images-maybe msg)
(when (not embedded) (setq mu4e~view-message msg))
(mu4e-view-mode)
@ -646,20 +646,6 @@ FUNC should be a function taking two arguments:
"Major mode for viewing an e-mail message in mu4e."
(mu4e~view-mode-body))
(defun mu4e~view-browse-url-func (url)
"Return a function that executes `browse-url' with URL.
The browser that is called depends on
`browse-url-browser-function' and `browse-url-mailto-function'."
(save-match-data
(if (string-match "^mailto:" url)
(lambda ()
(interactive)
(browse-url-mail url))
(lambda ()
(interactive)
(browse-url url)))))
(defun mu4e~view-show-images-maybe (msg)
"Show attached images, if `mu4e-show-images' is non-nil."
(when (and (display-images-p) mu4e-view-show-images)