;; By default, goto-address now sends using `mail' instead of `mh-send'.
;; To use mh-e to send mail, add the following to your .emacs file:
;;
-;; (setq goto-address-mail-method 'goto-address-send-using-mhe)
+;; (setq goto-address-mail-method 'goto-address-send-using-mh-e)
;;
;; The mouse click method is bound to [mouse-2] on highlighted URL's or
;; e-mail addresses only; it functions normally everywhere else. To bind
(require 'browse-url)
+(defgroup goto-address nil
+ "Click to browse URL or to send to e-mail address."
+ :group 'mouse
+ :group 'hypermedia)
+
+
;;; I don't expect users to want fontify'ing without highlighting.
-(defvar goto-address-fontify-p t
+(defcustom goto-address-fontify-p t
"*If t, URL's and e-mail addresses in buffer are fontified.
-But only if `goto-address-highlight-p' is also non-nil.")
+But only if `goto-address-highlight-p' is also non-nil."
+ :type 'boolean
+ :group 'goto-address)
-(defvar goto-address-highlight-p t
- "*If t, URL's and e-mail addresses in buffer are highlighted.")
+(defcustom goto-address-highlight-p t
+ "*If t, URL's and e-mail addresses in buffer are highlighted."
+ :type 'boolean
+ :group 'goto-address)
-(defvar goto-address-fontify-maximum-size 30000
- "*Maximum size of file in which to fontify and/or highlight URL's.")
+(defcustom goto-address-fontify-maximum-size 30000
+ "*Maximum size of file in which to fontify and/or highlight URL's."
+ :type 'integer
+ :group 'goto-address)
(defvar goto-address-mail-regexp
"[-a-zA-Z0-9._]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
"[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
"A regular expression probably matching a URL.")
-(defvar goto-address-mail-method
+(defcustom goto-address-mail-method
'goto-address-send-using-mail
"*Function to compose mail.
Two pre-made functions are `goto-address-send-using-mail' (sendmail);
-and `goto-address-send-using-mhe' (MH-E).")
+and `goto-address-send-using-mh-e' (MH-E)."
+ :type 'function
+ :group 'goto-address)
(defvar goto-address-highlight-keymap
(let ((m (make-sparse-keymap)))
m)
"keymap to hold goto-addr's mouse key defs under highlighted URLs.")
+(defcustom goto-address-url-face 'bold
+ "*Face to use for URLs."
+ :type 'face
+ :group 'goto-address)
+
+(defcustom goto-address-url-mouse-face 'highlight
+ "*Face to use for URLs when the mouse is on them."
+ :type 'face
+ :group 'goto-address)
+
+(defcustom goto-address-mail-face 'italic
+ "*Face to use for e-mail addresses."
+ :type 'face
+ :group 'goto-address)
+
+(defcustom goto-address-mail-mouse-face 'secondary-selection
+ "*Face to use for e-mail addresses when the mouse is on them."
+ :type 'face
+ :group 'goto-address)
+
(defun goto-address-fontify ()
"Fontify the URL's and e-mail addresses in the current buffer.
This function implements `goto-address-highlight-p'
(if (< (- (point-max) (point)) goto-address-fontify-maximum-size)
(progn
(while (re-search-forward goto-address-url-regexp nil t)
- (let ((s (match-beginning 0))
- (e (match-end 0)))
- (goto-char e)
+ (let* ((s (match-beginning 0))
+ (e (match-end 0))
+ (this-overlay (make-overlay s e)))
(and goto-address-fontify-p
- (put-text-property s e 'face 'bold))
- (put-text-property s e 'mouse-face 'highlight)
- (put-text-property
- s e 'local-map goto-address-highlight-keymap)))
+ (overlay-put this-overlay 'face goto-address-url-face))
+ (overlay-put this-overlay
+ 'mouse-face goto-address-url-mouse-face)
+ (overlay-put this-overlay
+ 'local-map goto-address-highlight-keymap)))
(goto-char (point-min))
(while (re-search-forward goto-address-mail-regexp nil t)
- (let ((s (match-beginning 0))
- (e (match-end 0)))
- (goto-char (match-end 0))
+ (let* ((s (match-beginning 0))
+ (e (match-end 0))
+ (this-overlay (make-overlay s e)))
(and goto-address-fontify-p
- (put-text-property (match-beginning 0) (match-end 0)
- 'face 'italic))
- (put-text-property (match-beginning 0) (match-end 0)
- 'mouse-face 'secondary-selection)
- (put-text-property
- s e 'local-map goto-address-highlight-keymap)))))
+ (overlay-put this-overlay 'face goto-address-mail-face))
+ (overlay-put this-overlay 'mouse-face
+ goto-address-mail-mouse-face)
+ (overlay-put this-overlay
+ 'local-map goto-address-highlight-keymap)))))
(and (buffer-modified-p)
(not modified)
(set-buffer-modified-p nil)))))
;;; code to find and goto addresses; much of this has been blatantly
;;; snarfed from browse-url.el
+;;;###autoload
(defun goto-address-at-mouse (event)
"Send to the e-mail address or load the URL clicked with the mouse.
Send mail to address at position of mouse click. See documentation for
(funcall browse-url-browser-function url)))
(funcall goto-address-mail-method address))))))
+;;;###autoload
(defun goto-address-at-point ()
"Send to the e-mail address or load the URL at point.
Send mail to address at point. See documentation for
(buffer-substring (match-beginning 0) (match-end 0))
"")))
-(defun goto-address-send-using-mhe (to)
+(defun goto-address-send-using-mh-e (to)
+ (require 'mh-comp)
(mh-find-path)
(let ((cc (mh-read-address "Cc: "))
(subject (read-string "Subject: "))
(delete-other-windows)
(mh-send-sub to cc subject config)))
+(fset 'goto-address-send-using-mhe 'goto-address-send-using-mh-e)
+
(defun goto-address-send-using-mail (to)
(mail-other-window nil to)
(and (goto-char (point-min))