Mercurial > emacs
comparison lisp/browse-url.el @ 20509:b0d79b1edeb6
(browse-url-path-regexp, browse-url-short-regexp,
browse-url-regexp): Variables deleted. (They were moved to
thingatpt.el.)
(browse-url-filename-alist): Default now has leading ange-ftp-type
patterns so that the "^/+" pattern doesn't mung such names in
advance.
(browse-url-file-url): Don't do explicit ange-ftp path munging
here.
(browse-url-netscape-program): Doc addition.
author | Dave Love <fx@gnu.org> |
---|---|
date | Mon, 22 Dec 1997 19:26:10 +0000 |
parents | 9bef2b27cdaa |
children | 64a6c0b65eaa |
comparison
equal
deleted
inserted
replaced
20508:16f1fd128350 | 20509:b0d79b1edeb6 |
---|---|
260 :value browse-url-generic) | 260 :value browse-url-generic) |
261 (function :tag "Your own function")) | 261 (function :tag "Your own function")) |
262 :group 'browse-url) | 262 :group 'browse-url) |
263 | 263 |
264 (defcustom browse-url-netscape-program "netscape" | 264 (defcustom browse-url-netscape-program "netscape" |
265 "*The name by which to invoke Netscape." | 265 ;; Info about netscape-remote from Kurt Swanson in gnu.emacs.gnus |
266 "*The name by which to invoke Netscape. | |
267 | |
268 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 | |
270 useful to set this variable to the name of a script which invokes that | |
271 program like: | |
272 #!/bin/sh | |
273 /usr/local/bin/netscape-remote \"$@\" > /dev/null 2>&1 | |
274 " | |
266 :type 'string | 275 :type 'string |
267 :group 'browse-url) | 276 :group 'browse-url) |
268 | 277 |
269 (defcustom browse-url-netscape-arguments nil | 278 (defcustom browse-url-netscape-arguments nil |
270 "*A list of strings to pass to Netscape as arguments." | 279 "*A list of strings to pass to Netscape as arguments." |
299 (defcustom browse-url-mosaic-arguments nil | 308 (defcustom browse-url-mosaic-arguments nil |
300 "*A list of strings to pass to Mosaic as arguments." | 309 "*A list of strings to pass to Mosaic as arguments." |
301 :type '(repeat (string :tag "Argument")) | 310 :type '(repeat (string :tag "Argument")) |
302 :group 'browse-url) | 311 :group 'browse-url) |
303 | 312 |
304 (defvar browse-url-path-regexp | |
305 "[^]\t\n \"'()<>[^`{}]*[^]\t\n \"'()<>[^`{}.,;]+" | |
306 "A regular expression to match the host, path or e-mail part of a URL.") | |
307 | |
308 (defvar browse-url-short-regexp | |
309 (concat "[-A-Za-z0-9.]+" browse-url-path-regexp) | |
310 "A regular expression probably matching a URL without an access scheme. | |
311 Hostname matching is stricter in this case than for | |
312 ``browse-url-regexp''.") | |
313 | |
314 (defvar browse-url-regexp | |
315 (concat | |
316 "\\(https?://\\|ftp://\\|gopher://\\|telnet://\\|wais://\\|file:/\\|s?news:\\|mailto:\\)" | |
317 browse-url-path-regexp) | |
318 "A regular expression probably matching a complete URL.") | |
319 | |
320 (defvar browse-url-markedup-regexp | |
321 "<URL:[^>]+>" | |
322 "A regular expression matching a URL marked up per RFC1738. | |
323 This may be broken across lines.") | |
324 | |
325 (defcustom browse-url-filename-alist | 313 (defcustom browse-url-filename-alist |
326 '(("^/+" . "file:/")) | 314 '(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/") |
327 "*An alist of (REGEXP . STRING) pairs. | 315 ;; The above loses the username to avoid the browser prompting for |
316 ;; it in anonymous cases. If it's not anonymous the next regexp | |
317 ;; applies. | |
318 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/") | |
319 ("^/+" . "file:/")) | |
320 "*An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'. | |
328 Any substring of a filename matching one of the REGEXPs is replaced by | 321 Any substring of a filename matching one of the REGEXPs is replaced by |
329 the corresponding STRING. All pairs are applied in the order given. | 322 the corresponding STRING using `replace-match', not treating STRING |
330 The default value prepends `file:' to any path beginning with `/'. | 323 literally. All pairs are applied in the order given. The default |
331 Used by the `browse-url-of-file' command. | 324 value converts ange-ftp/EFS-style paths into ftp URLs and prepends |
332 | 325 `file:' to any path beginning with `/'. |
333 For example, to map EFS filenames to URLs: | 326 |
327 For example, adding to the default a specific translation of an ange-ftp | |
328 address to an HTTP URL: | |
334 | 329 |
335 (setq browse-url-filename-alist | 330 (setq browse-url-filename-alist |
336 '((\"/webmaster@webserver:/home/www/html/\" . | 331 '((\"/webmaster@webserver:/home/www/html/\" . |
337 \"http://www.acme.co.uk/\") | 332 \"http://www.acme.co.uk/\") |
333 (\"^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*\" . \"ftp://\\2/\") | |
334 (\"^/\\([^:@]+@\\)?\\([^:]+\\):/*\" . \"ftp://\\1\\2/\") | |
338 (\"^/+\" . \"file:/\"))) | 335 (\"^/+\" . \"file:/\"))) |
339 " | 336 " |
340 :type '(repeat (cons :format "%v" | 337 :type '(repeat (cons :format "%v" |
341 (regexp :tag "Regexp") | 338 (regexp :tag "Regexp") |
342 (string :tag "Replacement"))) | 339 (string :tag "Replacement"))) |
340 :version "20.3" | |
343 :group 'browse-url) | 341 :group 'browse-url) |
344 | 342 |
345 (defcustom browse-url-save-file nil | 343 (defcustom browse-url-save-file nil |
346 "*If non-nil, save the buffer before displaying its file. | 344 "*If non-nil, save the buffer before displaying its file. |
347 Used by the `browse-url-of-file' command." | 345 Used by the `browse-url-of-file' command." |
510 (browse-url (browse-url-file-url file)) | 508 (browse-url (browse-url-file-url file)) |
511 (run-hooks 'browse-url-of-file-hook)) | 509 (run-hooks 'browse-url-of-file-hook)) |
512 | 510 |
513 (defun browse-url-file-url (file) | 511 (defun browse-url-file-url (file) |
514 "Return the URL corresponding to FILE. | 512 "Return the URL corresponding to FILE. |
515 Use variable `browse-url-filename-alist' to map filenames to URLs. | 513 Use variable `browse-url-filename-alist' to map filenames to URLs." |
516 Convert EFS file names of the form /USER@HOST:PATH to ftp://HOST/PATH." | |
517 ;; URL-encode special chars, do % first | 514 ;; URL-encode special chars, do % first |
518 (let ((s 0)) | 515 (let ((s 0)) |
519 (while (setq s (string-match "%" file s)) | 516 (while (setq s (string-match "%" file s)) |
520 (setq file (replace-match "%25" t t file) | 517 (setq file (replace-match "%25" t t file) |
521 s (1+ s)))) | 518 s (1+ s)))) |
527 (let* ((map (car maps)) | 524 (let* ((map (car maps)) |
528 (from-re (car map)) | 525 (from-re (car map)) |
529 (to-string (cdr map))) | 526 (to-string (cdr map))) |
530 (setq maps (cdr maps)) | 527 (setq maps (cdr maps)) |
531 (and (string-match from-re file) | 528 (and (string-match from-re file) |
532 (setq file (replace-match to-string t t file)))))) | 529 (setq file (replace-match to-string t nil file)))))) |
533 ;; Check for EFS path | |
534 (and (string-match "^/\\([^:@]+@\\)?\\([^:]+\\):/*" file) | |
535 (setq file (concat "ftp://" | |
536 (substring file (match-beginning 2) (match-end 2)) | |
537 "/" (substring file (match-end 0))))) | |
538 file) | 530 file) |
539 | 531 |
540 ;;;###autoload | 532 ;;;###autoload |
541 (defun browse-url-of-buffer (&optional buffer) | 533 (defun browse-url-of-buffer (&optional buffer) |
542 "Ask a WWW browser to display BUFFER. | 534 "Ask a WWW browser to display BUFFER. |