mu4e-view-gnus: use the gnus mech to identify urls
Add mu4e~view-urlify, which replaces mu4e~view-activate-urls, and let gnus determine where the URLs are.
This commit is contained in:
@ -67,10 +67,11 @@ etc."
|
|||||||
;; we need this for replying/forwarding, since the mu4e-compose
|
;; we need this for replying/forwarding, since the mu4e-compose
|
||||||
;; wants it that way.
|
;; wants it that way.
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
(let ((mm-discouraged-alternatives '("text/html")))
|
||||||
(insert-file-contents-literally
|
(insert-file-contents-literally
|
||||||
(mu4e-message-field msg :path) nil nil nil t)
|
(mu4e-message-field msg :path) nil nil nil t)
|
||||||
(mu4e~view-render-buffer msg)
|
(mu4e~view-render-buffer msg)
|
||||||
(buffer-string)))
|
(buffer-string))))
|
||||||
|
|
||||||
(defun mu4e-action-view-in-browser (msg)
|
(defun mu4e-action-view-in-browser (msg)
|
||||||
"Show current message MSG in browser, if it contains an html body."
|
"Show current message MSG in browser, if it contains an html body."
|
||||||
@ -109,6 +110,7 @@ buffer BUF."
|
|||||||
(charset (and charset (intern charset)))
|
(charset (and charset (intern charset)))
|
||||||
(mu4e~view-rendering t); Needed if e.g. an ics file is buttonized
|
(mu4e~view-rendering t); Needed if e.g. an ics file is buttonized
|
||||||
(gnus-article-emulate-mime t)
|
(gnus-article-emulate-mime t)
|
||||||
|
(gnus-unbuttonized-mime-types '(".*/.*"))
|
||||||
(gnus-buttonized-mime-types
|
(gnus-buttonized-mime-types
|
||||||
(append (list "multipart/signed" "multipart/encrypted")
|
(append (list "multipart/signed" "multipart/encrypted")
|
||||||
gnus-buttonized-mime-types))
|
gnus-buttonized-mime-types))
|
||||||
@ -123,12 +125,33 @@ buffer BUF."
|
|||||||
(mu4e-view-mode)
|
(mu4e-view-mode)
|
||||||
(run-hooks 'gnus-article-decode-hook)
|
(run-hooks 'gnus-article-decode-hook)
|
||||||
(gnus-article-prepare-display)
|
(gnus-article-prepare-display)
|
||||||
(mu4e~view-activate-urls)
|
(remove-overlays)
|
||||||
|
(mu4e~view-urlify)
|
||||||
(setq mu4e~gnus-article-mime-handles gnus-article-mime-handles
|
(setq mu4e~gnus-article-mime-handles gnus-article-mime-handles
|
||||||
gnus-article-decoded-p gnus-article-decode-hook)
|
gnus-article-decoded-p gnus-article-decode-hook)
|
||||||
(set-buffer-modified-p nil)
|
(set-buffer-modified-p nil)
|
||||||
(add-hook 'kill-buffer-hook #'mu4e~view-kill-mime-handles)))
|
(add-hook 'kill-buffer-hook #'mu4e~view-kill-mime-handles)))
|
||||||
|
|
||||||
|
|
||||||
|
(defun mu4e~view-urlify ()
|
||||||
|
"Get numbered URLs in the buffer."
|
||||||
|
(let ((num 0) (inhibit-read-only t)
|
||||||
|
(link-map (make-hash-table :size 32 :weakness nil)))
|
||||||
|
(save-excursion
|
||||||
|
(save-restriction
|
||||||
|
(narrow-to-region (point-min) (point-max))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(while (re-search-forward gnus-button-url-regexp nil t)
|
||||||
|
(let ((match-string (match-string-no-properties 0)))
|
||||||
|
(when (not (equal (substring match-string 0 4) "file"))
|
||||||
|
(cl-incf num)
|
||||||
|
(let* ((tag (propertize (format "\u200B[%d]" num)
|
||||||
|
'face 'mu4e-url-number-face))
|
||||||
|
(tag-ov (make-overlay (point) (+ (point) (length tag)))))
|
||||||
|
(overlay-put tag-ov 'before-string tag)
|
||||||
|
(puthash num match-string link-map)))))))
|
||||||
|
(setq mu4e~view-link-map link-map)))
|
||||||
|
|
||||||
(defun mu4e~view-kill-mime-handles ()
|
(defun mu4e~view-kill-mime-handles ()
|
||||||
"Kill cached MIME-handles, if any."
|
"Kill cached MIME-handles, if any."
|
||||||
(when mu4e~gnus-article-mime-handles
|
(when mu4e~gnus-article-mime-handles
|
||||||
@ -163,6 +186,7 @@ buffer BUF."
|
|||||||
(mu4e~view-gnus-insert-header-custom msg field)))))
|
(mu4e~view-gnus-insert-header-custom msg field)))))
|
||||||
(let ((gnus-treatment-function-alist
|
(let ((gnus-treatment-function-alist
|
||||||
'((gnus-treat-highlight-headers
|
'((gnus-treat-highlight-headers
|
||||||
|
gnus-article-add-buttons
|
||||||
gnus-article-highlight-headers))))
|
gnus-article-highlight-headers))))
|
||||||
(gnus-treat-article 'head))))))
|
(gnus-treat-article 'head))))))
|
||||||
|
|
||||||
@ -204,7 +228,6 @@ with no charset."
|
|||||||
(list handle attendee))
|
(list handle attendee))
|
||||||
handle-attendee))
|
handle-attendee))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e~view-mode-p ()
|
(defun mu4e~view-mode-p ()
|
||||||
(or (eq major-mode 'mu4e-view-mode)
|
(or (eq major-mode 'mu4e-view-mode)
|
||||||
(derived-mode-p '(mu4e-view-mode))))
|
(derived-mode-p '(mu4e-view-mode))))
|
||||||
|
|||||||
Reference in New Issue
Block a user