annotate lisp/net/goto-addr.el @ 112280:a0a140d8d84d

* lisp/isearch.el (isearch-abort): Don't quit if search has an incomplete regexp (isearch-error is non-nil). (Bug#7534)
author Juri Linkov <juri@jurta.org>
date Sun, 16 Jan 2011 01:04:22 +0000
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; goto-addr.el --- click to browse URL or to send to e-mail address
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1995, 2000, 2001, 2002, 2003, 2004,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
30192
7d917a6185d3 Change maintainer address.
Dave Love <fx@gnu.org>
parents: 29664
diff changeset
6 ;; Author: Eric Ding <ericding@alum.mit.edu>
30285
0ff2877c9bbe Change maintainer to FSF.
Gerd Moellmann <gerd@gnu.org>
parents: 30192
diff changeset
7 ;; Maintainer: FSF
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Created: 15 Aug 1995
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; Keywords: mh-e, www, mouse, mail
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94325
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94325
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94325
diff changeset
16 ;; (at your option) any later version.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94677
91e5880a36c1 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94325
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;; This package allows you to click or hit a key sequence while on a
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; URL or e-mail address, and either load the URL into a browser of
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; your choice using the browse-url package, or if it's an e-mail
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; address, to send an e-mail to that address. By default, we bind to
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; the [mouse-2] and the [C-c return] key sequences.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; INSTALLATION
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; To use goto-address in a particular mode (for example, while
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; reading mail in mh-e), add something like this in your .emacs file:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; (add-hook 'mh-show-mode-hook 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;
29664
3e03d72fadea (goto-address-fontify): Use keymap property, not local-map.
Dave Love <fx@gnu.org>
parents: 29653
diff changeset
41 ;; The mouse click method is bound to [mouse-2] on highlighted URLs or
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; e-mail addresses only; it functions normally everywhere else. To bind
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;; another mouse click to the function, add the following to your .emacs
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; (for example):
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 ;; (setq goto-address-highlight-keymap
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 ;; (let ((m (make-sparse-keymap)))
62130
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
48 ;; (define-key m [S-mouse-2] 'goto-address-at-point)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;; m))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;; Known bugs/features:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; * goto-address-mail-regexp only catches foo@bar.org style addressing,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;; not stuff like X.400 addresses, etc.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 ;; * regexp also catches Message-Id line, since it is in the format of
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 ;; an Internet e-mail address (like Compuserve addresses)
30345
d24028985f3d (goto-address-fontify): Don't bother with buffer-modified and read-only
Dave Love <fx@gnu.org>
parents: 30285
diff changeset
57 ;; * If the buffer is fontified after goto-address-fontify is run
d24028985f3d (goto-address-fontify): Don't bother with buffer-modified and read-only
Dave Love <fx@gnu.org>
parents: 30285
diff changeset
58 ;; (say, using font-lock-fontify-buffer), then font-lock faces will
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; override goto-address faces.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;;; Code:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
63 (require 'thingatpt)
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
64 (autoload 'browse-url-url-at-point "browse-url")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65
37423
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
66 ;; XEmacs needs the following definitions.
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
67 (unless (fboundp 'overlays-in)
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
68 (require 'overlay))
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
69 (unless (fboundp 'line-beginning-position)
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
70 (defalias 'line-beginning-position 'point-at-bol))
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
71 (unless (fboundp 'line-end-position)
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
72 (defalias 'line-end-position 'point-at-eol))
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
73 (unless (fboundp 'match-string-no-properties)
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
74 (defalias 'match-string-no-properties 'match-string))
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
75
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (defgroup goto-address nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 "Click to browse URL or to send to e-mail address."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 :group 'mouse
107379
3c0cd76e49ff Fix last change to use existing comm Custom group instead of `net'.
Chong Yidong <cyd@stupidchicken.com>
parents: 107378
diff changeset
79 :group 'comm)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81
39568
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
82 ;; I don't expect users to want fontify'ing without highlighting.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 (defcustom goto-address-fontify-p t
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
84 "*Non-nil means URLs and e-mail addresses in buffer are fontified.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 But only if `goto-address-highlight-p' is also non-nil."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 :type 'boolean
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (defcustom goto-address-highlight-p t
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
90 "*Non-nil means URLs and e-mail addresses in buffer are highlighted."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 :type 'boolean
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 (defcustom goto-address-fontify-maximum-size 30000
51098
9277afae9517 (goto-address-fontify-maximum-size): Value t means no limit.
Richard M. Stallman <rms@gnu.org>
parents: 49598
diff changeset
95 "*Maximum size of file in which to fontify and/or highlight URLs.
9277afae9517 (goto-address-fontify-maximum-size): Value t means no limit.
Richard M. Stallman <rms@gnu.org>
parents: 49598
diff changeset
96 A value of t means there is no limit--fontify regardless of the size."
9277afae9517 (goto-address-fontify-maximum-size): Value t means no limit.
Richard M. Stallman <rms@gnu.org>
parents: 49598
diff changeset
97 :type '(choice (integer :tag "Maximum size") (const :tag "No limit" t))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (defvar goto-address-mail-regexp
39790
1802ca573682 (goto-address-mail-regexp): Allow + in username.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39568
diff changeset
101 ;; Actually pretty much any char could appear in the username part. -stef
59117
7aa5e44f673f (goto-address-mail-regexp): Allow = in username.
Richard M. Stallman <rms@gnu.org>
parents: 56210
diff changeset
102 "[-a-zA-Z0-9=._+]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+"
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 "A regular expression probably matching an e-mail address.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104
48068
0560d7169eba (goto-address-url-regexp): Don't match `mailto'.
Richard M. Stallman <rms@gnu.org>
parents: 39790
diff changeset
105 (defvar goto-address-url-regexp
66695
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
106 (concat
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
107 "\\<\\("
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
108 (mapconcat 'identity
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
109 (delete "mailto:"
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
110 ;; Remove `data:', as it's not terribly useful to follow
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
111 ;; those. Leaving them causes `use Data::Dumper;' to be
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
112 ;; fontified oddly in Perl files.
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
113 (delete "data:"
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
114 (copy-sequence thing-at-point-uri-schemes)))
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
115 "\\|")
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
116 "\\)"
0ade01371c2e (goto-address-url-regexp): Remove `data:' URLs from goto-address-url-regexp.
Eli Zaretskii <eliz@gnu.org>
parents: 64701
diff changeset
117 thing-at-point-url-path-regexp)
39568
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
118 ;; (concat "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|"
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
119 ;; "telnet\\|wais\\):\\(//[-a-zA-Z0-9_.]+:"
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
120 ;; "[0-9]*\\)?[-a-zA-Z0-9_=?#$@~`%&*+|\\/.,]*"
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
121 ;; "[-a-zA-Z0-9_=#$@~`%&*+|\\/]")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 "A regular expression probably matching a URL.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (defvar goto-address-highlight-keymap
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (let ((m (make-sparse-keymap)))
62130
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
126 (define-key m (if (featurep 'xemacs) (kbd "<button2>") (kbd "<mouse-2>"))
62131
ae455ff58429 Paren typo again.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 62130
diff changeset
127 'goto-address-at-point)
37423
3ab2c865a8e5 Instead of defining line-beginning-position and
Gerd Moellmann <gerd@gnu.org>
parents: 30891
diff changeset
128 (define-key m (kbd "C-c RET") 'goto-address-at-point)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 m)
67914
f7b57b2971ba (goto-address-highlight-keymap): Fix docstring.
Juri Linkov <juri@jurta.org>
parents: 67083
diff changeset
130 "Keymap to hold goto-addr's mouse key defs under highlighted URLs.")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131
101184
8b936847a612 (goto-address-url-face): Change default value from `bold' to `link'.
Juri Linkov <juri@jurta.org>
parents: 100908
diff changeset
132 (defcustom goto-address-url-face 'link
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
133 "Face to use for URLs."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 :type 'face
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (defcustom goto-address-url-mouse-face 'highlight
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
138 "Face to use for URLs when the mouse is on them."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :type 'face
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (defcustom goto-address-mail-face 'italic
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
143 "Face to use for e-mail addresses."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 :type 'face
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (defcustom goto-address-mail-mouse-face 'secondary-selection
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
148 "Face to use for e-mail addresses when the mouse is on them."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 :type 'face
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 :group 'goto-address)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151
94318
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
152 (defun goto-address-unfontify (start end)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
153 "Remove `goto-address' fontification from the given region."
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
154 (dolist (overlay (overlays-in start end))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
155 (if (overlay-get overlay 'goto-address)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
156 (delete-overlay overlay))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
157
94325
693b7934455a (goto-address-prog-mode): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents: 94318
diff changeset
158 (defvar goto-address-prog-mode)
693b7934455a (goto-address-prog-mode): Declare for compiler.
Glenn Morris <rgm@gnu.org>
parents: 94318
diff changeset
159
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (defun goto-address-fontify ()
29664
3e03d72fadea (goto-address-fontify): Use keymap property, not local-map.
Dave Love <fx@gnu.org>
parents: 29653
diff changeset
161 "Fontify the URLs and e-mail addresses in the current buffer.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 This function implements `goto-address-highlight-p'
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 and `goto-address-fontify-p'."
30345
d24028985f3d (goto-address-fontify): Don't bother with buffer-modified and read-only
Dave Love <fx@gnu.org>
parents: 30285
diff changeset
164 ;; Clean up from any previous go.
94318
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
165 (goto-address-unfontify (point-min) (point-max))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166 (save-excursion
30345
d24028985f3d (goto-address-fontify): Don't bother with buffer-modified and read-only
Dave Love <fx@gnu.org>
parents: 30285
diff changeset
167 (let ((inhibit-point-motion-hooks t))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (goto-char (point-min))
94318
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
169 (when (or (eq t goto-address-fontify-maximum-size)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
170 (< (- (point-max) (point)) goto-address-fontify-maximum-size))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
171 (while (re-search-forward goto-address-url-regexp nil t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
172 (let* ((s (match-beginning 0))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
173 (e (match-end 0))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
174 this-overlay)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
175 (when (or (not goto-address-prog-mode)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
176 ;; This tests for both comment and string
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
177 ;; syntax.
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
178 (nth 8 (syntax-ppss)))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
179 (setq this-overlay (make-overlay s e))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
180 (and goto-address-fontify-p
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
181 (overlay-put this-overlay 'face goto-address-url-face))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
182 (overlay-put this-overlay 'evaporate t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
183 (overlay-put this-overlay
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
184 'mouse-face goto-address-url-mouse-face)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
185 (overlay-put this-overlay 'follow-link t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
186 (overlay-put this-overlay
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
187 'help-echo "mouse-2, C-c RET: follow URL")
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
188 (overlay-put this-overlay
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
189 'keymap goto-address-highlight-keymap)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
190 (overlay-put this-overlay 'goto-address t))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
191 (goto-char (point-min))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
192 (while (re-search-forward goto-address-mail-regexp nil t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
193 (let* ((s (match-beginning 0))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
194 (e (match-end 0))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
195 this-overlay)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
196 (when (or (not goto-address-prog-mode)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
197 ;; This tests for both comment and string
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
198 ;; syntax.
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
199 (nth 8 (syntax-ppss)))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
200 (setq this-overlay (make-overlay s e))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
201 (and goto-address-fontify-p
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
202 (overlay-put this-overlay 'face goto-address-mail-face))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
203 (overlay-put this-overlay 'evaporate t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
204 (overlay-put this-overlay 'mouse-face
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
205 goto-address-mail-mouse-face)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
206 (overlay-put this-overlay 'follow-link t)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
207 (overlay-put this-overlay
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
208 'help-echo "mouse-2, C-c RET: mail this address")
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
209 (overlay-put this-overlay
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
210 'keymap goto-address-highlight-keymap)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
211 (overlay-put this-overlay 'goto-address t))))))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
212
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
213 (defun goto-address-fontify-region (start end)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
214 "Fontify URLs and e-mail addresses in the given region."
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
215 (save-excursion
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
216 (save-restriction
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
217 (let ((beg-line (progn (goto-char start) (line-beginning-position)))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
218 (end-line (progn (goto-char end) (line-end-position))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
219 (narrow-to-region beg-line end-line)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
220 (goto-address-fontify)))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221
39568
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
222 ;; code to find and goto addresses; much of this has been blatantly
e67950065cf9 Change ;;; to ;; for outline-minor-mode.
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
223 ;; snarfed from browse-url.el
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 ;;;###autoload
62130
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
226 (define-obsolete-function-alias
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
227 'goto-address-at-mouse 'goto-address-at-point "22.1")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 ;;;###autoload
62130
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
230 (defun goto-address-at-point (&optional event)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 "Send to the e-mail address or load the URL at point.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 Send mail to address at point. See documentation for
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 `goto-address-find-address-at-point'. If no address is found
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 there, then load the URL at or before point."
62130
109432f1fa94 (goto-address-fontify): Make sure the overlays
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59117
diff changeset
235 (interactive (list last-input-event))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (save-excursion
67083
78a5a90bd7ec (goto-address-fontify): Put `follow-link' property on mail and url overlays.
John Paul Wallington <jpw@pobox.com>
parents: 66695
diff changeset
237 (if event (posn-set-point (event-end event)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 (let ((address (save-excursion (goto-address-find-address-at-point))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48068
diff changeset
239 (if (and address
37809
5bc4eff5115e (goto-address-at-point): Deal with URLs
Gerd Moellmann <gerd@gnu.org>
parents: 37423
diff changeset
240 (save-excursion
5bc4eff5115e (goto-address-at-point): Deal with URLs
Gerd Moellmann <gerd@gnu.org>
parents: 37423
diff changeset
241 (goto-char (previous-single-char-property-change
5bc4eff5115e (goto-address-at-point): Deal with URLs
Gerd Moellmann <gerd@gnu.org>
parents: 37423
diff changeset
242 (point) 'goto-address nil
5bc4eff5115e (goto-address-at-point): Deal with URLs
Gerd Moellmann <gerd@gnu.org>
parents: 37423
diff changeset
243 (line-beginning-position)))
5bc4eff5115e (goto-address-at-point): Deal with URLs
Gerd Moellmann <gerd@gnu.org>
parents: 37423
diff changeset
244 (not (looking-at goto-address-url-regexp))))
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
245 (compose-mail address)
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
246 (let ((url (browse-url-url-at-point)))
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
247 (if url
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
248 (browse-url url)
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
249 (error "No e-mail address or URL found")))))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (defun goto-address-find-address-at-point ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 "Find e-mail address around or before point.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 Then search backwards to beginning of line for the start of an e-mail
30891
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
254 address. If no e-mail address found, return nil."
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
255 (re-search-backward "[^-_A-z0-9.@]" (line-beginning-position) 'lim)
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
256 (if (or (looking-at goto-address-mail-regexp) ; already at start
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
257 (and (re-search-forward goto-address-mail-regexp
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
258 (line-end-position) 'lim)
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
259 (goto-char (match-beginning 0))))
42ce5997aa4a Don't require browse-url. Require thingatpt.
Dave Love <fx@gnu.org>
parents: 30345
diff changeset
260 (match-string-no-properties 0)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (defun goto-address ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 "Sets up goto-address functionality in the current buffer.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 Allows user to use mouse/keyboard command to click to go to a URL
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 or to send e-mail.
67914
f7b57b2971ba (goto-address-highlight-keymap): Fix docstring.
Juri Linkov <juri@jurta.org>
parents: 67083
diff changeset
267 By default, goto-address binds `goto-address-at-point' to mouse-2 and C-c RET
f7b57b2971ba (goto-address-highlight-keymap): Fix docstring.
Juri Linkov <juri@jurta.org>
parents: 67083
diff changeset
268 only on URLs and e-mail addresses.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 Also fontifies the buffer appropriately (see `goto-address-fontify-p' and
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 `goto-address-highlight-p' for more information)."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (if goto-address-highlight-p
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (goto-address-fontify)))
71636
0fa81d575f41 * net/goto-addr.el (goto-address): Mark as safe for local evals.
Chong Yidong <cyd@stupidchicken.com>
parents: 68648
diff changeset
275 ;;;###autoload(put 'goto-address 'safe-local-eval-function t)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276
94318
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
277 ;;;###autoload
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
278 (define-minor-mode goto-address-mode
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
279 "Minor mode to buttonize URLs and e-mail addresses in the current buffer."
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
280 nil
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
281 ""
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
282 nil
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
283 (if goto-address-mode
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
284 (jit-lock-register #'goto-address-fontify-region)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
285 (jit-lock-unregister #'goto-address-fontify-region)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
286 (save-restriction
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
287 (widen)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
288 (goto-address-unfontify (point-min) (point-max)))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
289
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
290 ;;;###autoload
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
291 (define-minor-mode goto-address-prog-mode
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
292 "Turn on `goto-address-mode', but only in comments and strings."
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
293 nil
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
294 ""
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
295 nil
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
296 (if goto-address-prog-mode
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
297 (jit-lock-register #'goto-address-fontify-region)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
298 (jit-lock-unregister #'goto-address-fontify-region)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
299 (save-restriction
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
300 (widen)
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
301 (goto-address-unfontify (point-min) (point-max)))))
76f3f9a141a5 Tom Tromey <tromey at redhat.com>
Glenn Morris <rgm@gnu.org>
parents: 79714
diff changeset
302
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (provide 'goto-addr)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 37809
diff changeset
305 ;;; goto-addr.el ends here