* mu4e-view: fix visiting mailto: links (emacs23)

This commit is contained in:
djcb 2012-06-23 19:38:06 +03:00
parent 5fba6583ef
commit 325dfdc483
1 changed files with 18 additions and 27 deletions

View File

@ -98,12 +98,7 @@ buffer."
"The maximum width for images to display; this is only effective
if you're using an emacs with Imagemagick support."
:group 'mu4e-view)
(defvar mu4e-view-browse-url-mailto-function
'mu4e~compose-browse-url-mail
"Function to use for mailto: links.")
(defvar mu4e-view-actions
'( ("capture message" . mu4e-action-capture-message)
("view as pdf" . mu4e-action-view-as-pdf))
@ -144,13 +139,7 @@ where:
"\\(\\(https?\\://\\|mailto:\\)[-+a-zA-Z0-9.?_$%/+&#@!~,:;=/()]+\\)"
"Regexp that matches http:/https:/mailto: URLs; match-string 1
will contain the matched URL, if any.")
(defconst mu4e~view-mailto-regexp
"\\("
"Regexp that matches mailto: URLs; match-string 1 will contain
the matched URL, if any.")
(defvar mu4e~view-attach-map nil
"A mapping of user-visible attachment number to the actual part index.")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -533,10 +522,7 @@ is nil, and otherwise open it."
(make-local-variable 'mu4e~view-lines-wrapped)
(make-local-variable 'mu4e~view-cited-hidden)
(make-local-variable 'browse-url-mailto-function)
(setq browse-url-mailto-function mu4e-view-browse-url-mailto-function)
(setq buffer-undo-list t) ;; don't record undo info
;; autopair mode gives error when pressing RET
@ -603,12 +589,17 @@ Seen; if the message is not New/Unread, do nothing."
"Return a function that executes `browse-url' with URL. What
browser is called is depending on `browse-url-browser-function' and
`browse-url-mailto-function'."
(lexical-let ((url url))
(lambda ()
(interactive)
(browse-url url))))
(save-match-data
(if (string-match "^mailto:" url)
(lexical-let ((url url))
(lambda ()
(interactive)
(mu4e~compose-browse-url-mail url)))
(lexical-let ((url url))
(lambda ()
(interactive)
(browse-url url))))))
(defun mu4e~view-show-images-maybe (msg)
"Show attached images, if `mu4e-view-show-images' is non-nil."
(when (and (display-images-p) mu4e-view-show-images)
@ -640,9 +631,9 @@ number them so they can be opened using `mu4e-view-go-to-url'."
`(face mu4e-view-link-face
mouse-face highlight
keymap ,map) url)
(replace-match (concat url
(propertize (format "[%d]" num)
'face 'mu4e-view-url-number-face))))))))
(replace-match
(concat url
(propertize (format "[%d]" num) 'face 'mu4e-view-url-number-face))))))))
(defun mu4e~view-wrap-lines ()
@ -1016,7 +1007,7 @@ user that unmarking only works in the header list."
(interactive "n[mu4e] Visit url with number: ")
(let ((url (gethash num mu4e~view-link-map)))
(unless url (error "Invalid number for URL"))
(browse-url url)))
(funcall (mu4e~view-browse-url-func url))))
(defconst mu4e~view-raw-buffer-name "*mu4e-raw-view*"
"*internal* Name for the raw message view buffer")