aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-07-28 15:55:31 +0200
committerLars Ingebrigtsen2019-07-28 15:55:37 +0200
commita32e1feb438e793a8378671c7124d226b58f65f0 (patch)
tree238eed9aeda4abfd361c57f557cfb1154d4640da
parentdcba39b445e8f71c5f8df34a38ae8fc726a51843 (diff)
downloademacs-a32e1feb438e793a8378671c7124d226b58f65f0.tar.gz
emacs-a32e1feb438e793a8378671c7124d226b58f65f0.zip
Enable browse-url to buttonize buffers
This patch also moves the internal/external browser logic from shr to browse-url, where it belongs more naturally. * doc/misc/eww.texi (Basics): Adjust to browse-url-external-browser. * doc/misc/gnus.texi (Article Commands): Ditto. * lisp/gnus/gnus-art.el (gnus-button-url-regexp): Default to `browse-url-button-regexp', which has taken over the definition previously enjoyed by this variable. * lisp/gnus/gnus-sum.el (gnus-summary-browse-url): Adjust usage. * lisp/net/browse-url.el (browse-url--browser-defcustom-type): New internal variable... (browse-url-browser-function, browse-url-external-browser): Used by these two; the latter of which is a new variable. (browse-url-botton-regexp): New variable. (browse-url-button-map): New keymap. (browse-url-button): New face. (browse-url-add-buttons): New function to add clickable browse-url buttons to almost any buffer. (browse-url-button-open): New command. (browse-url-button-copy): New command. * lisp/net/eww.el (eww-browse-with-external-browser) (eww-follow-link): Adjust usage. * lisp/net/shr.el (shr-external-browser): Make an obsolete alias of `browse-url-external-browser'. (shr-browse-url): Adjust usage.
-rw-r--r--doc/misc/eww.texi4
-rw-r--r--doc/misc/gnus.texi2
-rw-r--r--etc/NEWS10
-rw-r--r--lisp/gnus/gnus-art.el22
-rw-r--r--lisp/gnus/gnus-sum.el4
-rw-r--r--lisp/net/browse-url.el310
-rw-r--r--lisp/net/eww.el10
-rw-r--r--lisp/net/shr.el40
8 files changed, 201 insertions, 201 deletions
diff --git a/doc/misc/eww.texi b/doc/misc/eww.texi
index 8dc58e84257..cd74aa32c77 100644
--- a/doc/misc/eww.texi
+++ b/doc/misc/eww.texi
@@ -187,7 +187,7 @@ switch EWW buffers through a minibuffer prompt, press @kbd{s}
187(@code{eww-switch-to-buffer}). 187(@code{eww-switch-to-buffer}).
188 188
189@findex eww-browse-with-external-browser 189@findex eww-browse-with-external-browser
190@vindex shr-external-browser 190@vindex browse-url-external-browser
191@vindex eww-use-external-browser-for-content-type 191@vindex eww-use-external-browser-for-content-type
192@kindex & 192@kindex &
193@cindex External Browser 193@cindex External Browser
@@ -197,7 +197,7 @@ or are not implemented (E.g., JavaScript). If you have trouble
197viewing a website with EWW then hit @kbd{&} 197viewing a website with EWW then hit @kbd{&}
198(@code{eww-browse-with-external-browser}) inside the EWW buffer to 198(@code{eww-browse-with-external-browser}) inside the EWW buffer to
199open the website in the external browser specified by 199open the website in the external browser specified by
200@code{shr-external-browser}. Some content types, such as video or 200@code{browse-url-external-browser}. Some content types, such as video or
201audio content, do not make sense to display in GNU Emacs at all. You 201audio content, do not make sense to display in GNU Emacs at all. You
202can tell EWW to open specific content automatically in an external 202can tell EWW to open specific content automatically in an external
203browser by customizing 203browser by customizing
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi
index 3968fa58377..7a3322d9fc0 100644
--- a/doc/misc/gnus.texi
+++ b/doc/misc/gnus.texi
@@ -10164,7 +10164,7 @@ do so.
10164@findex gnus-summary-browse-url 10164@findex gnus-summary-browse-url
10165Scan the article buffer for links, and offer them to the user for 10165Scan the article buffer for links, and offer them to the user for
10166browsing with @code{browse-url}. With a prefix argument, browse with 10166browsing with @code{browse-url}. With a prefix argument, browse with
10167@code{shr-external-browser} instead. 10167@code{browse-url-external-browser} instead.
10168 10168
10169@end table 10169@end table
10170 10170
diff --git a/etc/NEWS b/etc/NEWS
index cccb8017bd4..6517f1938c2 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -765,6 +765,12 @@ start of a sentence or at '(point-min)', else '@ref'.
765It now treats the optional 2nd argument to mean that the URL should be 765It now treats the optional 2nd argument to mean that the URL should be
766shown in the currently selected window. 766shown in the currently selected window.
767 767
768*** A new function, 'browse-url-add-buttons' can be used to add clickable
769links to most ordinary special-mode buffers that display text that
770have URLs embedded. 'browse-url-button-regexp' controls what's
771considered a button.
772
773*** A new variable, 'browse-url-external-browser', has been added.
768** Comint 774** Comint
769 775
770+++ 776+++
@@ -1037,6 +1043,10 @@ has been executed.
1037If set, shr will not render tags with attribute 'aria-hidden="true"'. 1043If set, shr will not render tags with attribute 'aria-hidden="true"'.
1038This attribute is meant to tell screen readers to ignore a tag. 1044This attribute is meant to tell screen readers to ignore a tag.
1039 1045
1046+++
1047*** 'shr-external-browser' has been made into an obsolete alias
1048of 'browse-url-external-browser'.
1049
1040--- 1050---
1041*** 'shr-tag-ol' now respects the ordered list 'start' attribute. 1051*** 'shr-tag-ol' now respects the ordered list 'start' attribute.
1042 1052
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 65e1c8106d5..89f57712c56 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -7343,27 +7343,9 @@ groups."
7343 7343
7344;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. 7344;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7345 7345
7346;;; Internal Variables: 7346(defcustom gnus-button-url-regexp browse-url-button-regexp
7347
7348(defcustom gnus-button-url-regexp
7349 (concat
7350 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7351 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7352 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7353 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7354 (punct "!?:;.,"))
7355 (concat
7356 "\\(?:"
7357 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7358 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7359 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7360 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7361 "\\|"
7362 "[" chars punct "]+" "[" chars "]"
7363 "\\)"))
7364 "\\)")
7365 "Regular expression that matches URLs." 7347 "Regular expression that matches URLs."
7366 :version "24.4" 7348 :version "27.1"
7367 :group 'gnus-article-buttons 7349 :group 'gnus-article-buttons
7368 :type 'regexp) 7350 :type 'regexp)
7369 7351
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index b239890c884..d3103bd4b20 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -9478,7 +9478,7 @@ The 1st element is the widget named by `gnus-collect-urls-primary-text'."
9478 "Scan the current article body for links, and offer to browse them. 9478 "Scan the current article body for links, and offer to browse them.
9479 9479
9480Links are opened using `browse-url' unless a prefix argument is 9480Links are opened using `browse-url' unless a prefix argument is
9481given: Then `shr-external-browser' is used instead. 9481given: Then `browse-url-external-browser' is used instead.
9482 9482
9483If only one link is found, browse that directly, otherwise use 9483If only one link is found, browse that directly, otherwise use
9484completion to select a link. The first link marked in the 9484completion to select a link. The first link marked in the
@@ -9502,7 +9502,7 @@ default."
9502 (car urls))))) 9502 (car urls)))))
9503 (if target 9503 (if target
9504 (if external 9504 (if external
9505 (funcall shr-external-browser target) 9505 (funcall browse-url-external-browser target)
9506 (browse-url target)) 9506 (browse-url target))
9507 (message "No URLs found."))))) 9507 (message "No URLs found.")))))
9508 9508
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index aa31e25fa91..17b6d36ca87 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -131,9 +131,36 @@
131 :group 'external 131 :group 'external
132 :group 'comm) 132 :group 'comm)
133 133
134(defvar browse-url--browser-defcustom-type
135 '(choice
136 (function-item :tag "Emacs W3" :value browse-url-w3)
137 (function-item :tag "eww" :value eww-browse-url)
138 (function-item :tag "Mozilla" :value browse-url-mozilla)
139 (function-item :tag "Firefox" :value browse-url-firefox)
140 (function-item :tag "Google Chrome" :value browse-url-chrome)
141 (function-item :tag "Chromium" :value browse-url-chromium)
142 (function-item :tag "Epiphany" :value browse-url-epiphany)
143 (function-item :tag "Conkeror" :value browse-url-conkeror)
144 (function-item :tag "Text browser in an xterm window"
145 :value browse-url-text-xterm)
146 (function-item :tag "Text browser in an Emacs window"
147 :value browse-url-text-emacs)
148 (function-item :tag "KDE" :value browse-url-kde)
149 (function-item :tag "Elinks" :value browse-url-elinks)
150 (function-item :tag "Specified by `Browse Url Generic Program'"
151 :value browse-url-generic)
152 (function-item :tag "Default Windows browser"
153 :value browse-url-default-windows-browser)
154 (function-item :tag "Default macOS browser"
155 :value browse-url-default-macosx-browser)
156 (function-item :tag "Default browser"
157 :value browse-url-default-browser)
158 (function :tag "Your own function")
159 (alist :tag "Regexp/function association list"
160 :key-type regexp :value-type function)))
161
134;;;###autoload 162;;;###autoload
135(defcustom browse-url-browser-function 163(defcustom browse-url-browser-function 'browse-url-default-browser
136 'browse-url-default-browser
137 "Function to display the current buffer in a WWW browser. 164 "Function to display the current buffer in a WWW browser.
138This is used by the `browse-url-at-point', `browse-url-at-mouse', and 165This is used by the `browse-url-at-point', `browse-url-at-mouse', and
139`browse-url-of-file' commands. 166`browse-url-of-file' commands.
@@ -143,34 +170,17 @@ If the value is not a function it should be a list of pairs
143associated with the first REGEXP which matches the current URL. The 170associated with the first REGEXP which matches the current URL. The
144function is passed the URL and any other args of `browse-url'. The last 171function is passed the URL and any other args of `browse-url'. The last
145regexp should probably be \".\" to specify a default browser." 172regexp should probably be \".\" to specify a default browser."
146 :type '(choice 173 :type browse-url--browser-defcustom-type
147 (function-item :tag "Emacs W3" :value browse-url-w3) 174 :version "24.1")
148 (function-item :tag "eww" :value eww-browse-url) 175
149 (function-item :tag "Mozilla" :value browse-url-mozilla) 176(defcustom browse-url-external-browser 'browse-url-default-browser
150 (function-item :tag "Firefox" :value browse-url-firefox) 177 "Function used to launch an external browser.
151 (function-item :tag "Google Chrome" :value browse-url-chrome) 178This can actually be any browser, internal or external, used as
152 (function-item :tag "Chromium" :value browse-url-chromium) 179the secondary browser choice, and is typically used when giving a
153 (function-item :tag "Epiphany" :value browse-url-epiphany) 180prefix argument to the URL-opening command (in those modes that
154 (function-item :tag "Conkeror" :value browse-url-conkeror) 181support this (for instance, eww/shr)."
155 (function-item :tag "Text browser in an xterm window" 182 :version "27.1"
156 :value browse-url-text-xterm) 183 :type browse-url--browser-defcustom-type)
157 (function-item :tag "Text browser in an Emacs window"
158 :value browse-url-text-emacs)
159 (function-item :tag "KDE" :value browse-url-kde)
160 (function-item :tag "Elinks" :value browse-url-elinks)
161 (function-item :tag "Specified by `Browse Url Generic Program'"
162 :value browse-url-generic)
163 (function-item :tag "Default Windows browser"
164 :value browse-url-default-windows-browser)
165 (function-item :tag "Default macOS browser"
166 :value browse-url-default-macosx-browser)
167 (function-item :tag "Default browser"
168 :value browse-url-default-browser)
169 (function :tag "Your own function")
170 (alist :tag "Regexp/function association list"
171 :key-type regexp :value-type function))
172 :version "24.1"
173 :group 'browse-url)
174 184
175(defcustom browse-url-mailto-function 'browse-url-mail 185(defcustom browse-url-mailto-function 'browse-url-mail
176 "Function to display mailto: links. 186 "Function to display mailto: links.
@@ -181,8 +191,7 @@ be used instead."
181 :type '(choice 191 :type '(choice
182 (function-item :tag "Emacs Mail" :value browse-url-mail) 192 (function-item :tag "Emacs Mail" :value browse-url-mail)
183 (function-item :tag "None" nil)) 193 (function-item :tag "None" nil))
184 :version "24.1" 194 :version "24.1")
185 :group 'browse-url)
186 195
187(defcustom browse-url-man-function 'browse-url-man 196(defcustom browse-url-man-function 'browse-url-man
188 "Function to display man: links." 197 "Function to display man: links."
@@ -190,8 +199,28 @@ be used instead."
190 (function-item :tag "Emacs Man" :value browse-url-man) 199 (function-item :tag "Emacs Man" :value browse-url-man)
191 (const :tag "None" nil) 200 (const :tag "None" nil)
192 (function :tag "Other function")) 201 (function :tag "Other function"))
193 :version "26.1" 202 :version "26.1")
194 :group 'browse-url) 203
204(defcustom browse-url-button-regexp
205 (concat
206 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
207 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
208 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
209 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
210 (punct "!?:;.,"))
211 (concat
212 "\\(?:"
213 ;; Match paired parentheses, e.g. in Wikipedia URLs:
214 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
215 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
216 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
217 "\\|"
218 "[" chars punct "]+" "[" chars "]"
219 "\\)"))
220 "\\)")
221 "Regular expression that matches URLs."
222 :version "27.1"
223 :type 'regexp)
195 224
196(defcustom browse-url-netscape-program "netscape" 225(defcustom browse-url-netscape-program "netscape"
197 ;; Info about netscape-remote from Karl Berry. 226 ;; Info about netscape-remote from Karl Berry.
@@ -202,15 +231,13 @@ The free program `netscape-remote' from
202up very much quicker than `netscape'. Reported to compile on a GNU 231up very much quicker than `netscape'. Reported to compile on a GNU
203system, given vroot.h from the same directory, with cc flags 232system, given vroot.h from the same directory, with cc flags
204 -DSTANDALONE -L/usr/X11R6/lib -lXmu -lX11." 233 -DSTANDALONE -L/usr/X11R6/lib -lXmu -lX11."
205 :type 'string 234 :type 'string)
206 :group 'browse-url)
207 235
208(make-obsolete-variable 'browse-url-netscape-program nil "25.1") 236(make-obsolete-variable 'browse-url-netscape-program nil "25.1")
209 237
210(defcustom browse-url-netscape-arguments nil 238(defcustom browse-url-netscape-arguments nil
211 "A list of strings to pass to Netscape as arguments." 239 "A list of strings to pass to Netscape as arguments."
212 :type '(repeat (string :tag "Argument")) 240 :type '(repeat (string :tag "Argument")))
213 :group 'browse-url)
214 241
215(make-obsolete-variable 'browse-url-netscape-arguments nil "25.1") 242(make-obsolete-variable 'browse-url-netscape-arguments nil "25.1")
216 243
@@ -218,33 +245,27 @@ system, given vroot.h from the same directory, with cc flags
218 "A list of strings to pass to Netscape when it starts up. 245 "A list of strings to pass to Netscape when it starts up.
219Defaults to the value of `browse-url-netscape-arguments' at the time 246Defaults to the value of `browse-url-netscape-arguments' at the time
220`browse-url' is loaded." 247`browse-url' is loaded."
221 :type '(repeat (string :tag "Argument")) 248 :type '(repeat (string :tag "Argument")))
222
223 :group 'browse-url)
224 249
225(make-obsolete-variable 'browse-url-netscape-startup-arguments nil "25.1") 250(make-obsolete-variable 'browse-url-netscape-startup-arguments nil "25.1")
226 251
227(defcustom browse-url-browser-display nil 252(defcustom browse-url-browser-display nil
228 "The X display for running the browser, if not same as Emacs's." 253 "The X display for running the browser, if not same as Emacs's."
229 :type '(choice string (const :tag "Default" nil)) 254 :type '(choice string (const :tag "Default" nil)))
230 :group 'browse-url)
231 255
232(defcustom browse-url-mozilla-program "mozilla" 256(defcustom browse-url-mozilla-program "mozilla"
233 "The name by which to invoke Mozilla." 257 "The name by which to invoke Mozilla."
234 :type 'string 258 :type 'string)
235 :group 'browse-url)
236 259
237(defcustom browse-url-mozilla-arguments nil 260(defcustom browse-url-mozilla-arguments nil
238 "A list of strings to pass to Mozilla as arguments." 261 "A list of strings to pass to Mozilla as arguments."
239 :type '(repeat (string :tag "Argument")) 262 :type '(repeat (string :tag "Argument")))
240 :group 'browse-url)
241 263
242(defcustom browse-url-mozilla-startup-arguments browse-url-mozilla-arguments 264(defcustom browse-url-mozilla-startup-arguments browse-url-mozilla-arguments
243 "A list of strings to pass to Mozilla when it starts up. 265 "A list of strings to pass to Mozilla when it starts up.
244Defaults to the value of `browse-url-mozilla-arguments' at the time 266Defaults to the value of `browse-url-mozilla-arguments' at the time
245`browse-url' is loaded." 267`browse-url' is loaded."
246 :type '(repeat (string :tag "Argument")) 268 :type '(repeat (string :tag "Argument")))
247 :group 'browse-url)
248 269
249(defcustom browse-url-firefox-program 270(defcustom browse-url-firefox-program
250 (let ((candidates '("icecat" "iceweasel" "firefox"))) 271 (let ((candidates '("icecat" "iceweasel" "firefox")))
@@ -252,20 +273,17 @@ Defaults to the value of `browse-url-mozilla-arguments' at the time
252 (setq candidates (cdr candidates))) 273 (setq candidates (cdr candidates)))
253 (or (car candidates) "firefox")) 274 (or (car candidates) "firefox"))
254 "The name by which to invoke Firefox or a variant of it." 275 "The name by which to invoke Firefox or a variant of it."
255 :type 'string 276 :type 'string)
256 :group 'browse-url)
257 277
258(defcustom browse-url-firefox-arguments nil 278(defcustom browse-url-firefox-arguments nil
259 "A list of strings to pass to Firefox (or variant) as arguments." 279 "A list of strings to pass to Firefox (or variant) as arguments."
260 :type '(repeat (string :tag "Argument")) 280 :type '(repeat (string :tag "Argument")))
261 :group 'browse-url)
262 281
263(defcustom browse-url-firefox-startup-arguments browse-url-firefox-arguments 282(defcustom browse-url-firefox-startup-arguments browse-url-firefox-arguments
264 "A list of strings to pass to Firefox (or variant) when it starts up. 283 "A list of strings to pass to Firefox (or variant) when it starts up.
265Defaults to the value of `browse-url-firefox-arguments' at the time 284Defaults to the value of `browse-url-firefox-arguments' at the time
266`browse-url' is loaded." 285`browse-url' is loaded."
267 :type '(repeat (string :tag "Argument")) 286 :type '(repeat (string :tag "Argument")))
268 :group 'browse-url)
269 287
270(make-obsolete-variable 'browse-url-firefox-startup-arguments 288(make-obsolete-variable 'browse-url-firefox-startup-arguments
271 "it no longer has any effect." "24.5") 289 "it no longer has any effect." "24.5")
@@ -277,14 +295,12 @@ Defaults to the value of `browse-url-firefox-arguments' at the time
277 (or (car candidates) "chromium")) 295 (or (car candidates) "chromium"))
278 "The name by which to invoke the Chrome browser." 296 "The name by which to invoke the Chrome browser."
279 :type 'string 297 :type 'string
280 :version "25.1" 298 :version "25.1")
281 :group 'browse-url)
282 299
283(defcustom browse-url-chrome-arguments nil 300(defcustom browse-url-chrome-arguments nil
284 "A list of strings to pass to Google Chrome as arguments." 301 "A list of strings to pass to Google Chrome as arguments."
285 :type '(repeat (string :tag "Argument")) 302 :type '(repeat (string :tag "Argument"))
286 :version "25.1" 303 :version "25.1")
287 :group 'browse-url)
288 304
289(defcustom browse-url-chromium-program 305(defcustom browse-url-chromium-program
290 (let ((candidates '("chromium" "chromium-browser"))) 306 (let ((candidates '("chromium" "chromium-browser")))
@@ -293,26 +309,22 @@ Defaults to the value of `browse-url-firefox-arguments' at the time
293 (or (car candidates) "chromium")) 309 (or (car candidates) "chromium"))
294 "The name by which to invoke Chromium." 310 "The name by which to invoke Chromium."
295 :type 'string 311 :type 'string
296 :version "24.1" 312 :version "24.1")
297 :group 'browse-url)
298 313
299(defcustom browse-url-chromium-arguments nil 314(defcustom browse-url-chromium-arguments nil
300 "A list of strings to pass to Chromium as arguments." 315 "A list of strings to pass to Chromium as arguments."
301 :type '(repeat (string :tag "Argument")) 316 :type '(repeat (string :tag "Argument"))
302 :version "24.1" 317 :version "24.1")
303 :group 'browse-url)
304 318
305(defcustom browse-url-galeon-program "galeon" 319(defcustom browse-url-galeon-program "galeon"
306 "The name by which to invoke Galeon." 320 "The name by which to invoke Galeon."
307 :type 'string 321 :type 'string)
308 :group 'browse-url)
309 322
310(make-obsolete-variable 'browse-url-galeon-program nil "25.1") 323(make-obsolete-variable 'browse-url-galeon-program nil "25.1")
311 324
312(defcustom browse-url-galeon-arguments nil 325(defcustom browse-url-galeon-arguments nil
313 "A list of strings to pass to Galeon as arguments." 326 "A list of strings to pass to Galeon as arguments."
314 :type '(repeat (string :tag "Argument")) 327 :type '(repeat (string :tag "Argument")))
315 :group 'browse-url)
316 328
317(make-obsolete-variable 'browse-url-galeon-arguments nil "25.1") 329(make-obsolete-variable 'browse-url-galeon-arguments nil "25.1")
318 330
@@ -320,27 +332,23 @@ Defaults to the value of `browse-url-firefox-arguments' at the time
320 "A list of strings to pass to Galeon when it starts up. 332 "A list of strings to pass to Galeon when it starts up.
321Defaults to the value of `browse-url-galeon-arguments' at the time 333Defaults to the value of `browse-url-galeon-arguments' at the time
322`browse-url' is loaded." 334`browse-url' is loaded."
323 :type '(repeat (string :tag "Argument")) 335 :type '(repeat (string :tag "Argument")))
324 :group 'browse-url)
325 336
326(make-obsolete-variable 'browse-url-galeon-startup-arguments nil "25.1") 337(make-obsolete-variable 'browse-url-galeon-startup-arguments nil "25.1")
327 338
328(defcustom browse-url-epiphany-program "epiphany" 339(defcustom browse-url-epiphany-program "epiphany"
329 "The name by which to invoke Epiphany." 340 "The name by which to invoke Epiphany."
330 :type 'string 341 :type 'string)
331 :group 'browse-url)
332 342
333(defcustom browse-url-epiphany-arguments nil 343(defcustom browse-url-epiphany-arguments nil
334 "A list of strings to pass to Epiphany as arguments." 344 "A list of strings to pass to Epiphany as arguments."
335 :type '(repeat (string :tag "Argument")) 345 :type '(repeat (string :tag "Argument")))
336 :group 'browse-url)
337 346
338(defcustom browse-url-epiphany-startup-arguments browse-url-epiphany-arguments 347(defcustom browse-url-epiphany-startup-arguments browse-url-epiphany-arguments
339 "A list of strings to pass to Epiphany when it starts up. 348 "A list of strings to pass to Epiphany when it starts up.
340Defaults to the value of `browse-url-epiphany-arguments' at the time 349Defaults to the value of `browse-url-epiphany-arguments' at the time
341`browse-url' is loaded." 350`browse-url' is loaded."
342 :type '(repeat (string :tag "Argument")) 351 :type '(repeat (string :tag "Argument")))
343 :group 'browse-url)
344 352
345;; GNOME means of invoking either Mozilla or Netscape. 353;; GNOME means of invoking either Mozilla or Netscape.
346(defvar browse-url-gnome-moz-program "gnome-moz-remote") 354(defvar browse-url-gnome-moz-program "gnome-moz-remote")
@@ -350,8 +358,7 @@ Defaults to the value of `browse-url-epiphany-arguments' at the time
350(defcustom browse-url-gnome-moz-arguments '() 358(defcustom browse-url-gnome-moz-arguments '()
351 "A list of strings passed to the GNOME mozilla viewer as arguments." 359 "A list of strings passed to the GNOME mozilla viewer as arguments."
352 :version "21.1" 360 :version "21.1"
353 :type '(repeat (string :tag "Argument")) 361 :type '(repeat (string :tag "Argument")))
354 :group 'browse-url)
355 362
356(make-obsolete-variable 'browse-url-gnome-moz-arguments nil "25.1") 363(make-obsolete-variable 'browse-url-gnome-moz-arguments nil "25.1")
357 364
@@ -359,30 +366,26 @@ Defaults to the value of `browse-url-epiphany-arguments' at the time
359 "Whether to open up new windows in a tab or a new window. 366 "Whether to open up new windows in a tab or a new window.
360If non-nil, then open the URL in a new tab rather than a new window if 367If non-nil, then open the URL in a new tab rather than a new window if
361`browse-url-mozilla' is asked to open it in a new window." 368`browse-url-mozilla' is asked to open it in a new window."
362 :type 'boolean 369 :type 'boolean)
363 :group 'browse-url)
364 370
365(defcustom browse-url-firefox-new-window-is-tab nil 371(defcustom browse-url-firefox-new-window-is-tab nil
366 "Whether to open up new windows in a tab or a new window. 372 "Whether to open up new windows in a tab or a new window.
367If non-nil, then open the URL in a new tab rather than a new window if 373If non-nil, then open the URL in a new tab rather than a new window if
368`browse-url-firefox' is asked to open it in a new window." 374`browse-url-firefox' is asked to open it in a new window."
369 :type 'boolean 375 :type 'boolean)
370 :group 'browse-url)
371 376
372(defcustom browse-url-conkeror-new-window-is-buffer nil 377(defcustom browse-url-conkeror-new-window-is-buffer nil
373 "Whether to open up new windows in a buffer or a new window. 378 "Whether to open up new windows in a buffer or a new window.
374If non-nil, then open the URL in a new buffer rather than a new window if 379If non-nil, then open the URL in a new buffer rather than a new window if
375`browse-url-conkeror' is asked to open it in a new window." 380`browse-url-conkeror' is asked to open it in a new window."
376 :version "25.1" 381 :version "25.1"
377 :type 'boolean 382 :type 'boolean)
378 :group 'browse-url)
379 383
380(defcustom browse-url-galeon-new-window-is-tab nil 384(defcustom browse-url-galeon-new-window-is-tab nil
381 "Whether to open up new windows in a tab or a new window. 385 "Whether to open up new windows in a tab or a new window.
382If non-nil, then open the URL in a new tab rather than a new window if 386If non-nil, then open the URL in a new tab rather than a new window if
383`browse-url-galeon' is asked to open it in a new window." 387`browse-url-galeon' is asked to open it in a new window."
384 :type 'boolean 388 :type 'boolean)
385 :group 'browse-url)
386 389
387(make-obsolete-variable 'browse-url-galeon-new-window-is-tab nil "25.1") 390(make-obsolete-variable 'browse-url-galeon-new-window-is-tab nil "25.1")
388 391
@@ -390,16 +393,14 @@ If non-nil, then open the URL in a new tab rather than a new window if
390 "Whether to open up new windows in a tab or a new window. 393 "Whether to open up new windows in a tab or a new window.
391If non-nil, then open the URL in a new tab rather than a new window if 394If non-nil, then open the URL in a new tab rather than a new window if
392`browse-url-epiphany' is asked to open it in a new window." 395`browse-url-epiphany' is asked to open it in a new window."
393 :type 'boolean 396 :type 'boolean)
394 :group 'browse-url)
395 397
396(defcustom browse-url-netscape-new-window-is-tab nil 398(defcustom browse-url-netscape-new-window-is-tab nil
397 "Whether to open up new windows in a tab or a new window. 399 "Whether to open up new windows in a tab or a new window.
398If non-nil, then open the URL in a new tab rather than a new 400If non-nil, then open the URL in a new tab rather than a new
399window if `browse-url-netscape' is asked to open it in a new 401window if `browse-url-netscape' is asked to open it in a new
400window." 402window."
401 :type 'boolean 403 :type 'boolean)
402 :group 'browse-url)
403 404
404(make-obsolete-variable 'browse-url-netscape-new-window-is-tab nil "25.1") 405(make-obsolete-variable 'browse-url-netscape-new-window-is-tab nil "25.1")
405 406
@@ -407,42 +408,36 @@ window."
407 "Non-nil means always open a new browser window with appropriate browsers. 408 "Non-nil means always open a new browser window with appropriate browsers.
408Passing an interactive argument to \\[browse-url], or specific browser 409Passing an interactive argument to \\[browse-url], or specific browser
409commands reverses the effect of this variable." 410commands reverses the effect of this variable."
410 :type 'boolean 411 :type 'boolean)
411 :group 'browse-url)
412 412
413(defcustom browse-url-mosaic-program "xmosaic" 413(defcustom browse-url-mosaic-program "xmosaic"
414 "The name by which to invoke Mosaic (or mMosaic)." 414 "The name by which to invoke Mosaic (or mMosaic)."
415 :type 'string 415 :type 'string
416 :version "20.3" 416 :version "20.3")
417 :group 'browse-url)
418 417
419(make-obsolete-variable 'browse-url-mosaic-program nil "25.1") 418(make-obsolete-variable 'browse-url-mosaic-program nil "25.1")
420 419
421(defcustom browse-url-mosaic-arguments nil 420(defcustom browse-url-mosaic-arguments nil
422 "A list of strings to pass to Mosaic as arguments." 421 "A list of strings to pass to Mosaic as arguments."
423 :type '(repeat (string :tag "Argument")) 422 :type '(repeat (string :tag "Argument")))
424 :group 'browse-url)
425 423
426(make-obsolete-variable 'browse-url-mosaic-arguments nil "25.1") 424(make-obsolete-variable 'browse-url-mosaic-arguments nil "25.1")
427 425
428(defcustom browse-url-mosaic-pidfile "~/.mosaicpid" 426(defcustom browse-url-mosaic-pidfile "~/.mosaicpid"
429 "The name of the pidfile created by Mosaic." 427 "The name of the pidfile created by Mosaic."
430 :type 'string 428 :type 'string)
431 :group 'browse-url)
432 429
433(make-obsolete-variable 'browse-url-mosaic-pidfile nil "25.1") 430(make-obsolete-variable 'browse-url-mosaic-pidfile nil "25.1")
434 431
435(defcustom browse-url-conkeror-program "conkeror" 432(defcustom browse-url-conkeror-program "conkeror"
436 "The name by which to invoke Conkeror." 433 "The name by which to invoke Conkeror."
437 :type 'string 434 :type 'string
438 :version "25.1" 435 :version "25.1")
439 :group 'browse-url)
440 436
441(defcustom browse-url-conkeror-arguments nil 437(defcustom browse-url-conkeror-arguments nil
442 "A list of strings to pass to Conkeror as arguments." 438 "A list of strings to pass to Conkeror as arguments."
443 :version "25.1" 439 :version "25.1"
444 :type '(repeat (string :tag "Argument")) 440 :type '(repeat (string :tag "Argument")))
445 :group 'browse-url)
446 441
447(defcustom browse-url-filename-alist 442(defcustom browse-url-filename-alist
448 `(("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/") 443 `(("^/\\(ftp@\\|anonymous@\\)?\\([^:/]+\\):/*" . "ftp://\\2/")
@@ -473,26 +468,22 @@ address to an HTTP URL:
473 :type '(repeat (cons :format "%v" 468 :type '(repeat (cons :format "%v"
474 (regexp :tag "Regexp") 469 (regexp :tag "Regexp")
475 (string :tag "Replacement"))) 470 (string :tag "Replacement")))
476 :version "25.1" 471 :version "25.1")
477 :group 'browse-url)
478 472
479(defcustom browse-url-save-file nil 473(defcustom browse-url-save-file nil
480 "If non-nil, save the buffer before displaying its file. 474 "If non-nil, save the buffer before displaying its file.
481Used by the `browse-url-of-file' command." 475Used by the `browse-url-of-file' command."
482 :type 'boolean 476 :type 'boolean)
483 :group 'browse-url)
484 477
485(defcustom browse-url-of-file-hook nil 478(defcustom browse-url-of-file-hook nil
486 "Hook run after `browse-url-of-file' has asked a browser to load a file." 479 "Hook run after `browse-url-of-file' has asked a browser to load a file."
487 :type 'hook 480 :type 'hook)
488 :group 'browse-url)
489 481
490(defcustom browse-url-CCI-port 3003 482(defcustom browse-url-CCI-port 3003
491 "Port to access XMosaic via CCI. 483 "Port to access XMosaic via CCI.
492This can be any number between 1024 and 65535 but must correspond to 484This can be any number between 1024 and 65535 but must correspond to
493the value set in the browser." 485the value set in the browser."
494 :type 'integer 486 :type 'integer)
495 :group 'browse-url)
496 487
497(make-obsolete-variable 'browse-url-CCI-port nil "25.1") 488(make-obsolete-variable 'browse-url-CCI-port nil "25.1")
498 489
@@ -500,8 +491,7 @@ the value set in the browser."
500 "Host to access XMosaic via CCI. 491 "Host to access XMosaic via CCI.
501This should be the host name of the machine running XMosaic with CCI 492This should be the host name of the machine running XMosaic with CCI
502enabled. The port number should be set in `browse-url-CCI-port'." 493enabled. The port number should be set in `browse-url-CCI-port'."
503 :type 'string 494 :type 'string)
504 :group 'browse-url)
505 495
506(make-obsolete-variable 'browse-url-CCI-host nil "25.1") 496(make-obsolete-variable 'browse-url-CCI-host nil "25.1")
507 497
@@ -511,57 +501,48 @@ enabled. The port number should be set in `browse-url-CCI-port'."
511(defcustom browse-url-xterm-program "xterm" 501(defcustom browse-url-xterm-program "xterm"
512 "The name of the terminal emulator used by `browse-url-text-xterm'. 502 "The name of the terminal emulator used by `browse-url-text-xterm'.
513This might, for instance, be a separate color version of xterm." 503This might, for instance, be a separate color version of xterm."
514 :type 'string 504 :type 'string)
515 :group 'browse-url)
516 505
517(defcustom browse-url-xterm-args nil 506(defcustom browse-url-xterm-args nil
518 "A list of strings defining options for `browse-url-xterm-program'. 507 "A list of strings defining options for `browse-url-xterm-program'.
519These might set its size, for instance." 508These might set its size, for instance."
520 :type '(repeat (string :tag "Argument")) 509 :type '(repeat (string :tag "Argument")))
521 :group 'browse-url)
522 510
523(defcustom browse-url-gnudoit-program "gnudoit" 511(defcustom browse-url-gnudoit-program "gnudoit"
524 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'." 512 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'."
525 :type 'string 513 :type 'string)
526 :group 'browse-url)
527 514
528(defcustom browse-url-gnudoit-args '("-q") 515(defcustom browse-url-gnudoit-args '("-q")
529 "A list of strings defining options for `browse-url-gnudoit-program'. 516 "A list of strings defining options for `browse-url-gnudoit-program'.
530These might set the port, for instance." 517These might set the port, for instance."
531 :type '(repeat (string :tag "Argument")) 518 :type '(repeat (string :tag "Argument")))
532 :group 'browse-url)
533 519
534(defcustom browse-url-generic-program nil 520(defcustom browse-url-generic-program nil
535 "The name of the browser program used by `browse-url-generic'." 521 "The name of the browser program used by `browse-url-generic'."
536 :type '(choice string (const :tag "None" nil)) 522 :type '(choice string (const :tag "None" nil)))
537 :group 'browse-url)
538 523
539(defcustom browse-url-generic-args nil 524(defcustom browse-url-generic-args nil
540 "A list of strings defining options for `browse-url-generic-program'." 525 "A list of strings defining options for `browse-url-generic-program'."
541 :type '(repeat (string :tag "Argument")) 526 :type '(repeat (string :tag "Argument")))
542 :group 'browse-url)
543 527
544(defcustom browse-url-temp-dir temporary-file-directory 528(defcustom browse-url-temp-dir temporary-file-directory
545 "The name of a directory for browse-url's temporary files. 529 "The name of a directory for browse-url's temporary files.
546Such files are generated by functions like `browse-url-of-region'. 530Such files are generated by functions like `browse-url-of-region'.
547You might want to set this to somewhere with restricted read permissions 531You might want to set this to somewhere with restricted read permissions
548for privacy's sake." 532for privacy's sake."
549 :type 'string 533 :type 'string)
550 :group 'browse-url)
551 534
552(defcustom browse-url-netscape-version 3 535(defcustom browse-url-netscape-version 3
553 "The version of Netscape you are using. 536 "The version of Netscape you are using.
554This affects how URL reloading is done; the mechanism changed 537This affects how URL reloading is done; the mechanism changed
555incompatibly at version 4." 538incompatibly at version 4."
556 :type 'number 539 :type 'number)
557 :group 'browse-url)
558 540
559(make-obsolete-variable 'browse-url-netscape-version nil "25.1") 541(make-obsolete-variable 'browse-url-netscape-version nil "25.1")
560 542
561(defcustom browse-url-text-browser "lynx" 543(defcustom browse-url-text-browser "lynx"
562 "The name of the text browser to invoke." 544 "The name of the text browser to invoke."
563 :type 'string 545 :type 'string
564 :group 'browse-url
565 :version "23.1") 546 :version "23.1")
566 547
567(defcustom browse-url-text-emacs-args (and (not window-system) 548(defcustom browse-url-text-emacs-args (and (not window-system)
@@ -572,8 +553,7 @@ The default is none in a window system, otherwise `-show_cursor' to
572indicate the position of the current link in the absence of 553indicate the position of the current link in the absence of
573highlighting, assuming the normal default for showing the cursor." 554highlighting, assuming the normal default for showing the cursor."
574 :type '(repeat (string :tag "Argument")) 555 :type '(repeat (string :tag "Argument"))
575 :version "23.1" 556 :version "23.1")
576 :group 'browse-url)
577 557
578(defcustom browse-url-text-input-field 'avoid 558(defcustom browse-url-text-input-field 'avoid
579 "Action on selecting an existing text browser buffer at an input field. 559 "Action on selecting an existing text browser buffer at an input field.
@@ -586,36 +566,30 @@ down (this *won't* always work)."
586 :type '(choice (const :tag "Move to try to avoid field" :value avoid) 566 :type '(choice (const :tag "Move to try to avoid field" :value avoid)
587 (const :tag "Disregard" :value nil) 567 (const :tag "Disregard" :value nil)
588 (const :tag "Warn, don't emit URL" :value warn)) 568 (const :tag "Warn, don't emit URL" :value warn))
589 :version "23.1" 569 :version "23.1")
590 :group 'browse-url)
591 570
592(defcustom browse-url-text-input-attempts 10 571(defcustom browse-url-text-input-attempts 10
593 "How many times to try to move down from a series of text browser input fields." 572 "How many times to try to move down from a series of text browser input fields."
594 :type 'integer 573 :type 'integer
595 :version "23.1" 574 :version "23.1")
596 :group 'browse-url)
597 575
598(defcustom browse-url-text-input-delay 0.2 576(defcustom browse-url-text-input-delay 0.2
599 "Seconds to wait for a text browser between moves down from an input field." 577 "Seconds to wait for a text browser between moves down from an input field."
600 :type 'number 578 :type 'number
601 :version "23.1" 579 :version "23.1")
602 :group 'browse-url)
603 580
604(defcustom browse-url-kde-program "kfmclient" 581(defcustom browse-url-kde-program "kfmclient"
605 "The name by which to invoke the KDE web browser." 582 "The name by which to invoke the KDE web browser."
606 :type 'string 583 :type 'string
607 :version "21.1" 584 :version "21.1")
608 :group 'browse-url)
609 585
610(defcustom browse-url-kde-args '("openURL") 586(defcustom browse-url-kde-args '("openURL")
611 "A list of strings defining options for `browse-url-kde-program'." 587 "A list of strings defining options for `browse-url-kde-program'."
612 :type '(repeat (string :tag "Argument")) 588 :type '(repeat (string :tag "Argument")))
613 :group 'browse-url)
614 589
615(defcustom browse-url-elinks-wrapper '("xterm" "-e") 590(defcustom browse-url-elinks-wrapper '("xterm" "-e")
616 "Wrapper command prepended to the Elinks command-line." 591 "Wrapper command prepended to the Elinks command-line."
617 :type '(repeat (string :tag "Wrapper")) 592 :type '(repeat (string :tag "Wrapper")))
618 :group 'browse-url)
619 593
620;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 594;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
621;; URL encoding 595;; URL encoding
@@ -1673,6 +1647,58 @@ from `browse-url-elinks-wrapper'."
1673 (error "Unrecognized exit-code %d of process `elinks'" 1647 (error "Unrecognized exit-code %d of process `elinks'"
1674 exit-status)))) 1648 exit-status))))
1675 1649
1650;;; Adding buttons to a buffer to call `browse-url' when you hit them.
1651
1652(defvar browse-url-button-map
1653 (let ((map (make-sparse-keymap)))
1654 (define-key map "\r" 'browse-url-button-open)
1655 (define-key map [mouse-2] 'browse-url-button-open)
1656 (define-key map "w" 'browse-url-button-copy)
1657 map)
1658 "The keymap used for browse-url buttons.")
1659
1660(defface browse-url-button
1661 '((t :inherit link))
1662 "Face for browse-url buttons (i.e., links)."
1663 :version "27.1")
1664
1665(defun browse-url-add-buttons ()
1666 "Add clickable buttons to the text following point in the current buffer.
1667Everything that matches `browse-url-button-regexp' will be made
1668clickable and will use `browse-url' to open the URLs in question."
1669 (let ((inhibit-read-only t))
1670 (save-excursion
1671 (while (re-search-forward browse-url-button-regexp nil t)
1672 (add-text-properties (match-beginning 0)
1673 (match-end 0)
1674 `(help-echo "Open the URL under point"
1675 keymap ,browse-url-button-map
1676 face browse-url-button
1677 button t
1678 browse-url-data ,(match-string 0)))))))
1679
1680(defun browse-url-button-open (&optional external mouse-event)
1681 "Follow the link under point using `browse-url'.
1682If EXTERNAL (the prefix if used interactively), open with the
1683external browser instead of the default one."
1684 (interactive (list current-prefix-arg last-nonmenu-event))
1685 (mouse-set-point mouse-event)
1686 (let ((url (get-text-property (point) 'browse-url-data)))
1687 (unless url
1688 (error "No URL under point"))
1689 (if external
1690 (funcall browse-url-external-browser url)
1691 (browse-url url))))
1692
1693(defun browse-url-button-copy ()
1694 "Copy the URL under point"
1695 (interactive)
1696 (let ((url (get-text-property (point) 'browse-url-data)))
1697 (unless url
1698 (error "No URL under point"))
1699 (kill-new url)
1700 (message "Copied %s" url)))
1701
1676(provide 'browse-url) 1702(provide 'browse-url)
1677 1703
1678;;; browse-url.el ends here 1704;;; browse-url.el ends here
diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 206f9cfdf30..d839cc24c46 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -1501,13 +1501,15 @@ See URL `https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input'.")
1501 1501
1502(defun eww-browse-with-external-browser (&optional url) 1502(defun eww-browse-with-external-browser (&optional url)
1503 "Browse the current URL with an external browser. 1503 "Browse the current URL with an external browser.
1504The browser to used is specified by the `shr-external-browser' variable." 1504The browser to used is specified by the `browse-url-external-browser' variable."
1505 (interactive) 1505 (interactive)
1506 (funcall shr-external-browser (or url (plist-get eww-data :url)))) 1506 (funcall browse-url-external-browser (or url (plist-get eww-data :url))))
1507 1507
1508(defun eww-follow-link (&optional external mouse-event) 1508(defun eww-follow-link (&optional external mouse-event)
1509 "Browse the URL under point. 1509 "Browse the URL under point.
1510If EXTERNAL is single prefix, browse the URL using `shr-external-browser'. 1510If EXTERNAL is single prefix, browse the URL using
1511`browse-url-external-browser'.
1512
1511If EXTERNAL is double prefix, browse in new buffer." 1513If EXTERNAL is double prefix, browse in new buffer."
1512 (interactive (list current-prefix-arg last-nonmenu-event)) 1514 (interactive (list current-prefix-arg last-nonmenu-event))
1513 (mouse-set-point mouse-event) 1515 (mouse-set-point mouse-event)
@@ -1518,7 +1520,7 @@ If EXTERNAL is double prefix, browse in new buffer."
1518 ((string-match "^mailto:" url) 1520 ((string-match "^mailto:" url)
1519 (browse-url-mail url)) 1521 (browse-url-mail url))
1520 ((and (consp external) (<= (car external) 4)) 1522 ((and (consp external) (<= (car external) 4))
1521 (funcall shr-external-browser url) 1523 (funcall browse-url-external-browser url)
1522 (shr--blink-link)) 1524 (shr--blink-link))
1523 ;; This is a #target url in the same page as the current one. 1525 ;; This is a #target url in the same page as the current one.
1524 ((and (url-target (url-generic-parse-url url)) 1526 ((and (url-target (url-generic-parse-url url))
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 98b09ab2970..2bc25930fcb 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -53,53 +53,44 @@ width and height of the window. If they are larger than this,
53and Emacs supports it, then the images will be rescaled down to 53and Emacs supports it, then the images will be rescaled down to
54fit these criteria." 54fit these criteria."
55 :version "24.1" 55 :version "24.1"
56 :group 'shr
57 :type 'float) 56 :type 'float)
58 57
59(defcustom shr-blocked-images nil 58(defcustom shr-blocked-images nil
60 "Images that have URLs matching this regexp will be blocked." 59 "Images that have URLs matching this regexp will be blocked."
61 :version "24.1" 60 :version "24.1"
62 :group 'shr
63 :type '(choice (const nil) regexp)) 61 :type '(choice (const nil) regexp))
64 62
65(defcustom shr-use-fonts t 63(defcustom shr-use-fonts t
66 "If non-nil, use proportional fonts for text." 64 "If non-nil, use proportional fonts for text."
67 :version "25.1" 65 :version "25.1"
68 :group 'shr
69 :type 'boolean) 66 :type 'boolean)
70 67
71(defcustom shr-discard-aria-hidden nil 68(defcustom shr-discard-aria-hidden nil
72 "If non-nil, don't render tags with `aria-hidden=\"true\"'. 69 "If non-nil, don't render tags with `aria-hidden=\"true\"'.
73This attribute is meant to tell screen readers to ignore a tag." 70This attribute is meant to tell screen readers to ignore a tag."
74 :version "27.1" 71 :version "27.1"
75 :group 'shr
76 :type 'boolean) 72 :type 'boolean)
77 73
78(defcustom shr-use-colors t 74(defcustom shr-use-colors t
79 "If non-nil, respect color specifications in the HTML." 75 "If non-nil, respect color specifications in the HTML."
80 :version "26.1" 76 :version "26.1"
81 :group 'shr
82 :type 'boolean) 77 :type 'boolean)
83 78
84(defcustom shr-table-horizontal-line nil 79(defcustom shr-table-horizontal-line nil
85 "Character used to draw horizontal table lines. 80 "Character used to draw horizontal table lines.
86If nil, don't draw horizontal table lines." 81If nil, don't draw horizontal table lines."
87 :group 'shr
88 :type '(choice (const nil) character)) 82 :type '(choice (const nil) character))
89 83
90(defcustom shr-table-vertical-line ?\s 84(defcustom shr-table-vertical-line ?\s
91 "Character used to draw vertical table lines." 85 "Character used to draw vertical table lines."
92 :group 'shr
93 :type 'character) 86 :type 'character)
94 87
95(defcustom shr-table-corner ?\s 88(defcustom shr-table-corner ?\s
96 "Character used to draw table corners." 89 "Character used to draw table corners."
97 :group 'shr
98 :type 'character) 90 :type 'character)
99 91
100(defcustom shr-hr-line ?- 92(defcustom shr-hr-line ?-
101 "Character used to draw hr lines." 93 "Character used to draw hr lines."
102 :group 'shr
103 :type 'character) 94 :type 'character)
104 95
105(defcustom shr-width nil 96(defcustom shr-width nil
@@ -110,8 +101,7 @@ If `shr-use-fonts' is set, the mean character width is used to
110compute the pixel width, which is used instead." 101compute the pixel width, which is used instead."
111 :version "25.1" 102 :version "25.1"
112 :type '(choice (integer :tag "Fixed width in characters") 103 :type '(choice (integer :tag "Fixed width in characters")
113 (const :tag "Use the width of the window" nil)) 104 (const :tag "Use the width of the window" nil)))
114 :group 'shr)
115 105
116(defcustom shr-bullet "* " 106(defcustom shr-bullet "* "
117 "Bullet used for unordered lists. 107 "Bullet used for unordered lists.
@@ -119,19 +109,14 @@ Alternative suggestions are:
119- \" \" 109- \" \"
120- \" \"" 110- \" \""
121 :version "24.4" 111 :version "24.4"
122 :type 'string 112 :type 'string)
123 :group 'shr)
124 113
125(defcustom shr-external-browser 'browse-url-default-browser 114(define-obsolete-variable-alias 'shr-external-browser
126 "Function used to launch an external browser." 115 'browse-url-external-browser "27.1")
127 :version "24.4"
128 :group 'shr
129 :type 'function)
130 116
131(defcustom shr-image-animate t 117(defcustom shr-image-animate t
132 "Non nil means that images that can be animated will be." 118 "Non nil means that images that can be animated will be."
133 :version "24.4" 119 :version "24.4"
134 :group 'shr
135 :type 'boolean) 120 :type 'boolean)
136 121
137(defvar shr-content-function nil 122(defvar shr-content-function nil
@@ -144,28 +129,24 @@ cid: URL as the argument.")
144 129
145(defface shr-strike-through '((t :strike-through t)) 130(defface shr-strike-through '((t :strike-through t))
146 "Face for <s> elements." 131 "Face for <s> elements."
147 :version "24.1" 132 :version "24.1")
148 :group 'shr)
149 133
150(defface shr-link 134(defface shr-link
151 '((t :inherit link)) 135 '((t :inherit link))
152 "Face for link elements." 136 "Face for link elements."
153 :version "24.1" 137 :version "24.1")
154 :group 'shr)
155 138
156(defface shr-selected-link 139(defface shr-selected-link
157 '((t :inherit shr-link :background "red")) 140 '((t :inherit shr-link :background "red"))
158 "Temporary face for externally visited link elements. 141 "Temporary face for externally visited link elements.
159When a link is visited with an external browser, the link 142When a link is visited with an external browser, the link
160temporarily blinks with this face." 143temporarily blinks with this face."
161 :version "27.1" 144 :version "27.1")
162 :group 'shr)
163 145
164(defface shr-abbreviation 146(defface shr-abbreviation
165 '((t :inherit underline :underline (:style wave))) 147 '((t :inherit underline :underline (:style wave)))
166 "Face for <abbr> elements." 148 "Face for <abbr> elements."
167 :version "27.1" 149 :version "27.1")
168 :group 'shr)
169 150
170(defvar shr-inhibit-images nil 151(defvar shr-inhibit-images nil
171 "If non-nil, inhibit loading images.") 152 "If non-nil, inhibit loading images.")
@@ -973,7 +954,7 @@ size, and full-buffer size."
973(defun shr-browse-url (&optional external mouse-event) 954(defun shr-browse-url (&optional external mouse-event)
974 "Browse the URL at point using `browse-url'. 955 "Browse the URL at point using `browse-url'.
975If EXTERNAL is non-nil (interactively, the prefix argument), browse 956If EXTERNAL is non-nil (interactively, the prefix argument), browse
976the URL using `shr-external-browser'. 957the URL using `browse-url-external-browser'.
977If this function is invoked by a mouse click, it will browse the URL 958If this function is invoked by a mouse click, it will browse the URL
978at the position of the click. Optional argument MOUSE-EVENT describes 959at the position of the click. Optional argument MOUSE-EVENT describes
979the mouse click event." 960the mouse click event."
@@ -988,7 +969,7 @@ the mouse click event."
988 (t 969 (t
989 (if external 970 (if external
990 (progn 971 (progn
991 (funcall shr-external-browser url) 972 (funcall browse-url-external-browser url)
992 (shr--blink-link)) 973 (shr--blink-link))
993 (browse-url url)))))) 974 (browse-url url))))))
994 975
@@ -1534,7 +1515,6 @@ The key element should be a regexp matched against the type of the source or
1534url if no type is specified. The value should be a float in the range 0.0 to 1515url if no type is specified. The value should be a float in the range 0.0 to
15351.0. Media elements with higher value are preferred." 15161.0. Media elements with higher value are preferred."
1536 :version "24.4" 1517 :version "24.4"
1537 :group 'shr
1538 :type '(alist :key-type regexp :value-type float)) 1518 :type '(alist :key-type regexp :value-type float))
1539 1519
1540(defun shr--get-media-pref (elem) 1520(defun shr--get-media-pref (elem)