Mercurial > emacs
comparison lisp/net/browse-url.el @ 85759:906f71611b65
(browse-url-text-xterm): Renamed from browse-url-lynx-xterm and made generic.
(browse-url-text-emacs): Likewise.
(browse-url-text-browser): New variable.
(browse-url-text-emacs-args): Renamed from browse-url-lynx-emacs-args.
(browse-url-text-input-field, browse-url-text-input-attempts)
(browse-url-kde-program): Likewise.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 29 Oct 2007 13:55:06 +0000 |
parents | a55a536ce0db |
children | 22dc0bc9daf8 880960b70474 |
comparison
equal
deleted
inserted
replaced
85758:674b001d26e1 | 85759:906f71611b65 |
---|---|
44 ;; browse-url-netscape Netscape 1.1b1 | 44 ;; browse-url-netscape Netscape 1.1b1 |
45 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4 | 45 ;; browse-url-mosaic XMosaic/mMosaic <= 2.4 |
46 ;; browse-url-cci XMosaic 2.5 | 46 ;; browse-url-cci XMosaic 2.5 |
47 ;; browse-url-w3 w3 0 | 47 ;; browse-url-w3 w3 0 |
48 ;; browse-url-w3-gnudoit w3 remotely | 48 ;; browse-url-w3-gnudoit w3 remotely |
49 ;; browse-url-lynx-* Lynx 0 | 49 ;; browse-url-text-* Any text browser 0 |
50 ;; browse-url-generic arbitrary | 50 ;; browse-url-generic arbitrary |
51 ;; browse-url-default-windows-browser MS-Windows browser | 51 ;; browse-url-default-windows-browser MS-Windows browser |
52 ;; browse-url-default-macosx-browser Mac OS X browser | 52 ;; browse-url-default-macosx-browser Mac OS X browser |
53 ;; browse-url-gnome-moz GNOME interface to Mozilla | 53 ;; browse-url-gnome-moz GNOME interface to Mozilla |
54 ;; browse-url-kde KDE konqueror (kfm) | 54 ;; browse-url-kde KDE konqueror (kfm) |
244 (function-item :tag "Galeon" :value browse-url-galeon) | 244 (function-item :tag "Galeon" :value browse-url-galeon) |
245 (function-item :tag "Epiphany" :value browse-url-epiphany) | 245 (function-item :tag "Epiphany" :value browse-url-epiphany) |
246 (function-item :tag "Netscape" :value browse-url-netscape) | 246 (function-item :tag "Netscape" :value browse-url-netscape) |
247 (function-item :tag "Mosaic" :value browse-url-mosaic) | 247 (function-item :tag "Mosaic" :value browse-url-mosaic) |
248 (function-item :tag "Mosaic using CCI" :value browse-url-cci) | 248 (function-item :tag "Mosaic using CCI" :value browse-url-cci) |
249 (function-item :tag "Lynx in an xterm window" | 249 (function-item :tag "Text browser in an xterm window" |
250 :value browse-url-lynx-xterm) | 250 :value browse-url-text-xterm) |
251 (function-item :tag "Lynx in an Emacs window" | 251 (function-item :tag "Text browser in an Emacs window" |
252 :value browse-url-lynx-emacs) | 252 :value browse-url-text-emacs) |
253 (function-item :tag "KDE" :value browse-url-kde) | 253 (function-item :tag "KDE" :value browse-url-kde) |
254 (function-item :tag "Elinks" :value browse-url-elinks) | 254 (function-item :tag "Elinks" :value browse-url-elinks) |
255 (function-item :tag "Specified by `Browse Url Generic Program'" | 255 (function-item :tag "Specified by `Browse Url Generic Program'" |
256 :value browse-url-generic) | 256 :value browse-url-generic) |
257 (function-item :tag "Default Windows browser" | 257 (function-item :tag "Default Windows browser" |
500 :type 'string | 500 :type 'string |
501 :group 'browse-url) | 501 :group 'browse-url) |
502 | 502 |
503 (defvar browse-url-temp-file-name nil) | 503 (defvar browse-url-temp-file-name nil) |
504 (make-variable-buffer-local 'browse-url-temp-file-name) | 504 (make-variable-buffer-local 'browse-url-temp-file-name) |
505 | 505 |
506 (defcustom browse-url-xterm-program "xterm" | 506 (defcustom browse-url-xterm-program "xterm" |
507 "The name of the terminal emulator used by `browse-url-lynx-xterm'. | 507 "The name of the terminal emulator used by `browse-url-text-xterm'. |
508 This might, for instance, be a separate color version of xterm." | 508 This might, for instance, be a separate color version of xterm." |
509 :type 'string | 509 :type 'string |
510 :group 'browse-url) | 510 :group 'browse-url) |
511 | 511 |
512 (defcustom browse-url-xterm-args nil | 512 (defcustom browse-url-xterm-args nil |
513 "A list of strings defining options for `browse-url-xterm-program'. | 513 "A list of strings defining options for `browse-url-xterm-program'. |
514 These might set its size, for instance." | 514 These might set its size, for instance." |
515 :type '(repeat (string :tag "Argument")) | 515 :type '(repeat (string :tag "Argument")) |
516 :group 'browse-url) | |
517 | |
518 (defcustom browse-url-lynx-emacs-args (and (not window-system) | |
519 '("-show_cursor")) | |
520 "A list of strings defining options for Lynx in an Emacs buffer. | |
521 | |
522 The default is none in a window system, otherwise `-show_cursor' to | |
523 indicate the position of the current link in the absence of | |
524 highlighting, assuming the normal default for showing the cursor." | |
525 :type '(repeat (string :tag "Argument")) | |
526 :version "20.3" | |
527 :group 'browse-url) | 516 :group 'browse-url) |
528 | 517 |
529 (defcustom browse-url-gnudoit-program "gnudoit" | 518 (defcustom browse-url-gnudoit-program "gnudoit" |
530 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'." | 519 "The name of the `gnudoit' program used by `browse-url-w3-gnudoit'." |
531 :type 'string | 520 :type 'string |
560 This affects how URL reloading is done; the mechanism changed | 549 This affects how URL reloading is done; the mechanism changed |
561 incompatibly at version 4." | 550 incompatibly at version 4." |
562 :type 'number | 551 :type 'number |
563 :group 'browse-url) | 552 :group 'browse-url) |
564 | 553 |
565 (defcustom browse-url-lynx-input-field 'avoid | 554 (defcustom browse-url-text-browser "lynx" |
566 "Action on selecting an existing Lynx buffer at an input field. | 555 "The name of the text browser to invoke." |
567 What to do when sending a new URL to an existing Lynx buffer in Emacs | 556 :type 'string |
568 if the Lynx cursor is on an input field (in which case the `g' command | 557 :group 'browse-url |
558 :version "23.1") | |
559 | |
560 (defcustom browse-url-text-emacs-args (and (not window-system) | |
561 '("-show_cursor")) | |
562 "A list of strings defining options for a text browser in an Emacs buffer. | |
563 | |
564 The default is none in a window system, otherwise `-show_cursor' to | |
565 indicate the position of the current link in the absence of | |
566 highlighting, assuming the normal default for showing the cursor." | |
567 :type '(repeat (string :tag "Argument")) | |
568 :version "23.1" | |
569 :group 'browse-url) | |
570 | |
571 (defcustom browse-url-text-input-field 'avoid | |
572 "Action on selecting an existing text browser buffer at an input field. | |
573 What to do when sending a new URL to an existing text browser buffer in Emacs | |
574 if the browser cursor is on an input field (in which case the `g' command | |
569 would be entered as data). Such fields are recognized by the | 575 would be entered as data). Such fields are recognized by the |
570 underlines ____. Allowed values: nil: disregard it, 'warn: warn the | 576 underlines ____. Allowed values: nil: disregard it, `warn': warn the |
571 user and don't emit the URL, 'avoid: try to avoid the field by moving | 577 user and don't emit the URL, `avoid': try to avoid the field by moving |
572 down (this *won't* always work)." | 578 down (this *won't* always work)." |
573 :type '(choice (const :tag "Move to try to avoid field" :value avoid) | 579 :type '(choice (const :tag "Move to try to avoid field" :value avoid) |
574 (const :tag "Disregard" :value nil) | 580 (const :tag "Disregard" :value nil) |
575 (const :tag "Warn, don't emit URL" :value warn)) | 581 (const :tag "Warn, don't emit URL" :value warn)) |
576 :version "20.3" | 582 :version "23.1" |
577 :group 'browse-url) | 583 :group 'browse-url) |
578 | 584 |
579 (defcustom browse-url-lynx-input-attempts 10 | 585 (defcustom browse-url-text-input-attempts 10 |
580 "How many times to try to move down from a series of lynx input fields." | 586 "How many times to try to move down from a series of text browser input fields." |
581 :type 'integer | 587 :type 'integer |
582 :group 'browse-url) | 588 :version "23.1" |
583 | 589 :group 'browse-url) |
584 (defcustom browse-url-lynx-input-delay 0.2 | 590 |
585 "How many seconds to wait for lynx between moves down from an input field." | 591 (defcustom browse-url-text-input-delay 0.2 |
592 "Seconds to wait for a text browser between moves down from an input field." | |
586 :type 'number | 593 :type 'number |
594 :version "23.1" | |
587 :group 'browse-url) | 595 :group 'browse-url) |
588 | 596 |
589 (defcustom browse-url-kde-program "kfmclient" | 597 (defcustom browse-url-kde-program "kfmclient" |
590 "The name by which to invoke the KDE web browser." | 598 "The name by which to invoke the KDE web browser." |
591 :type 'string | 599 :type 'string |
874 ((executable-find browse-url-firefox-program) 'browse-url-firefox) | 882 ((executable-find browse-url-firefox-program) 'browse-url-firefox) |
875 ((executable-find browse-url-galeon-program) 'browse-url-galeon) | 883 ((executable-find browse-url-galeon-program) 'browse-url-galeon) |
876 ((executable-find browse-url-kde-program) 'browse-url-kde) | 884 ((executable-find browse-url-kde-program) 'browse-url-kde) |
877 ((executable-find browse-url-netscape-program) 'browse-url-netscape) | 885 ((executable-find browse-url-netscape-program) 'browse-url-netscape) |
878 ((executable-find browse-url-mosaic-program) 'browse-url-mosaic) | 886 ((executable-find browse-url-mosaic-program) 'browse-url-mosaic) |
879 ((executable-find browse-url-xterm-program) 'browse-url-lynx-xterm) | 887 ((executable-find browse-url-xterm-program) 'browse-url-text-xterm) |
880 ((locate-library "w3") 'browse-url-w3) | 888 ((locate-library "w3") 'browse-url-w3) |
881 (t | 889 (t |
882 (lambda (&ignore args) (error "No usable browser found")))) | 890 (lambda (&ignore args) (error "No usable browser found")))) |
883 url args)) | 891 url args)) |
884 | 892 |
1306 "(raise-frame)")))) | 1314 "(raise-frame)")))) |
1307 | 1315 |
1308 ;; --- Lynx in an xterm --- | 1316 ;; --- Lynx in an xterm --- |
1309 | 1317 |
1310 ;;;###autoload | 1318 ;;;###autoload |
1311 (defun browse-url-lynx-xterm (url &optional new-window) | 1319 (defun browse-url-text-xterm (url &optional new-window) |
1312 ;; new-window ignored | 1320 ;; new-window ignored |
1313 "Ask the Lynx WWW browser to load URL. | 1321 "Ask a text browser to load URL. |
1314 Default to the URL around or before point. A new Lynx process is run | 1322 URL defaults to the URL around or before point. |
1323 This runs the text browser specified by `browse-url-text-browser'. | |
1315 in an Xterm window using the Xterm program named by `browse-url-xterm-program' | 1324 in an Xterm window using the Xterm program named by `browse-url-xterm-program' |
1316 with possible additional arguments `browse-url-xterm-args'." | 1325 with possible additional arguments `browse-url-xterm-args'." |
1317 (interactive (browse-url-interactive-arg "Lynx URL: ")) | 1326 (interactive (browse-url-interactive-arg "Text browser URL: ")) |
1318 (apply #'start-process `(,(concat "lynx" url) nil ,browse-url-xterm-program | 1327 (apply #'start-process `(,(concat browse-url-text-browser url) |
1319 ,@browse-url-xterm-args "-e" "lynx" | 1328 nil ,browse-url-xterm-program |
1329 ,@browse-url-xterm-args "-e" browse-url-text-browser | |
1320 ,url))) | 1330 ,url))) |
1321 | 1331 |
1322 ;; --- Lynx in an Emacs "term" window --- | 1332 ;; --- Lynx in an Emacs "term" window --- |
1323 | 1333 |
1324 ;;;###autoload | 1334 ;;;###autoload |
1325 (defun browse-url-lynx-emacs (url &optional new-buffer) | 1335 (defun browse-url-text-emacs (url &optional new-buffer) |
1326 "Ask the Lynx WWW browser to load URL. | 1336 "Ask a text browser to load URL. |
1327 Default to the URL around or before point. With a prefix argument, run | 1337 URL defaults to the URL around or before point. |
1328 a new Lynx process in a new buffer. | 1338 This runs the text browser specified by `browse-url-text-browser'. |
1339 With a prefix argument, it runs a new browser process in a new buffer. | |
1329 | 1340 |
1330 When called interactively, if variable `browse-url-new-window-flag' is | 1341 When called interactively, if variable `browse-url-new-window-flag' is |
1331 non-nil, load the document in a new lynx in a new term window, | 1342 non-nil, load the document in a new browser process in a new term window, |
1332 otherwise use any existing one. A non-nil interactive prefix argument | 1343 otherwise use any existing one. A non-nil interactive prefix argument |
1333 reverses the effect of `browse-url-new-window-flag'. | 1344 reverses the effect of `browse-url-new-window-flag'. |
1334 | 1345 |
1335 When called non-interactively, optional second argument NEW-WINDOW is | 1346 When called non-interactively, optional second argument NEW-WINDOW is |
1336 used instead of `browse-url-new-window-flag'." | 1347 used instead of `browse-url-new-window-flag'." |
1337 (interactive (browse-url-interactive-arg "Lynx URL: ")) | 1348 (interactive (browse-url-interactive-arg "Text browser URL: ")) |
1338 (let* ((system-uses-terminfo t) ; Lynx uses terminfo | 1349 (let* ((system-uses-terminfo t) ; Lynx uses terminfo |
1339 ;; (term-term-name "vt100") ; ?? | 1350 ;; (term-term-name "vt100") ; ?? |
1340 (buf (get-buffer "*lynx*")) | 1351 (buf (get-buffer "*text browser*")) |
1341 (proc (and buf (get-buffer-process buf))) | 1352 (proc (and buf (get-buffer-process buf))) |
1342 (n browse-url-lynx-input-attempts)) | 1353 (n browse-url-text-input-attempts)) |
1343 (if (and (browse-url-maybe-new-window new-buffer) buf) | 1354 (if (and (browse-url-maybe-new-window new-buffer) buf) |
1344 ;; Rename away the OLD buffer. This isn't very polite, but | 1355 ;; Rename away the OLD buffer. This isn't very polite, but |
1345 ;; term insists on working in a buffer named *lynx* and would | 1356 ;; term insists on working in a buffer named *lynx* and would |
1346 ;; choke on *lynx*<1> | 1357 ;; choke on *lynx*<1> |
1347 (progn (set-buffer buf) | 1358 (progn (set-buffer buf) |
1348 (rename-uniquely))) | 1359 (rename-uniquely))) |
1349 (if (or (browse-url-maybe-new-window new-buffer) | 1360 (if (or (browse-url-maybe-new-window new-buffer) |
1350 (not buf) | 1361 (not buf) |
1351 (not proc) | 1362 (not proc) |
1352 (not (memq (process-status proc) '(run stop)))) | 1363 (not (memq (process-status proc) '(run stop)))) |
1353 ;; start a new lynx | 1364 ;; start a new text browser |
1354 (progn | 1365 (progn |
1355 (setq buf | 1366 (setq buf |
1356 (apply #'make-term | 1367 (apply #'make-term |
1357 `("lynx" "lynx" nil ,@browse-url-lynx-emacs-args | 1368 `(,browse-url-text-browser |
1369 ,browse-url-text-browser | |
1370 nil ,@browse-url-text-emacs-args | |
1358 ,url))) | 1371 ,url))) |
1359 (switch-to-buffer buf) | 1372 (switch-to-buffer buf) |
1360 (term-char-mode) | 1373 (term-char-mode) |
1361 (set-process-sentinel | 1374 (set-process-sentinel |
1362 (get-buffer-process buf) | 1375 (get-buffer-process buf) |
1364 ;; munged keymap.) | 1377 ;; munged keymap.) |
1365 (lambda (process event) | 1378 (lambda (process event) |
1366 (if (not (memq (process-status process) '(run stop))) | 1379 (if (not (memq (process-status process) '(run stop))) |
1367 (let ((buf (process-buffer process))) | 1380 (let ((buf (process-buffer process))) |
1368 (if buf (kill-buffer buf))))))) | 1381 (if buf (kill-buffer buf))))))) |
1369 ;; send the url to lynx in the old buffer | 1382 ;; Send the url to the text browser in the old buffer |
1370 (let ((win (get-buffer-window buf t))) | 1383 (let ((win (get-buffer-window buf t))) |
1371 (if win | 1384 (if win |
1372 (select-window win) | 1385 (select-window win) |
1373 (switch-to-buffer buf))) | 1386 (switch-to-buffer buf))) |
1374 (if (eq (following-char) ?_) | 1387 (if (eq (following-char) ?_) |
1375 (cond ((eq browse-url-lynx-input-field 'warn) | 1388 (cond ((eq browse-url-text-input-field 'warn) |
1376 (error "Please move out of the input field first")) | 1389 (error "Please move out of the input field first")) |
1377 ((eq browse-url-lynx-input-field 'avoid) | 1390 ((eq browse-url-text-input-field 'avoid) |
1378 (while (and (eq (following-char) ?_) (> n 0)) | 1391 (while (and (eq (following-char) ?_) (> n 0)) |
1379 (term-send-down) ; down arrow | 1392 (term-send-down) ; down arrow |
1380 (sit-for browse-url-lynx-input-delay)) | 1393 (sit-for browse-url-text-input-delay)) |
1381 (if (eq (following-char) ?_) | 1394 (if (eq (following-char) ?_) |
1382 (error "Cannot move out of the input field, sorry"))))) | 1395 (error "Cannot move out of the input field, sorry"))))) |
1383 (term-send-string proc (concat "g" ; goto | 1396 (term-send-string proc (concat "g" ; goto |
1384 "\C-u" ; kill default url | 1397 "\C-u" ; kill default url |
1385 url | 1398 url |