]> code.delx.au - gnu-emacs/blobdiff - lisp/goto-addr.el
Change term translate-XXX-map to map-XXX
[gnu-emacs] / lisp / goto-addr.el
index c6e81e9b05babf4cab917cf2b32b9869a77691b0..7a4026158a80553aabfc894e492c5f165dc890f4 100644 (file)
@@ -42,7 +42,7 @@
 ;; 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]+"
@@ -94,11 +106,13 @@ But only if `goto-address-highlight-p' is also non-nil.")
          "[-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)))
@@ -106,6 +120,26 @@ and `goto-address-send-using-mhe' (MH-E).")
     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'
@@ -118,26 +152,26 @@ and `goto-address-fontify-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)))))
@@ -145,6 +179,7 @@ and `goto-address-fontify-p'."
 ;;; 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
@@ -164,6 +199,7 @@ there, then load the URL at or before the position of the mouse click."
                (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
@@ -192,7 +228,8 @@ address.  If no e-mail address found, return the empty string."
        (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: "))
@@ -200,6 +237,8 @@ address.  If no e-mail address found, return the empty string."
     (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))