comparison lisp/browse-url.el @ 21078:64a6c0b65eaa

Various doc fixes, mainly to remove innappropriate leading "*"s. (browse-url-new-window-p, browse-url-netscape-display, browse-url-save-file, browse-url-generic-program): Add autoload cookie. (browse-url-mosaic-program, browse-url-lynx-input-field, browse-url-lynx-input-attempts, browse-url-lynx-input-delay): Add :version. (browse-url-of-file-hook): Add :options. (browse-url-lynx-emacs-args): New option. (browse-url-lynx-emacs): Use it. (browse-url-lynx-xterm): Use backquote. (browse-url-emacs-display): Use Emacs version, not XEmacs. ((require 'term)): When compiling.
author Dave Love <fx@gnu.org>
date Fri, 06 Mar 1998 18:56:39 +0000
parents b0d79b1edeb6
children 4d63d262b3d5
comparison
equal deleted inserted replaced
21077:4b5c8a2ce0b2 21078:64a6c0b65eaa
1 ;;; browse-url.el --- Pass a URL to a WWW browser 1 ;;; browse-url.el --- Pass a URL to a WWW browser
2 2
3 ;; Copyright 1995, 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 4
5 ;; Author: Denis Howe <dbh@doc.ic.ac.uk> 5 ;; Author: Denis Howe <dbh@doc.ic.ac.uk>
6 ;; Maintainer: Dave Love <d.love@dl.ac.uk> 6 ;; Maintainer: Dave Love <fx@gnu.org>
7 ;; Created: 03 Apr 1995 7 ;; Created: 03 Apr 1995
8 ;; Keywords: hypertext, hypermedia, mouse 8 ;; Keywords: hypertext, hypermedia, mouse
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the 23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA. 25 ;; Boston, MA 02111-1307, USA.
26 26
27 ;;; Commentary: 27 ;;; Commentary:
28
29 ;; The latest version of this package should be available from
30 ;; <URL:http://wombat.doc.ic.ac.uk/emacs/browse-url.el>.
31 28
32 ;; This package provides functions which read a URL (Uniform Resource 29 ;; This package provides functions which read a URL (Uniform Resource
33 ;; Locator) from the minibuffer, defaulting to the URL around point, 30 ;; Locator) from the minibuffer, defaulting to the URL around point,
34 ;; and ask a World-Wide Web browser to load it. It can also load the 31 ;; and ask a World-Wide Web browser to load it. It can also load the
35 ;; URL associated with the current buffer. Different browsers use 32 ;; URL associated with the current buffer. Different browsers use
36 ;; different methods of remote control so there is one function for 33 ;; different methods of remote control so there is one function for
37 ;; each supported browser. If the chosen browser is not running, it 34 ;; each supported browser. If the chosen browser is not running, it
38 ;; is started. Currently there is support for: 35 ;; is started. Currently there is support for:
39 36
40 ;; Function Browser Earliest version 37 ;; Function Browser Earliest version
41 ;; browse-url-netscape Netscape 1.1b1 38 ;; browse-url-netscape Netscape 1.1b1
42 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4 39 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4
43 ;; browse-url-cci XMosaic 2.5 40 ;; browse-url-cci XMosaic 2.5
44 ;; browse-url-w3 w3 0 41 ;; browse-url-w3 w3 0
45 ;; browse-url-w3-gnudoit w3 remotely 42 ;; browse-url-w3-gnudoit w3 remotely
46 ;; browse-url-iximosaic IXI Mosaic ? 43 ;; browse-url-iximosaic IXI Mosaic ?
72 ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/> 69 ;; Emacs <URL:ftp://cs.indiana.edu/pub/elisp/w3/>
73 ;; has a function w3-follow-url-at-point, but that 70 ;; has a function w3-follow-url-at-point, but that
74 ;; doesn't let you edit the URL like browse-url. 71 ;; doesn't let you edit the URL like browse-url.
75 ;; The `gnuserv' package that can be used to control it in another 72 ;; The `gnuserv' package that can be used to control it in another
76 ;; Emacs process is available from 73 ;; Emacs process is available from
77 ;; <URL:http://hplbwww.hpl.hp.com/people/ange/gnuserv/>. 74 ;; <URL:ftp://ftp.splode.com/pub/users/friedman/packages/>.
78 75
79 ;; Grail is the freely available WWW browser implemented in Python, a 76 ;; Grail is the freely available WWW browser implemented in Python, a
80 ;; cool object-oriented freely available interpreted language. Grail 77 ;; cool object-oriented freely available interpreted language. Grail
81 ;; 0.3b1 was the first version to have remote control as distributed. 78 ;; 0.3b1 was the first version to have remote control as distributed.
82 ;; For more information on Grail see 79 ;; For more information on Grail see
83 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on 80 ;; <URL:http://grail.cnri.reston.va.us/> and for more information on
84 ;; Python see <url:http://www.python.org/>. Grail support in 81 ;; Python see <url:http://www.python.org/>. Grail support in
85 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>. 82 ;; browse-url.el written by Barry Warsaw <bwarsaw@python.org>.
86 83
87 ;; MMM is the freely available WWW browser implemented in Caml Special 84 ;; MMM is the freely available WWW browser implemented in Objective
88 ;; Light, a cool impure functional programming language, by Francois 85 ;; Caml, a cool impure functional programming language, by Francois
89 ;; Rouaix. See the MMM home page 86 ;; Rouaix. See the MMM home page
90 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>. 87 ;; <URL:http://pauillac.inria.fr/%7Erouaix/mmm/>.
91 88
92 ;; Lynx is now distributed by the FSF. See also 89 ;; Lynx is now distributed by the FSF. See also
93 ;; <URL:http://lynx.browser.org/>. 90 ;; <URL:http://lynx.browser.org/>.
111 ;; PSGML the general SGML structure editor package 108 ;; PSGML the general SGML structure editor package
112 ;; <URL:ftp://ftp.lysator.liu.se/pub/sgml>; hm--html-menus can be used 109 ;; <URL:ftp://ftp.lysator.liu.se/pub/sgml>; hm--html-menus can be used
113 ;; with this. 110 ;; with this.
114 111
115 ;; This package generalises function html-previewer-process in Marc 112 ;; This package generalises function html-previewer-process in Marc
116 ;; Andreessen <marca@ncsa.uiuc.edu>'s html-mode (LCD 113 ;; Andreessen's html-mode (LCD modes/html-mode.el.Z). See also the
117 ;; modes/html-mode.el.Z) and provides better versions of the URL 114 ;; ffap.el package. The huge hyperbole package also contains similar
118 ;; functions in Michelangelo Grigni <mic@cs.ucsd.edu>'s ffap.el 115 ;; functions.
119 ;; (find-file-at-point) <URL:ftp://cs.ucsd.edu:/pub/mic/>. The huge
120 ;; hyperbole package also contains similar functions.
121 116
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 ;; Help! 118 ;; Help!
124 119
125 ;; Can you write and test some code for the Macintrash and Windoze 120 ;; Can you write and test some code for the Macintrash and Windoze
217 ;; ("." . browse-url-netscape))) 212 ;; ("." . browse-url-netscape)))
218 213
219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 214 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
220 ;;; Code: 215 ;;; Code:
221 216
222 (eval-when-compile (require 'dired)
223 (require 'thingatpt))
224
225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 217 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
226 ;; Variables 218 ;; Variables
219
220 (eval-when-compile (require 'dired)
221 (require 'thingatpt)
222 (require 'term))
227 223
228 (defgroup browse-url nil 224 (defgroup browse-url nil
229 "Use a web browser to look at a URL." 225 "Use a web browser to look at a URL."
230 :prefix "browse-url-" 226 :prefix "browse-url-"
231 :group 'hypermedia) 227 :group 'hypermedia)
236 "*Function to display the current buffer in a WWW browser. 232 "*Function to display the current buffer in a WWW browser.
237 This is used by the `browse-url-at-point', `browse-url-at-mouse', and 233 This is used by the `browse-url-at-point', `browse-url-at-mouse', and
238 `browse-url-of-file' commands. 234 `browse-url-of-file' commands.
239 235
240 If the value is not a function it should be a list of pairs 236 If the value is not a function it should be a list of pairs
241 (REGEXP.FUNCTION). In this case the function called will be the one 237 (REGEXP . FUNCTION). In this case the function called will be the one
242 associated with the first REGEXP which matches the current URL. The 238 associated with the first REGEXP which matches the current URL. The
243 function is passed the URL and any other args of `browse-url'. The last 239 function is passed the URL and any other args of `browse-url'. The last
244 regexp should probably be \".\" to specify a default browser." 240 regexp should probably be \".\" to specify a default browser."
245 :type '(choice 241 :type '(choice
246 (function-item :tag "Emacs W3" :value browse-url-w3) 242 (function-item :tag "Emacs W3" :value browse-url-w3)
261 (function :tag "Your own function")) 257 (function :tag "Your own function"))
262 :group 'browse-url) 258 :group 'browse-url)
263 259
264 (defcustom browse-url-netscape-program "netscape" 260 (defcustom browse-url-netscape-program "netscape"
265 ;; Info about netscape-remote from Kurt Swanson in gnu.emacs.gnus 261 ;; Info about netscape-remote from Kurt Swanson in gnu.emacs.gnus
266 "*The name by which to invoke Netscape. 262 "The name by which to invoke Netscape.
267 263
268 It is said that source is available for a program `netscape-remote' 264 It is said that source is available for a program `netscape-remote'
269 which starts up very much quicker than `netscape' and that it is 265 which starts up very much quicker than `netscape' and that it is
270 useful to set this variable to the name of a script which invokes that 266 useful to set this variable to the name of a script which invokes that
271 program like: 267 program like:
274 " 270 "
275 :type 'string 271 :type 'string
276 :group 'browse-url) 272 :group 'browse-url)
277 273
278 (defcustom browse-url-netscape-arguments nil 274 (defcustom browse-url-netscape-arguments nil
279 "*A list of strings to pass to Netscape as arguments." 275 "A list of strings to pass to Netscape as arguments."
280 :type '(repeat (string :tag "Argument")) 276 :type '(repeat (string :tag "Argument"))
281 :group 'browse-url) 277 :group 'browse-url)
282 278
283 (defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments 279 (defcustom browse-url-netscape-startup-arguments browse-url-netscape-arguments
284 "*A list of strings to pass to Netscape when it start up. 280 "A list of strings to pass to Netscape when it starts up.
285 Defaults to the value of `browse-url-netscape-arguments' at the time 281 Defaults to the value of `browse-url-netscape-arguments' at the time
286 `browse-url' is loaded." 282 `browse-url' is loaded."
287 :type '(repeat (string :tag "Argument")) 283 :type '(repeat (string :tag "Argument"))
288 :group 'browse-url) 284 :group 'browse-url)
289 285
286 ;;;###autoload
290 (defcustom browse-url-new-window-p nil 287 (defcustom browse-url-new-window-p nil
291 "*If non-nil, always open a new browser window with appropriate browsers. 288 "*If non-nil, always open a new browser window with appropriate browsers.
292 Passing an interactive argument to \\[browse-url], or specific browser 289 Passing an interactive argument to \\[browse-url], or specific browser
293 commands reverses the effect of this variable. Requires Netscape version 290 commands reverses the effect of this variable. Requires Netscape version
294 1.1N or later or XMosaic version 2.5 or later if using those browsers." 291 1.1N or later or XMosaic version 2.5 or later if using those browsers."
295 :type 'boolean 292 :type 'boolean
296 :group 'browse-url) 293 :group 'browse-url)
297 294
295 ;;;###autoload
298 (defcustom browse-url-netscape-display nil 296 (defcustom browse-url-netscape-display nil
299 "*The X display for running Netscape, if not same as Emacs'." 297 "*The X display for running Netscape, if not same as Emacs'."
300 :type '(choice string (const :tag "Default" nil)) 298 :type '(choice string (const :tag "Default" nil))
301 :group 'browse-url) 299 :group 'browse-url)
302 300
303 (defcustom browse-url-mosaic-program "xmosaic" 301 (defcustom browse-url-mosaic-program "xmosaic"
304 "*The name by which to invoke Mosaic (or mMosaic)." 302 "The name by which to invoke Mosaic (or mMosaic)."
305 :type 'string 303 :type 'string
304 :version "20.3"
306 :group 'browse-url) 305 :group 'browse-url)
307 306
308 (defcustom browse-url-mosaic-arguments nil 307 (defcustom browse-url-mosaic-arguments nil
309 "*A list of strings to pass to Mosaic as arguments." 308 "A list of strings to pass to Mosaic as arguments."
310 :type '(repeat (string :tag "Argument")) 309 :type '(repeat (string :tag "Argument"))
311 :group 'browse-url) 310 :group 'browse-url)
312 311
313 (defcustom browse-url-filename-alist 312 (defcustom browse-url-filename-alist
314 '(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/") 313 '(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/")
315 ;; The above loses the username to avoid the browser prompting for 314 ;; The above loses the username to avoid the browser prompting for
316 ;; it in anonymous cases. If it's not anonymous the next regexp 315 ;; it in anonymous cases. If it's not anonymous the next regexp
317 ;; applies. 316 ;; applies.
318 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") 317 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/")
319 ("^/+" . "file:/")) 318 ("^/+" . "file:/"))
320 "*An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. 319 "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
321 Any substring of a filename matching one of the REGEXPs is replaced by 320 Any substring of a filename matching one of the REGEXPs is replaced by
322 the corresponding STRING using `replace-match', not treating STRING 321 the corresponding STRING using `replace-match', not treating STRING
323 literally. All pairs are applied in the order given. The default 322 literally. All pairs are applied in the order given. The default
324 value converts ange-ftp/EFS-style paths into ftp URLs and prepends 323 value converts ange-ftp/EFS-style paths into ftp URLs and prepends
325 `file:' to any path beginning with `/'. 324 `file:' to any path beginning with `/'.
338 (regexp :tag "Regexp") 337 (regexp :tag "Regexp")
339 (string :tag "Replacement"))) 338 (string :tag "Replacement")))
340 :version "20.3" 339 :version "20.3"
341 :group 'browse-url) 340 :group 'browse-url)
342 341
342 ;;;###autoload
343 (defcustom browse-url-save-file nil 343 (defcustom browse-url-save-file nil
344 "*If non-nil, save the buffer before displaying its file. 344 "*If non-nil, save the buffer before displaying its file.
345 Used by the `browse-url-of-file' command." 345 Used by the `browse-url-of-file' command."
346 :type 'boolean 346 :type 'boolean
347 :group 'browse-url) 347 :group 'browse-url)
348 348
349 (defcustom browse-url-of-file-hook nil 349 (defcustom browse-url-of-file-hook nil
350 "*Run after `browse-url-of-file' has asked a browser to load a file. 350 "Run after `browse-url-of-file' has asked a browser to load a file.
351 351
352 Set this to `browse-url-netscape-reload' to force Netscape to load the 352 Set this to `browse-url-netscape-reload' to force Netscape to load the
353 file rather than displaying a cached copy." 353 file rather than displaying a cached copy."
354 :type 'hook 354 :type 'hook
355 :options '(browse-url-netscape-reload)
355 :group 'browse-url) 356 :group 'browse-url)
356 357
357 (defvar browse-url-usr1-signal 358 (defvar browse-url-usr1-signal
358 (if (and (boundp 'emacs-major-version) 359 (if (and (boundp 'emacs-major-version)
359 (or (> emacs-major-version 19) (>= emacs-minor-version 29))) 360 (or (> emacs-major-version 19) (>= emacs-minor-version 29)))
362 "The argument to `signal-process' for sending SIGUSR1 to XMosaic. 363 "The argument to `signal-process' for sending SIGUSR1 to XMosaic.
363 Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer 364 Emacs 19.29 accepts 'SIGUSR1, earlier versions require an integer
364 which is 30 on SunOS and 16 on HP-UX and Solaris.") 365 which is 30 on SunOS and 16 on HP-UX and Solaris.")
365 366
366 (defcustom browse-url-CCI-port 3003 367 (defcustom browse-url-CCI-port 3003
367 "*Port to access XMosaic via CCI. 368 "Port to access XMosaic via CCI.
368 This can be any number between 1024 and 65535 but must correspond to 369 This can be any number between 1024 and 65535 but must correspond to
369 the value set in the browser." 370 the value set in the browser."
370 :type 'integer 371 :type 'integer
371 :group 'browse-url) 372 :group 'browse-url)
372 373
379 380
380 (defvar browse-url-temp-file-name nil) 381 (defvar browse-url-temp-file-name nil)
381 (make-variable-buffer-local 'browse-url-temp-file-name) 382 (make-variable-buffer-local 'browse-url-temp-file-name)
382 383
383 (defcustom browse-url-xterm-program "xterm" 384 (defcustom browse-url-xterm-program "xterm"
384 "*The name of the terminal emulator used by `browse-url-lynx-xterm'. 385 "The name of the terminal emulator used by `browse-url-lynx-xterm'.
385 This might, for instance, be a separate colour version of xterm." 386 This might, for instance, be a separate colour version of xterm."
386 :type 'string 387 :type 'string
387 :group 'browse-url) 388 :group 'browse-url)
388 389
389 (defcustom browse-url-xterm-args nil 390 (defcustom browse-url-xterm-args nil
390 "*A list of strings defining options for `browse-url-xterm-program'. 391 "*A list of strings defining options for `browse-url-xterm-program'.
391 These might set its size, for instance." 392 These might set its size, for instance."
392 :type '(repeat (string :tag "Argument")) 393 :type '(repeat (string :tag "Argument"))
393 :group 'browse-url) 394 :group 'browse-url)
394 395
396 (defcustom browse-url-lynx-emacs-args (and (not window-system)
397 '("-show_cursor"))
398 "A list of strings defining options for Lynx in an Emacs buffer.
399
400 The default is none in a window system, otherwise `-show_cursor' to
401 indicate the position of the current link in the absence of
402 highlighting, assuming the normal default for showing the cursor."
403 :type '(repeat (string :tag "Argument"))
404 :version "20.3"
405 :group 'browse-url)
406
395 (defcustom browse-url-gnudoit-program "gnudoit" 407 (defcustom browse-url-gnudoit-program "gnudoit"
396 "*The name of the `gnudoit' program used by `browse-url-w3-gnudoit'." 408 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'."
397 :type 'string 409 :type 'string
398 :group 'browse-url) 410 :group 'browse-url)
399 411
400 (defcustom browse-url-gnudoit-args '("-q") 412 (defcustom browse-url-gnudoit-args '("-q")
401 "*A list of strings defining options for `browse-url-gnudoit-program'. 413 "*A list of strings defining options for `browse-url-gnudoit-program'.
402 These might set the port, for instance." 414 These might set the port, for instance."
403 :type '(repeat (string :tag "Argument")) 415 :type '(repeat (string :tag "Argument"))
404 :group 'browse-url) 416 :group 'browse-url)
405 417
418 ;;;###autoload
406 (defcustom browse-url-generic-program nil 419 (defcustom browse-url-generic-program nil
407 "*The name of the browser program used by `browse-url-generic'." 420 "*The name of the browser program used by `browse-url-generic'."
408 :type '(choice string (const :tag "None" nil)) 421 :type '(choice string (const :tag "None" nil))
409 :group 'browse-url) 422 :group 'browse-url)
410 423
413 :type '(repeat (string :tag "Argument")) 426 :type '(repeat (string :tag "Argument"))
414 :group 'browse-url) 427 :group 'browse-url)
415 428
416 (defcustom browse-url-temp-dir 429 (defcustom browse-url-temp-dir
417 (or (getenv "TMPDIR") "/tmp") 430 (or (getenv "TMPDIR") "/tmp")
418 "*The name of a directory for browse-url's temporary files. 431 "The name of a directory for browse-url's temporary files.
419 Such files are generated by functions like `browse-url-of-region'. 432 Such files are generated by functions like `browse-url-of-region'.
420 You might want to set this to somewhere with restricted read permissions 433 You might want to set this to somewhere with restricted read permissions
421 for privacy's sake." 434 for privacy's sake."
422 :type 'string 435 :type 'string
423 :group 'browse-url) 436 :group 'browse-url)
424 437
425 (defcustom browse-url-netscape-version 438 (defcustom browse-url-netscape-version
426 3 439 3
427 "*The version of Netscape you are using. 440 "The version of Netscape you are using.
428 This affects how URL reloading is done; the mechanism changed 441 This affects how URL reloading is done; the mechanism changed
429 incompatibly at version 4." 442 incompatibly at version 4."
430 :type 'number 443 :type 'number
431 :group 'browse-url) 444 :group 'browse-url)
432 445
439 user and don't emit the URL, 'avoid: try to avoid the field by moving 452 user and don't emit the URL, 'avoid: try to avoid the field by moving
440 down (this *won't* always work)." 453 down (this *won't* always work)."
441 :type '(choice (const :tag "Move to try to avoid field" :value avoid) 454 :type '(choice (const :tag "Move to try to avoid field" :value avoid)
442 (const :tag "Disregard" :value nil) 455 (const :tag "Disregard" :value nil)
443 (const :tag "Warn, don't emit URL" :value warn)) 456 (const :tag "Warn, don't emit URL" :value warn))
457 :version "20.3"
444 :group 'browse-url) 458 :group 'browse-url)
445 459
446 (defcustom browse-url-lynx-input-attempts 10 460 (defcustom browse-url-lynx-input-attempts 10
447 "*How many times to try to move down from a series of lynx input fields." 461 "*How many times to try to move down from a series of lynx input fields."
462 :version "20.3"
448 :type 'integer 463 :type 'integer
449 :group 'browse-url) 464 :group 'browse-url)
450 465
451 (defcustom browse-url-lynx-input-delay 0.2 466 (defcustom browse-url-lynx-input-delay 0.2
452 "*How many seconds to wait for lynx between moves down from an input field." 467 "How many seconds to wait for lynx between moves down from an input field."
468 :version "20.3"
453 :type 'number 469 :type 'number
454 :group 'browse-url) 470 :group 'browse-url)
455 471
456 (defvar browse-url-temp-file-list '()) 472 (defvar browse-url-temp-file-list '())
457 473
597 ;; Browser-independent commands 613 ;; Browser-independent commands
598 614
599 ;; A generic command to call the current browse-url-browser-function 615 ;; A generic command to call the current browse-url-browser-function
600 616
601 ;;;###autoload 617 ;;;###autoload
602 (defun browse-url (&rest args) 618 (defun browse-url (url &rest args)
603 "Ask a WWW browser to load URL. 619 "Ask a WWW browser to load URL.
604 Prompts for a URL, defaulting to the URL at or before point. Variable 620 Prompts for a URL, defaulting to the URL at or before point. Variable
605 `browse-url-browser-function' says which browser to use." 621 `browse-url-browser-function' says which browser to use."
606 (interactive (browse-url-interactive-arg "URL: ")) 622 (interactive (browse-url-interactive-arg "URL: "))
607 (if (consp browse-url-browser-function) 623 (let ((bf browse-url-browser-function) re)
608 (apply 'browse-url-choose-browser args) 624 (while (consp bf)
609 (apply browse-url-browser-function args))) 625 (setq re (car (car bf))
610 626 bf (if (string-match re url)
611 (defun browse-url-choose-browser (url &rest args) 627 (cdr (car bf)) ; The function
612 "Pass URL to a browser function chosen. 628 (cdr bf)))) ; More pairs
613 This is done according to the association list in variable 629 (or bf (error "No browser in browse-url-browser-function matching URL %s"
614 `browse-url-browser-function'." 630 url))
615 (let ((blist browse-url-browser-function) 631 (apply bf url args)))
616 re bf)
617 (while (consp blist)
618 (setq re (car (car blist))
619 bf (cdr (car blist))
620 blist (cdr blist))
621 (if (string-match re url)
622 (progn (apply bf url args) (setq blist t))))
623 (or blist
624 (error "No browser in browse-url-browser-function matching URL %s" url))))
625 632
626 ;;;###autoload 633 ;;;###autoload
627 (defun browse-url-at-point () 634 (defun browse-url-at-point ()
628 "Ask a WWW browser to load the URL at or before point. 635 "Ask a WWW browser to load the URL at or before point.
629 Doesn't let you edit the URL like `browse-url'. Variable 636 Doesn't let you edit the URL like `browse-url'. Variable
670 677
671 (defun browse-url-emacs-display () 678 (defun browse-url-emacs-display ()
672 "Return the X display Emacs is running on. 679 "Return the X display Emacs is running on.
673 This is nil if the display is the same as the DISPLAY environment variable. 680 This is nil if the display is the same as the DISPLAY environment variable.
674 681
675 Actually Emacs could be using several screens on several displays, as 682 Actually Emacs could be using several displays; this just returns the
676 listed by (emacs-display-list) and (x-display-screens DISPLAY), this 683 one showing the selected frame."
677 just returns the display showing the selected frame. You got a 684 (let ((display (cdr-safe (assq 'display (frame-parameters)))))
678 problem with that?" 685 (and (not (equal display (getenv "DISPLAY")))
679 (let (device display) 686 display)))
680 (and (fboundp 'selected-device) (fboundp 'device-type) (fboundp 'device-connection)
681 (setq device (selected-device))
682 (eq (device-type device) 'x)
683 (setq display (device-connection device))
684 (not (equal display (getenv "DISPLAY")))
685 display)))
686 687
687 ;;;###autoload 688 ;;;###autoload
688 (defun browse-url-netscape (url &optional new-window) 689 (defun browse-url-netscape (url &optional new-window)
689 "Ask the Netscape WWW browser to load URL. 690 "Ask the Netscape WWW browser to load URL.
690 691
708 browse-url-netscape-program 709 browse-url-netscape-program
709 (append browse-url-netscape-arguments 710 (append browse-url-netscape-arguments
710 (if (eq window-system 'w32) 711 (if (eq window-system 'w32)
711 (list url) 712 (list url)
712 (if new-window '("-noraise")) 713 (if new-window '("-noraise"))
713 (list "-remote" 714 (list "-remote"
714 (concat "openURL(" url 715 (concat "openURL(" url
715 (if (browse-url-maybe-new-window 716 (if (browse-url-maybe-new-window
716 new-window) 717 new-window)
717 ",new-window") 718 ",new-window")
718 ")"))))))) 719 ")")))))))
719 (set-process-sentinel process 720 (set-process-sentinel process
802 ;; --- Grail --- 803 ;; --- Grail ---
803 804
804 ;;;###autoload 805 ;;;###autoload
805 (defvar browse-url-grail 806 (defvar browse-url-grail
806 (concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py") 807 (concat (or (getenv "GRAILDIR") "~/.grail") "/user/rcgrail.py")
807 "*Location of Grail remote control client script `rcgrail.py'. 808 "Location of Grail remote control client script `rcgrail.py'.
808 Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.") 809 Typically found in $GRAILDIR/rcgrail.py, or ~/.grail/user/rcgrail.py.")
809 810
810 ;;;###autoload 811 ;;;###autoload
811 (defun browse-url-grail (url &optional new-window) 812 (defun browse-url-grail (url &optional new-window)
812 "Ask the Grail WWW browser to load URL. 813 "Ask the Grail WWW browser to load URL.
900 "Ask the Lynx WWW browser to load URL. 901 "Ask the Lynx WWW browser to load URL.
901 Default to the URL around or before point. A new Lynx process is run 902 Default to the URL around or before point. A new Lynx process is run
902 in an Xterm window using the Xterm program named by `browse-url-xterm-program' 903 in an Xterm window using the Xterm program named by `browse-url-xterm-program'
903 with possible additional arguments `browse-url-xterm-args'." 904 with possible additional arguments `browse-url-xterm-args'."
904 (interactive (browse-url-interactive-arg "Lynx URL: ")) 905 (interactive (browse-url-interactive-arg "Lynx URL: "))
905 (apply 'start-process (concat "lynx" url) nil browse-url-xterm-program 906 (apply #'start-process `(,(concat "lynx" url) nil ,browse-url-xterm-program
906 (append browse-url-xterm-args (list "-e" "lynx" url)))) 907 ,@browse-url-xterm-args "-e" "lynx" ,url)))
907 908
908 ;; --- Lynx in an Emacs "term" window --- 909 ;; --- Lynx in an Emacs "term" window ---
909 910
910 ;;;###autoload 911 ;;;###autoload
911 (defun browse-url-lynx-emacs (url &optional new-buffer) 912 (defun browse-url-lynx-emacs (url &optional new-buffer)
935 (if (or (browse-url-maybe-new-window new-buffer) 936 (if (or (browse-url-maybe-new-window new-buffer)
936 (not buf) 937 (not buf)
937 (not proc) 938 (not proc)
938 (not (memq (process-status proc) '(run stop)))) 939 (not (memq (process-status proc) '(run stop))))
939 ;; start a new lynx 940 ;; start a new lynx
940 (progn (setq buf (make-term "lynx" "lynx" nil url)) 941 (progn
941 (switch-to-buffer buf) 942 (setq buf
942 (term-char-mode) 943 (apply #'make-term
943 (set-process-sentinel 944 `("lynx" "lynx" nil ,@browse-url-lynx-emacs-args ,url)))
944 (get-buffer-process buf) 945 (switch-to-buffer buf)
945 ;; Don't leave around a dead one (especially because 946 (term-char-mode)
946 ;; of its munged keymap.) 947 (set-process-sentinel
947 (lambda (process event) 948 (get-buffer-process buf)
948 (if (not (memq (process-status process) '(run stop))) 949 ;; Don't leave around a dead one (especially because of its
949 (let ((buf (process-buffer process))) 950 ;; munged keymap.)
950 (if buf (kill-buffer buf))))))) 951 (lambda (process event)
952 (if (not (memq (process-status process) '(run stop)))
953 (let ((buf (process-buffer process)))
954 (if buf (kill-buffer buf)))))))
951 ;; send the url to lynx in the old buffer 955 ;; send the url to lynx in the old buffer
952 (let ((win (get-buffer-window buf t))) 956 (let ((win (get-buffer-window buf t)))
953 (if win 957 (if win
954 (select-window win) 958 (select-window win)
955 (switch-to-buffer buf))) 959 (switch-to-buffer buf)))